Files
mckernel/kernel/Makefile.mpiu
2013-02-15 19:58:03 +09:00

48 lines
1.1 KiB
Makefile
Executable File

BUILD_TARGET ?= attached-mic
SRC = $(CURDIR)
IHKBASE ?= $(SRC)/../../ihk/cokernel
O ?= $(KBUILD_OUTPUT)
V ?= $(VERBOSE)
CONFIG_V ?= KNF
EXTRA_OBJS ?=
KERNEL = kernel.img
KERNELS = $(addsuffix /$(KERNEL),$(addprefix $(O)/,$(BUILD_TARGET)))
SUBCMD_OPTS = V='$(V)'
$(if $(O),,$(error Specify the compilation target directory))
#$(if $(shell ls $(IHKBASE)/Makefile),,\
# $(error IHK is not found in $(IHKBASE)))
.PHONY: all clean depend
all: $(KERNELS)
%/kernel.img: %/Makefile
@echo 'Building for' $(dir $@)
@make --no-print-directory -C $(dir $@) $(SUBCMD_OPTS)
%/Makefile: Makefile.build.mpiu FORCE
rm -f $@
@mkdir -p $(dir $@)
@echo 'SRC = $(SRC)' > $@
@echo 'IHKBASE = $(IHKBASE)' >> $@
@echo 'TARGET = $(notdir $(patsubst %/,%,$(dir $@)))' >> $@
@echo 'TARGETDIR = $$(shell echo $$(TARGET) | sed "s/-/\//")' >> $@
@echo 'CONFIG_V = $(CONFIG_V)' >> $@
@echo 'EXTRA_OBJS = $(EXTRA_OBJS)' >> $@
@cat Makefile.build.mpiu >> $@
@rm -f $(dir $@)/Makefile.dep
clean: $(addsuffix .clean,$(BUILD_TARGET))
%.clean: $(O)/%/Makefile
@make --no-print-directory -C $(O)/$(basename $@) $(SUBCMD_OPTS) clean
FORCE: