2015-08-04 03:42:21 +08:00
|
|
|
# vim: filetype=make
|
|
|
|
|
2015-05-10 04:39:56 +08:00
|
|
|
PROJECT_BASE ?= $(shell pwd)
|
2015-08-02 22:05:07 +08:00
|
|
|
ARCH ?= x86
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-06-02 00:48:10 +08:00
|
|
|
O ?= $(PROJECT_BASE)/outdir
|
2015-07-23 07:15:43 +08: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-02 00:48:10 +08:00
|
|
|
|
2015-06-06 04:24:46 +08:00
|
|
|
export ARCH MDEF_FILE QEMU_EXTRA_FLAGS PROJECT_BASE
|
2015-05-06 06:21:55 +08:00
|
|
|
|
2015-07-15 05:22:18 +08:00
|
|
|
ifdef PLATFORM_CONFIG
|
|
|
|
ifndef KERNEL_TYPE
|
|
|
|
$(error KERNEL_TYPE is not defined! Set it to either micro or nano)
|
|
|
|
endif
|
2015-08-04 03:42:21 +08:00
|
|
|
ifndef KBUILD_DEFCONFIG
|
2015-07-15 05:22:18 +08:00
|
|
|
KBUILD_DEFCONFIG=$(KERNEL_TYPE)_$(PLATFORM_CONFIG)_defconfig
|
2015-08-04 03:42:21 +08:00
|
|
|
KBUILD_DEFCONFIG_PATH=$(ZEPHYR_BASE)/arch/$(ARCH)/configs/$(KBUILD_DEFCONFIG)
|
|
|
|
else
|
|
|
|
KBUILD_DEFCONFIG_PATH=$(KBUILD_DEFCONFIG)
|
|
|
|
endif
|
2015-07-15 05:22:18 +08:00
|
|
|
export KBUILD_DEFCONFIG
|
|
|
|
endif
|
|
|
|
|
2015-05-10 04:39:56 +08:00
|
|
|
ifdef KBUILD_DEFCONFIG
|
2015-06-02 00:48:10 +08:00
|
|
|
CONFIG_DEPS=$(O)/.initconfig
|
2015-05-10 04:39:56 +08:00
|
|
|
else
|
|
|
|
CONFIG_DEPS=FORCE
|
|
|
|
endif
|
|
|
|
|
2015-07-18 03:03:52 +08:00
|
|
|
SOURCE_DIR ?= $(PROJECT_BASE)/src/
|
|
|
|
# Kbuild doesn't work correctly if this is an absolute path
|
2015-07-30 04:21:49 +08:00
|
|
|
override SOURCE_DIR := $(shell python -c "import os.path; print(\"%s\" % os.path.relpath(os.path.realpath('$(SOURCE_DIR)'), os.path.realpath('$(ZEPHYR_BASE)')))")/
|
2015-05-10 19:59:05 +08:00
|
|
|
export SOURCE_DIR
|
2015-05-22 00:08:16 +08:00
|
|
|
|
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-27 05:50:44 +08: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 22:46:52 +08:00
|
|
|
all: $(CONFIG_DEPS) $(O)/.dir
|
2015-06-06 10:46:00 +08:00
|
|
|
$(Q)$(MAKE) -C $(ZEPHYR_BASE) O=$(O) \
|
2015-07-15 04:44:42 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) \
|
|
|
|
CFLAGS=$(CFLAGS)
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-08-02 22:05:07 +08:00
|
|
|
clean: distclean
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-05-18 20:58:55 +08:00
|
|
|
pristine: distclean
|
|
|
|
|
2015-08-02 22:05:07 +08:00
|
|
|
distclean:
|
|
|
|
@rm -rf $(O)
|
2015-05-11 02:37:10 +08:00
|
|
|
|
2015-08-02 22:05:07 +08:00
|
|
|
mrproper: clean FORCE
|
2015-07-15 04:44:42 +08:00
|
|
|
$(Q)$(MAKE) -C $(ZEPHYR_BASE) PROJECT=$(PROJECT_BASE) mrproper
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-06-18 22:46:52 +08:00
|
|
|
%config: $(O)/.dir FORCE
|
2015-07-15 04:44:42 +08:00
|
|
|
$(Q)$(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) PROJECT=$(PROJECT_BASE) $@
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-06-18 22:46:52 +08:00
|
|
|
qemu: $(CONFIG_DEPS) $(O)/.dir
|
2015-06-06 10:46:00 +08:00
|
|
|
$(Q)$(MAKE) -C $(ZEPHYR_BASE) O=$(O) \
|
2015-07-15 04:44:42 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) \
|
|
|
|
CFLAGS=$(CFLAGS) qemu
|
2015-05-06 06:21:55 +08:00
|
|
|
|
2015-06-06 00:08:43 +08:00
|
|
|
|
2015-06-18 22:46:52 +08:00
|
|
|
$(O)/.config: $(O)/.dir
|
2015-08-04 03:42:21 +08:00
|
|
|
$(Q)cp $(KBUILD_DEFCONFIG_PATH) $(O)/.config
|
2015-06-06 00:08:43 +08:00
|
|
|
|
|
|
|
$(O)/.initconfig: mergeconfig
|
2015-06-06 10:46:00 +08:00
|
|
|
$(Q)yes "" | $(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) \
|
2015-07-15 04:44:42 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) oldconfig
|
2015-06-06 00:08:43 +08:00
|
|
|
touch $@
|
|
|
|
|
2015-08-04 04:48:55 +08:00
|
|
|
ifneq ($(strip $(CONF_FILE)),)
|
2015-06-06 00:08:43 +08:00
|
|
|
mergeconfig: $(O)/.config $(CONF_FILE)
|
2015-06-06 10:46:00 +08:00
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
2015-07-15 04:44:42 +08:00
|
|
|
-q -m -O $(O) $(O)/.config $(CONF_FILE)
|
2015-06-06 00:08:43 +08:00
|
|
|
else
|
|
|
|
mergeconfig: defconfig $(CONF_FILE);
|
2015-05-13 01:30:57 +08:00
|
|
|
endif
|
2015-06-02 00:48:10 +08:00
|
|
|
|
2015-06-06 00:08:43 +08:00
|
|
|
$(CONF_FILE):;
|
2015-05-06 06:21:55 +08:00
|
|
|
|
2015-05-22 00:08:16 +08:00
|
|
|
%/.dir:
|
2015-05-27 05:50:44 +08:00
|
|
|
$(Q)set -e;
|
|
|
|
$(Q)test -s $(abspath $(dir $@)) || mkdir $(abspath $(dir $@)) -p
|
|
|
|
$(Q)touch $@
|
2015-05-22 00:08:16 +08:00
|
|
|
|
2015-05-22 05:32:31 +08:00
|
|
|
help:
|
2015-06-06 10:46:00 +08:00
|
|
|
$(Q)$(MAKE) -C $(ZEPHYR_BASE) help
|
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)
|
2015-05-22 00:08:16 +08:00
|
|
|
.PRECIOUS: %/.dir
|