2015-05-10 04:39:56 +08:00
|
|
|
PROJECT_BASE ?= $(shell pwd)
|
2015-02-22 06:05:51 +08:00
|
|
|
ARCH?=x86
|
|
|
|
|
2015-05-06 06:21:55 +08:00
|
|
|
export ARCH VPFILE
|
|
|
|
|
2015-05-10 04:39:56 +08:00
|
|
|
ifdef BSP
|
|
|
|
ifdef KERNEL_TYPE
|
|
|
|
KBUILD_DEFCONFIG=$(KERNEL_TYPE)_$(BSP)_defconfig
|
|
|
|
export KBUILD_DEFCONFIG
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef KBUILD_DEFCONFIG
|
|
|
|
CONFIG_DEPS=initconfig
|
|
|
|
else
|
|
|
|
CONFIG_DEPS=FORCE
|
|
|
|
endif
|
|
|
|
|
2015-05-10 06:34:57 +08:00
|
|
|
ifndef SOURCE_DIR
|
|
|
|
SOURCE_DIR=$(PROJECT_BASE)/src/
|
|
|
|
endif
|
|
|
|
|
2015-05-06 06:21:55 +08:00
|
|
|
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
|
|
|
else if [ -x /bin/bash ]; then echo /bin/bash; \
|
|
|
|
else echo sh; fi ; fi)
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-05-10 04:39:56 +08:00
|
|
|
all: $(CONFIG_DEPS)
|
2015-02-22 06:05:51 +08:00
|
|
|
$(Q)$(MAKE) -C $(TIMO_BASE) O=$(PROJECT_BASE) \
|
2015-05-10 06:34:57 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR)
|
2015-02-22 06:05:51 +08:00
|
|
|
|
|
|
|
rm-files:= final-linker.cmd linker.cmd modules.order \
|
2015-05-01 06:19:04 +08:00
|
|
|
staticIdt.o System.map *kernel.lnk \
|
|
|
|
*kernel.map *kernel.elf
|
2015-05-10 07:11:51 +08:00
|
|
|
rm-objects:= *.o
|
2015-02-22 06:05:51 +08:00
|
|
|
rm-dirs := arch drivers include kernel lib misc \
|
|
|
|
scripts source
|
|
|
|
|
2015-05-10 07:11:51 +08:00
|
|
|
cmd_clean_inner_files = \
|
|
|
|
$(shell cd $(PROJECT_BASE);rm $(rm-files) -f; rm $(rm-dirs) -rf)
|
|
|
|
|
2015-02-22 06:05:51 +08:00
|
|
|
clean: FORCE
|
2015-05-10 07:11:51 +08:00
|
|
|
@rm $(SOURCE_DIR)$(rm-objects) -f
|
|
|
|
$(call cmd_clean_inner_files)
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-05-10 07:11:51 +08:00
|
|
|
mrproper: FORCE
|
|
|
|
$(call cmd_clean_inner_files)
|
2015-02-22 06:05:51 +08:00
|
|
|
$(Q)$(MAKE) -C $(TIMO_BASE) \
|
2015-05-06 06:21:55 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) mrproper
|
2015-02-22 06:05:51 +08:00
|
|
|
|
|
|
|
%config: FORCE
|
|
|
|
$(Q)$(MAKE) -C $(TIMO_BASE) O=$(PROJECT_BASE) \
|
2015-05-06 06:21:55 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) $@
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-05-10 04:39:56 +08:00
|
|
|
qemu: $(CONFIG_DEPS)
|
2015-05-01 03:14:29 +08:00
|
|
|
$(Q)$(MAKE) -C $(TIMO_BASE) O=$(PROJECT_BASE) \
|
2015-05-06 06:21:55 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) qemu
|
|
|
|
|
2015-05-09 20:53:23 +08:00
|
|
|
cmd_defconfig = \
|
2015-05-10 04:39:56 +08:00
|
|
|
$(Q)test -s .config || $(Q) $(MAKE) -C $(TIMO_BASE) O=$(PROJECT_BASE) \
|
|
|
|
PROJECT=$(PROJECT_BASE) defconfig
|
2015-05-09 20:53:23 +08:00
|
|
|
|
2015-05-09 18:39:05 +08:00
|
|
|
cmd_merge_config = set -e; \
|
2015-05-09 20:53:23 +08:00
|
|
|
$(call cmd_defconfig) \
|
2015-05-10 04:39:56 +08:00
|
|
|
$(Q)test -s $(CONF_OVERLAY) || \
|
2015-05-06 06:21:55 +08:00
|
|
|
$(Q)$(CONFIG_SHELL) $(TIMO_BASE)/scripts/kconfig/merge_config.sh \
|
2015-05-10 04:39:56 +08:00
|
|
|
-m -O $(PROJECT_BASE) $(PROJECT_BASE)/.config $(CONF_OVERLAY)
|
2015-05-09 18:39:05 +08:00
|
|
|
|
2015-05-10 04:39:56 +08:00
|
|
|
initconfig:
|
2015-05-09 18:39:05 +08:00
|
|
|
$(call cmd_merge_config)
|
2015-05-06 06:21:55 +08:00
|
|
|
$(Q)yes "" | $(MAKE) -C $(TIMO_BASE) O=$(PROJECT_BASE) \
|
|
|
|
PROJECT=$(PROJECT_BASE) oldconfig
|
|
|
|
|
2015-05-01 03:14:29 +08:00
|
|
|
|
2015-05-10 07:11:51 +08:00
|
|
|
PHONY += FORCE clean mrproper
|
2015-02-22 06:05:51 +08:00
|
|
|
FORCE:
|
|
|
|
|
|
|
|
.PHONY: $(PHONY)
|