Browse Source

simplify building procedule

Chia-Che Tsai 9 years ago
parent
commit
87475b75ad
3 changed files with 69 additions and 44 deletions
  1. 4 2
      LibOS/Makefile
  2. 36 21
      LibOS/buildglibc.py
  3. 29 21
      Pal/Makefile

+ 4 - 2
LibOS/Makefile

@@ -5,10 +5,12 @@ GLIBC_TARGET = $(addprefix $(BUILD_DIR)/,libc.so.6 ld-linux-x86-64.so.2)
 
 all: $(GLIBC_TARGET)
 	make -C $(SHIM_DIR)/src
+	make -C $(SHIM_DIR)/test
 
 debug: DEBUG=debug
 debug: $(GLIBC_TARGET)
-	make -C $(SHIM_DIR)/src debug
+	make -C $(SHIM_DIR)/src  debug
+	make -C $(SHIM_DIR)/test debug
 
 # nothing to install
 install:
@@ -17,7 +19,7 @@ $(GLIBC_TARGET): $(BUILD_DIR)/Makefile
 	cd $(BUILD_DIR) && make
 
 $(BUILD_DIR)/Makefile: $(GLIBC_SRC)/configure
-	./buildglibc.py $(DEBUG)
+	./buildglibc.py --quiet $(DEBUG)
 
 $(GLIBC_SRC)/configure:
 	[ -f $(GLIBC_SRC).tar.gz ] || \

+ 36 - 21
LibOS/buildglibc.py

@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 
-import sys, os, string, subprocess, shutil, fileinput, multiprocessing, re
+import sys, os, string, subprocess, shutil, fileinput, multiprocessing, re, resource
 
 
 def replaceAll(fd,searchExp,replaceExp):
@@ -33,36 +33,47 @@ try:
     installDir = "/usr/local/graphene"
     commandStr = ""
     commandOutput = ""
-
+    quiet = False
     debug_flags = ""
-    if len(sys.argv) > 1 and sys.argv[1] == 'debug':
-        debug_flags = "-g"
-
 
+    for arg in sys.argv[1:]:
+        if arg == '--quiet' or arg == '-q':
+            quiet = True
+        if arg == 'debug':
+            debug_flags = "-g"
 
     #########################################
     #### get the locations of directories ###
     #########################################
 
-    iput = raw_input('use {0} as the source of GNU libc? ([y]/n):'.format(glibc)).lower()
-    if not iput == 'y' and not iput == '' :
-        glibc = raw_input('enter the glibc source to install with: ')
+    if not quiet:
+        iput = raw_input('use {0} as the source of GNU libc? ([y]/n):'.format(glibc)).lower()
+        if not iput == 'y' and not iput == '' :
+            glibc = raw_input('enter the glibc source to install with: ')
+
+    if not quiet:
+        iput = raw_input('{0} contains glibc code to compile? ([y]/n): '.format(glibc)).lower()
+        if not iput == 'y' and not iput == '':
+            glibc = raw_input('directory containing glibc code to compile: ')
 
-    iput = raw_input('{0} contains glibc code to compile? ([y]/n): '.format(glibc)).lower()
-    if not iput == 'y' and not iput == '':
-        glibc = raw_input('directory containing glibc code to compile: ')
     if os.path.isdir(glibc) :
         glibc = os.path.abspath(glibc)
         glibcParent,glibcDir = os.path.split(glibc)
-        print '{0} + {1}'.format(glibcParent, glibcDir)
+        print 'building in {0}: {1}'.format(glibcParent, glibcDir)
+
+    if not quiet:
+        iput = raw_input('use {0} as the directory to build glibc in? ([y]/n): '.format(buildDir)).lower()
+        if not iput == 'y' and not iput == '':
+            buildDir = raw_input('the directory to build glibc in:  ')
 
-    iput = raw_input('use {0} as the directory to build glibc in? ([y]/n): '.format(buildDir)).lower()
-    if not iput == 'y' and not iput == '':
-        buildDir = raw_input('the directory to build glibc in:  ')
     buildDir = os.path.abspath(buildDir)
     print 'using build dir: {0}'.format(buildDir)
     if os.path.isdir(buildDir) :
-        clean = raw_input('clean build (delete {0}, rerun configure, etc.)? ([y]/n): '.format(buildDir))
+        if not quiet:
+            clean = raw_input('clean build (delete {0}, rerun configure, etc.)? ([y]/n): '.format(buildDir))
+        else:
+            clean = 'y'
+
         if clean == 'y' or clean == '':
             shutil.rmtree(buildDir)
             os.makedirs(buildDir)
@@ -72,9 +83,11 @@ try:
     else :
         os.makedirs(buildDir)
 
-    iput = raw_input('use {0} as the directory to install glibc in? ([y]/n): '.format(installDir)).lower()
-    if not iput == 'y' and not iput == '':
-        installDir = raw_input('the directory to install glibc in:  ')
+    if not quiet:
+        iput = raw_input('use {0} as the directory to install glibc in? ([y]/n): '.format(installDir)).lower()
+        if not iput == 'y' and not iput == '':
+            installDir = raw_input('the directory to install glibc in:  ')
+
     installDir = os.path.abspath(installDir)
     print 'using install dir: {0}'.format(installDir)
 
@@ -87,11 +100,12 @@ try:
     os.chdir(buildDir)
 
     cflags = '{0} -O2 -U_FORTIFY_SOURCE -fno-stack-protector'.format(debug_flags)
+    extra_defs = ''
     disabled_features = { 'nscd' }
     extra_flags = '--with-tls --enable-add-ons=nptl --without-selinux {0}'.format(' '.join(['--disable-' + f for f in disabled_features]))
 
     ##    configure
-    commandStr = r'CFLAGS="{2}" {0}/configure --prefix={1} {3} | tee configure.out'.format(glibc, installDir, cflags, extra_flags)
+    commandStr = r'CFLAGS="{2}" {3} {0}/configure --prefix={1} {4} | tee configure.out'.format(glibc, installDir, cflags, extra_defs, extra_flags)
     print commandStr
     commandOutput = subprocess.call(commandStr, shell=True)
 
@@ -107,8 +121,9 @@ try:
     link_binaries = [ ( 'elf',    'ld-linux-x86-64.so.2' ),
                       ( 'nptl',   'libpthread.so.0' ),
                       ( 'nptl_db','libthread_db.so.1' ),
-                      ( 'dlfcn',  'libdl.so.2' ),
                       ( 'math',   'libm.so.6' ),
+                      ( 'dlfcn',  'libdl.so.2' ),
+                      ( 'login',  'libutil.so.1' ),
                       ( 'csu',    'crt1.o' ),
                       ( 'csu',    'crti.o' ),
                       ( 'csu',    'crtn.o' ),

+ 29 - 21
Pal/Makefile

@@ -1,32 +1,30 @@
-LINUX_GEN = 3.x
-LINUX_SRC = linux-3.14
-SRC_DIR = src
-TEST_DIR = test
-DIRS = ${SRC_DIR} ${TEST_DIR} $(LINUX_SRC)
-
-NPROCS := 1
-OS := $(shell uname -s)
+OS ?= $(shell uname -s)
 ifeq ($(OS),Linux)
-	NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
+	NPROCS ?= $(shell grep -c ^processor /proc/cpuinfo)
+else
+	NPROCS ?= 1
 endif
 
+ifeq ($(OS),Linux)
+	LINUX_GEN := 3.x
+	LINUX_SRC := linux-3.14
+	LINUX_KERNEL := $(LINUX_SRC)/arch/x86/boot/bzImage
+endif
+
+DIRS = src test
+
 all debug:
-	for d in ${SRC_DIR} $(TEST_DIR); \
+	for d in $(DIRS); \
 	do \
 		make -C $$d $@; \
 	done
-	make $(LINUX_SRC)/arch/x86/boot/bzImage
-
-$(LINUX_SRC)/arch/x86/boot/bzImage: $(LINUX_SRC)/Makefile $(LINUX_SRC)/.config
-	make -C $(LINUX_SRC) -j$(NPROCS)
 
-install: $(LINUX_SRC)/arch/x86/boot/bzImage
-	make -C $(LINUX_SRC) install modules_install headers_install
+.PHONY: kernel
+kernel: $(LINUX_KERNEL)
 
-.PHONY: test
-
-test:
-	make -C test test
+ifneq ($(LINUX_KERNEL),)
+$(LINUX_KERNEL): $(LINUX_SRC)/Makefile $(LINUX_SRC)/.config
+	make -C $(LINUX_SRC) -j$(NPROCS)
 
 $(LINUX_SRC)/Makefile:
 	[ -f $(LINUX_SRC).tar.gz ] || \
@@ -37,6 +35,9 @@ $(LINUX_SRC)/Makefile:
 $(LINUX_SRC)/.config:
 	cd $(LINUX_SRC) && make menuconfig
 
+install: $(LINUX_KERNEL)
+	make -C $(LINUX_SRC) install modules_install headers_install
+
 linux-deb:
 	if [ -f $(LINUX_SRC)/.config ]; then \
 		cp /boot/config-$(shell uname -r) $(LINUX_SRC)/.config && \
@@ -45,9 +46,16 @@ linux-deb:
 	CONCURRENCY_LEVEL=$(NPROCS) make-kpkg --rootcmd fakeroot \
 		--append-to-version -graphene --initrd \
 		kernel-image kernel-headers
+else
+install:
+endif
+
+.PHONY: test
+test:
+	make -C test test
 
 clean:
-	for d in ${SRC_DIR} $(TEST_DIR) $(LINUX_SRC); \
+	for d in $(DIRS) $(LINUX_KERNEL); \
 	do \
 		make -C $$d clean; \
 	done