2014-10-30 22:40:41 +01:00
|
|
|
all:
|
2014-05-15 17:12:42 +02:00
|
|
|
|
2013-04-01 00:18:07 +02:00
|
|
|
# set undefined variables
|
2014-02-12 13:09:30 +01:00
|
|
|
RIOTBASE ?= $(shell dirname "$(lastword $(MAKEFILE_LIST))")
|
2014-05-05 21:53:37 +02:00
|
|
|
RIOTBASE := $(abspath $(RIOTBASE))
|
2014-02-11 18:15:43 +01:00
|
|
|
|
2014-02-12 13:09:30 +01:00
|
|
|
RIOTCPU ?= $(RIOTBASE)/cpu
|
2014-05-05 21:53:37 +02:00
|
|
|
RIOTCPU := $(abspath $(RIOTCPU))
|
2014-02-12 13:09:30 +01:00
|
|
|
|
|
|
|
RIOTBOARD ?= $(RIOTBASE)/boards
|
2014-05-05 21:53:37 +02:00
|
|
|
RIOTBOARD := $(abspath $(RIOTBOARD))
|
2013-11-06 19:39:25 +01:00
|
|
|
|
2015-02-05 10:03:05 +01:00
|
|
|
RIOTPROJECT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd)
|
|
|
|
RIOTPROJECT := $(abspath $(RIOTPROJECT))
|
|
|
|
|
|
|
|
# Path to the current directory relative to the git root
|
|
|
|
BUILDRELPATH ?= $(shell git rev-parse --show-prefix)
|
|
|
|
|
2015-04-29 20:50:18 +02:00
|
|
|
APPDIR ?= $(CURDIR)
|
|
|
|
APPDIR := $(abspath $(APPDIR))/
|
|
|
|
|
|
|
|
BINDIRBASE ?= $(APPDIR)/bin
|
2014-10-30 22:40:41 +01:00
|
|
|
BINDIRBASE := $(abspath $(BINDIRBASE))
|
|
|
|
|
|
|
|
BINDIR ?= $(BINDIRBASE)/$(BOARD)
|
|
|
|
BINDIR := $(abspath $(BINDIR))/
|
|
|
|
|
|
|
|
COLOR_GREEN :=
|
|
|
|
COLOR_RED :=
|
|
|
|
COLOR_PURPLE :=
|
|
|
|
COLOR_RESET :=
|
|
|
|
COLOR_ECHO := /bin/echo
|
2014-12-15 16:16:44 +01:00
|
|
|
|
|
|
|
OS := $(shell uname)
|
|
|
|
|
2014-10-30 22:40:41 +01:00
|
|
|
ifeq (, ${JENKINS_URL})
|
|
|
|
ifeq (0, $(shell tput colors 2>&1 > /dev/null; echo $$?))
|
|
|
|
COLOR_GREEN := \033[1;32m
|
|
|
|
COLOR_RED := \033[1;31m
|
|
|
|
COLOR_PURPLE := \033[1;35m
|
|
|
|
COLOR_RESET := \033[0m
|
|
|
|
ifeq ($(OS),Darwin)
|
|
|
|
COLOR_ECHO := echo -e
|
|
|
|
SHELL=bash
|
|
|
|
else
|
|
|
|
COLOR_ECHO := /bin/echo -e
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2013-12-21 15:02:53 +01:00
|
|
|
|
2014-01-05 11:33:34 +01:00
|
|
|
ifeq ($(QUIET),1)
|
|
|
|
AD=@
|
2014-06-18 11:00:33 +02:00
|
|
|
MAKEFLAGS += --no-print-directory
|
2014-01-05 11:33:34 +01:00
|
|
|
else
|
|
|
|
AD=
|
|
|
|
endif
|
|
|
|
|
2014-10-30 22:40:41 +01:00
|
|
|
ifneq (10,$(if ${RIOT_VERSION},1,0)$(if ${__RIOTBUILD_FLAG},1,0))
|
|
|
|
|
|
|
|
# Provide a shallow sanity check. You cannot call `make` in a module directory.
|
|
|
|
export __RIOTBUILD_FLAG := RIOT
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
2013-04-01 00:18:07 +02:00
|
|
|
# mandatory includes!
|
2013-12-24 14:50:26 +01:00
|
|
|
include $(RIOTBASE)/Makefile.modules
|
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
|
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
|
|
|
|
|
|
|
|
# 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.
|
2015-01-20 21:05:44 +01:00
|
|
|
ifneq (0, $(shell mkdir -p $(BINDIR); $(AR) rc $(BINDIR)empty-archive.a 2> /dev/null; echo $$?))
|
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.
|
|
|
|
include $(RIOTBASE)/Makefile.cflags
|
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)
|
2014-07-30 15:33:07 +02:00
|
|
|
GIT_STRING := $(shell git describe --always --abbrev=4 --dirty=-`hostname` 2> /dev/null)
|
2014-07-27 13:44:52 +02:00
|
|
|
ifneq (,$(GIT_STRING))
|
|
|
|
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
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
|
2015-01-05 11:33:19 +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
|
2014-12-19 17:30:51 +01:00
|
|
|
export CFLAGS += -DRIOT_VERSION=\"$(RIOT_VERSION)\"
|
2014-06-21 18:29:16 +02:00
|
|
|
|
2014-05-23 14:28:27 +02:00
|
|
|
# the binaries to link
|
2013-12-24 13:20:25 +01:00
|
|
|
BASELIBS += $(BINDIR)$(BOARD)_base.a
|
2014-05-23 10:33:02 +02:00
|
|
|
BASELIBS += $(BINDIR)${APPLICATION}.a
|
2014-01-28 17:58:39 +01:00
|
|
|
BASELIBS += $(USEPKG:%=${BINDIR}%.a)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2015-01-13 18:29:42 +01:00
|
|
|
.PHONY: all clean flash term doc debug debug-server reset objdump help
|
2015-02-05 10:03:05 +01:00
|
|
|
.PHONY: ..in-docker-container
|
2013-08-08 15:44:44 +02:00
|
|
|
|
2014-05-05 21:53:37 +02:00
|
|
|
ELFFILE ?= $(BINDIR)$(APPLICATION).elf
|
|
|
|
HEXFILE ?= $(ELFFILE:.elf=.hex)
|
2014-05-16 18:18:35 +02:00
|
|
|
|
2014-06-25 03:17:20 +02:00
|
|
|
# variables used to complie 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)
|
|
|
|
|
2015-02-05 10:03:05 +01:00
|
|
|
ifeq ($(BUILD_IN_DOCKER),1)
|
|
|
|
all: ..in-docker-container
|
|
|
|
else
|
2014-05-23 10:33:02 +02:00
|
|
|
## make script for your application. Build RIOT-base here!
|
2015-02-21 13:59:41 +01:00
|
|
|
all: ..compiler-check ..build-message $(USEPKG:%=${BINDIR}%.a) $(APPDEPS)
|
2014-06-18 11:21:05 +02:00
|
|
|
$(AD)DIRS="$(DIRS)" "$(MAKE)" -C $(CURDIR) -f $(RIOTBASE)/Makefile.application
|
2014-04-22 16:53:16 +02:00
|
|
|
ifeq (,$(RIOTNOLINK))
|
2014-05-16 18:18:35 +02:00
|
|
|
ifeq ($(BUILDOSXNATIVE),1)
|
2014-07-05 01:33:08 +02:00
|
|
|
$(AD)$(if $(CPPMIX),$(CXX),$(LINK)) $(UNDEF) -o $(ELFFILE) $(BASELIBS) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie
|
2014-05-16 18:18:35 +02:00
|
|
|
else
|
2014-07-05 01:33:08 +02:00
|
|
|
$(AD)$(if $(CPPMIX),$(CXX),$(LINK)) $(UNDEF) -o $(ELFFILE) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(LINKFLAGPREFIX)--end-group $(LINKFLAGPREFIX)-Map=$(BINDIR)$(APPLICATION).map $(LINKFLAGS)
|
2014-05-16 18:18:35 +02:00
|
|
|
endif
|
|
|
|
$(AD)$(SIZE) $(ELFFILE)
|
|
|
|
$(AD)$(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
|
|
|
|
2015-02-21 13:59:41 +01:00
|
|
|
..compiler-check:
|
|
|
|
$(AD)command -v $(CC) >/dev/null 2>&1 || \
|
|
|
|
{ $(COLOR_ECHO) \
|
|
|
|
'${COLOR_RED} Compiler $(CC) is required but not found in PATH. Aborting.${COLOR_RESET}'; \
|
|
|
|
exit 1; }
|
|
|
|
|
2014-06-18 11:00:33 +02:00
|
|
|
..build-message:
|
2014-10-30 22:40:41 +01:00
|
|
|
@$(COLOR_ECHO) '${COLOR_GREEN}Building application "$(APPLICATION)" for "$(BOARD)" with MCU "$(MCU)".${COLOR_RESET}'
|
|
|
|
@$(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
|
|
|
|
|
|
|
|
USEMODULE_INCLUDES_ = $(shell echo $(USEMODULE_INCLUDES) | tr ' ' '\n' | awk '!a[$$0]++' | tr '\n' ' ')
|
|
|
|
|
|
|
|
INCLUDES += $(USEMODULE_INCLUDES_:%=-I%)
|
|
|
|
|
2014-05-16 19:09:22 +02:00
|
|
|
# The `clean` needs to be serialized before everything else.
|
|
|
|
ifneq (, $(filter clean, $(MAKECMDGOALS)))
|
2014-06-18 11:00:33 +02:00
|
|
|
all $(BASELIBS) $(USEPKG:%=$(RIOTBASE)/pkg/%/Makefile.include): 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)
|
|
|
|
$(RIOTBASE)/pkg/%/Makefile.include::
|
|
|
|
$(AD)"$(MAKE)" -C $(RIOTBASE)/pkg/$* Makefile.include
|
|
|
|
|
|
|
|
.PHONY: $(USEPKG:%=$(RIOTBASE)/pkg/%/Makefile.include)
|
|
|
|
-include $(USEPKG:%=$(RIOTBASE)/pkg/%/Makefile.include)
|
|
|
|
|
2014-07-22 20:27:43 +02:00
|
|
|
.PHONY: $(USEPKG:%=${BINDIR}%.a)
|
2014-05-24 19:22:18 +02:00
|
|
|
$(USEPKG:%=${BINDIR}%.a):
|
2014-01-28 21:12:55 +01:00
|
|
|
@mkdir -p ${BINDIR}
|
|
|
|
"$(MAKE)" -C $(RIOTBASE)/pkg/$(patsubst ${BINDIR}%.a,%,$@)
|
|
|
|
|
2013-03-10 16:51:40 +01:00
|
|
|
clean:
|
2014-08-04 22:03:05 +02:00
|
|
|
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i clean ; done
|
2014-10-10 10:08:57 +02:00
|
|
|
-@rm -rf $(BINDIR)
|
2014-08-04 22:03:05 +02:00
|
|
|
|
|
|
|
distclean:
|
|
|
|
-@for i in $(USEPKG) ; do "$(MAKE)" -C $(RIOTBASE)/pkg/$$i distclean ; done
|
2014-10-10 10:08:57 +02:00
|
|
|
-@rm -rf $(BINDIRBASE)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2014-11-19 15:04:51 +01:00
|
|
|
flash: all
|
2015-02-22 19:36:36 +01:00
|
|
|
$(AD)command -v $(FLASHER) >/dev/null 2>&1 || \
|
|
|
|
{ $(COLOR_ECHO) \
|
|
|
|
'${COLOR_RED} Flash program $(FLASHER) not found. Aborting.${COLOR_RESET}'; \
|
|
|
|
exit 1; }
|
2013-04-09 11:26:33 +02:00
|
|
|
$(FLASHER) $(FFLAGS)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
2014-12-03 11:33:27 +01:00
|
|
|
term: $(filter flash, $(MAKECMDGOALS))
|
2015-02-22 19:36:36 +01:00
|
|
|
$(AD)command -v $(TERMPROG) >/dev/null 2>&1 || \
|
|
|
|
{ $(COLOR_ECHO) \
|
|
|
|
'${COLOR_RED} Terminal program $(TERMPROG) not found. Aborting.${COLOR_RESET}'; \
|
|
|
|
exit 1; }
|
2014-08-10 05:20:57 +02:00
|
|
|
$(TERMPROG) $(TERMFLAGS)
|
2013-03-10 16:51:40 +01:00
|
|
|
|
|
|
|
doc:
|
|
|
|
make -BC $(RIOTBASE) doc
|
2013-07-12 12:31:16 +02:00
|
|
|
|
|
|
|
debug:
|
2015-02-22 19:36:36 +01:00
|
|
|
$(AD)command -v $(DEBUGGER) >/dev/null 2>&1 || \
|
|
|
|
{ $(COLOR_ECHO) \
|
|
|
|
'${COLOR_RED} Debug program $(DEBUGGER) not found. Aborting.${COLOR_RESET}'; \
|
|
|
|
exit 1; }
|
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:
|
2015-02-22 19:36:36 +01:00
|
|
|
$(AD)command -v $(DEBUGSERVER) >/dev/null 2>&1 || \
|
|
|
|
{ $(COLOR_ECHO) \
|
|
|
|
'${COLOR_RED} Debug server program $(DEBUGSERVER) not found. Aborting.${COLOR_RESET}'; \
|
|
|
|
exit 1; }
|
2014-08-05 00:49:59 +02:00
|
|
|
$(DEBUGSERVER) $(DEBUGSERVER_FLAGS)
|
|
|
|
|
|
|
|
reset:
|
2015-02-22 19:36:36 +01:00
|
|
|
$(AD)command -v $(RESET) >/dev/null 2>&1 || \
|
|
|
|
{ $(COLOR_ECHO) \
|
|
|
|
'${COLOR_RED} Reset program $(RESET) not found. Aborting.${COLOR_RESET}'; \
|
|
|
|
exit 1; }
|
2014-08-05 00:49:59 +02:00
|
|
|
$(RESET) $(RESET_FLAGS)
|
|
|
|
|
2014-09-27 08:11:29 +02:00
|
|
|
objdump:
|
2015-02-22 19:36:36 +01:00
|
|
|
$(AD)command -v $(PREFIX)objdump >/dev/null 2>&1 || \
|
|
|
|
{ $(COLOR_ECHO) \
|
|
|
|
'${COLOR_RED} Objdump program $(PREFIX)objdump not found. Aborting.${COLOR_RESET}'; \
|
|
|
|
exit 1; }
|
2014-09-27 08:11:29 +02:00
|
|
|
$(PREFIX)objdump -S -D -h $(ELFFILE) | less
|
|
|
|
|
2015-02-05 10:03:05 +01:00
|
|
|
export DOCKER_IMAGE ?= riot/riotbuild:latest
|
|
|
|
export DOCKER_BUILD_ROOT ?= /data/riotbuild
|
|
|
|
export DOCKER_FLAGS ?= --rm
|
|
|
|
# Default target for building inside a Docker container
|
|
|
|
export DOCKER_MAKECMDGOALS ?= all
|
|
|
|
# This will execute `make $(DOCKER_MAKECMDGOALS)` inside a Docker container.
|
|
|
|
# We do not push the regular $(MAKECMDGOALS) to the container's make command in
|
|
|
|
# order to only perform building inside the container and defer executing any
|
|
|
|
# extra commands such as flashing or debugging until after leaving the
|
|
|
|
# container.
|
|
|
|
# The `flash`, `term`, `debugserver` etc. targets usually require access to
|
|
|
|
# hardware which may not be reachable from inside the container.
|
|
|
|
..in-docker-container:
|
|
|
|
@$(COLOR_ECHO) '${COLOR_GREEN}Launching build container using image "$(DOCKER_IMAGE)".${COLOR_RESET}'
|
|
|
|
docker run $(DOCKER_FLAGS) -i -t -u "$$(id -u)" \
|
|
|
|
-v '$(RIOTBASE):$(DOCKER_BUILD_ROOT)/riotbase' \
|
|
|
|
-v '$(RIOTCPU):$(DOCKER_BUILD_ROOT)/riotcpu' \
|
|
|
|
-v '$(RIOTBOARD):$(DOCKER_BUILD_ROOT)/riotboard' \
|
|
|
|
-v '$(RIOTPROJECT):$(DOCKER_BUILD_ROOT)/riotproject' \
|
|
|
|
-e 'RIOTBASE=$(DOCKER_BUILD_ROOT)/riotbase' \
|
|
|
|
-e 'RIOTCPU=$(DOCKER_BUILD_ROOT)/riotcpu' \
|
|
|
|
-e 'RIOTBOARD=$(DOCKER_BUILD_ROOT)/riotboard' \
|
|
|
|
-e 'RIOTPROJECT=$(DOCKER_BUILD_ROOT)/riotproject' \
|
|
|
|
-e 'BOARD=$(BOARD)' \
|
|
|
|
-e 'RIOT_VERSION=$(RIOT_VERSION)' \
|
|
|
|
-e '__RIOTBUILD_FLAG=$(__RIOTBUILD_FLAG)' \
|
|
|
|
-e 'QUIET=$(QUIET)' \
|
|
|
|
-w '$(DOCKER_BUILD_ROOT)/riotproject/$(BUILDRELPATH)' \
|
|
|
|
'$(DOCKER_IMAGE)' make $(DOCKER_MAKECMDGOALS)
|
|
|
|
|
2014-05-14 13:46:27 +02:00
|
|
|
# Extra make goals for testing and comparing changes.
|
|
|
|
include $(RIOTBASE)/Makefile.buildtests
|
2014-05-05 21:53:37 +02:00
|
|
|
|
2014-10-26 23:36:05 +01:00
|
|
|
# import list of provided features
|
|
|
|
-include $(RIOTBOARD)/$(BOARD)/Makefile.features
|
|
|
|
|
2014-05-05 21:53:37 +02:00
|
|
|
# Export variables used throughout the whole make system:
|
|
|
|
include $(RIOTBASE)/Makefile.vars
|
2014-09-29 18:09:18 +02:00
|
|
|
|
2014-10-26 23:36:05 +01:00
|
|
|
# Warn if the selected board and drivers don't provide all needed featues:
|
2014-09-29 18:09:18 +02:00
|
|
|
ifneq (, $(filter all, $(if $(MAKECMDGOALS), $(MAKECMDGOALS), all)))
|
|
|
|
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)
|
|
|
|
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
|
|
|
|
|
|
|
|
# If there is a whitelist, then test if the board is whitelisted.
|
|
|
|
ifneq (, $(BOARD_WHITELIST))
|
|
|
|
ifeq (, $(filter $(BOARD_WHITELIST), $(BOARD)))
|
|
|
|
$(shell $(COLOR_ECHO) "$(COLOR_RED)The selected BOARD=${BOARD} is not whitelisted:$(COLOR_RESET) ${BOARD_WHITELIST}" 1>&2)
|
|
|
|
EXPECT_ERRORS := 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# If there is a blacklist, then test if the board is blacklisted.
|
|
|
|
ifneq (, $(BOARD_BLACKLIST))
|
|
|
|
ifneq (, $(filter $(BOARD_BLACKLIST), $(BOARD)))
|
|
|
|
$(shell $(COLOR_ECHO) "$(COLOR_RED)The selected BOARD=${BOARD} is blacklisted:$(COLOR_RESET) ${BOARD_BLACKLIST}" 1>&2)
|
|
|
|
EXPECT_ERRORS := 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (, $(EXPECT_ERRORS))
|
|
|
|
$(shell $(COLOR_ECHO) "\n\n$(COLOR_RED)EXPECT ERRORS!$(COLOR_RESET)\n\n" 1>&2)
|
|
|
|
endif
|
|
|
|
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)
|
|
|
|
ifeq (, ${NUM_RIOT_VERSION})
|
|
|
|
$(error The supplied RIOT_VERSION=$(RIOT_VERSION) is invalid!)
|
|
|
|
endif
|
|
|
|
|
|
|
|
all $(filter-out clean, ${MAKECMDGOALS}): ..delegate
|
|
|
|
ifneq (, $(filter clean, $(MAKECMDGOALS)))
|
|
|
|
all $(filter-out clean, ${MAKECMDGOALS}): clean
|
|
|
|
endif
|
|
|
|
|
|
|
|
clean:
|
|
|
|
-$(AD)rm -rf $(BINDIR)
|
|
|
|
|
|
|
|
$(BINDIR)riot-version/$(NUM_RIOT_VERSION)/Makefile.include:
|
|
|
|
$(AD)rm -rf $(@D)
|
|
|
|
$(AD)mkdir -p $(@D)
|
|
|
|
$(AD)cd $(RIOTBASE) && git archive --format=tar $(NUM_RIOT_VERSION) | ( cd $(@D) && tar x 1>&2 )
|
|
|
|
|
|
|
|
..delegate: $(BINDIR)riot-version/$(NUM_RIOT_VERSION)/Makefile.include
|
|
|
|
@$(COLOR_ECHO) '$(COLOR_GREEN)Using RIOT_VERSION=${NUM_RIOT_VERSION}$(COLOR_RESET)' 1>&2
|
|
|
|
@$(COLOR_ECHO)
|
|
|
|
$(MAKE) RIOTBASE=$(<D) $(filter-out clean, ${MAKECMDGOALS})
|
|
|
|
|
|
|
|
endif
|
2015-01-13 18:29:42 +01:00
|
|
|
|
|
|
|
help:
|
|
|
|
@$(MAKE) -qp | sed -ne 's/\(^[a-z][a-z_-]*\):.*/\1/p' | sort | uniq
|