소스 검색

added klibs and options for debug

rafael 9 년 전
부모
커밋
a23c77e3d2
2개의 변경된 파일433개의 추가작업 그리고 59개의 파일을 삭제
  1. 197 42
      BUILD
  2. 236 17
      BUILD.conf

+ 197 - 42
BUILD

@@ -51,15 +51,15 @@ check_utils()
 }
 
 #ARGS:
-
+#$1 -> libname
 build_l()
 {
 	if [ $DO_NOTHING -eq 0 ]
 	then
 		for j in $BUILD_IN
 		do
-			echo "$CC $CFLAGS $CFLAGS_EXTRA -c $j"
-			$CC $CFLAGS $CFLAGS_EXTRA -c $j
+			echo "$CC $CFLAGS_LIB $CFLAGS_EXTRA $BUILD_DEBUG -c $j"
+			$CC $CFLAGS_LIB $CFLAGS_EXTRA $BUILD_DEBUG -c $j
 			if [ $? -ne 0 ]
 			then
 				printf "\n\n ERROR COMPILING $1\n"
@@ -75,9 +75,32 @@ build_l()
 	fi
 }
 
+#ARGS:
+#$1 -> libname
+build_kl()
+{
+	if [ $DO_NOTHING -eq 0 ]
+	then
+		echo "$CC $CFLAGS_KLIB $CFLAGS_EXTRA -c $BUILD_IN"
+		$CC $CFLAGS_KLIB $CFLAGS_EXTRA $BUILD_DEBUG -c $BUILD_IN
+		if [ $? -ne 0 ]
+		then
+			printf "\n\n ERROR COMPILING $1\n"
+			exit 1
+		fi
+		echo "$AR rv \"$BUILD_OUT\" *.o"
+		$AR rv "$BUILD_OUT" *.o
+		if [ $? -ne 0 ]
+		then
+			printf "\n\n ERROR CREATING LIBRARY $1\n"
+		fi
+	fi
+}
+
 
 #ARGS:
 #$1 -> Lib name
+#$2 -> 0 a lib | 1 a klib
 build_a_lib()
 {
 	PATH_ORI=`pwd`
@@ -85,7 +108,12 @@ build_a_lib()
 	CFLAGS_EXTRA=
 	SUBDIRS=
 	DO_NOTHING=0
-	$1
+	if [ $2 -eq 1 ]
+	then
+		k${1} 1
+	else
+		$1 1
+	fi
 	if [ -n "$SUBDIRS" ]
 	then
 		for k in $SUBDIRS
@@ -93,12 +121,23 @@ build_a_lib()
 			CFLAGS_EXTRA=
 			DO_NOTHING=0
 			cd $k
-			$1_$k
-			build_l
+			if [ $2 -eq 1 ]
+			then
+				k${1}_$k 1
+				build_kl k${1}
+			else
+				$1_$k 1
+				build_l $1
+			fi
 			cd ..
 		done
 	else
-		build_l
+		if [ $2 -eq 1 ]
+		then
+			build_kl $1
+		else
+			build_l $1
+		fi
 	fi
 	
 	cd "$PATH_ORI" > /dev/null
@@ -106,19 +145,75 @@ build_a_lib()
 
 #ARGS:
 #$1 -> Lib name
+#$2 -> 0 a lib | 1 a klib
 clean_a_lib()
 {
+	PATH_ORI=`pwd`
 	cd "${SRC_DIR}/$1"
-	$1
-	printf "Cleaning $1 "
-	$CLEAN_COM
-	if [ $? -eq 0 ]
+	SUBDIRS=
+	DO_NOTHING=0
+	if [ $2 -eq 1 ]
 	then
-		printf "OK\n"
+		k${1} 2
 	else
-		printf "ERROR\n"
+		$1 2
 	fi
-	cd - > /dev/null
+	if [ $DO_NOTHING -eq 0 ]
+	then
+		if [ -n "$SUBDIRS" ]
+		then
+			for k in $SUBDIRS
+			do
+				DO_NOTHING=0
+				cd $k
+				if [ $2 -eq 1 ]
+				then
+					k${1}_$k 2
+					if [ $DO_NOTHING -eq 0 ]
+					then
+						printf "Cleaning k${1}/$k "
+						$CLEAN_COM
+						if [ $? -eq 0 ]
+						then
+							printf "OK\n"
+						else
+							printf "ERROR\n"
+						fi 
+					fi
+				else
+					$1_$k 2
+					if [ $DO_NOTHING -eq 0 ]
+					then
+						printf "Cleaning ${1}/$k "
+						$CLEAN_COM
+						if [ $? -eq 0 ]
+						then
+							printf "OK\n"
+						else
+							printf "ERROR\n"
+						fi 
+					fi
+				fi
+				cd ..
+			done
+		else
+			if [ $2 -eq 1 ]
+			then
+				K="k"
+			else
+				K=""
+			fi
+			printf "Cleaning ${K}$1 "
+			$CLEAN_COM
+			if [ $? -eq 0 ]
+			then
+				printf "OK\n"
+			else
+				printf "ERROR\n"
+			fi 
+		fi
+	fi
+	cd "$PATH_ORI" > /dev/null
 }
 
 #ARGS:
@@ -140,9 +235,9 @@ build_libs()
 	do
 		if [ $1 -eq 1 ]
 		then
-			build_a_lib $i
+			build_a_lib $i 0
 		else
-			clean_a_lib $i
+			clean_a_lib $i 0
 		fi
 	done
 	
@@ -152,6 +247,37 @@ build_libs()
 	fi
 }
 
+#ARGS:
+#$1 -> ACTION:
+#      1) Build
+#      2) Clean
+build_klibs()
+{
+	if [ $1 -eq 1 ]
+	then
+		SALIDA=`check_utils`
+		if [ $SALIDA -eq 1 ]
+		then
+			build_go_utils
+		fi
+	fi
+	
+	for i in $BUILD_KLIBS
+	do
+		if [ $1 -eq 1 ]
+		then
+			build_a_lib $i 1
+		else
+			clean_a_lib $i 1
+		fi
+	done
+	
+	if [ $1 -eq 1 ]
+	then
+		echo "ALL KLIBS COMPILED OK"
+	fi
+}
+
 show_help()
 {
 	printf "\n\nBUILD script for Harvey\n\n"
@@ -161,7 +287,12 @@ show_help()
 	printf "  libs       \tBuild the libraries\n"
 	printf "  libs <libname>\tBuild the library <libname>\n"
 	printf "  cleanlibs\tClean the libraries\n"
+	printf "  klibs       \tBuild the Klibraries\n"
+	printf "  klibs <libname>\tBuild the Klibrary <libname>\n"
+	printf "  cleanklibs\tClean the Klibraries\n"
 	printf "  utils     \tBuild go utils\n"
+	printf "\nFLAGS:\n"
+	printf "  -g        \tCompile with debugs flags"
 	printf "\n"
 
 }
@@ -172,33 +303,57 @@ then
 	show_help
 	exit 1
 else
-	case "$1" in
-		"all")
-				build_libs 1
-				printf "\n\nALL COMPONENTS COMPILED\n\n"
-				;;
-		"cleanall")
-				build_libs 2
-				printf "\n\nALL COMPONENTS CLEANED\n\n"
-				;;
-		"libs")
-				if [ -z "$2" ]
-				then
+	BUILD_DEBUG=
+	while [ -n "$1" ]
+	do
+		case "$1" in
+			"-g")
+					BUILD_DEBUG="$CFLAGS_DEBUG"
+					;;
+			"all")
 					build_libs 1
-				else
-					build_a_lib "$2"
-				fi
-			;;
-		"cleanlibs")
-				build_libs 2
-			;;
-		"utils")
-				build_go_utils
-			;;
-		*)
-			echo "Invalid option <$1>"
-			;;
-	esac
+					build_klibs 1
+					printf "\n\nALL COMPONENTS COMPILED\n\n"
+					;;
+			"cleanall")
+					build_libs 2
+					build_klibs 2
+					printf "\n\nALL COMPONENTS CLEANED\n\n"
+					;;
+			"libs")
+					if [ -z "$2" ]
+					then
+						build_libs 1
+					else
+						build_a_lib "$2" 0
+						shift
+					fi
+					;;
+			"klibs")
+					if [ -z "$2" ]
+					then
+						build_klibs 1
+					else
+						build_a_lib "$2" 1
+						shift
+					fi
+					;;
+			"cleanklibs")
+					build_klibs 2
+					;;
+			"cleanlibs")
+					build_libs 2
+					;;
+			"utils")
+					build_go_utils
+					;;
+			*)
+				echo "Invalid option <$1>"
+				exit 1
+				;;
+		esac
+		shift
+	done
 fi
 
 

+ 236 - 17
BUILD.conf

@@ -13,7 +13,9 @@ UTIL_DIR=${_BUILD_DIR}/util
 
 ### COMPILER ###
 CC=gcc
-CFLAGS="-O0 -g -static -fplan9-extensions -ffreestanding -fno-builtin -Wall -Wno-missing-braces -Wno-parentheses -Wno-unknown-pragmas -Wuninitialized -Wmaybe-uninitialized -I${INC_ARCH} -I${INC_DIR}"
+CFLAGS_DEBUG="-g"
+CFLAGS_LIB="-O0 -static -fplan9-extensions -ffreestanding -fno-builtin -Wall -Wno-missing-braces -Wno-parentheses -Wno-unknown-pragmas -Wuninitialized -Wmaybe-uninitialized -I${INC_ARCH} -I${INC_DIR}"
+CFLAGS_KLIB="-mcmodel=kernel -O0 -fplan9-extensions -ffreestanding -fno-builtin -Wall -Wno-missing-braces -Wno-parentheses -Wno-unknown-pragmas -Wuninitialized -Wmaybe-uninitialized -I${INC_ARCH} -I${INC_DIR}"
 LDFLAGS=-L$LIB_DIR
 AR=ar
 RANLIB=ranlib
@@ -22,6 +24,8 @@ RANLIB=ranlib
 BUILD_LIBS="lib9p libString libauth libauthsrv libavl libbin libbio libcomplete libcontrol libdisk libdraw libflate libframe libgeometry libhtml libhttpd\
 			liblex libmemdraw libmemlayer libndb libplumb libregexp libstdio libsunrpc libthread libventi libc libmp libip"
 
+BUILD_KLIBS="libc libip"
+
 
 lib9p()
 {
@@ -659,20 +663,23 @@ libc_9sys()
 
 libc_9syscall()
 {
-	DO_NOTHING=1
-	${UTIL_DIR}/mksys $ARCH
-	if [ $? -eq 0 ]
+	if [ $1 -eq 1 ]
 	then
-		echo $CC -c *.s
-		$CC -c *.s
-		if [ $? -ne 0 ]
+		DO_NOTHING=1
+		${UTIL_DIR}/mksys $ARCH
+		if [ $? -eq 0 ]
 		then
-			echo "ERROR compiling libc"
+			echo $CC $BUILD_DEBUG -c *.s
+			$CC $BUILD_DEBUG -c *.s
+			if [ $? -ne 0 ]
+			then
+				echo "ERROR compiling libc"
+			fi
+			echo $AR rv "${LIB_DIR}/libc.a" *.o
+			$AR rv "${LIB_DIR}/libc.a" *.o
+		else
+			echo "ERROR executing ${UTIL_DIR}/mksys $ARCH"
 		fi
-		echo $AR rv "${LIB_DIR}/libc.a" *.o
-		$AR rv "${LIB_DIR}/libc.a" *.o
-	else
-		echo "ERROR executing ${UTIL_DIR}/mksys $ARCH"
 	fi
 	CLEAN_COM="rm -f *.o *.s"
 }
@@ -842,11 +849,14 @@ libc_amd64()
 	BUILD_OUT=${LIB_DIR}/libc.a
 	CLEAN_COM="rm -f *.o"
 	
-	as  -o setjmp.o -c setjmp.s
-	as  -o sqrt.o -c sqrt.s
-	as  -o tas.o -c tas.s
-	echo "$CC $CFLAGS -o atom.o -c atom.S"
-	$CC $CFLAGS -o atom.o -c atom.S
+	if [ $1 -eq 1 ]
+	then
+		as  -o setjmp.o -c setjmp.s
+		as  -o sqrt.o -c sqrt.s
+		as  -o tas.o -c tas.s
+		echo "$CC $CFLAGS_LIB $BUILD_DEBUG -o atom.o -c atom.S"
+		$CC $CFLAGS_LIB $BUILD_DEBUG -o atom.o -c atom.S
+	fi
 }
 
 libmp()
@@ -915,3 +925,212 @@ libip()
 
 }
 
+klibc()
+{
+	BUILD_IN="	./9sys/abort.c \
+				./9sys/access.c \
+				./9sys/announce.c \
+				./9sys/convD2M.c \
+				./9sys/convM2D.c \
+				./9sys/convM2S.c \
+				./9sys/convS2M.c \
+				./9sys/cputime.c \
+				./9sys/ctime.c \
+				./9sys/dial.c \
+				./9sys/dirfstat.c \
+				./9sys/dirfwstat.c \
+				./9sys/dirmodefmt.c \
+				./9sys/dirread.c \
+				./9sys/dirstat.c \
+				./9sys/dirwstat.c \
+				./9sys/fcallfmt.c \
+				./9sys/fork.c \
+				./9sys/getnetconninfo.c \
+				./9sys/getenv.c \
+				./9sys/getpid.c \
+				./9sys/getppid.c \
+				./9sys/getwd.c \
+				./9sys/iounit.c \
+				./9sys/nulldir.c \
+				./9sys/postnote.c \
+				./9sys/privalloc.c \
+				./9sys/pushssl.c \
+				./9sys/pushtls.c \
+				./9sys/putenv.c \
+				./9sys/qlock.c \
+				./9sys/read.c \
+				./9sys/read9pmsg.c \
+				./9sys/readv.c \
+				./9sys/rerrstr.c \
+				./9sys/sbrk.c \
+				./9sys/setnetmtpt.c \
+				./9sys/sysfatal.c \
+				./9sys/syslog.c \
+				./9sys/sysname.c \
+				./9sys/time.c \
+				./9sys/times.c \
+				./9sys/tm2sec.c \
+				./9sys/truerand.c \
+				./9sys/wait.c \
+				./9sys/waitpid.c \
+				./9sys/werrstr.c \
+				./9sys/write.c \
+				./9sys/writev.c \
+				./fmt/dofmt.c \
+				./fmt/dorfmt.c \
+				./fmt/errfmt.c \
+				./fmt/fltfmt.c \
+				./fmt/fmt.c \
+				./fmt/fmtfd.c \
+				./fmt/fmtlock.c \
+				./fmt/fmtprint.c \
+				./fmt/fmtquote.c \
+				./fmt/fmtrune.c \
+				./fmt/fmtstr.c \
+				./fmt/fmtvprint.c \
+				./fmt/fprint.c \
+				./fmt/print.c \
+				./fmt/runefmtstr.c \
+				./fmt/runeseprint.c \
+				./fmt/runesmprint.c \
+				./fmt/runesnprint.c \
+				./fmt/runesprint.c \
+				./fmt/runevseprint.c \
+				./fmt/runevsmprint.c \
+				./fmt/runevsnprint.c \
+				./fmt/seprint.c \
+				./fmt/smprint.c \
+				./fmt/snprint.c \
+				./fmt/sprint.c \
+				./fmt/vfprint.c \
+				./fmt/vseprint.c \
+				./fmt/vsmprint.c \
+				./fmt/vsnprint.c \
+				./port/_assert.c \
+				./port/abs.c \
+				./port/asin.c \
+				./port/atan.c \
+				./port/atan2.c \
+				./port/atexit.c \
+				./port/atnotify.c \
+				./port/atof.c \
+				./port/atol.c \
+				./port/atoll.c \
+				./port/cistrcmp.c \
+				./port/cistrncmp.c \
+				./port/cistrstr.c \
+				./port/charstod.c \
+				./port/cleanname.c \
+				./port/crypt.c \
+				./port/ctype.c \
+				./port/encodefmt.c \
+				./port/execl.c \
+				./port/exp.c \
+				./port/fabs.c \
+				./port/floor.c \
+				./port/fmod.c \
+				./port/frand.c \
+				./port/frexp.c \
+				./port/getcallerpc.c \
+				./port/getfields.c \
+				./port/getuser.c \
+				./port/hangup.c \
+				./port/hypot.c \
+				./port/lnrand.c \
+				./port/lock.c \
+				./port/log.c \
+				./port/lrand.c \
+				./port/malloc.c \
+				./port/memccpy.c \
+				./port/memchr.c \
+				./port/memcmp.c \
+				./port/memmove.c \
+				./port/memset.c \
+				./port/mktemp.c \
+				./port/muldiv.c \
+				./port/nan.c \
+				./port/needsrcquote.c \
+				./port/netcrypt.c \
+				./port/netmkaddr.c \
+				./port/nrand.c \
+				./port/ntruerand.c \
+				./port/perror.c \
+				./port/pool.c \
+				./port/pow.c \
+				./port/pow10.c \
+				./port/profile.c \
+				./port/qsort.c \
+				./port/quote.c \
+				./port/rand.c \
+				./port/readn.c \
+				./port/rune.c \
+				./port/runebase.c \
+				./port/runebsearch.c \
+				./port/runestrcat.c \
+				./port/runestrchr.c \
+				./port/runestrcmp.c \
+				./port/runestrcpy.c \
+				./port/runestrecpy.c \
+				./port/runestrdup.c \
+				./port/runestrncat.c \
+				./port/runestrncmp.c \
+				./port/runestrncpy.c \
+				./port/runestrrchr.c \
+				./port/runestrlen.c \
+				./port/runestrstr.c \
+				./port/runetype.c \
+				./port/sin.c \
+				./port/sinh.c \
+				./port/sqrt.c \
+				./port/strcat.c \
+				./port/strchr.c \
+				./port/strcmp.c \
+				./port/strcpy.c \
+				./port/strecpy.c \
+				./port/strcspn.c \
+				./port/strdup.c \
+				./port/strlen.c \
+				./port/strncat.c \
+				./port/strncmp.c \
+				./port/strncpy.c \
+				./port/strpbrk.c \
+				./port/strrchr.c \
+				./port/strspn.c \
+				./port/strstr.c \
+				./port/strtod.c \
+				./port/strtok.c \
+				./port/strtol.c \
+				./port/strtoll.c \
+				./port/strtoul.c \
+				./port/strtoull.c \
+				./port/tan.c \
+				./port/tanh.c \
+				./port/tokenize.c \
+				./port/toupper.c \
+				./port/utfecpy.c \
+				./port/utflen.c \
+				./port/utfnlen.c \
+				./port/utfrune.c \
+				./port/utfrrune.c \
+				./port/utfutf.c \
+				./port/u16.c \
+				./port/u32.c \
+				./port/u64.c \
+				./amd64/_seek.c \
+				./amd64/notejmp.c \
+				./amd64/cycles.c \
+				./amd64/argv0.c \
+				./amd64/rdpmc.c
+				"
+	BUILD_OUT="${LIB_DIR}/klibc.a"
+	CLEAN_COM="rm -f *.o"
+}
+
+klibip()
+{
+	BUILD_IN="bo.c  classmask.c  eipfmt.c  equivip.c	ipaux.c  myetheraddr.c	myipaddr.c  parseether.c  parseip.c  ptclbsum.c  readipifc.c  testreadipifc.c"
+	BUILD_OUT=${LIB_DIR}/klibip.a
+	CLEAN_COM="rm -f *.o"
+}
+
+