2015-08-04 03:42:21 +08:00
|
|
|
# vim: filetype=make
|
2015-10-09 18:23:01 +08:00
|
|
|
#
|
|
|
|
|
2016-04-27 23:15:14 +08:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq (MINGW, $(findstring MINGW, $(UNAME)))
|
2016-08-23 06:22:07 +08:00
|
|
|
DQUOTE = '
|
|
|
|
# '
|
2016-04-27 23:15:14 +08:00
|
|
|
PROJECT_BASE ?= $(shell sh -c "pwd -W")
|
|
|
|
else
|
2016-08-23 06:22:07 +08:00
|
|
|
DQUOTE = "
|
|
|
|
# "
|
2015-12-31 06:17:36 +08:00
|
|
|
PROJECT_BASE ?= $(CURDIR)
|
2016-04-27 23:15:14 +08:00
|
|
|
endif
|
|
|
|
|
2016-08-24 03:32:20 +08:00
|
|
|
ifdef BOARD
|
2016-10-20 04:13:41 +08:00
|
|
|
KBUILD_DEFCONFIG_PATH=$(wildcard $(ZEPHYR_BASE)/boards/*/*/$(BOARD)_defconfig)
|
2016-08-24 03:32:20 +08:00
|
|
|
ifeq ($(KBUILD_DEFCONFIG_PATH),)
|
|
|
|
$(error Board $(BOARD) not found!)
|
|
|
|
endif
|
|
|
|
else
|
|
|
|
$(error BOARD is not defined!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Choose a default output directory if one wasn't supplied. Note that
|
|
|
|
# PRISTINE_O depends on whether this is default or not. If building
|
|
|
|
# in-tree, we want to remove the whole outdir and not just the BOARD
|
|
|
|
# specified (thus "pristine"). Out of tree, we can obviously remove
|
|
|
|
# only what we were told to build.
|
|
|
|
ifndef O
|
|
|
|
PRISTINE_O = outdir
|
|
|
|
O = $(PROJECT_BASE)/outdir/$(BOARD)
|
|
|
|
else
|
|
|
|
PRISTINE_O = $(O)
|
|
|
|
endif
|
2015-08-23 02:40:43 +08:00
|
|
|
|
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
|
2016-01-30 18:36:52 +08:00
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),help)
|
2015-07-23 07:15:43 +08:00
|
|
|
$(shell mkdir -p $(O))
|
2015-11-27 23:04:08 +08:00
|
|
|
override O := $(realpath $(O))
|
2016-01-30 18:36:52 +08:00
|
|
|
endif
|
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-30 18:36:52 +08:00
|
|
|
override CONF_FILE := $(strip $(subst $(DQUOTE),,$(CONF_FILE)))
|
2015-10-03 22:24:57 +08:00
|
|
|
|
2015-07-18 03:03:52 +08:00
|
|
|
SOURCE_DIR ?= $(PROJECT_BASE)/src/
|
2016-08-27 06:24:13 +08:00
|
|
|
override SOURCE_DIR := $(realpath $(SOURCE_DIR))
|
2015-12-31 07:38:26 +08:00
|
|
|
override SOURCE_DIR := $(subst \,/,$(SOURCE_DIR))
|
2016-06-03 22:51:56 +08:00
|
|
|
override SOURCE_DIR_PARENT := $(patsubst %, %/.., $(SOURCE_DIR))
|
|
|
|
override SOURCE_DIR_PARENT := $(abspath $(SOURCE_DIR_PARENT))
|
|
|
|
override SOURCE_DIR_PARENT := $(subst \,/,$(SOURCE_DIR_PARENT))
|
|
|
|
export SOURCE_DIR SOURCE_DIR_PARENT
|
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
|
|
|
|
|
2016-05-20 22:54:53 +08:00
|
|
|
export CFLAGS
|
|
|
|
|
2016-06-04 02:34:18 +08:00
|
|
|
zephyrmake = +$(MAKE) -C $(ZEPHYR_BASE) O=$(1) \
|
2016-08-23 06:22:07 +08:00
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(DQUOTE)$(SOURCE_DIR)$(DQUOTE) $(2)
|
2015-02-22 06:05:51 +08:00
|
|
|
|
2016-05-15 09:56:35 +08:00
|
|
|
BOARDCONFIG = $(O)/.board_$(BOARD)
|
|
|
|
|
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
|
|
|
|
2017-01-08 05:31:34 +08:00
|
|
|
debug: $(DOTCONFIG)
|
2015-08-23 02:40:43 +08:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-05-06 06:21:55 +08:00
|
|
|
|
2017-01-08 05:31:34 +08:00
|
|
|
flash: $(DOTCONFIG)
|
2016-02-02 11:24:21 +08:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2016-01-16 01:18:53 +08:00
|
|
|
|
2017-01-08 05:31:34 +08:00
|
|
|
qemugdb: debugserver
|
2017-01-08 02:22:21 +08:00
|
|
|
|
2017-01-08 05:31:34 +08:00
|
|
|
qemu: $(DOTCONFIG)
|
|
|
|
@echo This target is deprecated, use 'make run' instead
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
|
|
|
run: $(DOTCONFIG)
|
2016-01-16 01:18:53 +08:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
2016-02-02 08:42:54 +08:00
|
|
|
ifeq ($(MAKECMDGOALS),debugserver)
|
2016-11-10 13:34:19 +08:00
|
|
|
ARCH = $(notdir $(subst /$(BOARD),,$(wildcard $(ZEPHYR_BASE)/boards/*/$(BOARD))))
|
2016-10-20 04:13:41 +08:00
|
|
|
-include $(ZEPHYR_BASE)/boards/$(ARCH)/$(BOARD)/Makefile.board
|
2016-02-02 08:42:54 +08:00
|
|
|
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
|
|
|
|
BOARD_NAME = $(BOARD)
|
|
|
|
export BOARD_NAME
|
|
|
|
endif
|
2017-01-08 02:22:21 +08:00
|
|
|
|
2016-02-02 08:42:54 +08:00
|
|
|
debugserver: FORCE
|
2017-01-08 02:22:21 +08:00
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/support/$(DEBUG_SCRIPT) debugserver
|
2016-02-02 08:42:54 +08:00
|
|
|
|
2016-11-12 02:50:24 +08:00
|
|
|
initconfig outputexports: $(DOTCONFIG)
|
2015-10-04 05:49:46 +08:00
|
|
|
|
2016-05-15 09:56:35 +08:00
|
|
|
$(BOARDCONFIG):
|
|
|
|
@rm -f $(O)/.board_*
|
|
|
|
@touch $@
|
|
|
|
|
2016-05-23 00:34:06 +08:00
|
|
|
ram_report: initconfig
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
|
|
|
rom_report: initconfig
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
2015-10-15 05:42:59 +08:00
|
|
|
menuconfig: initconfig
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
2016-01-30 18:36:52 +08:00
|
|
|
help:
|
|
|
|
$(Q)$(MAKE) -s -C $(ZEPHYR_BASE) $@
|
|
|
|
|
2015-08-29 03:42:03 +08:00
|
|
|
# Catch all
|
|
|
|
%:
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-06-06 00:08:43 +08:00
|
|
|
|
2016-12-22 03:38:37 +08:00
|
|
|
OVERLAY_CONFIG += $(ZEPHYR_BASE)/kernel/configs/kernel.config
|
2015-10-03 22:24:57 +08:00
|
|
|
|
2016-05-15 09:56:35 +08:00
|
|
|
$(DOTCONFIG): $(BOARDCONFIG) $(KBUILD_DEFCONFIG_PATH) $(CONF_FILE)
|
2015-08-29 02:22:29 +08:00
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
2016-12-22 03:38:37 +08:00
|
|
|
-q -m -O $(O) $(KBUILD_DEFCONFIG_PATH) $(OVERLAY_CONFIG) $(CONF_FILE) \
|
2016-09-01 06:19:11 +08:00
|
|
|
$(wildcard $(O)/*.conf)
|
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:
|
2016-08-24 03:32:20 +08:00
|
|
|
$(Q)rm -rf $(PRISTINE_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)
|