2015-08-03 21:42:21 +02:00
|
|
|
# vim: filetype=make
|
|
|
|
|
2015-05-09 22:39:56 +02:00
|
|
|
PROJECT_BASE ?= $(shell pwd)
|
2015-08-22 20:40:43 +02:00
|
|
|
O ?= $(PROJECT_BASE)/outdir
|
|
|
|
|
2015-08-02 16:05:07 +02:00
|
|
|
ARCH ?= x86
|
2015-02-21 23:05:51 +01:00
|
|
|
|
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
|
|
|
ifndef KERNEL_TYPE
|
2015-10-03 16:24:57 +02:00
|
|
|
KERNEL_TYPE = micro
|
2015-07-14 23:22:18 +02:00
|
|
|
endif
|
2015-10-03 16:24:57 +02:00
|
|
|
|
|
|
|
ifdef PLATFORM_CONFIG
|
|
|
|
KBUILD_DEFCONFIG_PATH=$(ZEPHYR_BASE)/arch/$(ARCH)/configs/$(PLATFORM_CONFIG)_defconfig
|
|
|
|
export KBUILD_DEFCONFIG_PATH
|
2015-08-03 21:42:21 +02:00
|
|
|
else
|
2015-10-03 16:24:57 +02:00
|
|
|
$(error PLATFORM_CONFIG is not defined!)
|
2015-07-14 23:22:18 +02:00
|
|
|
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-08-22 20:40:43 +02:00
|
|
|
# FIXME Do not depend on python
|
2015-07-29 22:21:49 +02: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 13:59:05 +02:00
|
|
|
export SOURCE_DIR
|
2015-05-21 18:08:16 +02:00
|
|
|
|
2015-08-22 20:40:43 +02:00
|
|
|
|
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-08-22 20:40:43 +02:00
|
|
|
zephyrmake = @$(MAKE) -C $(ZEPHYR_BASE) O=$(1) CFLAGS="$(CFLAGS)" \
|
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) $(2)
|
2015-02-21 23:05:51 +01:00
|
|
|
|
2015-10-03 23:49:46 +02:00
|
|
|
|
|
|
|
|
2015-08-28 21:42:03 +02:00
|
|
|
DOTCONFIG = $(O)/.config
|
|
|
|
|
|
|
|
all: $(DOTCONFIG)
|
2015-08-22 20:40:43 +02:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-02-21 23:05:51 +01:00
|
|
|
|
2015-08-28 21:42:03 +02:00
|
|
|
qemu: $(DOTCONFIG)
|
2015-08-22 20:40:43 +02:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-05-06 00:21:55 +02:00
|
|
|
|
2015-10-03 23:49:46 +02:00
|
|
|
initconfig: $(DOTCONFIG)
|
|
|
|
|
2015-10-14 23:42:59 +02:00
|
|
|
menuconfig: initconfig
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
2015-08-28 21:42:03 +02:00
|
|
|
# Catch all
|
|
|
|
%:
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-06-05 18:08:43 +02:00
|
|
|
|
2015-10-03 16:24:57 +02:00
|
|
|
KERNEL_CONFIG = $(ZEPHYR_BASE)/kernel/configs/$(KERNEL_TYPE).config
|
|
|
|
|
|
|
|
$(DOTCONFIG): $(KBUILD_DEFCONFIG_PATH) $(CONF_FILE)
|
2015-08-28 20:22:29 +02:00
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
2015-10-03 16:24:57 +02:00
|
|
|
-q -m -O $(O) $(KBUILD_DEFCONFIG_PATH) $(KERNEL_CONFIG) $(CONF_FILE)
|
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-08-22 20:40:43 +02:00
|
|
|
|
|
|
|
pristine:
|
|
|
|
$(Q)rm -rf $(O)
|
2015-05-06 00:21:55 +02:00
|
|
|
|
2015-10-03 23:49:46 +02:00
|
|
|
PHONY += FORCE initconfig
|
2015-08-28 20:22:29 +02:00
|
|
|
FORCE:
|
2015-08-14 18:21:36 +02:00
|
|
|
|
2015-02-21 23:05:51 +01:00
|
|
|
.PHONY: $(PHONY)
|