Kbuild Makefile mechanism for samples and projects.

This commit adds the capability to the Kbuild system of adding
samples and projects to the build process.
This commits adds the hello_world and philosophers sample code
as an example of how to configure a project into the build
system.
The project can be hosted inside the kernel source tree or
outside the kernel source tree.

Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
Change-Id: Id980e959ac6e0061f8227d5d81191a169bfc8fc3
This commit is contained in:
Juan Manuel Cruz 2015-02-21 16:05:51 -06:00 committed by Anas Nashif
parent 6de34008ab
commit 4ee8a8e042
8 changed files with 54 additions and 1 deletions

31
Makefile.inc Normal file
View file

@ -0,0 +1,31 @@
PROJECT_BASE = $(shell pwd)
ARCH?=x86
export ARCH CFLAGS LDFLAGS KBUILD_DEFCONFIG
all: FORCE
$(Q)$(MAKE) -C $(TIMO_BASE) O=$(PROJECT_BASE) \
PROJECT=$(PROJECT_BASE) VPFILE=$(VPFILE)
rm-files:= final-linker.cmd linker.cmd modules.order \
staticIdt.o System.map tinymountain.lnk \
tinymountain.map tinymountain.elf
rm-dirs := arch drivers include kernel lib misc \
scripts source
clean: FORCE
$(shell rm $(rm-files))
$(shell rm $(rm-dirs) -r)
mrproper: clean
$(Q)$(MAKE) -C $(TIMO_BASE) \
PROJECT=$(PROJECT_BASE) VPFILE=$(VPFILE) mrproper
%config: FORCE
$(Q)$(MAKE) -C $(TIMO_BASE) O=$(PROJECT_BASE) \
PROJECT=$(PROJECT_BASE) VPFILE=$(VPFILE) $@
PHONY += FORCE
FORCE:
.PHONY: $(PHONY)

View file

@ -1,2 +1,2 @@
obj-y = configs.o
obj-$(CONFIG_MICROKERNEL) += nodes/
obj-$(SYSGEN_EXEC) += nodes/

View file

@ -0,0 +1,4 @@
TIMO_BASE = $(strip $(subst /samples/microkernel/apps/hello_world,,$(shell pwd) ))
VPFILE ?= prj.vpf
include ${TIMO_BASE}/Makefile.inc

View file

@ -0,0 +1,3 @@
EXTRA_CFLAGS += ${PROJECTINCLUDE}
obj-y = hello.o

View file

@ -0,0 +1,4 @@
TIMO_BASE = $(strip $(subst /samples/microkernel/apps/philosophers,,$(shell pwd) ))
VPFILE ?= prj.vpf
include ${TIMO_BASE}/Makefile.inc

View file

@ -0,0 +1,3 @@
EXTRA_CFLAGS += ${PROJECTINCLUDE}
lib-y = phil_fiber.o phil_task.o

View file

@ -0,0 +1,4 @@
TIMO_BASE = $(strip $(subst /samples/nanokernel/apps/hello_world,,$(shell pwd) ))
VPFILE ?= prj.vpf
include ${TIMO_BASE}/Makefile.inc

View file

@ -0,0 +1,4 @@
TIMO_BASE = $(strip $(subst /samples/nanokernel/apps/philosophers,,$(shell pwd) ))
VPFILE ?= prj.vpf
include ${TIMO_BASE}/Makefile.inc