Commit 3511bec6 authored by Charlie Jacobsen's avatar Charlie Jacobsen Committed by Vikram Narayanan
Browse files

test-v2: Refactor test modules/examples build for external build.

I re-create the test_mods directory hierarchy in the build dir, and
bring over the Kbuilds. I also auto-generate the 'src =' line in
the Kbuilds for the external build hack.

Throughout the top-level Makefile, I use an additional hack. Let me
explain. We use recursive make to build dependencies (like versions
of libcap), because only the recursive make knows how to check that
the dependencies are up to date. But this means we have to make the
dependency targets phonies, so they always run. This in turn means
that those targets that depend on *them* will always run. To avoid
this, I use 'check for presence only' dependencies for these types
of dependencies that would trigger a full rebuild. The trick though
is to specify the final build output file as the dependency, rather
than the phony target, and to not create a rule for the final build
output file. (This way, if the file does not exist, the top-level
Makefile will just fail and say it doesn't know how to build the
file. It won't know that one of the phony targets does that.)

Anyway, test_mods is one example. It depends on liblcd.a being built,
but in order to prevent triggering a recursive make on liblcd.a, we
just use a 'check for presence only' type of dependency. It's up
to the person building to ensure they rebuild top-level targets
as necessary. (It doesn't seem easy to chain the whole build
together, with proper dependency management, since we're using
recursive make for dependency builds and kernel builds.)

build_all.sh updated to trigger build of all targets in the correct
order.
parent 862baeb8
#
# Top level build file for microkernel, tests, and test mods
#
# Note that: kliblcd is built with the microkernel, and
# liblcd is built before touching anything else (so we
# don't get recursive make issues).
#
# I hack KBUILD_CFLAGS so we don't have to do this in every kbuild file.
KBUILD_CFLAGS := $(KBUILD_CFLAGS) $(LCD_DOMAINS_CFLAGS)
# Dive into subdirs (note that kliblcd is built with microkernel)
obj-m += microkernel/
#obj-m += tests/
#obj-m += test-mods/
#
# Top-level makefile for building everything LCD-related.
#
# TARGETS:
# TARGETS (all phony):
#
# all -- Build microkernel, liblcd, and all
# test modules/examples
#
# libcap.microkernel -- Build libcap for the microkernel
#
# microkernel -- Build the LCD microkernel and kLIBLCD
# microkernel -- Build the LCD microkernel and kLIBLCD;
# depends on libcap.microkernel being exec'd
# from prior make run (we don't list this as
# a target dependency because otherwise it triggers
# a full microkernel re-build every time)
#
# libcap.liblcd -- Build libcap for isolated liblcd library kernel
#
# liblcd -- Build liblcd library kernel;
# depends on libcap.liblcd being exec'd from
# prior make run
#
# test_mods -- Builds all of the test modules/examples. It
# depends on liblcd target being exec'd from
# prior make run.
#
# clean -- Remove built object files and local
# install directories. But doesn't delete
......@@ -32,7 +49,15 @@ MAKEFLAGS += --no-print-directory
# in our Kbuild files.)
ARCH=x86
LCD_BUILD_DIR=$(LCD_DOMAINS_TOP_SRC_DIR)/build
LCD_BUILD_DIR_REL=build
LCD_BUILD_DIR=$(LCD_DOMAINS_TOP_SRC_DIR)/$(LCD_BUILD_DIR_REL)
# ------------------------------------------------------------
# all targets
# build_all.sh does the right target sequencing
all:
scripts/build_all.sh
# ------------------------------------------------------------
# Microkernel build setup
......@@ -54,17 +79,14 @@ MICROKERNEL_LIBCAP=$(MICROKERNEL_BUILD_DIR)/libcap.install/lib/libcap.a
MICROKERNEL_LIBCAP_CFLAGS= \
"-DLCD_DOMAINS -I$(LCD_DOMAINS_TOP_SRC_DIR)/include -I$(LCD_DOMAINS_TOP_SRC_DIR)/config/non_isolated"
microkernel: $(MICROKERNEL_BUILD_DIR)/Kbuild $(MICROKERNEL_LIBCAP) | \
$(MICROKERNEL_BUILD_DIRS)
$(MAKE) -C .. M=$(MICROKERNEL_BUILD_DIR) -j8
microkernel: $(MICROKERNEL_BUILD_DIR)/Kbuild | \
$(MICROKERNEL_LIBCAP) $(MICROKERNEL_BUILD_DIRS)
$(MAKE) -C .. M=$(MICROKERNEL_BUILD_DIR) $(MAKEFLAGS)
# (We don't combine this with the LCD microkernel build, because install
# triggers every time, and as a result, triggers a full microkernel
# rebuild.)
libcap.microkernel: $(MICROKERNEL_BUILD_DIR)/libcap.build/Makefile
$(MAKE) -C $(MICROKERNEL_BUILD_DIR)/libcap.build \
CFLAGS=$(MICROKERNEL_LIBCAP_CFLAGS) && \
$(MAKE) -C $(MICROKERNEL_BUILD_DIR)/libcap.build install
CFLAGS=$(MICROKERNEL_LIBCAP_CFLAGS) $(MAKEFLAGS) && \
$(MAKE) -C $(MICROKERNEL_BUILD_DIR)/libcap.build install $(MAKEFLAGS)
$(MICROKERNEL_BUILD_DIR)/libcap.build/Makefile: libcap/configure | \
$(MICROKERNEL_BUILD_DIRS)
......@@ -81,7 +103,8 @@ $(MICROKERNEL_BUILD_DIR)/Kbuild: scripts/Kbuild.microkernel | \
cp scripts/Kbuild.microkernel $(MICROKERNEL_BUILD_DIR)/Kbuild
$(MICROKERNEL_BUILD_DIRS):
mkdir -p $@
@echo " MKDIR $@"
@mkdir -p $@
# ------------------------------------------------------------
# LIBLCD build setup
......@@ -110,20 +133,18 @@ LIBLCD_LIBCAP_CFLAGS= \
# I mash this in one line for now.
LIBLCD_AR_SCRIPT="CREATE $(LIBLCD_BUILD_DIR)/liblcd.a\nADDLIB $(LIBLCD_BUILD_DIR)/lib.a\nADDLIB $(LIBLCD_BUILD_DIR)/libcap.install/lib/libcap.a\nSAVE\nEND\n"
liblcd: $(LIBLCD_BUILD_DIR)/liblcd.a
$(LIBLCD_BUILD_DIR)/liblcd.a: $(LIBLCD_BUILD_DIR)/lib.a $(LIBLCD_LIBCAP)
liblcd: $(LIBLCD_BUILD_DIR)/lib.a | $(LIBLCD_LIBCAP)
@echo " AR $@"
@echo $(LIBLCD_AR_SCRIPT) | ar -M
$(LIBLCD_BUILD_DIR)/lib.a: $(LIBLCD_BUILD_DIR)/Kbuild | \
$(LIBLCD_BUILD_DIRS)
$(MAKE) -C .. M=$(LIBLCD_BUILD_DIR) -j8
$(MAKE) -C .. M=$(LIBLCD_BUILD_DIR) $(MAKEFLAGS)
libcap.liblcd: $(LIBLCD_BUILD_DIR)/libcap.build/Makefile
$(MAKE) -C $(LIBLCD_BUILD_DIR)/libcap.build \
CFLAGS=$(LIBLCD_LIBCAP_CFLAGS) && \
$(MAKE) -C $(LIBLCD_BUILD_DIR)/libcap.build install
CFLAGS=$(LIBLCD_LIBCAP_CFLAGS) $(MAKEFLAGS) && \
$(MAKE) -C $(LIBLCD_BUILD_DIR)/libcap.build install $(MAKEFLAGS)
$(LIBLCD_BUILD_DIR)/libcap.build/Makefile: libcap/configure | \
$(LIBLCD_BUILD_DIRS)
......@@ -139,7 +160,45 @@ $(LIBLCD_BUILD_DIR)/Kbuild: scripts/Kbuild.liblcd | \
cp scripts/Kbuild.liblcd $(LIBLCD_BUILD_DIR)/Kbuild
$(LIBLCD_BUILD_DIRS):
mkdir -p $@
@echo " MKDIR $@"
@mkdir -p $@
# ------------------------------------------------------------
# Test modules/examples
LCD_TEST_MODULES_DIR=$(PWD)/test_mods
export LCD_TEST_MODULES_DIR
LCD_TEST_MODULES_BUILD_DIR=$(LCD_BUILD_DIR)/test_mods
export LCD_TEST_MODULES_BUILD_DIR
# Collect all of the example directories and kbuilds
TEST_MODULES_DIRS=$(shell cd $(LCD_TEST_MODULES_DIR) && \
find . -mindepth 1 -type d)
TEST_MODULES_KBUILDS=$(shell cd $(LCD_TEST_MODULES_DIR) && \
find . -name "Kbuild")
TEST_MODULES_BUILD_DIRS=$(foreach dir,$(TEST_MODULES_DIRS), \
$(LCD_TEST_MODULES_BUILD_DIR)/$(dir))
TEST_MODULES_BUILD_KBUILDS=$(foreach kb,$(TEST_MODULES_KBUILDS), \
$(LCD_TEST_MODULES_BUILD_DIR)/$(kb))
test_mods: $(TEST_MODULES_BUILD_KBUILDS) $(TEST_MODULES_BUILD_DIRS) | \
$(LIBLCD_BUILD_DIR)/liblcd.a
$(MAKE) -C .. M=$(LCD_TEST_MODULES_BUILD_DIR) $(MAKEFLAGS)
# This rule does the external source hack (define "src" in Kbuild file)
$(LCD_TEST_MODULES_BUILD_DIR)/%/Kbuild: $(LCD_TEST_MODULES_DIR)/%/Kbuild | \
$(TEST_MODULES_BUILD_DIRS)
@echo " KBUILD $^"
@printf "#\n# BEGIN: Auto-generated part. ('src =' line auto-generated).\n#\n\n" > $@ && \
printf "src = $(shell dirname `readlink -f $^`)\n\n" >> $@ && \
printf "#\n# END: Auto-generated part.\n#\n\n" >> $@ && \
cat $^ >> $@
$(TEST_MODULES_BUILD_DIRS):
@echo " MKDIR $@"
@mkdir -p $@
# ------------------------------------------------------------
# Some libcap tidbits
......@@ -165,6 +224,7 @@ clean:
fi
rm -rf $(MICROKERNEL_BUILD_DIR)/libcap.install
rm -rf $(LIBLCD_BUILD_DIR)/libcap.install
rm -rf $(LCD_TEST_MODULES_BUILD_DIR)
distclean:
rm -rf $(LCD_BUILD_DIR)
......@@ -177,5 +237,6 @@ distclean:
libcap.microkernel \
liblcd \
libcap.liblcd \
test_mods \
clean \
distclean
#
# Top level makefile (this isn't touched by the kernel
# since we have a kbuild file)
#
export LCD_DOMAINS_INCLUDE=$(PWD)/include
export LCD_DOMAINS_CFLAGS=-Werror \
-I$(LCD_DOMAINS_INCLUDE) \
-DLCD_DOMAINS \
-DCONFIG_LAZY_THC
# Don't print "Entering directory..." etc.
MAKEFLAGS += --no-print-directory
all: liblcd the_rest
the_rest: liblcd libcap.microkernel
$(MAKE) -C .. M=$(PWD) -j8
liblcd: libcap.lcd
$(MAKE) -C .. M=$(PWD)/liblcd -j8
libcap.lcd: libcap.build.lcd/Makefile
$(MAKE) -C libcap.build.lcd && \
$(MAKE) -C libcap.build.lcd install
libcap.build.lcd/Makefile: libcap/configure | libcap.build.lcd libcap.out.lcd
cd libcap.build.lcd && \
../libcap/configure PLATFORM=kernel --disable-test-build \
--with-kernel-headers=$(PWD)/.. \
--disable-kernel-module \
--prefix=$(PWD)/libcap.out.lcd
libcap.build.lcd:
mkdir -p libcap.build.lcd
libcap.out.lcd:
mkdir -p libcap.out.lcd
libcap.microkernel: libcap.build.microkernel/Makefile
$(MAKE) -C libcap.build.microkernel && \
$(MAKE) -C libcap.build.microkernel install
libcap.build.microkernel/Makefile: libcap/configure | libcap.build.microkernel \
libcap.out.microkernel
cd libcap.build.microkernel && \
../libcap/configure PLATFORM=kernel --disable-test-build \
--disable-global-cap-types \
--with-kernel-headers=$(PWD)/.. \
--disable-kernel-module \
--prefix=$(PWD)/libcap.out.microkernel
libcap.build.microkernel:
mkdir -p libcap.build.microkernel
libcap.out.microkernel:
mkdir -p libcap.out.microkernel
libcap/configure:
cd libcap && ./autogen.sh
clean:
$(MAKE) -C .. M=$(PWD) clean
$(MAKE) -C .. M=$(PWD)/liblcd clean
if test -d libcap.build.lcd; then $(MAKE) -C libcap.build.lcd clean; fi
if test -d libcap.build.microkernel; then $(MAKE) -C libcap.build.microkernel clean; fi
distclean: clean
if test -d libcap.build.lcd; then $(MAKE) -C libcap.build.lcd distclean; fi
if test -d libcap.build.microkernel; then \
$(MAKE) -C libcap.build.microkernel distclean; fi
rm -rf libcap.build.microkernel libcap.out.microkernel
rm -rf libcap.build.lcd libcap.out.lcd
.PHONY: all the_rest liblcd libcap.microkernel libcap.lcd
......@@ -3,4 +3,5 @@
make libcap.microkernel
make microkernel
make libcap.liblcd
make liblcd
\ No newline at end of file
make liblcd
make test_mods
#
# Modules for testing
#
# This should be built before entering this file (it will be
# if you use the top level makefile in lcd-domains/Makefile)
export LIBLCD = ../../liblcd/lib.a
obj-m += load/
obj-m += ipc1/
obj-m += ipc2/
obj-m += liblcd_tests/
obj-m += create_klcd/
obj-m += glue_example/
obj-m += pmfs/
obj-m += async/
obj-m += string_example/
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment