- make should be $(MAKE) - add + in front of rules spawning long-lasted make process in a subshell. (This would not be needed with $(MAKE) -C .. target, but our makefiles do not handle that because they use $(PWD)) - split the main 'all' rule as all 4 targets are independant - fix dependencies where appropriate for parallelism Extra, not speed-related changes: - remove some double-colon for targets as they do not need it This cuts build time from 5s to 1.5s on a laptop with -j4, and more importantly from 85s to 35s on a KNL node. As a bonus, the fixed dependencies removes the need to clean before rebuilding all the time. Probably.
53 lines
1.3 KiB
Makefile
53 lines
1.3 KiB
Makefile
BUILD_TARGET ?= @TARGET@
|
|
KERNDIR=@KERNDIR@
|
|
VPATH=@abs_srcdir@
|
|
|
|
ifeq ($(ARCH), arm64)
|
|
vdsodir=@abs_builddir@/../arch/$(ARCH)/kernel/vdso
|
|
endif
|
|
|
|
IHKBASE ?= $(VPATH)/../../ihk/cokernel
|
|
O ?= $(CURDIR)/build
|
|
V ?= $(VERBOSE)
|
|
|
|
KERNEL = kernel.img
|
|
KERNELS = $(addsuffix /$(KERNEL),$(addprefix $(O)/,$(BUILD_TARGET)))
|
|
|
|
SUBCMD_OPTS = V='$(V)' BUILD_IHK_COKERNEL=@abs_builddir@/../../ihk/cokernel
|
|
|
|
$(if $(O),,$(error Specify the compilation target directory))
|
|
#$(if $(shell ls $(IHKBASE)/Makefile),,\
|
|
# $(error IHK is not found in $(IHKBASE)))
|
|
|
|
.PHONY: all clean depend install
|
|
|
|
all: $(O) $(KERNELS)
|
|
|
|
$(O):
|
|
mkdir -p $(O)
|
|
|
|
%/kernel.img: %/Makefile $(KERNELS)
|
|
@echo 'Building for' $(dir $@)
|
|
+@make --no-print-directory -C $(dir $@) $(SUBCMD_OPTS)
|
|
|
|
%/Makefile: Makefile.build FORCE
|
|
@mkdir -p $(dir $@)
|
|
@echo 'SRC = $(SRC)' > $@
|
|
@echo 'IHKBASE = $(IHKBASE)' >> $@
|
|
@echo 'TARGET = $(notdir $(patsubst %/,%,$(dir $@)))' >> $@
|
|
@echo 'TARGETDIR = $$(shell echo $$(TARGET) | sed "s/-/\//")' >> $@
|
|
@cat Makefile.build >> $@
|
|
@rm -f $(dir $@)/Makefile.dep
|
|
|
|
clean:
|
|
rm -rf $(O)
|
|
ifeq ($(ARCH), arm64)
|
|
@rm -f $(vdsodir)/*.o $(vdsodir)/vdso.* $(vdsodir)/Makefile.dep -r $(vdsodir)/../include
|
|
endif
|
|
|
|
install:
|
|
mkdir -p -m 755 $(KERNDIR)
|
|
install -m 755 $(O)/$(BUILD_TARGET)/kernel.img $(KERNDIR)/mckernel.img
|
|
|
|
FORCE:
|