2015-08-03 15:42:21 -04:00
|
|
|
# vim: filetype=make
|
2015-10-09 06:23:01 -04:00
|
|
|
#
|
|
|
|
|
2016-01-05 16:28:37 -05:00
|
|
|
DQUOTE = "
|
|
|
|
# "
|
|
|
|
|
2015-10-09 06:23:01 -04:00
|
|
|
ARCH ?= x86
|
2015-08-03 15:42:21 -04:00
|
|
|
|
2016-04-27 10:15:14 -05:00
|
|
|
UNAME := $(shell uname)
|
|
|
|
ifeq (MINGW, $(findstring MINGW, $(UNAME)))
|
|
|
|
PROJECT_BASE ?= $(shell sh -c "pwd -W")
|
|
|
|
else
|
2015-12-30 16:17:36 -06:00
|
|
|
PROJECT_BASE ?= $(CURDIR)
|
2016-04-27 10:15:14 -05:00
|
|
|
endif
|
|
|
|
|
2015-08-22 14:40:43 -04:00
|
|
|
O ?= $(PROJECT_BASE)/outdir
|
|
|
|
|
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.
|
2015-11-27 10:04:08 -05:00
|
|
|
# Need to create the directory first to make realpath happy
|
2016-01-30 05:36:52 -05:00
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),help)
|
2015-07-22 16:15:43 -07:00
|
|
|
$(shell mkdir -p $(O))
|
2015-11-27 10:04:08 -05:00
|
|
|
override O := $(realpath $(O))
|
2016-01-30 05:36:52 -05:00
|
|
|
endif
|
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
|
|
|
|
2016-01-05 16:28:37 -05:00
|
|
|
KERNEL_TYPE ?= micro
|
2016-01-30 05:36:52 -05:00
|
|
|
override CONF_FILE := $(strip $(subst $(DQUOTE),,$(CONF_FILE)))
|
2015-10-03 10:24:57 -04:00
|
|
|
|
2015-12-13 15:00:31 -05:00
|
|
|
ifdef BOARD
|
2016-03-12 08:41:31 -05:00
|
|
|
KBUILD_DEFCONFIG_PATH=$(wildcard $(ZEPHYR_BASE)/boards/*/$(BOARD)_defconfig)
|
2016-04-23 21:45:58 -04:00
|
|
|
ifeq ($(KBUILD_DEFCONFIG_PATH),)
|
|
|
|
$(error Board $(BOARD) not found!)
|
|
|
|
endif
|
2015-08-03 15:42:21 -04:00
|
|
|
else
|
2015-12-13 15:00:31 -05:00
|
|
|
$(error BOARD is not defined!)
|
2015-07-14 17:22:18 -04:00
|
|
|
endif
|
|
|
|
|
2015-07-17 12:03:52 -07:00
|
|
|
SOURCE_DIR ?= $(PROJECT_BASE)/src/
|
2016-06-10 14:15:05 -04:00
|
|
|
# Kbuild doesn't work correctly if this is an absolute path
|
|
|
|
# FIXME Do not depend on python
|
|
|
|
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-30 17:38:26 -06:00
|
|
|
override SOURCE_DIR := $(subst \,/,$(SOURCE_DIR))
|
2015-05-10 07:59:05 -04:00
|
|
|
export SOURCE_DIR
|
2015-05-21 11:08:16 -05: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
|
|
|
|
|
2016-05-20 11:54:53 -03:00
|
|
|
export CFLAGS
|
|
|
|
|
|
|
|
zephyrmake = @+$(MAKE) -C $(ZEPHYR_BASE) O=$(1) \
|
2015-08-22 14:40:43 -04:00
|
|
|
PROJECT=$(PROJECT_BASE) SOURCE_DIR=$(SOURCE_DIR) $(2)
|
2015-02-21 16:05:51 -06:00
|
|
|
|
2016-05-14 21:56:35 -04:00
|
|
|
BOARDCONFIG = $(O)/.board_$(BOARD)
|
|
|
|
|
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-12-13 15:00:31 -05:00
|
|
|
ifeq ($(findstring qemu_,$(BOARD)),)
|
2015-11-13 16:17:27 -08:00
|
|
|
qemu:
|
|
|
|
@echo "Emulation not available for this platform"
|
|
|
|
else
|
2015-08-28 15:42:03 -04:00
|
|
|
qemu: $(DOTCONFIG)
|
2015-08-22 14:40:43 -04:00
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-11-13 16:17:27 -08:00
|
|
|
endif
|
2015-05-05 17:21:55 -05:00
|
|
|
|
2016-02-01 22:24:21 -05:00
|
|
|
debug: $(DOTCONFIG)
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2016-01-15 12:18:53 -05:00
|
|
|
|
|
|
|
flash: $(DOTCONFIG)
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
2016-02-01 19:42:54 -05:00
|
|
|
ifeq ($(MAKECMDGOALS),debugserver)
|
|
|
|
-include $(ZEPHYR_BASE)/boards/$(BOARD)/Makefile.board
|
|
|
|
-include $(ZEPHYR_BASE)/scripts/Makefile.toolchain.$(ZEPHYR_GCC_VARIANT)
|
|
|
|
BOARD_NAME = $(BOARD)
|
|
|
|
export BOARD_NAME
|
|
|
|
endif
|
|
|
|
debugserver: FORCE
|
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/support/$(FLASH_SCRIPT) debugserver
|
|
|
|
|
|
|
|
|
2015-10-03 17:49:46 -04:00
|
|
|
initconfig: $(DOTCONFIG)
|
|
|
|
|
2016-05-14 21:56:35 -04:00
|
|
|
$(BOARDCONFIG):
|
|
|
|
@rm -f $(O)/.board_*
|
|
|
|
@touch $@
|
|
|
|
|
2016-05-22 12:34:06 -04:00
|
|
|
|
|
|
|
ram_report: initconfig
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
|
|
|
rom_report: initconfig
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
2015-10-14 17:42:59 -04:00
|
|
|
menuconfig: initconfig
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
|
|
|
|
2016-01-30 05:36:52 -05:00
|
|
|
help:
|
|
|
|
$(Q)$(MAKE) -s -C $(ZEPHYR_BASE) $@
|
|
|
|
|
2015-08-28 15:42:03 -04:00
|
|
|
# Catch all
|
|
|
|
%:
|
|
|
|
$(Q)$(call zephyrmake,$(O),$@)
|
2015-06-05 11:08:43 -05:00
|
|
|
|
2015-10-03 10:24:57 -04:00
|
|
|
KERNEL_CONFIG = $(ZEPHYR_BASE)/kernel/configs/$(KERNEL_TYPE).config
|
|
|
|
|
2016-05-14 21:56:35 -04:00
|
|
|
$(DOTCONFIG): $(BOARDCONFIG) $(KBUILD_DEFCONFIG_PATH) $(CONF_FILE)
|
2015-08-28 14:22:29 -04:00
|
|
|
$(Q)$(CONFIG_SHELL) $(ZEPHYR_BASE)/scripts/kconfig/merge_config.sh \
|
2016-01-30 05:36:52 -05:00
|
|
|
-q -m -O $(O) $(KBUILD_DEFCONFIG_PATH) $(KERNEL_CONFIG) $(CONF_FILE)
|
2015-11-26 20:39:26 -05:00
|
|
|
$(Q)$(MAKE) $(S) -C $(ZEPHYR_BASE) O=$(O) PROJECT=$(PROJECT_BASE) oldnoconfig
|
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)
|