2018-12-05 19:45:55 +01:00
MATCH_MAKE_VERSION = 4.%
2020-02-18 12:07:32 +01:00
MAKEFLAGS += --no-builtin-rules
2018-12-05 19:45:55 +01:00
i f e q ( , $( filter $ ( MATCH_MAKE_VERSION ) ,$ ( MAKE_VERSION ) ) )
2020-01-28 10:34:48 +01:00
$( error GNU Make $( MAKE_VERSION) is not supported by RIOT since release \
2020.01. Please upgrade your system to use GNU Make \
$( MATCH_MAKE_VERSION) or later.)
2018-12-05 19:45:55 +01:00
e n d i f
2021-03-16 11:21:07 +01:00
#
# enable second expansion of prerequisites.
#
# Doing that here enables it globally for all applications.
#
# See https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
# for what it can be used for.
.SECONDEXPANSION :
2020-04-25 19:10:00 +02:00
# Will evaluate to the absolute path of the Makefile it's evaluated in.¹
#
2020-04-28 15:45:27 +02:00
# This variable MUST be immediately evaluated (tmp_var := $(LAST_MAKEFILEDIR))
2020-04-25 19:10:00 +02:00
# unless it is used directly.
#
# [1] Note that this will in fact return the path of the last Makefile that
# was included, so it must be evaluated before any subsequent includes.
2020-04-28 15:45:27 +02:00
LAST_MAKEFILEDIR = $( abspath $( dir $( lastword $( MAKEFILE_LIST) ) ) )
2020-04-09 15:17:41 +02:00
2018-10-29 11:47:16 +01:00
# 'Makefile.include' directory, must be evaluated before other 'include'
2020-04-28 15:45:27 +02:00
_riotbase := $( LAST_MAKEFILEDIR)
2018-10-29 11:47:16 +01:00
2018-10-26 15:04:32 +02:00
# include RIOT_MAKEFILES_GLOBAL_PRE configuration files
# allows setting user specific system wide configuration parsed before the body
# of $(RIOTBASE)/Makefile.include
i n c l u d e $( RIOT_MAKEFILES_GLOBAL_PRE )
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
- i n c l u d e M a k e f i l e . l o c a l
2013-04-01 00:18:07 +02:00
# set undefined variables
2021-02-26 18:41:51 +01:00
RIOTBASE ?= $( _riotbase)
RIOTCPU ?= $( RIOTBASE) /cpu
2020-04-14 15:23:23 +02:00
# Deprecated to set RIOTBOARD, use EXTERNAL_BOARD_DIRS
2021-02-26 18:41:51 +01:00
RIOTBOARD ?= $( RIOTBASE) /boards
EXTERNAL_BOARD_DIRS ?=
RIOTMAKE ?= $( RIOTBASE) /makefiles
2021-11-03 10:04:54 +01:00
RIOTKCONFIG ?= $( RIOTBASE) /kconfigs
2021-02-26 18:41:51 +01:00
RIOTPKG ?= $( RIOTBASE) /pkg
2022-01-31 11:38:03 +01:00
EXTERNAL_PKG_DIRS ?=
2021-02-26 18:41:51 +01:00
RIOTTOOLS ?= $( RIOTBASE) /dist/tools
RIOTPROJECT ?= $( shell git rev-parse --show-toplevel 2>/dev/null || pwd )
BUILD_DIR ?= $( RIOTBASE) /build
APPDIR ?= $( CURDIR)
BINDIRBASE ?= $( APPDIR) /bin
BINDIR ?= $( BINDIRBASE) /$( BOARD)
2023-05-16 22:16:43 +02:00
PKGDIRBASE ?= $( BUILD_DIR) /pkg
2021-02-26 18:41:51 +01:00
DLCACHE ?= $( RIOTTOOLS) /dlcache/dlcache.sh
DLCACHE_DIR ?= $( RIOTBASE) /.dlcache
2021-09-26 15:57:56 +02:00
RIOT_VERSION_DUMMY_CODE ?= RIOT_VERSION_NUM\( 2042,5,23,0\)
2016-04-01 01:01:59 +02:00
2019-10-09 15:35:41 +02:00
# include CI info such as BOARD_INSUFFICIENT_MEMORY, if existing
- i n c l u d e M a k e f i l e . c i
2016-01-27 10:47:12 +01:00
__DIRECTORY_VARIABLES := \
RIOTBASE \
RIOTCPU \
RIOTMAKE \
RIOTPKG \
2018-02-02 10:43:28 +01:00
RIOTTOOLS \
2016-01-27 10:47:12 +01:00
RIOTPROJECT \
APPDIR \
2018-09-25 17:51:18 +02:00
BUILD_DIR \
2016-01-27 10:47:12 +01:00
BINDIRBASE \
BINDIR \
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
2019-09-09 16:51:16 +02:00
# In GNU make command line is supposed to override the value set in makefile
# These variables can be overridden even when set from command line
__OVERRIDE_DIRECTORY_VARIABLES := $( __DIRECTORY_VARIABLES)
# Use absolute paths in recursive "make" even if overridden on command line.
MAKEOVERRIDES += $( foreach v,$( __OVERRIDE_DIRECTORY_VARIABLES) ,$( v) = $( $( v) ) )
2021-02-26 18:41:51 +01:00
# Setting EXTERNAL_BOARD_DIRS and EXTERNAL_MODULE_DIRS as command line argument
# is too messy to handle: Even when every path in EXTERNAL_BOARD_DIRS is turned
# into an absolute path using override, sub-makes will still get the original
# value. Using MAKEOVERRIDES has issues with spaces in the values, which are
# used as separator in EXTERNAL_BOARD_DIRS. So we just enforce setting the value
2020-04-14 15:23:23 +02:00
# either in a Makefile, or as environment variable.
2021-02-26 18:41:51 +01:00
i f e q ( $( INSIDE_DOCKER ) , 0 )
2020-04-14 15:23:23 +02:00
# In Docker absolute paths are always given, so only fail when not in docker
2021-02-26 18:41:51 +01:00
ifeq ( $( origin EXTERNAL_BOARD_DIRS) ,command line)
2020-04-14 15:23:23 +02:00
$( error EXTERNAL_BOARD_DIRS must be passed as environment variable, and not as command line argument)
endif
2021-02-26 18:41:51 +01:00
ifeq ( $( origin EXTERNAL_MODULE_DIRS) ,command line)
$( error EXTERNAL_MODULE_DIRS must be passed as environment variable, and not as command line argument)
endif
2022-01-31 11:38:03 +01:00
ifeq ( $( origin EXTERNAL_PKG_DIRS) ,command line)
$( error EXTERNAL_PKG_DIRS must be passed as environment variable, and not as command line argument)
endif
2020-04-14 15:23:23 +02:00
e n d i f
2019-09-09 17:29:06 +02:00
# Deprecation of configuring 'RIOTBOARD'
i f n e q ( $( abspath $ ( RIOTBASE ) /boards ) , $( abspath $ ( RIOTBOARD ) ) )
2020-04-14 15:23:23 +02:00
$( warning overriding RIOTBOARD for external boards is deprecated, use EXTERNAL_BOARD_DIRS instead)
2019-09-09 17:29:06 +02:00
override RIOTBOARD := $( abspath $( RIOTBOARD) )
__DIRECTORY_VARIABLES += RIOTBOARD
e n d i f
2021-02-26 18:41:51 +01:00
# Only warn users, not the CI.
i f n e q ( $( RIOT_CI_BUILD ) , 1 )
# Do not warn when set from sub-make
ifeq ( $( MAKELEVEL) ,0)
ifneq ( ,$( BOARDSDIR) )
2020-05-20 16:25:06 +02:00
$( warning Using BOARDSDIR is deprecated use EXTERNAL_BOARD_DIRS instead)
endif
2020-04-14 15:23:23 +02:00
endif
2021-02-26 18:41:51 +01:00
e n d i f
# Needed for backward compatibility:
i f n e q ( , $( BOARDSDIR ) )
2020-04-14 15:23:23 +02:00
EXTERNAL_BOARD_DIRS += $( BOARDSDIR)
e n d i f
2019-09-09 16:55:55 +02:00
2020-04-14 15:23:23 +02:00
# Make all paths absolute.
override RIOTBASE : = $( abspath $ ( RIOTBASE ) )
override RIOTCPU : = $( abspath $ ( RIOTCPU ) )
override RIOTMAKE : = $( abspath $ ( RIOTMAKE ) )
override RIOTPKG : = $( abspath $ ( RIOTPKG ) )
override RIOTTOOLS : = $( abspath $ ( RIOTTOOLS ) )
override RIOTPROJECT : = $( abspath $ ( RIOTPROJECT ) )
override APPDIR : = $( abspath $ ( APPDIR ) )
override BUILD_DIR : = $( abspath $ ( BUILD_DIR ) )
override BINDIRBASE : = $( abspath $ ( BINDIRBASE ) )
override BINDIR : = $( abspath $ ( BINDIR ) )
override PKGDIRBASE : = $( abspath $ ( PKGDIRBASE ) )
override DLCACHE_DIR : = $( abspath $ ( DLCACHE_DIR ) )
EXTERNAL_BOARD_DIRS := $( foreach dir,\
$( EXTERNAL_BOARD_DIRS) ,\
$( abspath $( dir) ) )
2021-02-26 18:41:51 +01:00
EXTERNAL_MODULE_DIRS := $( foreach dir,\
$( EXTERNAL_MODULE_DIRS) ,\
$( abspath $( dir) ) )
2022-01-31 11:38:03 +01:00
EXTERNAL_PKG_DIRS := $( foreach dir,\
$( EXTERNAL_PKG_DIRS) ,\
$( abspath $( dir) ) )
2019-09-09 16:55:55 +02:00
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
i f n e q ( , $( 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!)
e n d i f
2016-03-05 00:53:05 +01:00
2016-04-05 15:27:34 +02:00
# Path to the current directory relative to RIOTPROJECT
2018-07-27 21:01:55 +02:00
# trailing '/' is important when RIOTPROJECT == CURDIR
BUILDRELPATH ?= $( patsubst $( RIOTPROJECT) /%,%,$( CURDIR) /)
2016-03-20 12:40:20 +01:00
2019-07-12 12:34:42 +02:00
# Set CLEAN to "clean" if that target was requested.
# Allows recipes to be run after cleaning, without triggering it implicitly:
#
# all: | $(CLEAN)
#
CLEAN = $( filter clean, $( MAKECMDGOALS) )
2019-06-07 18:17:26 +02:00
# include makefiles utils tools
i n c l u d e $( RIOTMAKE ) / u t i l s / v a r i a b l e s . m k
2019-08-29 13:42:52 +02:00
i n c l u d e $( RIOTMAKE ) / u t i l s / s t r i n g s . m k
2019-06-07 18:17:26 +02:00
2021-11-24 14:51:30 +01:00
# include nimble makefile tools
i n c l u d e $( RIOTMAKE ) / p k g / n i m b l e . a d v . m k
2019-10-17 11:04:31 +02:00
# UNAME is always needed so use simple variable expansion so only evaluated once
2019-10-18 08:07:37 +02:00
UNAME := $( shell uname -m -s)
2019-10-17 11:04:31 +02:00
OS = $( word 1, $( UNAME) )
OS_ARCH = $( word 2, $( UNAME) )
2017-09-09 00:06:29 +02:00
2018-08-10 11:32:38 +02:00
# set python path, e.g. for tests
PYTHONPATH := $( RIOTBASE) /dist/pythonlibs/:$( PYTHONPATH)
2018-11-06 18:59:15 +01:00
# Basic utilities included before anything else
i n c l u d e $( RIOTMAKE ) / u t i l s / c h e c k s . m k
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
i n c l u d e $( RIOTMAKE ) / d o c k e r . i n c . m k
2015-05-06 13:54:57 +02:00
2017-09-09 00:06:29 +02:00
# include color echo macros
2019-08-30 15:02:16 +02:00
i n c l u d e $( RIOTMAKE ) / u t i l s / a n s i . m k
2017-09-09 00:06:29 +02:00
i n c l u d e $( RIOTMAKE ) / c o l o r . i n c . m k
2015-07-21 11:32:47 +02:00
2017-09-20 12:04:36 +02:00
# include concurrency helpers
i n c l u d e $( RIOTMAKE ) / i n f o - n p r o c . i n c . m k
2019-05-27 20:59:19 +02:00
# List of boards variables
i n c l u d e $( RIOTMAKE ) / b o a r d s . i n c . m k
2019-08-13 16:02:38 +02:00
# Debug targets for build system migration
i n c l u d e $( RIOTMAKE ) / d e p e n d e n c i e s _ d e b u g . i n c . m k
2021-01-21 18:30:48 +01:00
# Use TOOLCHAIN environment variable to select the toolchain to use.
2024-02-02 15:41:31 +01:00
i f n e q ( , $( filter native native 64,$ ( BOARD ) ) )
2021-01-21 18:30:48 +01:00
ifeq ( $( OS) ,Darwin)
2022-10-13 15:48:26 +02:00
$( shell $( COLOR_ECHO) " $( COLOR_RED) " Buildin on macOS is not supported." \
" We recommend vagrant for building: $( COLOR_RESET) " \
" https://github.com/RIOT-OS/RIOT/blob/master/dist/tools/vagrant/README.md 1>&2)
2021-01-21 18:30:48 +01:00
endif
e n d i f
# Use override so that we can redefine a variable set on the command line (as
# opposed to one set in the environment)
i f e q ( c l a n g , $( TOOLCHAIN ) )
# TOOLCHAIN = clang is an alias for TOOLCHAIN = llvm
override TOOLCHAIN := llvm
e n d i f
i f e q ( g c c , $( TOOLCHAIN ) )
# TOOLCHAIN = gcc is an alias for TOOLCHAIN = gnu
override TOOLCHAIN := gnu
e n d i f
i f e q ( , $( TOOLCHAIN ) )
override TOOLCHAIN := gnu
e n d i f
2021-04-02 19:01:19 +02:00
i n c l u d e $( RIOTMAKE ) / c a r g o - s e t t i n g s . i n c . m k
2020-05-25 09:38:27 +02:00
GLOBAL_GOALS += buildtest \
buildtest-indocker \
info-boards-features-blacklisted \
2020-08-13 09:14:49 +02:00
info-boards-features-conflicting \
2020-05-25 09:38:27 +02:00
info-boards-features-missing \
info-boards-supported \
info-buildsizes info-buildsizes-diff \
2023-02-04 11:52:15 +01:00
generate-Makefile.ci \
2020-05-25 09:38:27 +02:00
#
2017-09-09 00:06:29 +02:00
i f n e q ( , $( filter $ ( GLOBAL_GOALS ) , $ ( MAKECMDGOALS ) ) )
include $( RIOTMAKE) /info-global.inc.mk
include $( RIOTMAKE) /buildtests.inc.mk
e l s e
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
2020-04-14 15:23:23 +02:00
# Folders to search: First the external boards, than the official
BOARDSDIRS := $( EXTERNAL_BOARD_DIRS) $( RIOTBOARD)
# Take the first folder in $(BOARDSDIRS) that contains a folder named $(BOARD)
BOARDDIR := $( word 1,$( foreach dir,$( BOARDSDIRS) ,$( wildcard $( dir) /$( BOARD) /.) ) )
# Sanitize folder
BOARDDIR := $( abspath $( BOARDDIR) )
# Also provide BOARDSDIR for compatibility and for accessing common folders
# (e.g. include $(BOARDSDIR)/common/external_common/Makefile.dep)
BOARDSDIR := $( dir $( BOARDDIR) )
i f e q ( , $( BOARDDIR ) )
$( info Folders searched for the board: $( BOARDSDIRS) )
$( error The specified board $( BOARD) does not exist.)
2019-12-14 23:16:01 +01:00
e n d i f
2017-09-09 00:06:29 +02:00
i n c l u d e $( RIOTMAKE ) / i n f o . i n c . m k
# Static code analysis tools provided by LLVM
i n c l u d e $( RIOTMAKE ) / s c a n - b u i l d . i n c . m k
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
i f e q ( $( OS ) , D a r w i n )
OPEN := open
e l s e
OPEN := xdg-open
e n d i f
2016-09-06 14:59:48 +02:00
QUIET ?= 1
2021-05-31 09:45:46 +02:00
QUIETER ?= 0
2016-09-06 14:59:48 +02:00
2014-01-05 11:33:34 +01:00
i f e q ( $( 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
e l s e
2016-12-17 01:16:07 +01:00
Q =
2015-07-21 07:05:14 +02:00
e n d i f
2021-09-23 15:37:02 +02:00
# Set this to 1 to enable pretty-printing the assert location in addition
# to the address of the failing assert.
# This saves you to resolve the address manually with addr2line at the cost
# of greater ROM consumption.
VERBOSE_ASSERT ?= 0
i f e q ( $( VERBOSE_ASSERT ) , 1 )
CFLAGS += -DDEBUG_ASSERT_VERBOSE
DEVELHELP := 1
e n d i f
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
i f e q ( $( DEVELHELP ) , 1 )
CFLAGS += -DDEVELHELP
e n d i f
2019-11-24 16:19:48 +01:00
# Set this to 1 to enable thread names
THREAD_NAMES ?= 0
i f e q ( $( THREAD_NAMES ) , 1 )
CFLAGS += -DCONFIG_THREAD_NAMES
e n d i f
2019-05-28 10:43:17 +02:00
# Override LOG_LEVEL if variable is set and if CFLAGS doesn't already contain
# a LOG_LEVEL config
i f d e f L O G _ L E V E L
2019-11-27 12:50:47 +01:00
ifeq ( ,$( filter -DLOG_LEVEL= %,$( CFLAGS) ) )
2019-05-28 10:43:17 +02:00
CFLAGS += -DLOG_LEVEL= $( LOG_LEVEL)
endif
e n d i f
2015-07-21 07:05:14 +02:00
# Fail on warnings. Can be overridden by `make WERROR=0`.
WERROR ?= 1
i f e q ( $( WERROR ) , 1 )
2018-06-14 23:32:04 +02:00
CFLAGS += -Werror
2017-10-31 11:51:37 +01:00
e n d i f
WPEDANTIC ?= 0
i f e q ( $( WPEDANTIC ) , 1 )
2018-06-14 23:32:04 +02:00
CFLAGS += -Wpedantic
2014-01-05 11:33:34 +01:00
e n d i f
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
i f e q ( , $( and $ ( DOWNLOAD_TO_STDOUT ) ,$ ( DOWNLOAD_TO_FILE ) ) )
ifeq ( ,$( WGET) )
2021-09-03 11:27:03 +02:00
ifeq ( 0,$( shell which wget > /dev/null 2>& 1 ; echo $$ ?) )
WGET = $( call memoized,WGET,$( shell which wget) )
2014-11-03 17:04:26 +01:00
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) )
2021-09-03 11:27:03 +02:00
ifeq ( 0,$( shell which curl > /dev/null 2>& 1 ; echo $$ ?) )
CURL = $( call memoized,CURL,$( shell which curl) )
2014-11-03 17:04:26 +01:00
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) )
2021-08-28 11:31:48 +02:00
$( warning 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) )
2021-08-28 11:31:48 +02:00
DOWNLOAD_TO_STDOUT ?= $( if $( CURL) ,$( CURL) -s,$( WGET) -q -O-)
2014-11-03 17:04:26 +01:00
endif
ifeq ( ,$( DOWNLOAD_TO_FILE) )
2021-08-28 11:31:48 +02:00
DOWNLOAD_TO_FILE ?= $( if $( WGET) ,$( WGET) -nv -c -O,$( CURL) -s -o)
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
e n d i f
i f e q ( , $( UNZIP_HERE ) )
2021-09-03 11:27:03 +02:00
ifeq ( 0,$( shell which unzip > /dev/null 2>& 1 ; echo $$ ?) )
UNZIP_HERE = $( call memoized,UNZIP_HERE,$( shell which unzip) -q)
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
else
2021-09-03 11:27:03 +02:00
ifeq ( 0,$( shell which 7z > /dev/null 2>& 1 ; echo $$ ?) )
UNZIP_HERE = $( call memoized,UNZIP_HERE,$( shell which 7z) x -bd)
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
else
2021-08-28 11:31:48 +02:00
$( warning Neither unzip nor 7z 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
endif
e n d i f
2018-08-07 16:13:17 +02:00
# Tool saving stdin to a file only on content update.
# It keeps the file timestamp if it would end up the same.
LAZYSPONGE ?= $( RIOTTOOLS) /lazysponge/lazysponge.py
LAZYSPONGE_FLAGS ?= $( if $( filter 1,$( QUIET) ) ,,--verbose)
2018-03-22 16:20:19 +01:00
i f e q ( , $( APPLICATION ) )
2016-03-08 21:07:44 +01:00
$( error An application name must be specified as APPLICATION.)
e n d i f
2015-02-22 21:11:30 +01:00
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) -)
2019-09-27 17:08:03 +02:00
# set default PROGRAMMER value if flashing a board on IoT-LAB
# This must be done before parsing the Makefile.include of the board and cannot
# be done in makefile.iotlab.single.inc.mk which is included after.
i f n e q ( , $( IOTLAB_NODE ) )
PROGRAMMER ?= iotlab
2020-07-10 16:09:25 +02:00
# iotlab uses ELFFILE by default for flashing boards.
FLASHFILE ?= $( ELFFILE)
2022-01-27 14:56:00 +01:00
# Disable IOTLAB_NODE if inside Docker to avoid including the
# iotlab.single.inc.mk file which is useless there: it's only useful for
# flashing and this is done outside of Docker.
ifeq ( 1,$( INSIDE_DOCKER) )
IOTLAB_NODE :=
endif
2019-09-27 17:08:03 +02:00
e n d i f
2016-07-12 07:43:58 +02:00
# Add standard include directories
2020-10-22 13:37:31 +02:00
INCLUDES += -I$( RIOTBASE) /core/lib/include
INCLUDES += -I$( RIOTBASE) /core/include
INCLUDES += -I$( RIOTBASE) /drivers/include
INCLUDES += -I$( RIOTBASE) /sys/include
2016-07-12 07:43:58 +02:00
2017-09-09 15:28:01 +02:00
# process provided features
2019-05-02 16:47:08 +02:00
i n c l u d e $( RIOTBASE ) / M a k e f i l e . f e a t u r e s
2017-09-09 15:28:01 +02:00
2021-12-01 10:35:53 +01:00
i f n e q ( $( RIOT_CI_BUILD ) , 1 )
# Warn about used deprecated boards
include $( RIOTMAKE) /deprecated_boards.inc.mk
include $( RIOTMAKE) /deprecated_cpus.inc.mk
e n d i f
2013-04-01 00:18:07 +02:00
# mandatory includes!
2016-01-27 10:47:12 +01:00
i n c l u d e $( RIOTMAKE ) / p s e u d o m o d u l e s . i n c . m k
2022-02-15 13:33:37 +01:00
i n c l u d e $( RIOTMAKE ) / d e f a u l t m o d u l e s _ r e g u l a r . i n c . m k
2018-03-01 16:19:34 +01:00
2020-07-27 18:16:11 +02:00
# Include Kconfig functionalities
i n c l u d e $( RIOTMAKE ) / k c o n f i g . m k
2024-03-26 10:32:53 +01:00
# always select provided architecture features
FEATURES_REQUIRED += $( filter arch_%,$( FEATURES_PROVIDED) )
# always select CPU core features
FEATURES_REQUIRED += $( filter cpu_core_%,$( FEATURES_PROVIDED) )
2022-01-22 21:48:28 +01:00
2024-03-26 10:32:53 +01:00
# check if required features are provided and update $(FEATURES_USED)
i n c l u d e $( RIOTMAKE ) / f e a t u r e s _ c h e c k . i n c . m k
2022-02-01 10:22:13 +01:00
2024-03-26 10:32:53 +01:00
# handle removal of default modules
USEMODULE += $( filter-out $( DISABLE_MODULE) , $( DEFAULT_MODULE) )
2021-11-15 09:40:01 +01:00
2024-03-26 10:32:53 +01:00
# avoid recursive expansion
USEMODULE := $( sort $( USEMODULE) )
2020-09-11 17:10:42 +02:00
2024-03-26 10:32:53 +01:00
# process dependencies
i n c l u d e $( RIOTMAKE ) / d e p e n d e n c y _ r e s o l u t i o n . i n c . m k
2020-06-23 17:26:33 +02:00
2022-11-26 18:47:59 +01:00
# Include dfu-util configuration when using riotboot_dfu bootloader before
# including the board's Makefile.include which could define dfu-util
# configuration for other DFU bootloaders in use.
i n c l u d e $( RIOTMAKE ) / b o o t / r i o t b o o t _ d f u - u t i l . m k
2018-03-01 16:19:34 +01:00
# Include Board and CPU configuration
2020-04-14 15:23:23 +02:00
INCLUDES += $( addprefix -I,$( wildcard $( BOARDDIR) /include) )
i n c l u d e $( BOARDDIR ) / M a k e f i l e . i n c l u d e
2018-03-01 16:19:34 +01:00
INCLUDES += -I$( RIOTCPU) /$( CPU) /include
2013-12-22 20:02:59 +01:00
i n c l u d e $( RIOTCPU ) / $( CPU ) / M a k e f i l e . i n c l u d e
2015-07-19 12:16:34 +02:00
2020-12-08 13:15:03 +01:00
# Include common serial logic to define TERMPROG, TERMFLAGS variables based on
# the content of RIOT_TERMINAL
i n c l u d e $( RIOTMAKE ) / t o o l s / s e r i a l . i n c . m k
2020-11-26 14:43:20 +01:00
# Include emulator code when required and if available
i f e q ( 1 , $( EMULATE ) )
2020-11-20 14:21:55 +01:00
# Use renode as default emulator
RIOT_EMULATOR ?= renode
-include $( RIOTMAKE) /tools/$( RIOT_EMULATOR) .inc.mk
2020-11-26 14:43:20 +01:00
TERMDEPS += $( EMULATORDEPS)
DEBUGDEPS += $( EMULATORDEPS)
2020-11-20 14:21:55 +01:00
e n d i f
2020-11-19 18:07:33 +01:00
# Include common programmer logic if available
- i n c l u d e $( RIOTMAKE ) / t o o l s / $( PROGRAMMER ) . i n c . m k
2021-02-11 12:12:37 +01:00
# Check if programmer is supported by the board, only if PROGRAMMERS_SUPPORTED
# is set and if programmer is not iotlab
2022-08-12 10:28:58 +02:00
i f n e q ( $( RIOT_CI_BUILD ) , 1 )
ifneq ( iotlab,$( PROGRAMMER) )
ifneq ( ,$( PROGRAMMERS_SUPPORTED) )
ifeq ( ,$( filter $( PROGRAMMER) ,$( PROGRAMMERS_SUPPORTED) ) )
2024-02-16 20:07:13 +01:00
$( warning '$(PROGRAMMER)' programmer is not supported by this board. \
2022-08-12 10:28:58 +02:00
Supported programmers: '$(PROGRAMMERS_SUPPORTED)' )
endif
2021-02-11 12:12:37 +01:00
endif
endif
e n d i f
2018-08-07 16:22:49 +02:00
# Assume GCC/GNU as supported toolchain if CPU's Makefile.include doesn't
# provide this macro
TOOLCHAINS_SUPPORTED ?= gnu
2016-12-21 13:03:58 +01:00
# Import all toolchain settings
2016-01-27 10:47:12 +01:00
i n c l u d e $( RIOTMAKE ) / t o o l c h a i n / $( TOOLCHAIN ) . i n c . m k
2016-12-21 13:03:58 +01:00
2024-02-12 20:55:58 +01:00
# Other than on native, RWX segments in ROM are not actually RWX, as regular
# store instructions won't write to flash.
i f e q ( , $( filter native native 64,$ ( BOARD ) ) )
LINKER_SUPPORTS_NOWARNRWX ?= $( shell LC_ALL = C $( LINK) $( RIOTTOOLS) /testprogs/minimal_linkable.c -o /dev/null -lc -Wall -Wextra -pedantic -Wl,--no-warn-rwx-segments 2> /dev/null && echo 1 || echo 0)
ifeq ( 1,$( LINKER_SUPPORTS_NOWARNRWX) )
LINKFLAGS += -Wl,--no-warn-rwx-segments
endif
e n d i f
2018-05-04 09:41:53 +02:00
# Append ldscript path after importing CPU and board makefiles to allow
# overriding the core ldscripts
LINKFLAGS += -L$( RIOTBASE) /core/ldscripts
2019-01-16 14:45:46 +01:00
# include undefined behaviour sanitizer (UBSAN) support
i n c l u d e $( RIOTMAKE ) / u b s a n . i n c . m k
2018-08-12 00:26:52 +02:00
# Tell ccache to pass the original file to the compiler, instead of passing the
# preprocessed code. Without this setting, the compilation will fail with
# -Wimplicit-fallthrough warnings even when the fall through case is properly
# commented because the preprocessor has stripped the comments from the code.
# This also fixes some other false warnings when compiling with LLVM/Clang.
# The environment variable only affects builds with ccache (e.g. on CI/Murdock).
# Non cached builds are not affected in any way.
# For more information, see http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
export CCACHE_CPP2 = yes
2016-12-17 00:17:26 +01:00
# set some settings useful for continuous integration builds
i f e q ( $( RIOT_CI_BUILD ) , 1 )
2019-07-01 18:57:41 +02:00
RIOT_VERSION ?= buildtest
2021-08-21 13:39:17 +02:00
# set a dummy version number
2021-09-26 15:57:56 +02:00
RIOT_VERSION_CODE ?= $( RIOT_VERSION_DUMMY_CODE)
2016-12-17 00:17:26 +01:00
ifneq ( $( filter $( BOARD_INSUFFICIENT_MEMORY) , $( BOARD) ) ,)
RIOTNOLINK:= 1
endif
2016-12-22 12:18:38 +01:00
# be more quiet when building for CI
2021-05-31 09:45:46 +02:00
QUIETER = 1
e n d i f
i f e q ( $( QUIETER ) , 1 )
QQ = @
e l s e
QQ =
2016-12-17 00:17:26 +01:00
e n d i f
2014-08-01 02:33:22 +02:00
# if you want to publish the board into the sources as an uppercase #define
2019-08-29 14:21:21 +02:00
BOARDDEF = $( call uppercase_and_underscore,$( BOARD) )
CPUDEF = $( call uppercase_and_underscore,$( CPU) )
2019-03-05 14:00:41 +01:00
CFLAGS += -DRIOT_APPLICATION= \" $( APPLICATION) \"
2014-12-19 17:30:51 +01:00
CFLAGS += -DBOARD_$( BOARDDEF) = \" $( BOARD) \" -DRIOT_BOARD= BOARD_$( BOARDDEF)
CFLAGS += -DCPU_$( CPUDEF) = \" $( CPU) \" -DRIOT_CPU= CPU_$( CPUDEF)
2014-08-01 02:33:22 +02:00
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
i n c l u d e $( RIOTMAKE ) / c f l a g s . i n c . m k
2014-02-17 07:04:36 +01:00
2018-08-10 16:15:56 +02:00
# Include VERSION for releases
- i n c l u d e $( RIOTBASE ) / V E R S I O N
2021-08-21 13:39:17 +02:00
- i n c l u d e $( RIOTBASE ) / E X T R A V E R S I O N
2018-08-10 16:15:56 +02:00
2019-07-22 12:01:18 +02:00
i n c l u d e $( RIOTMAKE ) / g i t _ v e r s i o n . i n c . m k
RIOT_VERSION ?= $( or $( GIT_VERSION) ,'UNKNOWN (builddir: $(RIOTBASE))' )
2021-08-21 13:39:17 +02:00
RIOT_EXTRAVERSION ?= 0
2015-05-19 18:29:04 +02:00
2019-07-01 18:57:41 +02:00
# Deprecate using RIOT_VERSION_OVERRIDE but currently keep the behavior
i f n e q ( , $( RIOT_VERSION_OVERRIDE ) )
$( warning 'RIOT_VERSION_OVERRIDE' is deprecated, it can now be set with 'RIOT_VERSION' directly.)
RIOT_VERSION = $( RIOT_VERSION_OVERRIDE)
e n d i f
2021-08-21 13:39:17 +02:00
# Generate machine readable RIOT VERSION macro
2021-09-26 15:57:56 +02:00
RIOT_VERSION_CODE ?= $( shell echo $( RIOT_VERSION) | \
sed -E 's/([0-9]+)\.([0-9]+)\.?([0-9]+)?.*/RIOT_VERSION_NUM\\\(\1,\2,0\3,$(RIOT_EXTRAVERSION)\\\)/' | \
grep RIOT_VERSION_NUM || echo " $( RIOT_VERSION_DUMMY_CODE) " )
2021-08-21 13:39:17 +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
2020-08-10 14:45:39 +02:00
BASELIBS += $( APPLICATION_MODULE) .module
2016-02-26 15:02:02 +01:00
BASELIBS += $( APPDEPS)
2013-03-10 16:51:40 +01:00
2018-06-18 17:52:48 +02:00
2018-06-20 19:08:19 +02:00
# add extra include paths for packages in $(USEMODULE)
2020-01-10 14:07:04 +01:00
USEMODULE_INCLUDES =
2018-06-20 19:08:19 +02:00
i n c l u d e $( RIOTBASE ) / s y s / M a k e f i l e . i n c l u d e
2021-10-18 22:12:41 +02:00
# add default board_init()
DIRS += $( RIOTBASE) /boards/common/init
2020-06-25 22:38:19 +02:00
# include Makefile.includes of each driver modules if they exist
-include $(USEMODULE : %=$( RIOTBASE ) /drivers /%/Makefile .include )
2022-01-22 21:48:28 +01:00
# include Makefile.includes for packages in $(PKG_PATHS)
-include $(PKG_PATHS : %=%Makefile .include )
2018-06-20 19:08:19 +02:00
2018-04-19 16:05:43 +02:00
# include external modules configuration
2022-02-01 11:22:06 +01:00
-include $(EXTERNAL_MODULE_PATHS : %=%Makefile .include )
2018-04-19 16:05:43 +02:00
2018-07-03 11:36:41 +02:00
# Deduplicate includes without sorting them
# see https://stackoverflow.com/questions/16144115/makefile-remove-duplicate-words-without-sorting
2018-07-10 15:35:28 +02:00
d e f i n e u n i q
2018-07-03 11:36:41 +02:00
$( eval seen := )
$( foreach _,$1 ,$( if $( filter $_ ,$( seen) ) ,,$( eval seen += $_ ) ) )
$( seen)
e n d e f
USEMODULE_INCLUDES_ = $( strip $( call uniq,$( USEMODULE_INCLUDES) ) )
2018-06-20 19:08:19 +02:00
INCLUDES += $( USEMODULE_INCLUDES_:%= -I%)
2018-06-18 17:52:48 +02:00
# include bindist target
i n c l u d e $( RIOTMAKE ) / b i n d i s t . i n c . m k
# Add all USEMODULE modules to CFLAGS and populate BASELIBS
i n c l u d e $( RIOTMAKE ) / m o d u l e s . i n c . m k
2019-06-28 13:12:20 +02:00
.PHONY : all link clean flash flash -only termdeps term doc debug debug -server reset objdump help info -modules
2023-06-17 11:48:01 +02:00
.PHONY : print -size elffile lstfile binfile hexfile flashfile cosy
2015-02-05 10:03:05 +01:00
.PHONY : ..in -docker -container
2018-07-23 17:03:07 +02:00
# 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
2018-03-26 13:54:25 +02:00
.PHONY : FORCE
2013-08-08 15:44:44 +02:00
2019-10-08 14:11:40 +02:00
i f n e q ( , $( IOTLAB_NODE ) )
2021-05-27 08:33:03 +02:00
# iot-lab archi mapping
include $( RIOTBASE) /dist/testbed-support/makefile.iotlab.archi.inc.mk
ifneq ( ,$( IOTLAB_ARCHI) )
# iot-lab serial and flasher
include $( RIOTBASE) /dist/testbed-support/makefile.iotlab.single.inc.mk
else
$( info $( COLOR_YELLOW) Board " $( BOARD) " incompatible with IOTLAB_NODE variable$( COLOR_RESET) )
endif
2019-10-08 14:11:40 +02:00
e n d i f
2016-10-18 23:27:59 +02:00
ELFFILE ?= $( BINDIR) /$( APPLICATION) .elf
2014-05-05 21:53:37 +02:00
HEXFILE ?= $( ELFFILE:.elf= .hex)
2018-03-27 11:55:08 +02:00
BINFILE ?= $( ELFFILE:.elf= .bin)
2022-06-16 09:54:44 +02:00
HASHFILE ?= $( BINFILE)
2021-02-24 00:24:17 +01:00
MAPFILE ?= $( ELFFILE:.elf= .map)
2023-06-17 11:48:01 +02:00
LSTFILE ?= $( ELFFILE:.elf= .lst)
2014-05-16 18:18:35 +02:00
2021-07-27 11:42:30 +02:00
i f n e q ( , $( filter suit ,$ ( USEMODULE ) ) )
2020-03-23 10:17:37 +01:00
include $( RIOTMAKE) /suit.base.inc.mk
e n d i f
2020-02-26 14:48:24 +01:00
2019-03-01 16:28:22 +01:00
# include bootloaders support. It should be included early to allow using
# variables defined in `riotboot.mk` for `FLASHFILE` before it is evaluated.
# It should be included after defining 'BINFILE' for 'riotboot.bin' handling.
i n c l u d e $( RIOTMAKE ) / b o o t / r i o t b o o t . m k
2021-07-27 11:42:30 +02:00
# include suit targets
i f n e q ( , $( filter suit ,$ ( USEMODULE ) ) )
include $( RIOTMAKE) /suit.inc.mk
e n d i f
2022-05-31 12:39:16 +02:00
# elf file used for the debugger, must include bootloader offset
DEBUG_ELFFILE ?= $( ELFFILE)
2018-03-27 15:09:57 +02:00
# Targets to get given file
elffile : $( ELFFILE )
hexfile : $( HEXFILE )
binfile : $( BINFILE )
2023-06-17 11:48:01 +02:00
lstfile : $( LSTFILE )
2018-12-19 18:10:57 +01:00
# FLASHFILE is the file used by the flasher
2019-03-01 15:48:02 +01:00
# Usually set to $(ELFFILE), $(HEXFILE) or $(BINFILE) in the board/flasher
# or application specific files
2018-12-19 18:10:57 +01:00
flashfile : $( FLASHFILE )
2018-03-27 15:09:57 +02:00
2019-03-01 15:48:02 +01:00
i f e q ( , $( FLASHFILE ) )
2022-06-16 14:36:16 +02:00
$( error FLASHFILE is not defined for this board: $( BOARD) )
2019-03-01 15:48:02 +01:00
e n d i f
2022-06-16 09:54:44 +02:00
BUILD_FILES += $( ELFFILE) $( BINFILE) $( FLASHFILE) $( HASHFILE)
2019-09-25 10:35:33 +02:00
2015-05-06 13:54:57 +02:00
# variables used to compile and link c++
2021-06-25 11:48:59 +02:00
i f n e q ( , $( filter cpp ,$ ( USEMODULE ) ) )
2020-07-09 21:15:38 +02:00
CPPMIX ?= 1
e n d i f
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,
2021-02-26 18:41:51 +01:00
# Also build external modules
DIRS += $( EXTERNAL_MODULE_PATHS)
2014-10-01 18:19:19 +02:00
2018-04-23 14:19:13 +02:00
# Define dependencies required for building (headers, downloading source files,)
BUILDDEPS += $( RIOTBUILD_CONFIG_HEADER_C)
2018-04-23 14:49:35 +02:00
BUILDDEPS += pkg-prepare
2018-04-23 14:31:27 +02:00
BUILDDEPS += $( APPDEPS)
2020-09-01 17:09:57 +02:00
BUILDDEPS += $( MODULE_LIST_DIR)
2018-04-23 14:19:13 +02:00
2023-01-02 21:16:37 +01:00
# Build dependencies depend on clean (if a make goal), as clean may wipe them.
# Without them depending on clean parallel builds occasionally fail due to
# clean removing dependencies that make previously considered as up to date.
$(BUILDDEPS) : $( CLEAN )
2024-02-06 07:46:38 +01:00
# include makefile snippets for packages in $(PKG_PATHS) that modify GENSRC:
-include $(PKG_PATHS : %=%Makefile .gensrc )
# remove duplicates & make accessible to subprocesses
GENSRC := $( sort $( GENSRC) )
export GENSRC
2018-06-20 18:59:21 +02:00
# Save value to verify it is not modified later
_BASELIBS_VALUE_BEFORE_USAGE := $( BASELIBS)
2018-03-23 16:13:47 +01:00
# Linker rule
2020-08-10 14:45:39 +02:00
# Only use --start-group when archives are defined
ARCHIVES_GROUP = $( if $( ARCHIVES) ,$( LINKFLAGPREFIX) --start-group $( ARCHIVES) -lm $( LINKFLAGPREFIX) --end-group, -lm)
2018-03-26 13:54:25 +02:00
$(ELFFILE) : FORCE
2018-03-23 16:13:47 +01:00
i f e q ( $( BUILDOSXNATIVE ) , 1 )
2020-11-03 09:58:50 +01:00
_LINK = $( if $( CPPMIX) ,$( LINKXX) ,$( LINK) ) $$ ( find $( BASELIBS:%.module= $( BINDIR) /%/) -name "*.o" 2> /dev/null | sort) $( ARCHIVES_GROUP) $( LINKFLAGS) $( LINKFLAGPREFIX) -no_pie
2018-03-23 16:13:47 +01:00
e l s e
2020-11-03 09:58:50 +01:00
_LINK = $( if $( CPPMIX) ,$( LINKXX) ,$( LINK) ) $$ ( find $( BASELIBS:%.module= $( BINDIR) /%/) -name "*.o" 2> /dev/null | sort) $( ARCHIVES_GROUP) $( LINKFLAGS) $( LINKFLAGPREFIX) -Map= $( BINDIR) /$( APPLICATION) .map
2018-03-23 16:13:47 +01:00
e n d i f # BUILDOSXNATIVE
2017-06-09 17:54:12 +02:00
2023-08-09 13:20:05 +02:00
COMPILE_COMMANDS_PATH ?= $( if $( findstring $( RIOTBASE) ,$( APPDIR) ) ,$( RIOTBASE) /compile_commands.json, $( APPDIR) /compile_commands.json)
2023-05-17 22:44:43 +02:00
COMPILE_COMMANDS_FLAGS ?= --clangd
.PHONY : compile -commands
2024-05-31 13:35:04 +02:00
compile-commands : $( COMPILE_COMMANDS_PATH )
%/compile_commands.json : $( BUILDDEPS )
2023-05-17 22:44:43 +02:00
$( Q) DIRS = " $( DIRS) " APPLICATION_BLOBS = " $( BLOBS) " \
2023-10-26 16:32:17 +02:00
APPLICATION_SRC = " $( SRC) " APPLICATION_SRCXX = " $( SRCXX) " APPLICATION_ASMSRC = " $( ASMSRC) " APPLICATION_ASSMSRC = " $( ASSMSRC) " \
2023-05-17 22:44:43 +02:00
" $( MAKE) " -C $( APPDIR) -f $( RIOTMAKE) /application.inc.mk compile-commands
$( Q) $( RIOTTOOLS) /compile_commands/compile_commands.py $( COMPILE_COMMANDS_FLAGS) $( BINDIR) \
2024-05-31 13:35:04 +02:00
> $@
2023-05-17 22:44:43 +02:00
2015-02-05 10:03:05 +01:00
i f e q ( $( BUILD_IN_DOCKER ) , 1 )
2017-06-09 17:54:12 +02:00
link : ..in -docker -container
2015-02-05 10:03:05 +01:00
e l s e
2014-04-22 16:53:16 +02:00
i f e q ( , $( RIOTNOLINK ) )
2020-09-01 17:09:57 +02:00
link : ..compiler -check ..build -message $( BUILD_FILES ) print -size ..module -check
2018-03-26 13:54:25 +02:00
e l s e
2020-09-01 17:09:57 +02:00
link : ..compiler -check ..build -message $( BASELIBS ) $( ARCHIVES ) ..module -check
2018-03-26 13:54:25 +02:00
e n d i f # RIOTNOLINK
2022-12-31 15:29:06 +01:00
$(ELFFILE) : $( BASELIBS ) $( ARCHIVES ) $( LD_SCRIPTS )
2018-03-26 13:54:25 +02:00
$( Q) $( _LINK) -o $@
2020-08-10 14:45:39 +02:00
.PHONY : $( APPLICATION_MODULE ) .module
2020-09-01 17:09:57 +02:00
..module-check : $( BASELIBS )
@[ -z " $( strip $( NON_GENERATED_MODULES) ) " ] || \
( $( COLOR_ECHO) " $( COLOR_RED) Error - using unknown modules: $( COLOR_RESET) $( NON_GENERATED_MODULES) " && false )
2020-08-10 14:45:39 +02:00
$(APPLICATION_MODULE).module : pkg -build $( BUILDDEPS )
2019-07-19 12:20:28 +02:00
$( Q) DIRS = " $( DIRS) " APPLICATION_BLOBS = " $( BLOBS) " \
2023-10-26 16:32:17 +02:00
APPLICATION_SRC = " $( SRC) " APPLICATION_SRCXX = " $( SRCXX) " APPLICATION_ASMSRC = " $( ASMSRC) " APPLICATION_ASSMSRC = " $( ASSMSRC) " \
2019-07-19 12:20:28 +02:00
" $( MAKE) " -C $( APPDIR) -f $( RIOTMAKE) /application.inc.mk
2020-08-10 14:45:39 +02:00
$(APPLICATION_MODULE).module : FORCE
2018-03-26 13:54:25 +02:00
2018-04-10 16:17:19 +02:00
# Other modules are built by application.inc.mk and packages building
2020-08-10 14:45:39 +02:00
_SUBMAKE_LIBS = $( filter-out $( APPLICATION_MODULE) .module $( APPDEPS) , $( BASELIBS) $( ARCHIVES) )
2024-02-06 07:46:38 +01:00
$(_SUBMAKE_LIBS) : $( APPLICATION_MODULE ) .module pkg -build $( GENSRC )
2018-04-10 16:17:19 +02:00
2018-03-26 13:54:25 +02:00
# 'print-size' triggers a rebuild. Use 'info-buildsize' if you do not need to rebuild.
print-size : $( ELFFILE )
2018-04-26 11:18:15 +02:00
$( Q) $( SIZE) $( SIZEFLAGS) $<
2018-03-26 13:54:25 +02:00
2018-03-27 11:55:08 +02:00
%.hex : %.elf
$( Q) $( OBJCOPY) $( OFLAGS) -Oihex $< $@
%.bin : %.elf
$( Q) $( OBJCOPY) $( OFLAGS) -Obinary $< $@
2018-03-26 13:54:25 +02:00
2023-06-17 11:48:01 +02:00
%.lst : %.elf
$( Q) $( OBJDUMP) --disassemble-all --file-headers --file-offsets \
--section-headers --line-numbers --private-headers --source --wide \
--disassemble-zeroes $< > $@
2015-02-05 10:03:05 +01:00
e n d i f # 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'
d e f i n e c h e c k _ c m d
@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; }
e n d e f
2018-10-19 13:27:11 +02:00
# Check if setsid command is available on the system for debug target
# This is not the case on MacOSX, so it must be built on the fly
2020-07-28 18:35:20 +02:00
i f e q ( $( OS ) , D a r w i n )
ifneq ( ,$( filter debug, $( MAKECMDGOALS) ) )
2021-08-24 14:39:04 +02:00
ifneq ( 0,$( shell command -v setsid > /dev/null 2>& 1 ; echo $$ ?) )
2020-07-28 18:35:20 +02:00
SETSID = $( RIOTTOOLS) /setsid/setsid
$( call target-export-variables,debug,$( SETSID) )
DEBUGDEPS += $( SETSID)
endif
2018-10-19 13:27:11 +02:00
endif
e n d i f
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
2020-10-09 18:01:33 +02:00
..build-message : $( if $ ( SHOULD_RUN_KCONFIG ) , check -kconfig -errors )
2024-02-16 20:38:25 +01:00
@$( COLOR_ECHO) '$(COLOR_GREEN)Building application "$(APPLICATION)" for "$(BOARD)" with CPU "$(CPU)".$(COLOR_RESET)'
2014-10-30 22:40:41 +01:00
@$( COLOR_ECHO)
2013-04-22 00:55:11 +02:00
2014-05-16 19:09:22 +02:00
# The `clean` needs to be serialized before everything else.
2024-02-06 07:46:38 +01:00
all $(BASELIBS) $(ARCHIVES) $(BUILDDEPS) $(GENSRC) ..in-docker-container : | $( CLEAN )
2014-05-16 19:09:22 +02:00
2022-01-22 21:48:28 +01:00
.PHONY : pkg -prepare pkg -build
2017-06-28 14:34:23 +02:00
pkg-prepare :
2022-01-22 21:48:28 +01:00
-@$( foreach dir,$( PKG_PATHS) ," $( MAKE) " -C $( dir) prepare $( NEWLINE) )
2017-06-28 14:34:23 +02:00
2024-02-06 07:46:38 +01:00
$(GENSRC) : pkg -prepare
pkg-build : $( BUILDDEPS ) | $( GENSRC )
2022-01-22 21:48:28 +01:00
$( foreach dir,$( PKG_PATHS) ,$( QQ) " $( MAKE) " -C $( dir) $( NEWLINE) )
2014-01-28 21:12:55 +01:00
2013-03-10 16:51:40 +01:00
clean :
2020-07-30 14:46:01 +02:00
i f n d e f M A K E _ R E S T A R T S
2022-01-22 21:48:28 +01:00
-@$( foreach dir,$( PKG_PATHS) ," $( MAKE) " -C $( dir) clean $( NEWLINE) )
2014-10-10 10:08:57 +02:00
-@rm -rf $( BINDIR)
2015-07-22 20:30:34 +02:00
-@rm -rf $( SCANBUILD_OUTPUTDIR)
2020-07-30 14:46:01 +02:00
e n d i f
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 :
2022-01-22 21:48:28 +01:00
-@$( foreach dir,$( PKG_PATHS) ," $( MAKE) " -C $( dir) distclean $( NEWLINE) )
2015-07-10 14:08:47 +02:00
-@rm -rf $( BINDIR) /*.a $( BINDIR) /*/
2016-03-25 13:54:31 +01:00
clean-pkg :
2022-01-22 21:48:28 +01:00
-@$( foreach dir,$( PKG_PATHS) ," $( MAKE) " -C $( dir) distclean $( NEWLINE) )
2016-03-25 13:54:31 +01:00
2014-08-04 22:03:05 +02:00
distclean :
2022-01-22 21:48:28 +01:00
-@$( foreach dir,$( PKG_PATHS) ," $( MAKE) " -C $( dir) distclean $( NEWLINE) )
2014-10-10 10:08:57 +02:00
-@rm -rf $( BINDIRBASE)
2013-03-10 16:51:40 +01:00
2021-02-09 17:49:56 +01:00
# Include PROGRAMMER_FLASH/PROGRAMMER_RESET variables
i n c l u d e $( RIOTMAKE ) / t o o l s / p r o g r a m m e r . i n c . m k
2019-04-23 14:55:55 +02:00
# Define flash-recipe with a default value
d e f i n e d e f a u l t - f l a s h - r e c i p e
2018-12-05 12:33:12 +01:00
$( call check_cmd,$( FLASHER) ,Flash program)
2021-02-09 17:49:56 +01:00
$( PROGRAMMER_FLASH)
2018-12-05 12:33:12 +01:00
e n d e f
2019-04-23 14:55:55 +02:00
flash-recipe ?= $( default-flash-recipe)
2018-12-05 12:33:12 +01:00
# Do not add dependencies to "flash" directly, use FLASHDEPS, as this is shared
# with flash-only too
2018-01-16 17:37:19 +01:00
2018-12-05 12:33:12 +01:00
flash : all $( FLASHDEPS )
$( flash-recipe)
2013-03-10 16:51:40 +01:00
2018-12-05 12:33:12 +01:00
flash-only : $( FLASHDEPS )
$( flash-recipe)
2018-01-16 17:37:19 +01:00
preflash : $( BUILD_BEFORE_FLASH )
2020-06-11 11:41:45 +02:00
$( PREFLASHER_PREFIX) $( PREFLASHER) $( PREFFLAGS)
2017-05-17 11:54:52 +02:00
2021-02-24 00:24:17 +01:00
# graphical memory usage analyzer
COSY_TOOL ?= $( PKGDIRBASE) /cosy/cosy.py
2022-06-11 14:44:21 +02:00
COSY_PORT ?= 12345
2021-02-24 00:24:17 +01:00
cosy : $( ELFFILE ) $( COSY_TOOL )
2022-06-11 14:44:21 +02:00
$( COSY_TOOL) --port $( COSY_PORT) --riot-base $( RIOTBASE) $( APPDIR) $( BOARD) $( ELFFILE) $( MAPFILE)
2021-02-24 00:24:17 +01:00
2020-07-31 09:46:43 +02:00
i f n e q ( , $( TERMLOG ) $( TERMTEE ) )
TERMTEE ?= | tee -a $( TERMLOG)
e n d i f
2019-10-10 11:53:54 +02:00
TERMFLASHDEPS ?= $( filter flash flash-only,$( MAKECMDGOALS) )
2019-10-10 11:56:57 +02:00
# Add TERMFLASHDEPS to TERMDEPS so it also applies to `test`
TERMDEPS += $( TERMFLASHDEPS)
2019-06-28 13:12:20 +02:00
termdeps : $( TERMDEPS )
2019-10-10 11:56:57 +02:00
term : $( TERMDEPS )
2018-03-23 15:12:35 +01:00
$( call check_cmd,$( TERMPROG) ,Terminal program)
2022-08-29 16:58:16 +02:00
${ TERMENV } $( TERMPROG) $( TERMFLAGS) $( TERMTEE)
2013-03-10 16:51:40 +01:00
2019-08-28 17:27:53 +02:00
# Term without the pyterm added logging
2019-11-18 11:45:19 +01:00
# PYTERMFLAGS must be exported for `jlink.sh term-rtt`.
2020-03-11 14:56:50 +01:00
cleanterm : export PYTERMFLAGS += --no -reconnect --noprefix --no -repeat -command -on -empty -line
2019-10-10 11:56:57 +02:00
cleanterm : $( TERMDEPS )
2019-08-28 17:27:53 +02:00
$( call check_cmd,$( TERMPROG) ,Terminal program)
2020-07-31 09:46:43 +02:00
$( TERMPROG) $( TERMFLAGS) $( TERMTEE)
2019-08-28 17:27:53 +02:00
2015-10-27 10:36:42 +01:00
list-ttys :
2022-03-03 13:49:47 +01:00
$( Q) $( RIOTTOOLS) /usb-serial/ttys.py
2015-10-27 10:36:42 +01:00
2013-03-10 16:51:40 +01:00
doc :
2020-07-03 11:17:57 +02:00
$( MAKE) -BC $( RIOTBASE) doc
2013-07-12 12:31:16 +02:00
2018-10-19 13:27:11 +02:00
debug : $( DEBUGDEPS )
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
2023-06-10 00:04:56 +02:00
debug-client :
$( call check_cmd,$( DEBUGCLIENT) ,Debug client program)
$( DEBUGCLIENT) $( DEBUGCLIENT_FLAGS)
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)
2020-11-26 14:43:20 +01:00
i f e q ( 1 , $( EMULATE ) )
emulate :
2020-11-21 18:44:36 +01:00
$( call check_cmd,$( EMULATOR) ,Emulation program)
$( EMULATOR) $( EMULATOR_FLAGS)
2020-11-21 18:13:17 +01:00
e n d i f
2020-11-21 13:39:36 +01:00
2014-08-05 00:49:59 +02:00
reset :
2018-03-23 15:12:35 +01:00
$( call check_cmd,$( RESET) ,Reset program)
2021-02-09 17:49:56 +01:00
$( PROGRAMMER_RESET)
2014-08-05 00:49:59 +02:00
2019-08-02 15:51:52 +02:00
# tests related targets and variables
i n c l u d e $( RIOTMAKE ) / t e s t s / t e s t s . i n c . m k
2019-03-23 18:03:44 +01:00
2020-01-17 17:01:31 +01:00
.PHONY : fuzz
fuzz :
env FLASHFILE = " $( FLASHFILE) " PORT = " $( PORT) " TERMFLAGS = " $( TERMFLAGS) " \
2022-12-15 13:10:19 +01:00
" $( RIOTBASE) " /dist/tools/fuzzing/afl.sh $( FLAGS_FOR_AFL)
2020-01-17 17:01:31 +01:00
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
2021-05-28 11:41:20 +02:00
# inlcude clang-tidy
i n c l u d e $( RIOTMAKE ) / c l a n g _ t i d y . i n c . m k
2018-12-05 15:22:42 +01:00
# Support Eclipse IDE.
i n c l u d e $( RIOTMAKE ) / e c l i p s e . i n c . m k
2015-05-23 10:32:10 +02:00
2014-05-05 21:53:37 +02:00
# Export variables used throughout the whole make system:
2016-01-27 10:47:12 +01:00
i n c l u d e $( RIOTMAKE ) / v a r s . i n c . m k
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
i n c l u d e $( RIOTMAKE ) / t o o l s / t a r g e t s . i n c . m k
2020-02-17 09:30:42 +01:00
# Checks and defaults for USB Vendor and Product ID
i n c l u d e $( RIOTMAKE ) / u s b - c o d e s . i n c . m k
2016-04-21 10:57:26 +02:00
# Warn if the selected board and drivers don't provide all needed features:
2018-09-18 16:19:03 +02:00
i f n e q ( , $( filter all flash , $ ( if $ ( MAKECMDGOALS ) , $ ( MAKECMDGOALS ) , all ) ) )
2014-09-29 18:09:18 +02:00
EXPECT_ERRORS :=
# 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.
2019-05-03 16:19:20 +02:00
ifneq ( ,$( FEATURES_MISSING) )
2014-09-29 18:09:18 +02:00
$( shell $( COLOR_ECHO) " $( COLOR_RED) There are unsatisfied feature requirements: $( COLOR_RESET) " \
2019-05-03 16:19:20 +02:00
" $( FEATURES_MISSING) " 1>& 2)
2014-09-29 18:09:18 +02:00
EXPECT_ERRORS := 1
endif
2019-10-15 07:55:08 +02:00
# Test if no feature in the requirements used is blacklisted for the selected board.
ifneq ( ,$( FEATURES_USED_BLACKLISTED) )
$( shell $( COLOR_ECHO) " $( COLOR_RED) Some feature requirements are blacklisted: $( COLOR_RESET) " \
" $( FEATURES_USED_BLACKLISTED) " 1>& 2)
EXPECT_ERRORS := 1
endif
2018-04-11 17:41:38 +02:00
# Test if any used feature conflict with another one.
2019-05-03 17:47:42 +02:00
ifneq ( ,$( FEATURES_CONFLICTING) )
2024-11-20 21:45:14 +01:00
$( shell $( COLOR_ECHO) " $( COLOR_RED) The following features conflict: $( COLOR_RESET) " \
2019-05-03 17:47:42 +02:00
" $( FEATURES_CONFLICTING) " 1>& 2)
2014-11-24 14:22:30 +01:00
ifneq ( , $( FEATURES_CONFLICT_MSG) )
$( shell $( COLOR_ECHO) " $( COLOR_YELLOW) Rationale: $( COLOR_RESET) $( FEATURES_CONFLICT_MSG) " 1>& 2)
endif
2024-11-20 21:45:14 +01:00
EXPECT_ERRORS := 1
2014-11-24 14:22:30 +01:00
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
2018-08-07 16:22:49 +02:00
# test if toolchain is supported.
ifeq ( ,$( filter $( TOOLCHAIN) ,$( TOOLCHAINS_SUPPORTED) ) )
$( shell $( COLOR_ECHO) " $( COLOR_RED) The selected TOOLCHAIN= $( TOOLCHAIN) is not supported. $( COLOR_RESET) \nSupported toolchains: $( TOOLCHAINS_SUPPORTED) " 1>& 2)
EXPECT_ERRORS := 1
endif
# If there is a blacklist, then test if the board is blacklisted.
ifneq ( ,$( TOOLCHAINS_BLACKLIST) )
ifneq ( ,$( filter $( TOOLCHAIN) ,$( TOOLCHAINS_BLACKLIST) ) )
$( shell $( COLOR_ECHO) " $( COLOR_RED) The selected TOOLCHAIN= $( TOOLCHAIN) is blacklisted: $( COLOR_RESET) $( TOOLCHAINS_BLACKLIST) " 1>& 2)
EXPECT_ERRORS := 1
endif
endif
2019-10-14 19:25:01 +02:00
# Fail by default when errors are expected
CONTINUE_ON_EXPECTED_ERRORS ?= 0
2014-09-29 18:09:18 +02:00
ifneq ( , $( EXPECT_ERRORS) )
2019-10-14 19:25:01 +02:00
ifneq ( 1,$( CONTINUE_ON_EXPECTED_ERRORS) )
$( error You can let the build continue on expected errors by setting CONTINUE_ON_EXPECTED_ERRORS = 1 to the command line)
endif
2014-09-29 18:09:18 +02:00
$( 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
e n d i f
2014-10-30 22:40:41 +01:00
2015-01-13 18:29:42 +01:00
help :
2023-12-15 10:37:46 +01:00
# filter all targets starting with lowercase and containing lowercase letters, hyphens, or underscores; explicitly include generate-Makefile.ci
@$( MAKE) -qp | sed -ne 's/\(^[a-z][a-z_-]*\|generate-Makefile.ci\):.*/\1/p' | sort -u
2015-07-18 10:54:43 +02:00
2020-07-10 16:09:25 +02:00
i f e q ( i o t l a b - m 3 , $( 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
e n d i f
2016-03-10 15:21:09 +01:00
2020-06-25 22:37:13 +02:00
i f n e q ( , $( filter openv -%,$ ( MAKECMDGOALS ) ) )
include $( RIOTBASE) /dist/tools/openvisualizer/makefile.openvisualizer.inc.mk
e n d i f
2016-03-10 15:21:09 +01:00
# Include desvirt Makefile
2018-03-22 17:15:52 +01:00
i n c l u d e $( RIOTTOOLS ) / d e s v i r t / M a k e f i l e . d e s v i r t
2015-01-27 17:25:16 +01:00
2016-03-17 13:05:15 +01:00
# Build a header file with all common macro definitions and undefinitions
2019-10-01 10:49:34 +02:00
# Everytime the header is updated, it will trigger a new compilation.
#
# The file is created first through a `.in` file that will be modified if
# any CFLAGS changed. It depends on FORCE to re-run of the script every time
# even if the file exists but the file will only be updated on modifications.
#
# The header is then created by keeping only the macros. Keeping the
# comments added absolute path in the file that screwed caching.
#
# The rebuild behavior could even only be done with an empty file, but currently
# some macros definitions are passed through this file.
$(RIOTBUILD_CONFIG_HEADER_C) : $( RIOTBUILD_CONFIG_HEADER_C ) .in
2019-10-13 15:33:53 +02:00
$( Q) sed -n -e ' 1i\
/ * G e n e r a t e d f i l e d o n o t e d i t * / ' -e ' / ^ #.*/ p' $< > $@
2019-10-01 10:49:34 +02:00
.SECONDARY : $( RIOTBUILD_CONFIG_HEADER_C ) .in
$(RIOTBUILD_CONFIG_HEADER_C).in : FORCE | $( CLEAN )
2016-03-17 13:05:15 +01:00
@mkdir -p '$(dir $@)'
2018-03-16 18:13:12 +01:00
$( Q) '$(RIOTTOOLS)/genconfigheader/genconfigheader.sh' $( CFLAGS_WITH_MACROS) \
| '$(LAZYSPONGE)' $( LAZYSPONGE_FLAGS) '$@'
2016-03-17 13:05:15 +01:00
2019-09-17 15:39:26 +02:00
CFLAGS_WITH_MACROS += $( CFLAGS)
2019-07-01 18:57:41 +02:00
CFLAGS_WITH_MACROS += -DRIOT_VERSION= \" $( RIOT_VERSION) \"
2021-08-21 13:39:17 +02:00
CFLAGS_WITH_MACROS += -DRIOT_VERSION_CODE= $( RIOT_VERSION_CODE)
2024-02-05 14:18:14 +01:00
i f n e q ( , $( RIOT_VERSION_EXTRA ) )
CFLAGS_WITH_MACROS += -DCONFIG_RIOT_VERSION_EXTRA= \" " $( RIOT_VERSION_EXTRA) " \"
e n d i f
2019-09-17 15:39:26 +02:00
# MODULE_NAME defines. Declared in 'makefiles/modules.inc.mk'
CFLAGS_WITH_MACROS += $( EXTDEFINES)
2016-07-27 09:23:39 +02:00
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
i n c l u d e $( RIOTMAKE ) / m c u b o o t . m k
2018-03-28 16:49:30 +02:00
2018-03-19 11:31:52 +01:00
# include Murdock helpers
i n c l u d e $( RIOTMAKE ) / m u r d o c k . i n c . m k
2018-03-28 16:49:30 +02:00
# Sanity check, 'all' should be the default goal
i f n e q ( a l l , $( .DEFAULT_GOAL ) )
$( error .DEFAULT_GOAL := $( .DEFAULT_GOAL) )
e n d i f
2018-03-19 11:31:52 +01:00
2018-06-20 18:59:21 +02:00
# Detect if BASELIBS changed since its first use
i f n e q ( $( _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)
e n d i f
2020-05-20 16:26:31 +02:00
e n d i f
2018-10-26 15:04:32 +02:00
2021-04-02 19:01:19 +02:00
i n c l u d e $( RIOTMAKE ) / c a r g o - t a r g e t s . i n c . m k
2018-10-26 15:04:32 +02:00
# include RIOT_MAKEFILES_GLOBAL_POST configuration files
# allows setting user specific system wide configuration parsed after the body
# of $(RIOTBASE)/Makefile.include
i n c l u d e $( RIOT_MAKEFILES_GLOBAL_POST )