2015-05-09 22:39:56 +02:00
|
|
|
PROJECT_BASE ?= $(shell pwd)
|
2015-02-21 23:05:51 +01:00
|
|
|
ARCH?=x86
|
|
|
|
|
2015-06-01 18:48:10 +02:00
|
|
|
O ?= $(PROJECT_BASE)/outdir
|
2015-07-23 01:15:43 +02:00
|
|
|
# Turn O into an absolute path; we call the main Kbuild with $(MAKE) -C
|
|
|
|
# which changes the working directory, relative paths don't work right.
|
|
|
|
# Need to create the directory first to make readlink happy
|
|
|
|
$(shell mkdir -p $(O))
|
|
|
|
override O := $(shell readlink -f $(O))
|
2015-06-01 18:48:10 +02:00
|
|
|
|
2015-06-05 22:24:46 +02:00
|
|
|
export ARCH MDEF_FILE QEMU_EXTRA_FLAGS PROJECT_BASE
|
2015-05-06 00:21:55 +02:00
|
|
|
|
2015-07-14 23:22:18 +02:00
|
|
|
ifdef PLATFORM_CONFIG
|
|
|
|
ifndef KERNEL_TYPE
|
|
|
|
$(error KERNEL_TYPE is not defined! Set it to either micro or nano)
|
|
|
|
endif
|
|
|
|
KBUILD_DEFCONFIG=$(KERNEL_TYPE)_$(PLATFORM_CONFIG)_defconfig
|
|
|
|
export KBUILD_DEFCONFIG
|
|
|
|
endif
|
|
|
|
|
2015-05-09 22:39:56 +02:00
|
|
|
ifdef KBUILD_DEFCONFIG
|
2015-06-01 18:48:10 +02:00
|
|
|
CONFIG_DEPS=$(O)/.initconfig
|
2015-05-09 22:39:56 +02:00
|
|
|
else
|
|
|
|
CONFIG_DEPS=FORCE
|
|
|
|
endif
|
|
|
|
|
2015-07-17 21:03:52 +02:00
|
|
|
SOURCE_DIR ?= $(PROJECT_BASE)/src/
|
|
|
|
# Kbuild doesn't work correctly if this is an absolute path
|
2015-07-28 13:44:03 +02:00
|
|
|
override SOURCE_DIR := $(shell python -c "import os.path; print(\"%s\" % os.path.relpath('$(SOURCE_DIR)', '$(ZEPHYR_BASE)'))")/
|
2015-05-10 13:59:05 +02:00
|
|
|
export SOURCE_DIR
|
2015-05-21 18:08:16 +02:00
|
|
|
|
2015-05-06 00:21:55 +02: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-21 23:05:51 +01:00
|
|
|
|
2015-05-26 23:50:44 +02:00
|
|
|
ifeq ("$(origin V)", "command line")
|
|
|
|
KBUILD_VERBOSE = $(V)
|
|
|
|
endif
|
|
|
|
ifndef KBUILD_VERBOSE
|
|
|
|
KBUILD_VERBOSE = 0
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(KBUILD_VERBOSE),1)
|
|
|
|
Q =
|
|
|
|
S =
|
|
|
|
else
|
|
|
|
Q = @
|
|
|
|
S = -s
|
|
|
|
endif
|
|
|
|
|
2015-06-18 16:46:52 +02:00
|
|
|
all: $(CONFIG_DEPS) $(O)/.dir
|
2015-06-06 04:46:00 +02:00
|
|
|
$(Q)$(MAKE) -C $(ZEPHYR_BASE) O=$(O) \
|
2015-07-14 22:44:42 +02:00
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) \
|
|
|
|
CFLAGS=$(CFLAGS)
|
2015-02-21 23:05:51 +01:00
|
|
|
|
2015-05-21 18:08:16 +02:00
|
|
|
rm-files:= .config
|
2015-05-10 01:11:51 +02:00
|
|
|
rm-objects:= *.o
|
2015-05-21 18:08:16 +02:00
|
|
|
rm-dirs := $(O)
|
2015-02-21 23:05:51 +01:00
|
|
|
|
2015-05-10 01:11:51 +02:00
|
|
|
cmd_clean_inner_files = \
|
2015-07-14 22:44:42 +02:00
|
|
|
$(shell cd $(PROJECT_BASE);rm $(rm-files) -f; rm $(rm-dirs) -rf)
|
2015-05-10 01:11:51 +02:00
|
|
|
|
2015-02-21 23:05:51 +01:00
|
|
|
clean: FORCE
|
2015-05-26 23:50:44 +02:00
|
|
|
$(Q)rm $(SOURCE_DIR)$(rm-objects) -f
|
|
|
|
$(Q)rm $(SOURCE_DIR)/modules.order -f
|
|
|
|
$(Q)rm $(SOURCE_DIR)/.*.cmd -f
|
2015-05-10 01:11:51 +02:00
|
|
|
$(call cmd_clean_inner_files)
|
2015-02-21 23:05:51 +01:00
|
|
|
|
2015-05-18 14:58:55 +02:00
|
|
|
pristine: distclean
|
|
|
|
|
2015-05-10 20:37:10 +02:00
|
|
|
distclean: clean
|
|
|
|
@rm $(PROJECT_BASE)/.config -f
|
2015-05-19 23:36:10 +02:00
|
|
|
@rm $(PROJECT_BASE)/.config.old -f
|
|
|
|
@rm $(PROJECT_BASE)/.version -f
|
2015-05-10 20:37:10 +02:00
|
|
|
|
2015-05-10 01:11:51 +02:00
|
|
|
mrproper: FORCE
|
|
|
|
$(call cmd_clean_inner_files)
|
2015-07-14 22:44:42 +02:00
|
|
|
$(Q)$(MAKE) -C $(ZEPHYR_BASE) PROJECT=$(PROJECT_BASE) mrproper
|
2015-02-21 23:05:51 +01:00
|
|
|
|
2015-06-18 16:46:52 +02:00
|
|
|
%config: $(O)/.dir FORCE
|
2015-07-14 22:44:42 +02:00
|
|
|
$(Q)$(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) PROJECT=$(PROJECT_BASE) $@
|
2015-02-21 23:05:51 +01:00
|
|
|
|
2015-06-18 16:46:52 +02:00
|
|
|
qemu: $(CONFIG_DEPS) $(O)/.dir
|
2015-06-06 04:46:00 +02:00
|
|
|
$(Q)$(MAKE) -C $(ZEPHYR_BASE) O=$(O) \
|
2015-07-14 22:44:42 +02:00
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) \
|
|
|
|
CFLAGS=$(CFLAGS) qemu
|
2015-05-06 00:21:55 +02:00
|
|
|
|
2015-06-05 18:08:43 +02:00
|
|
|
|
2015-06-18 16:46:52 +02:00
|
|
|
$(O)/.config: $(O)/.dir
|
2015-07-14 22:44:42 +02:00
|
|
|
$(Q)cp $(ZEPHYR_BASE)/arch/$(ARCH)/configs/$(KBUILD_DEFCONFIG) \
|
|
|
|
$(O)/.config
|
2015-06-05 18:08:43 +02:00
|
|
|
|
|
|
|
$(O)/.initconfig: mergeconfig
|
2015-06-06 04:46:00 +02:00
|
|
|
$(Q)yes "" | $(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) \
|
2015-07-14 22:44:42 +02:00
|
|
|
PROJECT=$(PROJECT_BASE) oldconfig
|
2015-06-05 18:08:43 +02:00
|
|
|
touch $@
|
|
|
|
|
2015-05-20 00:26:59 +02:00
|
|
|
ifneq (($strip $(CONF_FILE)),)
|
2015-06-05 18:08:43 +02:00
|
|
|
mergeconfig: $(O)/.config $(CONF_FILE)
|
2015-06-06 04:46:00 +02:00
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
2015-07-14 22:44:42 +02:00
|
|
|
-q -m -O $(O) $(O)/.config $(CONF_FILE)
|
2015-06-05 18:08:43 +02:00
|
|
|
else
|
|
|
|
mergeconfig: defconfig $(CONF_FILE);
|
2015-05-12 19:30:57 +02:00
|
|
|
endif
|
2015-06-01 18:48:10 +02:00
|
|
|
|
2015-06-05 18:08:43 +02:00
|
|
|
$(CONF_FILE):;
|
2015-05-06 00:21:55 +02:00
|
|
|
|
2015-05-21 18:08:16 +02:00
|
|
|
%/.dir:
|
2015-05-26 23:50:44 +02:00
|
|
|
$(Q)set -e;
|
|
|
|
$(Q)test -s $(abspath $(dir $@)) || mkdir $(abspath $(dir $@)) -p
|
|
|
|
$(Q)touch $@
|
2015-05-21 18:08:16 +02:00
|
|
|
|
2015-05-21 23:32:31 +02:00
|
|
|
help:
|
2015-06-06 04:46:00 +02:00
|
|
|
$(Q)$(MAKE) -C $(ZEPHYR_BASE) help
|
2015-04-30 21:14:29 +02:00
|
|
|
|
2015-05-10 01:11:51 +02:00
|
|
|
PHONY += FORCE clean mrproper
|
2015-02-21 23:05:51 +01:00
|
|
|
FORCE:
|
|
|
|
|
|
|
|
.PHONY: $(PHONY)
|
2015-05-21 18:08:16 +02:00
|
|
|
.PRECIOUS: %/.dir
|