Improve Makefile.
authorAnselm Busse <anselm.busse@tu-berlin.de>
Thu, 21 Jan 2016 20:44:52 +0000 (21:44 +0100)
committerAnselm Busse <anselm.busse@tu-berlin.de>
Sat, 23 Jan 2016 20:25:44 +0000 (21:25 +0100)
framework/os/linux/Makefile
linux/Makefile

index 8bdc9fa..e962f56 100644 (file)
@@ -24,10 +24,8 @@ obj-$(CONFIG_MOD_FCFS)                               += ../../modules/fcfs.o
 obj-$(CONFIG_MOD_LOAD_BALANCING)       += ../../modules/load_balance.o
 obj-$(CONFIG_MOD_AFFINITIES)           += ../../modules/affinities.o
 
-$(obj)/os.o: modsched_dirs
+$(obj)/os.o: $(obj)/../../lib $(obj)/../../modules $(obj)/../../generated
 
-modsched_dirs:
-       $(Q)mkdir -p $(obj)/../../lib
-       $(Q)mkdir -p $(obj)/../../modules
-       $(Q)mkdir -p $(obj)/../../generated
+$(obj)/../../lib $(obj)/../../modules $(obj)/../../generated:
+       $(Q)mkdir -p $@
 
index 56f9b38..ade5924 100644 (file)
@@ -7,14 +7,16 @@ DEV_DIR = dev
 PWD = $(shell pwd)
 BUILD_DIR ?= $(PWD)/build
 
+# Set to latest kernel version
+KERNEL_VERSION ?= 4.4.0
 # Set to latest BusyBox version
-BB_VERSION = 1.24.1
+BB_VERSION ?= 1.24.1
 
 # Enter BusyBox configuration filename
-BB_CONFIG = bb_config
+BB_CONFIG ?= busybox-$(BB_VERSION)-config
 
 # Enter Linux kernel configuration filename
-KERNEL_CONFIG = kernel-4.4.0-config
+KERNEL_CONFIG ?= kernel-$(KERNEL_VERSION)-config
 
 # Initramfs configuration file for Linux kernel
 INITRAMFS_TMPL = initramfs.conf.tmpl
@@ -42,10 +44,10 @@ GIT_ARCHIVE = archive --remote=git:projects/modsched/$(DEV_DIR).git HEAD:linux/
 MAKE_DIR = $(shell pwd)
 
 # Number of cores
-CPU_CORES ?= 16
+CPU_CORES ?= 6
 
 # Dependencies
-PREREQ_CONFIG = $(INITRAMFS_CONFIG) $(BB_BIN) $(KERNEL_CONFIG) $(US_BIN)
+PREREQ_CONFIG = $(INITRAMFS_CONFIG) $(KERNEL_CONFIG)
 
 
 
@@ -73,59 +75,54 @@ CP  = cp
 .PHONY : $(BUILD_DIR)/arch/x86/boot/bzImage
 
 .PHONY : all 
-all: check bzImage $(LINUX_DIR)/bzImage $(LINUX_DIR)/vmlinux
-
+all: bzImage vmlinux
 
 .PHONY : clean
 clean:
-       $(RM) -r busybox-1.21.0*  $(INITRAMFS_CONFIG)
-
+       $(RM) -r busybox-*  $(INITRAMFS_CONFIG)
 
-check:
-       @if [ ! -f ./$(LINUX_DIR)/Makefile ]; then \
-               echo "Error: No Linux Kernel found."; \
-               echo "Please clone the latest linux kernel from 'modsched' repository first."; \
-               false; \
-       fi
+.PHONY: menuconfig
+menuconfig:
+       $(CD) $(LINUX_DIR) && $(MAKE) O=$(BUILD_DIR) menuconfig
 
 vmlinux: $(BUILD_DIR)/vmlinux
        $(CP) $< $@
 
-$(LINUX_DIR)/vmlinux: vmlinux
-       $(CP) $< $@
+$(BUILD_DIR)/vmlinux: $(BUILD_DIR)/arch/x86/boot/bzImage
+       touch $@
 
 bzImage: $(BUILD_DIR)/arch/x86/boot/bzImage
        $(CP) $< $@
 
-$(LINUX_DIR)/bzImage: bzImage
-       $(CP) $< $@
-
-$(BUILD_DIR)/vmlinux:
-       @echo "Building bzImage kernel..."
-       $(CD) $(LINUX_DIR); $(MAKE) O=$(BUILD_DIR) vmlinux
-       @echo "Finished."
+$(BUILD_DIR)/arch/x86/boot/bzImage: $(BUILD_DIR)/.config $(BUILD_DIR)/initramfs.conf
+       @echo "Recompiling Linux kernel..."
+       $(CD) $(LINUX_DIR) && $(MAKE) O=$(BUILD_DIR) bzImage vmlinux
+       
 
-$(BUILD_DIR)/arch/x86/boot/bzImage: $(PREREQ_CONFIG) $(BUILD_DIR)/.config
-       @echo "Building bzImage kernel..."
-       $(CD) $(LINUX_DIR); $(MAKE) O=$(BUILD_DIR) bzImage
-       @echo "Finished."
+$(BUILD_DIR)/.config: $(KERNEL_CONFIG)
+       if [ ! -d $(BUILD_DIR) ]; then \
+               echo "Creating build directory..."; \
+               $(MKDIR) $(BUILD_DIR); \
+       fi; \
+       if [ -f $@ ]; then \
+               echo "Creating backup of kernel configuration..."; \
+               $(MV) $@ $@.old; \
+       fi; \
+       $(CP) $< $@
 
-$(BB_CONFIG):
-       @echo "Fetching BusyBox Config..."
-       $(GIT) $(GIT_ARCHIVE) $(BB_CONFIG) | $(TAR) -x; \
-       @echo " done."
+$(BUILD_DIR)/initramfs.conf: $(INITRAMFS_TMPL)
+       if [ ! -d $(BUILD_DIR) ]; then \
+               echo "Creating build directory..."; \
+               $(MKDIR) $(BUILD_DIR); \
+       fi; \
+       $(SED) "s|===HOME===|$(PWD)|g" $< > $@
 
-$(BB_BIN): $(BB_CONFIG) $(BB_DIR)
+$(BB_BIN): $(BB_DIR)/.config
        @echo "Building BusyBox..."
-       $(CD) $(BB_DIR) && $(CP) ../$(BB_CONFIG) .config && $(MAKE)
+       $(CD) $(BB_DIR) && $(MAKE)
        @echo " done."
 
-#ifeq ($(BB_CONFIG),)
-#              @echo "ERROR: No configuration file for BusyBox was found."             
-#+             false
-#      endif
-
-$(BB_DIR):
+$(BB_DIR)/.config: $(BB_CONFIG)
        if [ ! -e "$(BB_DIR)" ] ; then \
                echo "Link '$(BB_DIR)' is invalid."; \
                if [ ! -e "$(BB_PACKAGE)" ] ; then \
@@ -137,31 +134,8 @@ $(BB_DIR):
                ln -sf busybox-$(BB_VERSION) busybox; \
                echo "Regenerating link to '$(BB_DIR)'"; \
        fi
-
-
-$(KERNEL_CONFIG):
-       @echo "Checking if kernel configuration exist..."
-       $(GIT) $(GIT_ARCHIVE) $(KERNEL_CONFIG) | $(TAR) -x; \
-       @echo " done."
-
-$(INITRAMFS_CONFIG): $(INITRAMFS_TMPL)
-       if [ ! -d $(BUILD_DIR) ]; then \
-               echo "Creating build directory..."; \
-               $(MKDIR) $(BUILD_DIR); \
-       fi; \
-       $(SED) "s|===HOME===|$(PWD)|g" $< > $@
-       
-
-$(BUILD_DIR)/.config: $(KERNEL_CONFIG)
-       if [ ! -d $(BUILD_DIR) ]; then \
-               echo "Creating build directory..."; \
-               $(MKDIR) $(BUILD_DIR); \
-       fi; \
-       if [ -f $@ ]; then \
-               echo "Creating backup of kernel configuration..."; \
-               $(MV) $@ $@.old; \
-       fi; \
        $(CP) $< $@
 
+
 $(US_BIN): $(US_BIN).c
        $(CC) -static $< -o $@
\ No newline at end of file