加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Makefile.include 20.93 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
# Globally set default goal to `all`
.DEFAULT_GOAL := all
# include Makefile.local if it exists
-include Makefile.local
# set undefined variables
RIOTBASE ?= $(dir $(lastword $(MAKEFILE_LIST)))
CCACHE_BASEDIR ?= $(RIOTBASE)
RIOTCPU ?= $(RIOTBASE)/cpu
RIOTBOARD ?= $(RIOTBASE)/boards
RIOTMAKE ?= $(RIOTBASE)/makefiles
RIOTPKG ?= $(RIOTBASE)/pkg
RIOTTOOLS ?= $(RIOTBASE)/dist/tools
RIOTPROJECT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd)
GITCACHE ?= $(RIOTTOOLS)/git/git-cache
APPDIR ?= $(CURDIR)
BINDIRBASE ?= $(APPDIR)/bin
BINDIR ?= $(BINDIRBASE)/$(BOARD)
PKGDIRBASE ?= $(BINDIRBASE)/pkg/$(BOARD)
DLCACHE ?= $(RIOTTOOLS)/dlcache/dlcache.sh
DLCACHE_DIR ?= $(RIOTBASE)/.dlcache
__DIRECTORY_VARIABLES := \
RIOTBASE \
RIOTCPU \
RIOTBOARD \
RIOTMAKE \
RIOTPKG \
RIOTTOOLS \
RIOTPROJECT \
APPDIR \
BINDIRBASE \
BINDIR \
CCACHE_BASEDIR \
GITCACHE \
PKGDIRBASE \
DLCACHE_DIR \
#
# Make all paths absolute.
override RIOTBASE := $(abspath $(RIOTBASE))
override CCACHE_BASEDIR := $(abspath $(CCACHE_BASEDIR))
override RIOTCPU := $(abspath $(RIOTCPU))
override RIOTBOARD := $(abspath $(RIOTBOARD))
override RIOTMAKE := $(abspath $(RIOTMAKE))
override RIOTPKG := $(abspath $(RIOTPKG))
override RIOTTOOLS := $(abspath $(RIOTTOOLS))
override RIOTPROJECT := $(abspath $(RIOTPROJECT))
override GITCACHE := $(abspath $(GITCACHE))
override APPDIR := $(abspath $(APPDIR))
override BINDIRBASE := $(abspath $(BINDIRBASE))
override BINDIR := $(abspath $(BINDIR))
override PKGDIRBASE := $(abspath $(PKGDIRBASE))
override DLCACHE_DIR := $(abspath $(DLCACHE_DIR))
# Ensure that all directories are set and don't contain spaces.
ifneq (, $(filter-out 1, $(foreach v,$(__DIRECTORY_VARIABLES),$(words $($(v))))))
$(info Aborting compilation for your safety.)
$(info Related variables = $(__DIRECTORY_VARIABLES))
$(error Make sure no path override is empty or contains spaces!)
endif
# Use absolute paths in recusive "make" even if overriden on command line.
MAKEOVERRIDES += $(foreach v,$(__DIRECTORY_VARIABLES),$(v)=$($(v)))
# Path to the current directory relative to RIOTPROJECT
BUILDRELPATH ?= $(CURDIR:$(RIOTPROJECT)/%=%)/
# get host operating system
OS := $(shell uname)
# Include Docker settings near the top because we need to build the environment
# command line before some of the variable origins are overwritten below when
# using abspath, strip etc.
include $(RIOTMAKE)/docker.inc.mk
# include color echo macros
include $(RIOTMAKE)/color.inc.mk
# include concurrency helpers
include $(RIOTMAKE)/info-nproc.inc.mk
GLOBAL_GOALS := buildtest info-boards-supported info-boards-features-missing info-buildsizes info-buildsizes-diff
ifneq (, $(filter $(GLOBAL_GOALS), $(MAKECMDGOALS)))
BOARD=none
endif
ifeq (none,$(BOARD))
include $(RIOTMAKE)/info-global.inc.mk
include $(RIOTMAKE)/buildtests.inc.mk
else
all: link
include $(RIOTMAKE)/info.inc.mk
# Static code analysis tools provided by LLVM
include $(RIOTMAKE)/scan-build.inc.mk
export RIOTBUILD_CONFIG_HEADER_C = $(BINDIR)/riotbuild/riotbuild.h
ifeq ($(OS),Darwin)
OPEN := open
else
OPEN := xdg-open
endif
QUIET ?= 1
ifeq ($(QUIET),1)
Q=@
MAKEFLAGS += --no-print-directory
else
Q=
endif
QQ=
# Set this to 1 to enable code in RIOT that does safety checking
# which is not needed in a production environment but helps in the
# development process:
DEVELHELP ?= 0
ifeq ($(DEVELHELP),1)
CFLAGS += -DDEVELHELP
endif
# Fail on warnings. Can be overridden by `make WERROR=0`.
WERROR ?= 1
export WERROR
ifeq ($(WERROR),1)
CFLAGS += -Werror
endif
WPEDANTIC ?= 0
export WPEDANTIC
ifeq ($(WPEDANTIC),1)
CFLAGS += -Wpedantic
endif
# remove this once codebase is adapted
CFLAGS += -Wno-implicit-fallthrough
CXXFLAGS += -Wno-implicit-fallthrough
ifneq (10,$(if $(RIOT_VERSION),1,0)$(if $(__RIOTBUILD_FLAG),1,0))
# Provide a shallow sanity check. You cannot call `make` in a module directory.
export __RIOTBUILD_FLAG := RIOT
BOARD := $(strip $(BOARD))
APPLICATION := $(strip $(APPLICATION))
# provide common external programs for `Makefile.include`s
ifeq (,$(and $(DOWNLOAD_TO_STDOUT),$(DOWNLOAD_TO_FILE)))
ifeq (,$(WGET))
ifeq (0,$(shell which wget 2>&1 > /dev/null ; echo $$?))
WGET := $(shell which wget)
endif
endif
ifeq (,$(CURL))
ifeq (0,$(shell which curl 2>&1 > /dev/null ; echo $$?))
CURL := $(shell which curl)
endif
endif
ifeq (,$(WGET)$(CURL))
$(error Neither wget nor curl is installed!)
endif
ifeq (,$(DOWNLOAD_TO_STDOUT))
DOWNLOAD_TO_STDOUT := $(if $(CURL),$(CURL) -s,$(WGET) -q -O-)
endif
ifeq (,$(DOWNLOAD_TO_FILE))
DOWNLOAD_TO_FILE := $(if $(WGET),$(WGET) -nv -c -O,$(CURL) -s -o)
endif
endif
ifeq (,$(UNZIP_HERE))
ifeq (0,$(shell which unzip 2>&1 > /dev/null ; echo $$?))
UNZIP_HERE := $(shell which unzip) -q
else
ifeq (0,$(shell which 7z 2>&1 > /dev/null ; echo $$?))
UNZIP_HERE := $(shell which 7z) x -bd
else
$(error Neither unzip nor 7z is installed.)
endif
endif
endif
ifeq (, $(APPLICATION))
$(error An application name must be specified as APPLICATION.)
endif
ifneq (0,$(shell test -d $(RIOTBOARD)/$(BOARD); echo $$?))
$(error The specified board $(BOARD) does not exist.)
endif
# Use TOOLCHAIN environment variable to select the toolchain to use.
# Default for macOS: llvm; for other OS: gnu
ifeq ($(BOARD),native)
ifeq ($(OS),Darwin)
TOOLCHAIN ?= llvm
endif
endif
TOOLCHAIN ?= gnu
# TOOLCHAIN = clang is an alias for TOOLCHAIN = llvm
ifeq (clang,$(TOOLCHAIN))
# use override so that we can redefine a variable set on the command line (as
# opposed to one set in the environment)
override TOOLCHAIN := llvm
endif
# TOOLCHAIN = gcc is an alias for TOOLCHAIN = gnu
ifeq (gcc,$(TOOLCHAIN))
# use override so that we can redefine a variable set on the command line (as
# opposed to one set in the environment)
override TOOLCHAIN := gnu
endif
ifeq (,$(TOOLCHAIN))
override TOOLCHAIN := gnu
endif
export TOOLCHAIN
# default toolchain prefix, defaults to target triple followed by a dash, you
# will most likely not need to touch this.
export PREFIX ?= $(if $(TARGET_ARCH),$(TARGET_ARCH)-)
# Add standard include directories
INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include
# process provided features
-include $(RIOTBOARD)/$(BOARD)/Makefile.features
# mandatory includes!
include $(RIOTMAKE)/pseudomodules.inc.mk
include $(RIOTMAKE)/defaultmodules.inc.mk
# Include Board and CPU configuration
INCLUDES += $(addprefix -I,$(wildcard $(RIOTBOARD)/$(BOARD)/include))
include $(RIOTBOARD)/$(BOARD)/Makefile.include
INCLUDES += -I$(RIOTCPU)/$(CPU)/include
include $(RIOTCPU)/$(CPU)/Makefile.include
# Import all toolchain settings
include $(RIOTMAKE)/toolchain/$(TOOLCHAIN).inc.mk
# get number of interfaces straight before resolving dependencies
GNRC_NETIF_NUMOF ?= 1
ifneq ($(GNRC_NETIF_NUMOF),1)
CFLAGS += -DGNRC_NETIF_NUMOF=$(GNRC_NETIF_NUMOF)
endif
# process dependencies
include $(RIOTBASE)/Makefile.dep
USEMODULE += $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE))
ifeq ($(strip $(MCU)),)
MCU = $(CPU)
endif
# set some settings useful for continuous integration builds
ifeq ($(RIOT_CI_BUILD),1)
RIOT_VERSION_OVERRIDE:=buildtest
ifneq ($(filter $(BOARD_INSUFFICIENT_MEMORY), $(BOARD)),)
$(info CI-build: skipping link step)
RIOTNOLINK:=1
endif
# be more quiet when building for CI
QQ:=@
endif
# if you want to publish the board into the sources as an uppercase #define
BOARDDEF := $(shell echo $(BOARD) | tr 'a-z' 'A-Z' | tr '-' '_')
CPUDEF := $(shell echo $(CPU) | tr 'a-z' 'A-Z' | tr '-' '_')
MCUDEF := $(shell echo $(MCU) | tr 'a-z' 'A-Z' | tr '-' '_')
CFLAGS += -DBOARD_$(BOARDDEF)=\"$(BOARD)\" -DRIOT_BOARD=BOARD_$(BOARDDEF)
CFLAGS += -DCPU_$(CPUDEF)=\"$(CPU)\" -DRIOT_CPU=CPU_$(CPUDEF)
CFLAGS += -DMCU_$(MCUDEF)=\"$(MCU)\" -DRIOT_MCU=MCU_$(MCUDEF)
# OSX fails to create empty archives. Provide a wrapper to catch that error.
ifneq (0, $(shell mkdir -p $(BINDIR); $(AR) rc $(BINDIR)/empty-archive.a 2> /dev/null; \
echo $$?; rm -f $(BINDIR)/empty-archive.a 2>&1 > /dev/null))
AR := $(RIOTBASE)/dist/ar-wrapper $(AR)
endif
# Feature test default CFLAGS and LINKFLAGS for the set compiled.
include $(RIOTMAKE)/cflags.inc.mk
# make the RIOT version available to the program
ifeq ($(origin RIOT_VERSION), undefined)
GIT_STRING := $(shell git --git-dir="$(RIOTBASE)/.git" describe --always --abbrev=4 --dirty=-`hostname` 2> /dev/null)
ifneq (,$(GIT_STRING))
GIT_BRANCH := $(shell git --git-dir="$(RIOTBASE)/.git" rev-parse --abbrev-ref HEAD)
ifeq ($(strip $(GIT_BRANCH)),master)
RIOT_VERSION := $(GIT_STRING)
else
RIOT_VERSION := $(GIT_STRING)-$(GIT_BRANCH)
endif
else
RIOT_VERSION := 'UNKNOWN (builddir: $(RIOTBASE))'
endif
endif
# Set module by prepending APPLICATION name with 'application_'.
# It prevents conflict with application and modules with the same name.
APPLICATION_MODULE ?= application_$(APPLICATION)
# the binaries to link
BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).a
BASELIBS += $(APPDEPS)
# add extra include paths for packages in $(USEMODULE)
export USEMODULE_INCLUDES =
include $(RIOTBASE)/sys/Makefile.include
include $(RIOTBASE)/drivers/Makefile.include
# include Makefile.includes for packages in $(USEPKG)
$(RIOTPKG)/%/Makefile.include::
$(Q)"$(MAKE)" -C $(RIOTPKG)/$* Makefile.include
$(USEPKG:%=$(RIOTPKG)/%/Makefile.include): FORCE
-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)
# Deduplicate includes without sorting them
# see https://stackoverflow.com/questions/16144115/makefile-remove-duplicate-words-without-sorting
define uniq
$(eval seen :=)
$(foreach _,$1,$(if $(filter $_,$(seen)),,$(eval seen += $_)))
$(seen)
endef
USEMODULE_INCLUDES_ = $(strip $(call uniq,$(USEMODULE_INCLUDES)))
INCLUDES += $(USEMODULE_INCLUDES_:%=-I%)
# include bindist target
include $(RIOTMAKE)/bindist.inc.mk
# Add all USEMODULE modules to CFLAGS and populate BASELIBS
include $(RIOTMAKE)/modules.inc.mk
.PHONY: all link clean flash flash-only term doc debug debug-server reset objdump help info-modules
.PHONY: print-size elffile binfile hexfile
.PHONY: ..in-docker-container
# Targets that depend on FORCE will always be rebuilt. Contrary to a .PHONY
# target, they are considered real files and the modification timestamp is taken
# into account.
#
# FORCE is useful for goals that may keep outputs unchanged (for example, if it
# depends on environment or configuration variables). If the goal were .PHONY, it
# would trigger a rebuild of all its dependents regardless of file modification.
#
# As general rule, use .PHONY only for non-file targets.
#
# For more information, see:
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
# https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
.PHONY: FORCE
ELFFILE ?= $(BINDIR)/$(APPLICATION).elf
HEXFILE ?= $(ELFFILE:.elf=.hex)
BINFILE ?= $(ELFFILE:.elf=.bin)
# Targets to get given file
elffile: $(ELFFILE)
hexfile: $(HEXFILE)
binfile: $(BINFILE)
# variables used to compile and link c++
CPPMIX ?= $(if $(wildcard *.cpp),1,)
# We assume $(LINK) to be gcc-like. Use `LINKFLAGPREFIX :=` for ld-like linker options.
LINKFLAGPREFIX ?= -Wl,
DIRS += $(EXTERNAL_MODULE_DIRS)
# Define dependencies required for building (headers, downloading source files,)
BUILDDEPS += $(RIOTBUILD_CONFIG_HEADER_C)
BUILDDEPS += pkg-prepare
BUILDDEPS += $(APPDEPS)
# Save value to verify it is not modified later
_BASELIBS_VALUE_BEFORE_USAGE := $(BASELIBS)
# Linker rule
$(ELFFILE): FORCE
ifeq ($(BUILDOSXNATIVE),1)
_LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $$(find $(BASELIBS) -size +8c) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie
else
_LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(LINKFLAGPREFIX)--end-group $(LINKFLAGS) $(LINKFLAGPREFIX)-Map=$(BINDIR)/$(APPLICATION).map
endif # BUILDOSXNATIVE
ifeq ($(BUILD_IN_DOCKER),1)
link: ..in-docker-container
else
ifeq (,$(RIOTNOLINK))
link: ..compiler-check ..build-message $(ELFFILE) $(HEXFILE) print-size
else
link: ..compiler-check ..build-message $(BASELIBS)
endif # RIOTNOLINK
$(ELFFILE): $(BASELIBS)
$(Q)$(_LINK) -o $@
$(BINDIR)/$(APPLICATION_MODULE).a: $(USEPKG:%=$(BINDIR)/%.a) $(BUILDDEPS)
$(Q)DIRS="$(DIRS)" "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk
$(BINDIR)/$(APPLICATION_MODULE).a: FORCE
# Other modules are built by application.inc.mk and packages building
_SUBMAKE_LIBS = $(filter-out $(BINDIR)/$(APPLICATION_MODULE).a $(USEPKG:%=$(BINDIR)/%.a) $(APPDEPS), $(BASELIBS))
$(_SUBMAKE_LIBS): $(BINDIR)/$(APPLICATION_MODULE).a $(USEPKG:%=$(BINDIR)/%.a)
# 'print-size' triggers a rebuild. Use 'info-buildsize' if you do not need to rebuild.
print-size: $(ELFFILE)
$(Q)$(SIZE) $(SIZEFLAGS) $<
%.hex: %.elf
$(Q)$(OBJCOPY) $(OFLAGS) -Oihex $< $@
%.bin: %.elf
$(Q)$(OBJCOPY) $(OFLAGS) -Obinary $< $@
endif # BUILD_IN_DOCKER
# Check given command is available in the path
# check_cmd 'command' 'description'
define check_cmd
@command -v $1 >/dev/null 2>&1 || \
{ $(COLOR_ECHO) \
'$(COLOR_RED)$2 $1 is required but not found in PATH. Aborting.$(COLOR_RESET)'; \
exit 1;}
endef
..compiler-check:
$(call check_cmd,$(CC),Compiler)
..build-message:
@$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)'
@$(COLOR_ECHO)
# The `clean` needs to be serialized before everything else.
ifneq (, $(filter clean, $(MAKECMDGOALS)))
all $(BASELIBS) $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) $(BUILDDEPS): clean
endif
.PHONY: pkg-prepare
pkg-prepare:
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i prepare ; done
$(USEPKG:%=$(BINDIR)/%.a): $(BUILDDEPS) FORCE
@mkdir -p $(BINDIR)
$(QQ)"$(MAKE)" -C $(RIOTPKG)/$(patsubst $(BINDIR)/%.a,%,$@)
clean:
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i clean ; done
-@rm -rf $(BINDIR)
-@rm -rf $(SCANBUILD_OUTPUTDIR)
# Remove intermediates, but keep the .elf, .hex and .map etc.
clean-intermediates:
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
-@rm -rf $(BINDIR)/*.a $(BINDIR)/*/
clean-pkg:
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
distclean:
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
-@rm -rf $(BINDIRBASE)
# if make target != 'flash-only', add target 'all' to ensure build before flash
ifeq (,$(filter flash-only, $(MAKECMDGOALS)))
BUILD_BEFORE_FLASH = all
endif
flash: $(BUILD_BEFORE_FLASH) $(FLASHDEPS)
$(call check_cmd,$(FLASHER),Flash program)
$(FLASHER) $(FFLAGS)
flash-only: flash
preflash: $(BUILD_BEFORE_FLASH)
$(PREFLASHER) $(PREFFLAGS)
term: $(filter flash, $(MAKECMDGOALS)) $(TERMDEPS)
$(call check_cmd,$(TERMPROG),Terminal program)
$(TERMPROG) $(TERMFLAGS)
list-ttys:
$(Q)$(RIOTTOOLS)/usb-serial/list-ttys.sh
doc:
make -BC $(RIOTBASE) doc
debug:
$(call check_cmd,$(DEBUGGER),Debug program)
$(DEBUGGER) $(DEBUGGER_FLAGS)
debug-server:
$(call check_cmd,$(DEBUGSERVER),Debug server program)
$(DEBUGSERVER) $(DEBUGSERVER_FLAGS)
emulate:
$(call check_cmd,$(EMULATOR),Emulation program)
$(EMULATOR) $(EMULATOR_FLAGS)
reset:
$(call check_cmd,$(RESET),Reset program)
$(RESET) $(RESET_FLAGS)
# Default OBJDUMPFLAGS for platforms which do not specify it:
OBJDUMPFLAGS ?= -S -D -h
objdump:
$(call check_cmd,$(OBJDUMP),Objdump program)
$(OBJDUMP) $(OBJDUMPFLAGS) $(ELFFILE) | less
# Generate an XML file containing all macro definitions and include paths for
# use in Eclipse CDT
.PHONY: eclipsesym eclipsesym.xml
eclipsesym: $(CURDIR)/eclipsesym.xml
eclipsesym.xml: $(CURDIR)/eclipsesym.xml
$(CURDIR)/eclipsesym.xml: FORCE
$(Q)printf "%s\n" $(CC) $(CFLAGS_WITH_MACROS) $(INCLUDES) | \
$(RIOTTOOLS)/eclipsesym/cmdline2xml.sh > $@
# Export variables used throughout the whole make system:
include $(RIOTMAKE)/vars.inc.mk
# Include build targets for selected tools
include $(RIOTMAKE)/tools/targets.inc.mk
# Warn if the selected board and drivers don't provide all needed features:
ifneq (, $(filter all, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all)))
EXPECT_ERRORS :=
EXPECT_CONFLICT :=
# Test if there where dependencies against a module in DISABLE_MODULE.
ifneq (, $(filter $(DISABLE_MODULE), $(USEMODULE)))
$(shell $(COLOR_ECHO) "$(COLOR_RED)Required modules were disabled using DISABLE_MODULE:$(COLOR_RESET)"\
"$(sort $(filter $(DISABLE_MODULE), $(USEMODULE)))" 1>&2)
USEMODULE := $(filter-out $(DISABLE_MODULE), $(USEMODULE))
EXPECT_ERRORS := 1
endif
# Test if all feature requirements were met by the selected board.
ifneq (, $(filter-out $(FEATURES_PROVIDED) $(FEATURES_OPTIONAL), $(FEATURES_REQUIRED)))
$(shell $(COLOR_ECHO) "$(COLOR_RED)There are unsatisfied feature requirements:$(COLOR_RESET)"\
"$(sort $(filter-out $(FEATURES_PROVIDED) $(FEATURES_OPTIONAL), $(FEATURES_REQUIRED)))" 1>&2)
EXPECT_ERRORS := 1
endif
# Test if any used feature conflict with another one.
CONFLICT := $(foreach var,$(FEATURES_CONFLICT),$(if $(filter $(words $(subst :, ,$(var))),$(words $(filter $(FEATURES_USED),$(subst :, ,$(var))))),$(subst :, ,$(var))))
ifneq (, $(strip $(CONFLICT)))
$(shell $(COLOR_ECHO) "$(COLOR_YELLOW)The following features may conflict:$(COLOR_RESET)"\
"$(COLOR_GREEN)$(sort $(filter $(FEATURES_USED), $(CONFLICT)))$(COLOR_RESET)" 1>&2)
ifneq (, $(FEATURES_CONFLICT_MSG))
$(shell $(COLOR_ECHO) "$(COLOR_YELLOW)Rationale: $(COLOR_RESET)$(FEATURES_CONFLICT_MSG)" 1>&2)
endif
EXPECT_CONFLICT := 1
endif
# If there is a whitelist, then test if the board is whitelisted.
ifneq (, $(BOARD_WHITELIST))
ifeq (, $(filter $(BOARD_WHITELIST), $(BOARD)))
$(shell $(COLOR_ECHO) "$(COLOR_RED)The selected BOARD=$(BOARD) is not whitelisted:$(COLOR_RESET) $(BOARD_WHITELIST)" 1>&2)
EXPECT_ERRORS := 1
endif
endif
# If there is a blacklist, then test if the board is blacklisted.
ifneq (, $(BOARD_BLACKLIST))
ifneq (, $(filter $(BOARD_BLACKLIST), $(BOARD)))
$(shell $(COLOR_ECHO) "$(COLOR_RED)The selected BOARD=$(BOARD) is blacklisted:$(COLOR_RESET) $(BOARD_BLACKLIST)" 1>&2)
EXPECT_ERRORS := 1
endif
endif
ifneq (, $(EXPECT_CONFLICT))
$(shell $(COLOR_ECHO) "\n$(COLOR_YELLOW)EXPECT undesired behaviour!$(COLOR_RESET)" 1>&2)
endif
ifneq (, $(EXPECT_ERRORS))
$(shell $(COLOR_ECHO) "\n\n$(COLOR_RED)EXPECT ERRORS!$(COLOR_RESET)\n\n" 1>&2)
endif
endif
else # RIOT_VERSION
export __RIOTBUILD_FLAG := RIOT
NUM_RIOT_VERSION := $(shell cd $(RIOTBASE) && git rev-parse --verify --short "$(RIOT_VERSION)" 2>/dev/null)
ifeq (, $(NUM_RIOT_VERSION))
$(error The supplied RIOT_VERSION=$(RIOT_VERSION) is invalid!)
endif
all $(filter-out clean, $(MAKECMDGOALS)): ..delegate
ifneq (, $(filter clean, $(MAKECMDGOALS)))
all $(filter-out clean, $(MAKECMDGOALS)): clean
endif
clean:
-$(Q)rm -rf $(BINDIR)
$(BINDIR)/riot-version/$(NUM_RIOT_VERSION)/Makefile.include:
$(Q)rm -rf $(@D)
$(Q)mkdir -p $(@D)
$(Q)cd $(RIOTBASE) && git archive --format=tar $(NUM_RIOT_VERSION) | ( cd $(@D) && tar x 1>&2 )
..delegate: $(BINDIR)/riot-version/$(NUM_RIOT_VERSION)/Makefile.include
@$(COLOR_ECHO) '$(COLOR_GREEN)Using RIOT_VERSION=$(NUM_RIOT_VERSION)$(COLOR_RESET)' 1>&2
@$(COLOR_ECHO)
$(MAKE) RIOTBASE=$(<D) $(filter-out clean, $(MAKECMDGOALS))
endif
help:
@$(MAKE) -qp | sed -ne 's/\(^[a-z][a-z_-]*\):.*/\1/p' | sort | uniq
ifneq (,$(filter iotlab-m3 wsn430-v1_3b wsn430-v1_4,$(BOARD)))
ifneq (,$(filter iotlab-%,$(MAKECMDGOALS)))
include $(RIOTBASE)/dist/testbed-support/Makefile.iotlab
endif
endif
ifneq (,$(IOTLAB_NODE))
# iot-lab serial and flasher
include $(RIOTBASE)/dist/testbed-support/makefile.iotlab.single.inc.mk
endif
# Include desvirt Makefile
include $(RIOTTOOLS)/desvirt/Makefile.desvirt
# Build a header file with all common macro definitions and undefinitions
# make it depend on FORCE to re-run of the script every time even if the file exists
# The script will only touch the file if anything has changed since last time.
$(RIOTBUILD_CONFIG_HEADER_C): FORCE
@mkdir -p '$(dir $@)'
$(Q)'$(RIOTTOOLS)/genconfigheader/genconfigheader.sh' '$@' $(CFLAGS_WITH_MACROS)
CFLAGS_WITH_MACROS := $(CFLAGS)
ifneq (,$(RIOT_VERSION_OVERRIDE))
export CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION_OVERRIDE)\"
else
export CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION)\"
endif
CFLAGS := $(patsubst -D%,,$(CFLAGS))
CFLAGS := $(patsubst -U%,,$(CFLAGS))
CFLAGS += -include '$(RIOTBUILD_CONFIG_HEADER_C)'
# include mcuboot support
include $(RIOTMAKE)/mcuboot.mk
# include Murdock helpers
include $(RIOTMAKE)/murdock.inc.mk
# Sanity check, 'all' should be the default goal
ifneq (all, $(.DEFAULT_GOAL))
$(error .DEFAULT_GOAL := $(.DEFAULT_GOAL))
endif
# Detect if BASELIBS changed since its first use
ifneq ($(_BASELIBS_VALUE_BEFORE_USAGE),$(BASELIBS))
$(warning $(sort $(filter-out $(_BASELIBS_VALUE_BEFORE_USAGE), $(BASELIBS)) \
$(filter-out $(BASELIBS), $(_BASELIBS_VALUE_BEFORE_USAGE))))
$(error BASELIBS value changed)
endif
endif # BOARD=none
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化