new Makefile

This commit is contained in:
Taku Shimosawa
2011-09-28 16:11:27 +09:00
parent abaa2d3a08
commit 6ba196e1df
2 changed files with 33 additions and 27 deletions

View File

@ -1,27 +1,37 @@
BUILD_TARGET = mee knf
BUILD_DIR = ../../build/mcos
SRC = $PWD
SRC = $(CURDIR)
AALBASE ?= $(SRC)/../../aal/manycore
O ?= $(KBUILD_OUTPUT)
V ?= $(VERBOSE)
KERNEL = kernel.img
KERNELS = $(addsuffix /$(KERNEL),$(addprefix $(BUILD_DIR)/,$(BUILD_TARGET)))
KERNELS = $(addsuffix /$(KERNEL),$(addprefix $(O)/,$(BUILD_TARGET)))
SUBCMD_OPTS = V='$(V)'
$(if $(O),,$(error Specify the compilation target directory))
$(if $(shell ls $(AALBASE)/Makefile.aal),,\
$(error AAL is not found in $(AALBASE)))
.PHONY: all clean
all: $(KERNELS)
%/kernel.img: %/Makefile
@echo 'MAKE TARGET' $(dir $@)
@make -C $(dir $@)
@echo 'Building for' $(dir $@)
@make --no-print-directory -C $(dir $@) $(SUBCMD_OPTS)
%/Makefile: Makefile.build FORCE
@mkdir -p $(dir $@)
@echo 'SRC = $(PWD)' > $@
@echo 'SRC = $(SRC)' > $@
@echo 'AALBASE = $(AALBASE)' >> $@
@echo 'TARGET = $(notdir $(patsubst %/,%,$(dir $@)))' >> $@
@cat Makefile.build >> $@
clean: $(addsuffix .clean,$(BUILD_TARGET))
%.clean: $(BUILD_DIR)/%/Makefile
@make -C $(BUILD_DIR)/$(basename $@) clean
%.clean: $(O)/%/Makefile
@make -C $(O)/$(basename $@) $(SUBCMD_OPTS) clean
FORCE: