From: Jack Lange Date: Wed, 16 Mar 2011 00:11:45 +0000 (-0500) Subject: reworked build system to automatically compile Linux kernel module when selected... X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=ed4aa27a4901310df5fa1127ad62645da1bb4802;p=palacios.git reworked build system to automatically compile Linux kernel module when selected as the target OS --- diff --git a/Kconfig b/Kconfig index 6c11bac..5374402 100644 --- a/Kconfig +++ b/Kconfig @@ -17,8 +17,8 @@ config KITTEN help This enables the necesary options to compile Palacios with Kitten -config LINUX - bool "Linux 2.6" +config LINUX_BUILTIN + bool "OLD Linux (Built in) -- to be deprecated" select BUILT_IN_STDLIB select BUILT_IN_ATOI select FILE @@ -26,6 +26,23 @@ config LINUX This enables the necessary options to compile Palacios with Linux 2.6 Currently, this is in development, and only 2.6.32 is verified to work + +config LINUX + bool "Linux Module" + select BUILT_IN_STDLIB + select BUILT_IN_ATOI + select FILE + help + This enables the necessary options to compile Palacios as a Linux module + + +config LINUX_KERN + depends on LINUX + string "Linux Kernel Source directory" + default "/usr/src/linux" + help + This is the directory containing the linux source for the kernel module to be built + config MINIX bool "MINIX 3" help diff --git a/Makefile b/Makefile index 9acf2de..eb383bd 100644 --- a/Makefile +++ b/Makefile @@ -298,8 +298,10 @@ V3_INCLUDE := -Ipalacios/include \ CPPFLAGS := $(V3_INCLUDE) -D__V3VEE__ -CFLAGS := -fno-stack-protector -Wall -Werror -fPIC -mno-red-zone -fno-common -#-fPIC +CFLAGS := -fno-stack-protector -Wall -Werror -mno-red-zone -fno-common + + + #-ffreestanding @@ -434,6 +436,9 @@ libs-y := palacios/lib/$(ARCH)/ devices-y := palacios/src/devices/ modules-y := modules/ + + + ifeq ($(dot-config),1) # In this section, we need .config @@ -460,7 +465,12 @@ else palacios/include/autoconf.h: ; endif + +ifdef CONFIG_LINUX +DEFAULT_EXTRA_TARGETS=linux_module +else DEFAULT_EXTRA_TARGETS= +endif # The all: target is the default when no target is given on the # command line. @@ -469,6 +479,12 @@ DEFAULT_EXTRA_TARGETS= all: palacios $(DEFAULT_EXTRA_TARGETS) +ifdef CONFIG_LINUX +CFLAGS += -mcmodel=kernel +else +CFLAGS += -fPIC +endif + ifdef CONFIG_FRAME_POINTER CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) else @@ -529,6 +545,7 @@ core-y := $(patsubst %/, %/built-in.o, $(core-y)) devices-y := $(patsubst %/, %/built-in.o, $(devices-y)) libs-y := $(patsubst %/, %/built-in.o, $(libs-y)) modules-y := $(patsubst %/, %/built-in.o, $(modules-y)) + #core-y := $(patsubst %/, %/lib.a, $(core-y)) #devices-y := $(patsubst %/, %/lib.a, $(devices-y)) @@ -553,7 +570,8 @@ modules-y := $(patsubst %/, %/built-in.o, $(modules-y)) palacios := $(core-y) $(devices-y) $(libs-y) $(modules-y) -# Rule to link palacios - also used during CONFIG_KALLSYMS + +# Rule to link palacios - also used during CONFIG_CONFIGKALLSYMS # May be overridden by /Makefile.$(ARCH) quiet_cmd_palacios__ ?= AR $@ cmd_palacios__ ?= $(AR) rcs $@ $^ @@ -592,6 +610,14 @@ libv3vee.a: $(palacios) palacios: libv3vee.a + +linux_module/v3vee.ko: + cd linux_module/ && make CONFIG_LINUX_KERN=$(CONFIG_LINUX_KERN) + cp linux_module/v3vee.ko v3vee.ko + + +linux_module: linux_module/v3vee.ko + palacios.asm: palacios $(OBJDUMP) --disassemble $< > $@ @@ -707,7 +733,7 @@ clean: archclean $(clean-dirs) @find . $(RCS_FIND_IGNORE) \ \( -name 'lib' \) -prune -o \ \( -name '*.[oas]' -o -name '.*.cmd' \ - -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' -o -name '*.ko' \) \ -type f -print | xargs rm -f # mrproper - Delete all generated files, including .config diff --git a/linux_module/Makefile b/linux_module/Makefile index 55eb199..92cb318 100644 --- a/linux_module/Makefile +++ b/linux_module/Makefile @@ -1,33 +1,35 @@ -KERNELDIR := ../../linux-2.6.32.y/ -CONFIG_PALACIOS_PATH := /home/jarusl/palacios +LDFLAGS += --whole-archive --script=$(PWD)/link.cmd +EXTRA_CFLAGS += -I$(PWD)/../palacios/include/ -DMODULE=1 -D__KERNEL__=1 -v3vee-objs := palacios.o palacios-dev.o palacios-vm.o palacios-file.o palacios-stream.o palacios-console.o palacios-mm.o palacios-serial.o palacios-queue.o palacios-ringbuffer.o +v3vee-objs:= palacios.o \ + palacios-dev.o \ + palacios-vm.o \ + palacios-file.o \ + palacios-stream.o \ + palacios-console.o \ + palacios-mm.o \ + palacios-serial.o \ + palacios-queue.o \ + palacios-ringbuffer.o + #palacios-socket.o #palacios-vnet.o palacios-packet.o -v3vee-objs += ../../palacios/libv3vee.a +v3vee-objs += ../libv3vee.a obj-m := v3vee.o -LDFLAGS = --whole-archive --script=$(PWD)/link.cmd - - -EXTRA_CFLAGS := -I$(CONFIG_PALACIOS_PATH)/palacios/include/ -DMODULE=1 -D__KERNEL__=1 - - all: - $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + $(MAKE) -C $(CONFIG_LINUX_KERN) M=$(PWD) modules -clean: - $(MAKE) -C $(KERNELDIR) M=$(PWD) clean -install: - $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install /sbin/ -ae +clean: + $(MAKE) -C $(CONFIG_LINUX_KERN) M=$(PWD) clean