2015-08-04 03:42:21 +08:00
|
|
|
# vim: filetype=make
|
2015-10-09 18:23:01 +08:00
|
|
|
#
|
|
|
|
|
2016-01-06 05:28:37 +08:00
|
|
|
DQUOTE = "
|
|
|
|
# "
|
|
|
|
|
2015-10-09 18:23:01 +08:00
|
|
|
ARCH ?= x86
|
2015-08-04 03:42:21 +08:00
|
|
|
|
2015-12-31 06:17:36 +08:00
|
|
|
PROJECT_BASE ?= $(CURDIR)
|
2015-08-23 02:40:43 +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.
|
2015-11-27 23:04:08 +08:00
|
|
|
# Need to create the directory first to make realpath happy
|
2015-07-23 07:15:43 +08:00
|
|
|
$(shell mkdir -p $(O))
|
2015-11-27 23:04:08 +08:00
|
|
|
override O := $(realpath $(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
|
|
|
|
2016-01-06 05:28:37 +08:00
|
|
|
KERNEL_TYPE ?= micro
|
|
|
|
CONF_FILE_LOCAL = $(strip $(subst $(DQUOTE),,$(CONF_FILE)))
|
2015-10-03 22:24:57 +08:00
|
|
|
|
2015-12-14 04:00:31 +08:00
|
|
|
ifdef BOARD
|
2015-12-14 08:24:59 +08:00
|
|
|
KBUILD_DEFCONFIG_PATH=$(ZEPHYR_BASE)/boards/$(BOARD)/$(BOARD)_defconfig
|
2015-10-03 22:24:57 +08:00
|
|
|
export KBUILD_DEFCONFIG_PATH
|
2015-08-04 03:42:21 +08:00
|
|
|
else
|
2015-12-14 04:00:31 +08:00
|
|
|
$(error BOARD is not defined!)
|
2015-07-15 05:22:18 +08:00
|
|
|
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-08-23 02:40:43 +08:00
|
|
|
# FIXME Do not depend on python
|
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-12-31 07:38:26 +08:00
|
|
|
override SOURCE_DIR := $(subst \,/,$(SOURCE_DIR))
|
2015-05-10 19:59:05 +08:00
|
|
|
export SOURCE_DIR
|
2015-05-22 00:08:16 +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-12-16 06:29:09 +08:00
|
|
|
zephyrmake = @$(MAKE) -C $(ZEPHYR_BASE) O=$(1) CFLAGS=$(CFLAGS) \
|
2015-08-23 02:40:43 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) $(2)
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-08-29 03:42:03 +08:00
|
|
|
DOTCONFIG = $(O)/.config
|
|
|
|
|
|
|
|
all: $(DOTCONFIG)
|
2015-08-23 02:40:43 +08:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2015-12-14 04:00:31 +08:00
|
|
|
ifeq ($(findstring qemu_,$(BOARD)),)
|
2015-11-14 08:17:27 +08:00
|
|
|
qemu:
|
|
|
|
@echo "Emulation not available for this platform"
|
|
|
|
else
|
2015-08-29 03:42:03 +08:00
|
|
|
qemu: $(DOTCONFIG)
|
2015-08-23 02:40:43 +08:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-11-14 08:17:27 +08:00
|
|
|
endif
|
2015-05-06 06:21:55 +08:00
|
|
|
|
2015-10-04 05:49:46 +08:00
|
|
|
initconfig: $(DOTCONFIG)
|
|
|
|
|
2015-10-15 05:42:59 +08:00
|
|
|
menuconfig: initconfig
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
2015-08-29 03:42:03 +08:00
|
|
|
# Catch all
|
|
|
|
%:
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-06-06 00:08:43 +08:00
|
|
|
|
2015-10-03 22:24:57 +08:00
|
|
|
KERNEL_CONFIG = $(ZEPHYR_BASE)/kernel/configs/$(KERNEL_TYPE).config
|
|
|
|
|
2016-01-06 05:28:37 +08:00
|
|
|
$(DOTCONFIG): $(KBUILD_DEFCONFIG_PATH) $(CONF_FILE_LOCAL)
|
2015-08-29 02:22:29 +08:00
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
2016-01-06 05:28:37 +08:00
|
|
|
-q -m -O $(O) $(KBUILD_DEFCONFIG_PATH) $(KERNEL_CONFIG) $(CONF_FILE_LOCAL)
|
2015-11-27 09:39:26 +08:00
|
|
|
$(Q)$(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) PROJECT=$(PROJECT_BASE) oldnoconfig
|
2015-08-23 02:40:43 +08:00
|
|
|
|
|
|
|
pristine:
|
|
|
|
$(Q)rm -rf $(O)
|
2015-05-06 06:21:55 +08:00
|
|
|
|
2015-10-04 05:49:46 +08:00
|
|
|
PHONY += FORCE initconfig
|
2015-08-29 02:22:29 +08:00
|
|
|
FORCE:
|
2015-08-15 00:21:36 +08:00
|
|
|
|
2015-02-22 06:05:51 +08:00
|
|
|
.PHONY: $(PHONY)
|