2015-08-03 15:42:21 -04:00
|
|
|
# vim: filetype=make
|
|
|
|
|
2015-05-09 15:39:56 -05:00
|
|
|
PROJECT_BASE ?= $(shell pwd)
|
2015-08-22 14:40:43 -04:00
|
|
|
O ?= $(PROJECT_BASE)/outdir
|
|
|
|
|
2015-08-02 10:05:07 -04:00
|
|
|
ARCH ?= x86
|
2015-02-21 16:05:51 -06:00
|
|
|
|
2015-07-22 16:15:43 -07: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 09:48:10 -07:00
|
|
|
|
2015-06-05 16:24:46 -04:00
|
|
|
export ARCH MDEF_FILE QEMU_EXTRA_FLAGS PROJECT_BASE
|
2015-05-05 17:21:55 -05:00
|
|
|
|
2015-08-22 14:40:43 -04:00
|
|
|
# FIXME: Simplify this, very ugly
|
2015-07-14 17:22:18 -04:00
|
|
|
ifdef PLATFORM_CONFIG
|
|
|
|
ifndef KERNEL_TYPE
|
|
|
|
$(error KERNEL_TYPE is not defined! Set it to either micro or nano)
|
|
|
|
endif
|
2015-08-03 15:42:21 -04:00
|
|
|
ifndef KBUILD_DEFCONFIG
|
2015-07-14 17:22:18 -04:00
|
|
|
KBUILD_DEFCONFIG=$(KERNEL_TYPE)_$(PLATFORM_CONFIG)_defconfig
|
2015-08-03 15:42:21 -04:00
|
|
|
KBUILD_DEFCONFIG_PATH=$(ZEPHYR_BASE)/arch/$(ARCH)/configs/$(KBUILD_DEFCONFIG)
|
|
|
|
else
|
|
|
|
KBUILD_DEFCONFIG_PATH=$(KBUILD_DEFCONFIG)
|
|
|
|
endif
|
2015-07-14 17:22:18 -04:00
|
|
|
export KBUILD_DEFCONFIG
|
|
|
|
endif
|
|
|
|
|
2015-07-17 12:03:52 -07:00
|
|
|
SOURCE_DIR ?= $(PROJECT_BASE)/src/
|
|
|
|
# Kbuild doesn't work correctly if this is an absolute path
|
2015-08-22 14:40:43 -04:00
|
|
|
# FIXME Do not depend on python
|
2015-07-29 13:21:49 -07: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 07:59:05 -04:00
|
|
|
export SOURCE_DIR
|
2015-05-21 11:08:16 -05:00
|
|
|
|
2015-08-22 14:40:43 -04:00
|
|
|
|
2015-02-21 16:05:51 -06:00
|
|
|
|
2015-05-26 16:50:44 -05: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-08-22 14:40:43 -04:00
|
|
|
zephyrmake = @$(MAKE) -C $(ZEPHYR_BASE) O=$(1) CFLAGS="$(CFLAGS)" \
|
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) $(2)
|
2015-02-21 16:05:51 -06:00
|
|
|
|
2015-10-03 17:49:46 -04:00
|
|
|
|
|
|
|
|
2015-08-28 15:42:03 -04:00
|
|
|
DOTCONFIG = $(O)/.config
|
|
|
|
|
|
|
|
all: $(DOTCONFIG)
|
2015-08-22 14:40:43 -04:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-02-21 16:05:51 -06:00
|
|
|
|
2015-08-28 15:42:03 -04:00
|
|
|
qemu: $(DOTCONFIG)
|
2015-08-22 14:40:43 -04:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-05-05 17:21:55 -05:00
|
|
|
|
2015-10-03 17:49:46 -04:00
|
|
|
initconfig: $(DOTCONFIG)
|
|
|
|
|
2015-08-28 15:42:03 -04:00
|
|
|
# Catch all
|
|
|
|
%:
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-06-05 11:08:43 -05:00
|
|
|
|
2015-08-28 15:42:03 -04:00
|
|
|
$(DOTCONFIG): $(CONF_FILE)
|
2015-08-28 14:22:29 -04:00
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
|
|
|
-q -m -O $(O) $(KBUILD_DEFCONFIG_PATH) $<
|
2015-06-05 22:46:00 -04:00
|
|
|
$(Q)yes "" | $(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) \
|
2015-07-14 13:44:42 -07:00
|
|
|
PROJECT=$(PROJECT_BASE) oldconfig
|
2015-08-22 14:40:43 -04:00
|
|
|
|
|
|
|
pristine:
|
|
|
|
$(Q)rm -rf $(O)
|
2015-05-05 17:21:55 -05:00
|
|
|
|
2015-10-03 17:49:46 -04:00
|
|
|
PHONY += FORCE initconfig
|
2015-08-28 14:22:29 -04:00
|
|
|
FORCE:
|
2015-08-14 11:21:36 -05:00
|
|
|
|
2015-02-21 16:05:51 -06:00
|
|
|
|
|
|
|
.PHONY: $(PHONY)
|