2018-03-28 16:27:12 +02:00
|
|
|
# Globally set default goal to `all`
|
|
|
|
.DEFAULT_GOAL := all
|
|
|
|
|
2015-11-17 14:59:54 +01:00
|
|
|
# include Makefile.local if it exists
|
|
|
|
-include Makefile.local
|
|
|
|
|
2013-04-01 00:18:07 +02:00
|
|
|
# set undefined variables
|
2016-04-12 13:37:29 +02:00
|
|
|
RIOTBASE ?= $(dir $(lastword $(MAKEFILE_LIST)))
|
2016-04-05 11:39:57 +02:00
|
|
|
CCACHE_BASEDIR ?= $(RIOTBASE)
|
2016-04-01 01:01:59 +02:00
|
|
|
RIOTCPU ?= $(RIOTBASE)/cpu
|
|
|
|
RIOTBOARD ?= $(RIOTBASE)/boards
|
2016-01-27 10:47:12 +01:00
|
|
|
RIOTMAKE ?= $(RIOTBASE)/makefiles
|
2016-04-01 01:01:59 +02:00
|
|
|
RIOTPKG ?= $(RIOTBASE)/pkg
|
|
|
|
RIOTPROJECT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd)
|
|
|
|
GITCACHE ?= $(RIOTBASE)/dist/tools/git/git-cache
|
|
|
|
APPDIR ?= $(CURDIR)
|
|
|
|
BINDIRBASE ?= $(APPDIR)/bin
|
|
|
|
BINDIR ?= $(BINDIRBASE)/$(BOARD)
|
2017-02-25 15:41:22 +01:00
|
|
|
PKGDIRBASE ?= $(BINDIRBASE)/pkg/$(BOARD)
|
2017-02-23 17:34:32 +01:00
|
|
|
DLCACHE ?= $(RIOTBASE)/dist/tools/dlcache/dlcache.sh
|
|
|
|
DLCACHE_DIR ?= $(RIOTBASE)/.dlcache
|
2016-04-01 01:01:59 +02:00
|
|
|
|
2016-01-27 10:47:12 +01:00
|
|
|
__DIRECTORY_VARIABLES := \
|
|
|
|
RIOTBASE \
|
|
|
|
RIOTCPU \
|
|
|
|
RIOTBOARD \
|
|
|
|
RIOTMAKE \
|
|
|
|
RIOTPKG \
|
|
|
|
RIOTPROJECT \
|
|
|
|
APPDIR \
|
|
|
|
BINDIRBASE \
|
|
|
|
BINDIR \
|
|
|
|
CCACHE_BASEDIR \
|
|
|
|
GITCACHE \
|
|
|
|
PKGDIRBASE \
|
2017-02-23 17:34:32 +01:00
|
|
|
DLCACHE_DIR \
|
2016-01-27 10:47:12 +01:00
|
|
|
#
|
2016-04-01 01:01:59 +02:00
|
|
|
|
|
|
|
# Make all paths absolute.
|
|
|
|
override RIOTBASE := $(abspath $(RIOTBASE))
|
|
|
|
override CCACHE_BASEDIR := $(abspath $(CCACHE_BASEDIR))
|
|
|
|
override RIOTCPU := $(abspath $(RIOTCPU))
|
|
|
|
override RIOTBOARD := $(abspath $(RIOTBOARD))
|
2016-01-27 10:47:12 +01:00
|
|
|
override RIOTMAKE := $(abspath $(RIOTMAKE))
|
2016-04-01 01:01:59 +02:00
|
|
|
override RIOTPKG := $(abspath $(RIOTPKG))
|
|
|
|
override RIOTPROJECT := $(abspath $(RIOTPROJECT))
|
|
|
|
override GITCACHE := $(abspath $(GITCACHE))
|
2016-10-18 23:27:59 +02:00
|
|
|
override APPDIR := $(abspath $(APPDIR))
|
2016-04-01 01:01:59 +02:00
|
|
|
override BINDIRBASE := $(abspath $(BINDIRBASE))
|
2016-10-18 23:27:59 +02:00
|
|
|
override BINDIR := $(abspath $(BINDIR))
|
2017-02-25 15:41:22 +01:00
|
|
|
override PKGDIRBASE := $(abspath $(PKGDIRBASE))
|
2017-02-23 17:34:32 +01:00
|
|
|
override DLCACHE_DIR := $(abspath $(DLCACHE_DIR))
|
2016-04-01 01:01:59 +02:00
|
|
|
|
|
|
|
# Ensure that all directories are set and don't contain spaces.
|
2018-03-22 16:20:19 +01:00
|
|
|
ifneq (, $(filter-out 1, $(foreach v,$(__DIRECTORY_VARIABLES),$(words $($(v))))))
|
2016-04-01 01:01:59 +02:00
|
|
|
$(info Aborting compilation for your safety.)
|
2018-03-22 16:20:19 +01:00
|
|
|
$(info Related variables = $(__DIRECTORY_VARIABLES))
|
2016-04-01 01:01:59 +02:00
|
|
|
$(error Make sure no path override is empty or contains spaces!)
|
|
|
|
endif
|
2016-03-05 00:53:05 +01:00
|
|
|
|
2016-04-01 01:01:59 +02:00
|
|
|
# Use absolute paths in recusive "make" even if overriden on command line.
|
2018-03-22 16:20:19 +01:00
|
|
|
MAKEOVERRIDES += $(foreach v,$(__DIRECTORY_VARIABLES),$(v)=$($(v)))
|
2015-02-05 10:03:05 +01:00
|
|
|
|
2016-04-05 15:27:34 +02:00
|
|
|
# Path to the current directory relative to RIOTPROJECT
|
2018-03-22 16:20:19 +01:00
|
|
|
BUILDRELPATH ?= $(PWD:$(RIOTPROJECT)/%=%)/
|
2016-03-20 12:40:20 +01:00
|
|
|
|
2017-09-09 00:06:29 +02:00
|
|
|
# get host operating system
|
|
|
|
OS := $(shell uname)
|
|
|
|
|
2015-05-06 13:54:57 +02:00
|
|
|
# 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.
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/docker.inc.mk
|
2015-05-06 13:54:57 +02:00
|
|
|
|
2017-09-09 00:06:29 +02:00
|
|
|
# include color echo macros
|
|
|
|
include $(RIOTMAKE)/color.inc.mk
|
2015-07-21 11:32:47 +02:00
|
|
|
|
2017-09-20 12:04:36 +02:00
|
|
|
# include concurrency helpers
|
|
|
|
include $(RIOTMAKE)/info-nproc.inc.mk
|
|
|
|
|
2017-09-09 00:06:29 +02:00
|
|
|
GLOBAL_GOALS := buildtest info-boards-supported info-boards-features-missing info-buildsizes info-buildsizes-diff
|
|
|
|
ifneq (, $(filter $(GLOBAL_GOALS), $(MAKECMDGOALS)))
|
|
|
|
BOARD=none
|
|
|
|
endif
|
2016-03-17 13:05:15 +01:00
|
|
|
|
2017-09-09 00:06:29 +02:00
|
|
|
ifeq (none,$(BOARD))
|
|
|
|
include $(RIOTMAKE)/info-global.inc.mk
|
|
|
|
include $(RIOTMAKE)/buildtests.inc.mk
|
|
|
|
else
|
2014-12-15 16:16:44 +01:00
|
|
|
|
2017-09-09 00:06:29 +02:00
|
|
|
all: link
|
2014-12-15 16:16:44 +01:00
|
|
|
|
2017-09-09 00:06:29 +02:00
|
|
|
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
|
2013-12-21 15:02:53 +01:00
|
|
|
|
2015-07-21 11:32:47 +02:00
|
|
|
ifeq ($(OS),Darwin)
|
|
|
|
OPEN := open
|
|
|
|
else
|
|
|
|
OPEN := xdg-open
|
|
|
|
endif
|
|
|
|
|
2016-09-06 14:59:48 +02:00
|
|
|
QUIET ?= 1
|
|
|
|
|
2014-01-05 11:33:34 +01:00
|
|
|
ifeq ($(QUIET),1)
|
2016-12-17 01:16:07 +01:00
|
|
|
Q=@
|
2015-07-21 07:05:14 +02:00
|
|
|
MAKEFLAGS += --no-print-directory
|
2014-01-05 11:33:34 +01:00
|
|
|
else
|
2016-12-17 01:16:07 +01:00
|
|
|
Q=
|
2015-07-21 07:05:14 +02:00
|
|
|
endif
|
|
|
|
|
2016-12-22 12:18:38 +01:00
|
|
|
QQ=
|
|
|
|
|
2017-11-14 11:04:54 +01:00
|
|
|
# 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
|
|
|
|
|
2015-07-21 07:05:14 +02:00
|
|
|
# Fail on warnings. Can be overridden by `make WERROR=0`.
|
|
|
|
WERROR ?= 1
|
|
|
|
export WERROR
|
|
|
|
ifeq ($(WERROR),1)
|
2017-10-31 11:51:37 +01:00
|
|
|
CFLAGS += -Wall -Werror -Wextra
|
|
|
|
endif
|
|
|
|
|
|
|
|
WPEDANTIC ?= 0
|
|
|
|
export WPEDANTIC
|
|
|
|
ifeq ($(WPEDANTIC),1)
|
|
|
|
CFLAGS += -Wpedantic -pedantic-errors
|
2014-01-05 11:33:34 +01:00
|
|
|
endif
|
|
|
|
|
2018-02-20 15:45:18 +01:00
|
|
|
# remove this once codebase is adapted
|
|
|
|
CFLAGS += -Wno-implicit-fallthrough
|
2018-02-22 14:28:22 +01:00
|
|
|
CXXFLAGS += -Wno-implicit-fallthrough
|
2018-02-20 15:45:18 +01:00
|
|
|
|
2018-03-22 16:20:19 +01:00
|
|
|
ifneq (10,$(if $(RIOT_VERSION),1,0)$(if $(__RIOTBUILD_FLAG),1,0))
|
2014-10-30 22:40:41 +01:00
|
|
|
|
|
|
|
# Provide a shallow sanity check. You cannot call `make` in a module directory.
|
|
|
|
export __RIOTBUILD_FLAG := RIOT
|
|
|
|
|
2014-01-08 16:46:16 +01:00
|
|
|
BOARD := $(strip $(BOARD))
|
2014-11-21 20:23:13 +01:00
|
|
|
APPLICATION := $(strip $(APPLICATION))
|
2014-01-08 16:46:16 +01:00
|
|
|
|
make: centralize wget/curl & unzip/7z feature test
With many open PRs that could benefit from loading SDKs when needed,
instead adding vast amounts of code to RIOTs master, this PR provides
the "functions" `$(DOWNLOAD_TO_STDOUT)`, `$(DOWNLOAD_TO_FILE)`, and
`$(UNZIP_HERE)`.
The first "function" takes one argument, the URL from where to download
the content. It is then piped to stdout. To be used e.g. with `tar xz`.
The second "function" taken two arguments, the destination file name,
and the source URL. If the previous invocation was interrupted, then the
download gets continued, if possible.
The last "function" takes one argument, the source ZIP file. The file
gets extracted into the cwd, so best use this "function" with
`cd $(SOME_WHERE) &&`.
The clumsy name `$(UNZIP_HERE)` is taken because the program "unzip"
takes the environment variable `UNZIP` as the source file, even if
another file name was given on the command line. The rationale for that
is that the hackers of "unzip" hate their users. Also they sacrifice
hamsters to Satan.
2014-07-16 00:29:18 +02:00
|
|
|
# provide common external programs for `Makefile.include`s
|
|
|
|
|
2014-11-03 17:04:26 +01:00
|
|
|
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
|
make: centralize wget/curl & unzip/7z feature test
With many open PRs that could benefit from loading SDKs when needed,
instead adding vast amounts of code to RIOTs master, this PR provides
the "functions" `$(DOWNLOAD_TO_STDOUT)`, `$(DOWNLOAD_TO_FILE)`, and
`$(UNZIP_HERE)`.
The first "function" takes one argument, the URL from where to download
the content. It is then piped to stdout. To be used e.g. with `tar xz`.
The second "function" taken two arguments, the destination file name,
and the source URL. If the previous invocation was interrupted, then the
download gets continued, if possible.
The last "function" takes one argument, the source ZIP file. The file
gets extracted into the cwd, so best use this "function" with
`cd $(SOME_WHERE) &&`.
The clumsy name `$(UNZIP_HERE)` is taken because the program "unzip"
takes the environment variable `UNZIP` as the source file, even if
another file name was given on the command line. The rationale for that
is that the hackers of "unzip" hate their users. Also they sacrifice
hamsters to Satan.
2014-07-16 00:29:18 +02:00
|
|
|
endif
|
2014-11-03 17:04:26 +01:00
|
|
|
ifeq (,$(CURL))
|
|
|
|
ifeq (0,$(shell which curl 2>&1 > /dev/null ; echo $$?))
|
|
|
|
CURL := $(shell which curl)
|
|
|
|
endif
|
make: centralize wget/curl & unzip/7z feature test
With many open PRs that could benefit from loading SDKs when needed,
instead adding vast amounts of code to RIOTs master, this PR provides
the "functions" `$(DOWNLOAD_TO_STDOUT)`, `$(DOWNLOAD_TO_FILE)`, and
`$(UNZIP_HERE)`.
The first "function" takes one argument, the URL from where to download
the content. It is then piped to stdout. To be used e.g. with `tar xz`.
The second "function" taken two arguments, the destination file name,
and the source URL. If the previous invocation was interrupted, then the
download gets continued, if possible.
The last "function" takes one argument, the source ZIP file. The file
gets extracted into the cwd, so best use this "function" with
`cd $(SOME_WHERE) &&`.
The clumsy name `$(UNZIP_HERE)` is taken because the program "unzip"
takes the environment variable `UNZIP` as the source file, even if
another file name was given on the command line. The rationale for that
is that the hackers of "unzip" hate their users. Also they sacrifice
hamsters to Satan.
2014-07-16 00:29:18 +02:00
|
|
|
endif
|
2014-11-03 17:04:26 +01:00
|
|
|
ifeq (,$(WGET)$(CURL))
|
|
|
|
$(error Neither wget nor curl is installed!)
|
make: centralize wget/curl & unzip/7z feature test
With many open PRs that could benefit from loading SDKs when needed,
instead adding vast amounts of code to RIOTs master, this PR provides
the "functions" `$(DOWNLOAD_TO_STDOUT)`, `$(DOWNLOAD_TO_FILE)`, and
`$(UNZIP_HERE)`.
The first "function" takes one argument, the URL from where to download
the content. It is then piped to stdout. To be used e.g. with `tar xz`.
The second "function" taken two arguments, the destination file name,
and the source URL. If the previous invocation was interrupted, then the
download gets continued, if possible.
The last "function" takes one argument, the source ZIP file. The file
gets extracted into the cwd, so best use this "function" with
`cd $(SOME_WHERE) &&`.
The clumsy name `$(UNZIP_HERE)` is taken because the program "unzip"
takes the environment variable `UNZIP` as the source file, even if
another file name was given on the command line. The rationale for that
is that the hackers of "unzip" hate their users. Also they sacrifice
hamsters to Satan.
2014-07-16 00:29:18 +02:00
|
|
|
endif
|
|
|
|
|
2014-11-03 17:04:26 +01:00
|
|
|
ifeq (,$(DOWNLOAD_TO_STDOUT))
|
|
|
|
DOWNLOAD_TO_STDOUT := $(if $(CURL),$(CURL) -s,$(WGET) -q -O-)
|
|
|
|
endif
|
|
|
|
ifeq (,$(DOWNLOAD_TO_FILE))
|
make: centralize wget/curl & unzip/7z feature test
With many open PRs that could benefit from loading SDKs when needed,
instead adding vast amounts of code to RIOTs master, this PR provides
the "functions" `$(DOWNLOAD_TO_STDOUT)`, `$(DOWNLOAD_TO_FILE)`, and
`$(UNZIP_HERE)`.
The first "function" takes one argument, the URL from where to download
the content. It is then piped to stdout. To be used e.g. with `tar xz`.
The second "function" taken two arguments, the destination file name,
and the source URL. If the previous invocation was interrupted, then the
download gets continued, if possible.
The last "function" takes one argument, the source ZIP file. The file
gets extracted into the cwd, so best use this "function" with
`cd $(SOME_WHERE) &&`.
The clumsy name `$(UNZIP_HERE)` is taken because the program "unzip"
takes the environment variable `UNZIP` as the source file, even if
another file name was given on the command line. The rationale for that
is that the hackers of "unzip" hate their users. Also they sacrifice
hamsters to Satan.
2014-07-16 00:29:18 +02:00
|
|
|
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
|
|
|
|
|
2018-03-22 16:20:19 +01:00
|
|
|
ifeq (, $(APPLICATION))
|
2016-03-08 21:07:44 +01:00
|
|
|
$(error An application name must be specified as APPLICATION.)
|
|
|
|
endif
|
2015-02-22 21:11:30 +01:00
|
|
|
ifneq (0,$(shell test -d $(RIOTBOARD)/$(BOARD); echo $$?))
|
|
|
|
$(error The specified board $(BOARD) does not exist.)
|
|
|
|
endif
|
|
|
|
|
2016-03-15 11:55:40 +01:00
|
|
|
# Use TOOLCHAIN environment variable to select the toolchain to use.
|
2017-03-16 20:19:30 +01:00
|
|
|
# Default for macOS: llvm; for other OS: gnu
|
|
|
|
ifeq ($(BOARD),native)
|
|
|
|
ifeq ($(OS),Darwin)
|
|
|
|
TOOLCHAIN ?= llvm
|
|
|
|
endif
|
|
|
|
endif
|
2016-03-15 11:55:40 +01:00
|
|
|
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
|
|
|
|
|
2016-03-21 09:03:20 +01:00
|
|
|
# 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)-)
|
|
|
|
|
2016-07-12 07:43:58 +02:00
|
|
|
# Add standard include directories
|
|
|
|
INCLUDES += -I$(RIOTBASE)/core/include -I$(RIOTBASE)/drivers/include -I$(RIOTBASE)/sys/include
|
|
|
|
INCLUDES += -I$(RIOTCPU)/$(CPU)/include
|
|
|
|
INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include
|
|
|
|
|
2017-09-09 15:28:01 +02:00
|
|
|
# process provided features
|
|
|
|
-include $(RIOTBOARD)/$(BOARD)/Makefile.features
|
|
|
|
|
2013-04-01 00:18:07 +02:00
|
|
|
# mandatory includes!
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/pseudomodules.inc.mk
|
|
|
|
include $(RIOTMAKE)/defaultmodules.inc.mk
|
2013-03-10 16:51:40 +01:00
|
|
|
include $(RIOTBOARD)/$(BOARD)/Makefile.include
|
2013-12-22 20:02:59 +01:00
|
|
|
include $(RIOTCPU)/$(CPU)/Makefile.include
|
2015-07-19 12:16:34 +02:00
|
|
|
|
2016-12-21 13:03:58 +01:00
|
|
|
# Import all toolchain settings
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/toolchain/$(TOOLCHAIN).inc.mk
|
2016-12-21 13:03:58 +01:00
|
|
|
|
2015-07-19 12:16:34 +02:00
|
|
|
# get number of interfaces straight before resolving dependencies
|
2015-08-17 15:41:29 +02:00
|
|
|
GNRC_NETIF_NUMOF ?= 1
|
2015-07-19 12:16:34 +02:00
|
|
|
|
2015-08-17 15:41:29 +02:00
|
|
|
ifneq ($(GNRC_NETIF_NUMOF),1)
|
|
|
|
CFLAGS += -DGNRC_NETIF_NUMOF=$(GNRC_NETIF_NUMOF)
|
2015-07-19 12:16:34 +02:00
|
|
|
endif
|
|
|
|
|
2017-09-09 00:06:29 +02:00
|
|
|
# process dependencies
|
2014-02-07 21:24:42 +01:00
|
|
|
include $(RIOTBASE)/Makefile.dep
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2014-12-25 16:32:56 +01:00
|
|
|
USEMODULE += $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE))
|
|
|
|
|
2014-08-01 02:33:22 +02:00
|
|
|
ifeq ($(strip $(MCU)),)
|
|
|
|
MCU = $(CPU)
|
|
|
|
endif
|
|
|
|
|
2016-12-17 00:17:26 +01:00
|
|
|
# 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
|
2016-12-22 12:18:38 +01:00
|
|
|
# be more quiet when building for CI
|
|
|
|
QQ:=@
|
2016-12-17 00:17:26 +01:00
|
|
|
endif
|
|
|
|
|
2014-08-01 02:33:22 +02:00
|
|
|
# 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 '-' '_')
|
2014-12-19 17:30:51 +01:00
|
|
|
CFLAGS += -DBOARD_$(BOARDDEF)=\"$(BOARD)\" -DRIOT_BOARD=BOARD_$(BOARDDEF)
|
|
|
|
CFLAGS += -DCPU_$(CPUDEF)=\"$(CPU)\" -DRIOT_CPU=CPU_$(CPUDEF)
|
|
|
|
CFLAGS += -DMCU_$(MCUDEF)=\"$(MCU)\" -DRIOT_MCU=MCU_$(MCUDEF)
|
2014-08-01 02:33:22 +02:00
|
|
|
|
2014-06-19 13:13:06 +02:00
|
|
|
# OSX fails to create empty archives. Provide a wrapper to catch that error.
|
2016-10-18 23:27:59 +02:00
|
|
|
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))
|
2014-06-19 13:13:06 +02:00
|
|
|
AR := $(RIOTBASE)/dist/ar-wrapper $(AR)
|
|
|
|
endif
|
|
|
|
|
2014-05-07 13:02:22 +02:00
|
|
|
# Feature test default CFLAGS and LINKFLAGS for the set compiled.
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/cflags.inc.mk
|
2014-02-17 07:04:36 +01:00
|
|
|
|
2014-06-21 18:29:16 +02:00
|
|
|
# make the RIOT version available to the program
|
2014-07-27 13:44:52 +02:00
|
|
|
ifeq ($(origin RIOT_VERSION), undefined)
|
2015-08-13 19:11:23 +02:00
|
|
|
GIT_STRING := $(shell git --git-dir="$(RIOTBASE)/.git" describe --always --abbrev=4 --dirty=-`hostname` 2> /dev/null)
|
2014-07-27 13:44:52 +02:00
|
|
|
ifneq (,$(GIT_STRING))
|
2015-08-13 19:11:23 +02:00
|
|
|
GIT_BRANCH := $(shell git --git-dir="$(RIOTBASE)/.git" rev-parse --abbrev-ref HEAD)
|
2014-07-27 13:44:52 +02:00
|
|
|
ifeq ($(strip $(GIT_BRANCH)),master)
|
|
|
|
RIOT_VERSION := $(GIT_STRING)
|
|
|
|
else
|
|
|
|
RIOT_VERSION := $(GIT_STRING)-$(GIT_BRANCH)
|
|
|
|
endif
|
2014-07-10 21:48:22 +02:00
|
|
|
else
|
2016-03-01 20:38:01 +01:00
|
|
|
RIOT_VERSION := 'UNKNOWN (builddir: $(RIOTBASE))'
|
2014-07-10 21:48:22 +02:00
|
|
|
endif
|
2014-06-21 18:29:16 +02:00
|
|
|
endif
|
2015-05-19 18:29:04 +02:00
|
|
|
|
2018-01-29 15:48:18 +01:00
|
|
|
# Set module by prepending APPLICATION name with 'application_'.
|
|
|
|
# It prevents conflict with application and modules with the same name.
|
|
|
|
APPLICATION_MODULE ?= application_$(APPLICATION)
|
|
|
|
|
2014-05-23 14:28:27 +02:00
|
|
|
# the binaries to link
|
2018-01-29 15:48:18 +01:00
|
|
|
BASELIBS += $(BINDIR)/$(APPLICATION_MODULE).a
|
2016-02-26 15:02:02 +01:00
|
|
|
BASELIBS += $(APPDEPS)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2018-01-16 17:37:19 +01:00
|
|
|
.PHONY: all link clean flash flash-only term doc debug debug-server reset objdump help info-modules
|
2015-02-05 10:03:05 +01:00
|
|
|
.PHONY: ..in-docker-container
|
2013-08-08 15:44:44 +02:00
|
|
|
|
2016-10-18 23:27:59 +02:00
|
|
|
ELFFILE ?= $(BINDIR)/$(APPLICATION).elf
|
2014-05-05 21:53:37 +02:00
|
|
|
HEXFILE ?= $(ELFFILE:.elf=.hex)
|
2014-05-16 18:18:35 +02:00
|
|
|
|
2015-05-06 13:54:57 +02:00
|
|
|
# variables used to compile and link c++
|
2014-05-05 21:53:37 +02:00
|
|
|
CPPMIX ?= $(if $(wildcard *.cpp),1,)
|
2014-06-25 03:17:20 +02:00
|
|
|
|
2014-07-05 01:33:08 +02:00
|
|
|
# We assume $(LINK) to be gcc-like. Use `LINKFLAGPREFIX :=` for ld-like linker options.
|
|
|
|
LINKFLAGPREFIX ?= -Wl,
|
|
|
|
|
2014-10-01 18:19:19 +02:00
|
|
|
DIRS += $(EXTERNAL_MODULE_DIRS)
|
|
|
|
|
2018-03-23 16:13:47 +01:00
|
|
|
# Linker rule
|
|
|
|
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
|
2017-06-09 17:54:12 +02:00
|
|
|
|
2015-02-05 10:03:05 +01:00
|
|
|
ifeq ($(BUILD_IN_DOCKER),1)
|
2017-06-09 17:54:12 +02:00
|
|
|
link: ..in-docker-container
|
2015-02-05 10:03:05 +01:00
|
|
|
else
|
2014-05-23 10:33:02 +02:00
|
|
|
## make script for your application. Build RIOT-base here!
|
2018-03-22 16:20:19 +01:00
|
|
|
link: ..compiler-check ..build-message $(RIOTBUILD_CONFIG_HEADER_C) $(USEPKG:%=$(BINDIR)/%.a) $(APPDEPS)
|
2016-01-27 10:47:12 +01:00
|
|
|
$(Q)DIRS="$(DIRS)" "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk
|
2014-04-22 16:53:16 +02:00
|
|
|
ifeq (,$(RIOTNOLINK))
|
2017-06-09 17:54:12 +02:00
|
|
|
$(Q)$(_LINK) -o $(ELFFILE)
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)$(SIZE) $(ELFFILE)
|
|
|
|
$(Q)$(OBJCOPY) $(OFLAGS) $(ELFFILE) $(HEXFILE)
|
2014-04-22 16:53:16 +02:00
|
|
|
endif
|
2015-02-05 10:03:05 +01:00
|
|
|
endif # BUILD_IN_DOCKER
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2018-03-23 15:12:35 +01:00
|
|
|
# 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
|
|
|
|
|
2015-02-21 13:59:41 +01:00
|
|
|
..compiler-check:
|
2018-03-23 15:12:35 +01:00
|
|
|
$(call check_cmd,$(CC),Compiler)
|
2015-02-21 13:59:41 +01:00
|
|
|
|
2014-06-18 11:00:33 +02:00
|
|
|
..build-message:
|
2018-03-22 16:20:19 +01:00
|
|
|
@$(COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".$(COLOR_RESET)'
|
2014-10-30 22:40:41 +01:00
|
|
|
@$(COLOR_ECHO)
|
2013-04-22 00:55:11 +02:00
|
|
|
|
2014-02-26 23:23:15 +01:00
|
|
|
# add extra include paths for packages in $(USEMODULE)
|
|
|
|
export USEMODULE_INCLUDES =
|
|
|
|
|
|
|
|
include $(RIOTBASE)/sys/Makefile.include
|
|
|
|
include $(RIOTBASE)/drivers/Makefile.include
|
|
|
|
|
2014-05-16 19:09:22 +02:00
|
|
|
# The `clean` needs to be serialized before everything else.
|
|
|
|
ifneq (, $(filter clean, $(MAKECMDGOALS)))
|
2017-06-28 14:34:23 +02:00
|
|
|
all $(BASELIBS) $(USEPKG:%=$(RIOTPKG)/%/Makefile.include) $(RIOTBUILD_CONFIG_HEADER_C) pkg-prepare: clean
|
2014-05-16 19:09:22 +02:00
|
|
|
endif
|
|
|
|
|
2014-01-28 21:12:55 +01:00
|
|
|
# include Makefile.includes for packages in $(USEPKG)
|
2016-03-05 00:53:05 +01:00
|
|
|
$(RIOTPKG)/%/Makefile.include::
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)"$(MAKE)" -C $(RIOTPKG)/$* Makefile.include
|
2014-01-28 21:12:55 +01:00
|
|
|
|
2016-03-05 00:53:05 +01:00
|
|
|
.PHONY: $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)
|
|
|
|
-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.include)
|
2014-01-28 21:12:55 +01:00
|
|
|
|
2016-03-22 16:02:51 +01:00
|
|
|
USEMODULE_INCLUDES_ = $(shell echo $(USEMODULE_INCLUDES) | tr ' ' '\n' | awk '!a[$$0]++' | tr '\n' ' ')
|
|
|
|
|
|
|
|
INCLUDES += $(USEMODULE_INCLUDES_:%=-I%)
|
|
|
|
|
2018-03-22 16:20:19 +01:00
|
|
|
.PHONY: pkg-prepare $(USEPKG:%=$(BINDIR)/%.a)
|
2017-06-28 14:34:23 +02:00
|
|
|
pkg-prepare:
|
|
|
|
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i prepare ; done
|
|
|
|
|
2018-03-22 16:20:19 +01:00
|
|
|
$(USEPKG:%=$(BINDIR)/%.a): $(RIOTBUILD_CONFIG_HEADER_C) pkg-prepare
|
|
|
|
@mkdir -p $(BINDIR)
|
|
|
|
$(QQ)"$(MAKE)" -C $(RIOTPKG)/$(patsubst $(BINDIR)/%.a,%,$@)
|
2014-01-28 21:12:55 +01:00
|
|
|
|
2013-03-10 16:51:40 +01:00
|
|
|
clean:
|
2016-03-05 00:53:05 +01:00
|
|
|
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i clean ; done
|
2014-10-10 10:08:57 +02:00
|
|
|
-@rm -rf $(BINDIR)
|
2015-07-22 20:30:34 +02:00
|
|
|
-@rm -rf $(SCANBUILD_OUTPUTDIR)
|
2014-08-04 22:03:05 +02:00
|
|
|
|
2015-07-10 14:08:47 +02:00
|
|
|
# Remove intermediates, but keep the .elf, .hex and .map etc.
|
|
|
|
clean-intermediates:
|
2016-07-06 17:33:28 +02:00
|
|
|
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
|
2015-07-10 14:08:47 +02:00
|
|
|
-@rm -rf $(BINDIR)/*.a $(BINDIR)/*/
|
|
|
|
|
2016-03-25 13:54:31 +01:00
|
|
|
clean-pkg:
|
|
|
|
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
|
|
|
|
|
2014-08-04 22:03:05 +02:00
|
|
|
distclean:
|
2016-03-05 00:53:05 +01:00
|
|
|
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTPKG)/$$i distclean ; done
|
2014-10-10 10:08:57 +02:00
|
|
|
-@rm -rf $(BINDIRBASE)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2018-01-16 17:37:19 +01:00
|
|
|
# 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)
|
2018-03-23 15:12:35 +01:00
|
|
|
$(call check_cmd,$(FLASHER),Flash program)
|
2013-04-09 11:26:33 +02:00
|
|
|
$(FLASHER) $(FFLAGS)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2018-01-16 17:37:19 +01:00
|
|
|
flash-only: flash
|
|
|
|
|
|
|
|
preflash: $(BUILD_BEFORE_FLASH)
|
2017-05-17 11:54:52 +02:00
|
|
|
$(PREFLASHER) $(PREFFLAGS)
|
|
|
|
|
2017-05-18 12:35:47 +02:00
|
|
|
term: $(filter flash, $(MAKECMDGOALS)) $(TERMDEPS)
|
2018-03-23 15:12:35 +01:00
|
|
|
$(call check_cmd,$(TERMPROG),Terminal program)
|
2014-08-10 05:20:57 +02:00
|
|
|
$(TERMPROG) $(TERMFLAGS)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2015-10-27 10:36:42 +01:00
|
|
|
list-ttys:
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)$(RIOTBASE)/dist/tools/usb-serial/list-ttys.sh
|
2015-10-27 10:36:42 +01:00
|
|
|
|
2013-03-10 16:51:40 +01:00
|
|
|
doc:
|
|
|
|
make -BC $(RIOTBASE) doc
|
2013-07-12 12:31:16 +02:00
|
|
|
|
|
|
|
debug:
|
2018-03-23 15:12:35 +01:00
|
|
|
$(call check_cmd,$(DEBUGGER),Debug program)
|
2013-07-12 12:31:16 +02:00
|
|
|
$(DEBUGGER) $(DEBUGGER_FLAGS)
|
2013-11-12 14:57:17 +01:00
|
|
|
|
2014-08-05 00:49:59 +02:00
|
|
|
debug-server:
|
2018-03-23 15:12:35 +01:00
|
|
|
$(call check_cmd,$(DEBUGSERVER),Debug server program)
|
2014-08-05 00:49:59 +02:00
|
|
|
$(DEBUGSERVER) $(DEBUGSERVER_FLAGS)
|
|
|
|
|
2017-11-07 17:14:41 +01:00
|
|
|
emulate:
|
2018-03-23 15:12:35 +01:00
|
|
|
$(call check_cmd,$(EMULATOR),Emulation program)
|
2017-11-07 17:14:41 +01:00
|
|
|
$(EMULATOR) $(EMULATOR_FLAGS)
|
|
|
|
|
2014-08-05 00:49:59 +02:00
|
|
|
reset:
|
2018-03-23 15:12:35 +01:00
|
|
|
$(call check_cmd,$(RESET),Reset program)
|
2014-08-05 00:49:59 +02:00
|
|
|
$(RESET) $(RESET_FLAGS)
|
|
|
|
|
2016-02-24 18:14:05 +01:00
|
|
|
# Default OBJDUMPFLAGS for platforms which do not specify it:
|
|
|
|
OBJDUMPFLAGS ?= -S -D -h
|
|
|
|
|
2014-09-27 08:11:29 +02:00
|
|
|
objdump:
|
2018-03-23 15:12:35 +01:00
|
|
|
$(call check_cmd,$(OBJDUMP),Objdump program)
|
2016-02-24 18:14:05 +01:00
|
|
|
$(OBJDUMP) $(OBJDUMPFLAGS) $(ELFFILE) | less
|
2014-09-27 08:11:29 +02:00
|
|
|
|
2015-05-23 10:32:10 +02:00
|
|
|
# Generate an XML file containing all macro definitions and include paths for
|
|
|
|
# use in Eclipse CDT
|
|
|
|
.PHONY: eclipsesym eclipsesym.xml $(CURDIR)/eclipsesym.xml
|
|
|
|
eclipsesym: $(CURDIR)/eclipsesym.xml
|
|
|
|
eclipsesym.xml: $(CURDIR)/eclipsesym.xml
|
|
|
|
|
|
|
|
$(CURDIR)/eclipsesym.xml:
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)printf "%s\n" $(CC) $(CFLAGS_WITH_MACROS) $(INCLUDES) | \
|
2015-05-23 10:32:10 +02:00
|
|
|
$(RIOTBASE)/dist/tools/eclipsesym/cmdline2xml.sh > $@
|
|
|
|
|
2014-05-05 21:53:37 +02:00
|
|
|
# Export variables used throughout the whole make system:
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/vars.inc.mk
|
2014-09-29 18:09:18 +02:00
|
|
|
|
2018-03-28 17:32:11 +02:00
|
|
|
# Include build targets for selected tools
|
2017-05-17 11:54:52 +02:00
|
|
|
include $(RIOTMAKE)/tools/targets.inc.mk
|
|
|
|
|
2016-04-21 10:57:26 +02:00
|
|
|
# Warn if the selected board and drivers don't provide all needed features:
|
2014-09-29 18:09:18 +02:00
|
|
|
ifneq (, $(filter all, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all)))
|
|
|
|
EXPECT_ERRORS :=
|
2014-11-24 14:22:30 +01:00
|
|
|
EXPECT_CONFLICT :=
|
2014-09-29 18:09:18 +02:00
|
|
|
|
|
|
|
# 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)
|
2015-05-09 19:10:03 +02:00
|
|
|
USEMODULE := $(filter-out $(DISABLE_MODULE), $(USEMODULE))
|
2014-09-29 18:09:18 +02:00
|
|
|
EXPECT_ERRORS := 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Test if all feature requirements were met by the selected board.
|
2014-10-26 23:18:58 +01:00
|
|
|
ifneq (, $(filter-out $(FEATURES_PROVIDED) $(FEATURES_OPTIONAL), $(FEATURES_REQUIRED)))
|
2014-09-29 18:09:18 +02:00
|
|
|
$(shell $(COLOR_ECHO) "$(COLOR_RED)There are unsatisfied feature requirements:$(COLOR_RESET)"\
|
2014-10-26 23:18:58 +01:00
|
|
|
"$(sort $(filter-out $(FEATURES_PROVIDED) $(FEATURES_OPTIONAL), $(FEATURES_REQUIRED)))" 1>&2)
|
2014-09-29 18:09:18 +02:00
|
|
|
EXPECT_ERRORS := 1
|
|
|
|
endif
|
|
|
|
|
2014-11-24 14:22:30 +01:00
|
|
|
# Test if any required feature conflict with another one.
|
|
|
|
CONFLICT := $(foreach var,$(FEATURES_CONFLICT),$(if $(filter $(words $(subst :, ,$(var))),$(words $(filter $(FEATURES_REQUIRED),$(subst :, ,$(var))))),$(subst :, ,$(var))))
|
|
|
|
ifneq (, $(strip $(CONFLICT)))
|
|
|
|
$(shell $(COLOR_ECHO) "$(COLOR_YELLOW)The following features may conflict:$(COLOR_RESET)"\
|
|
|
|
"$(COLOR_GREEN)$(sort $(filter $(FEATURES_REQUIRED), $(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
|
|
|
|
|
2014-09-29 18:09:18 +02:00
|
|
|
# If there is a whitelist, then test if the board is whitelisted.
|
|
|
|
ifneq (, $(BOARD_WHITELIST))
|
|
|
|
ifeq (, $(filter $(BOARD_WHITELIST), $(BOARD)))
|
2018-03-22 16:20:19 +01:00
|
|
|
$(shell $(COLOR_ECHO) "$(COLOR_RED)The selected BOARD=$(BOARD) is not whitelisted:$(COLOR_RESET) $(BOARD_WHITELIST)" 1>&2)
|
2014-09-29 18:09:18 +02:00
|
|
|
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)))
|
2018-03-22 16:20:19 +01:00
|
|
|
$(shell $(COLOR_ECHO) "$(COLOR_RED)The selected BOARD=$(BOARD) is blacklisted:$(COLOR_RESET) $(BOARD_BLACKLIST)" 1>&2)
|
2014-09-29 18:09:18 +02:00
|
|
|
EXPECT_ERRORS := 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2014-11-24 14:22:30 +01:00
|
|
|
ifneq (, $(EXPECT_CONFLICT))
|
|
|
|
$(shell $(COLOR_ECHO) "\n$(COLOR_YELLOW)EXPECT undesired behaviour!$(COLOR_RESET)" 1>&2)
|
|
|
|
endif
|
|
|
|
|
2014-09-29 18:09:18 +02:00
|
|
|
ifneq (, $(EXPECT_ERRORS))
|
|
|
|
$(shell $(COLOR_ECHO) "\n\n$(COLOR_RED)EXPECT ERRORS!$(COLOR_RESET)\n\n" 1>&2)
|
|
|
|
endif
|
2014-11-24 14:22:30 +01:00
|
|
|
|
2014-09-29 18:09:18 +02:00
|
|
|
endif
|
2014-10-30 22:40:41 +01:00
|
|
|
|
|
|
|
else # RIOT_VERSION
|
|
|
|
|
|
|
|
export __RIOTBUILD_FLAG := RIOT
|
|
|
|
|
|
|
|
NUM_RIOT_VERSION := $(shell cd $(RIOTBASE) && git rev-parse --verify --short "$(RIOT_VERSION)" 2>/dev/null)
|
2018-03-22 16:20:19 +01:00
|
|
|
ifeq (, $(NUM_RIOT_VERSION))
|
2014-10-30 22:40:41 +01:00
|
|
|
$(error The supplied RIOT_VERSION=$(RIOT_VERSION) is invalid!)
|
|
|
|
endif
|
|
|
|
|
2018-03-22 16:20:19 +01:00
|
|
|
all $(filter-out clean, $(MAKECMDGOALS)): ..delegate
|
2014-10-30 22:40:41 +01:00
|
|
|
ifneq (, $(filter clean, $(MAKECMDGOALS)))
|
2018-03-22 16:20:19 +01:00
|
|
|
all $(filter-out clean, $(MAKECMDGOALS)): clean
|
2014-10-30 22:40:41 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
clean:
|
2016-12-17 01:16:59 +01:00
|
|
|
-$(Q)rm -rf $(BINDIR)
|
2014-10-30 22:40:41 +01:00
|
|
|
|
2016-10-18 23:27:59 +02:00
|
|
|
$(BINDIR)/riot-version/$(NUM_RIOT_VERSION)/Makefile.include:
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)rm -rf $(@D)
|
|
|
|
$(Q)mkdir -p $(@D)
|
|
|
|
$(Q)cd $(RIOTBASE) && git archive --format=tar $(NUM_RIOT_VERSION) | ( cd $(@D) && tar x 1>&2 )
|
2014-10-30 22:40:41 +01:00
|
|
|
|
2016-10-18 23:27:59 +02:00
|
|
|
..delegate: $(BINDIR)/riot-version/$(NUM_RIOT_VERSION)/Makefile.include
|
2018-03-22 16:20:19 +01:00
|
|
|
@$(COLOR_ECHO) '$(COLOR_GREEN)Using RIOT_VERSION=$(NUM_RIOT_VERSION)$(COLOR_RESET)' 1>&2
|
2014-10-30 22:40:41 +01:00
|
|
|
@$(COLOR_ECHO)
|
2018-03-22 16:20:19 +01:00
|
|
|
$(MAKE) RIOTBASE=$(<D) $(filter-out clean, $(MAKECMDGOALS))
|
2014-10-30 22:40:41 +01:00
|
|
|
|
|
|
|
endif
|
2015-01-13 18:29:42 +01:00
|
|
|
|
|
|
|
help:
|
|
|
|
@$(MAKE) -qp | sed -ne 's/\(^[a-z][a-z_-]*\):.*/\1/p' | sort | uniq
|
2015-07-18 10:54:43 +02:00
|
|
|
|
2015-08-19 20:59:06 +02:00
|
|
|
ifneq (,$(filter iotlab-m3 wsn430-v1_3b wsn430-v1_4,$(BOARD)))
|
2015-11-28 20:43:03 +01:00
|
|
|
ifneq (,$(filter iotlab-%,$(MAKECMDGOALS)))
|
|
|
|
include $(RIOTBASE)/dist/testbed-support/Makefile.iotlab
|
|
|
|
endif
|
2015-07-18 10:54:43 +02:00
|
|
|
endif
|
2016-03-10 15:21:09 +01:00
|
|
|
|
|
|
|
# Include desvirt Makefile
|
|
|
|
include $(RIOTBASE)/dist/tools/desvirt/Makefile.desvirt
|
2015-01-27 17:25:16 +01:00
|
|
|
|
|
|
|
# include bindist target
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/bindist.inc.mk
|
2016-03-17 13:05:15 +01:00
|
|
|
|
2016-07-12 07:43:58 +02:00
|
|
|
# Add all USEMODULE modules to CFLAGS
|
2016-01-27 10:47:12 +01:00
|
|
|
include $(RIOTMAKE)/modules.inc.mk
|
2016-07-12 07:43:58 +02:00
|
|
|
|
2016-03-17 13:05:15 +01:00
|
|
|
# Build a header file with all common macro definitions and undefinitions
|
|
|
|
# make it phony to force 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.
|
|
|
|
.PHONY: $(RIOTBUILD_CONFIG_HEADER_C)
|
|
|
|
$(RIOTBUILD_CONFIG_HEADER_C):
|
|
|
|
@mkdir -p '$(dir $@)'
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)'$(RIOTBASE)/dist/tools/genconfigheader/genconfigheader.sh' '$@' $(CFLAGS_WITH_MACROS)
|
2016-03-17 13:05:15 +01:00
|
|
|
|
2016-09-23 08:57:07 +02:00
|
|
|
CFLAGS_WITH_MACROS := $(CFLAGS)
|
|
|
|
|
2016-03-17 13:05:15 +01:00
|
|
|
ifneq (,$(RIOT_VERSION_OVERRIDE))
|
2016-09-23 08:57:07 +02:00
|
|
|
export CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION_OVERRIDE)\"
|
2016-03-17 13:05:15 +01:00
|
|
|
else
|
2016-09-23 08:57:07 +02:00
|
|
|
export CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION)\"
|
2016-03-17 13:05:15 +01:00
|
|
|
endif
|
2016-07-27 09:23:39 +02:00
|
|
|
|
|
|
|
CFLAGS := $(patsubst -D%,,$(CFLAGS))
|
|
|
|
CFLAGS := $(patsubst -U%,,$(CFLAGS))
|
|
|
|
CFLAGS += -include '$(RIOTBUILD_CONFIG_HEADER_C)'
|
2017-06-09 17:54:12 +02:00
|
|
|
|
2017-11-07 12:27:13 +01:00
|
|
|
# include mcuboot support
|
|
|
|
include $(RIOTMAKE)/mcuboot.mk
|
2018-03-28 16:49:30 +02:00
|
|
|
|
2018-03-19 11:31:52 +01:00
|
|
|
# include Murdock helpers
|
|
|
|
include $(RIOTMAKE)/murdock.inc.mk
|
|
|
|
|
2018-03-28 16:49:30 +02:00
|
|
|
# Sanity check, 'all' should be the default goal
|
|
|
|
ifneq (all, $(.DEFAULT_GOAL))
|
|
|
|
$(error .DEFAULT_GOAL := $(.DEFAULT_GOAL))
|
|
|
|
endif
|
2018-03-19 11:31:52 +01:00
|
|
|
|
2017-09-09 00:06:29 +02:00
|
|
|
endif # BOARD=none
|