# set undefined variables RIOTBASE ?= $(shell dirname "$(lastword $(MAKEFILE_LIST))") export RIOTBASE := $(abspath $(RIOTBASE)) RIOTCPU ?= $(RIOTBASE)/cpu export RIOTCPU := $(abspath $(RIOTCPU)) RIOTBOARD ?= $(RIOTBASE)/boards export RIOTBOARD := $(abspath $(RIOTBOARD)) ifeq ($(strip $(MCU)),) MCU = $(CPU) endif ifeq (,$(filter buildtest,$(MAKECMDGOALS))) ifneq (,$(BOARD_WHITELIST)) ifeq (,$(filter $(BOARD),$(BOARD_WHITELIST))) $(error This application only runs on following boards: $(BOARD_WHITELIST)) endif endif ifneq (,$(filter $(BOARD),$(BOARD_BLACKLIST))) $(error This application does not run on following boards: $(BOARD_BLACKLIST)) endif endif # if you want to publish the board into the sources as an uppercase #define BB = $(shell echo $(BOARD)|tr 'a-z' 'A-Z'|tr '-' '_') CPUDEF = $(shell echo $(CPU)|tr 'a-z' 'A-Z'|tr '-' '_') CFLAGS += -DBOARD_$(BB) -DCPU_$(CPUDEF) export CFLAGS export BINDIR =$(CURDIR)/bin/$(BOARD)/ ifeq ($(QUIET),1) AD=@ else AD= endif export AD BOARD := $(strip $(BOARD)) # mandatory includes! include $(RIOTBASE)/Makefile.modules include $(RIOTBOARD)/$(BOARD)/Makefile.include include $(RIOTCPU)/$(CPU)/Makefile.include include $(RIOTBASE)/Makefile.dep # Test if there where dependencies against a module in DISABLE_MODULE. ifneq (, $(filter $(DISABLE_MODULE), $(USEMODULE))) $(error "Required modules were disabled using DISABLE_MODULE: $(sort $(filter $(DISABLE_MODULE), $(USEMODULE)))") endif # Test if the input language was specified externally. # Otherwise test if the compiler unterstands the "-std=gnu99" flag, and use it if so. # Otherwise test if the compiler unterstands the "-std=c99" flag, and use it if so. ifeq ($(filter -std=%,$(CFLAGS)),) ifeq ($(shell $(CC) -std=gnu99 -E - 2>/dev/null >/dev/null /dev/null >/dev/null y` was accessed. # 0x0 might be a sane memory location for embedded systems, so the test must not be removed. # Right now clang does not use the *delete-null-pointer* optimization, and does not understand the parameter. # Related issues: #628, #664. ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null &1 1>/dev/null &1 > /dev/null; then \ GREEN='\033[1;32m'; RED='\033[1;31m'; RESET='\033[0m'; \ ECHO='echo -e'; \ else \ GREEN=''; RED=''; RESET=''; \ ECHO='echo'; \ fi; \ \ if [ -z "$(BOARD_WHITELIST)" ]; then \ BOARDS=$$(find $(RIOTBOARD) -mindepth 1 -maxdepth 1 -type d \! -name \*-common -printf '%f\n' ); \ else \ BOARDS="$(BOARD_WHITELIST)"; \ fi; \ \ for BOARD in $(BOARD_BLACKLIST); do \ echo "Ignoring $${BOARD} (blacklisted)"; \ BOARDS=$$(echo \ $${BOARDS}\ | sed -e 's/ '$${BOARD}' / /'); \ done; \ \ for BOARD in $${BOARDS}; do \ $${ECHO} -n "Building for $${BOARD} .. "; \ LOG=$$(env -i \ HOME=$${HOME} \ PATH=$${PATH} \ BOARD=$${BOARD} \ RIOTBASE=$${RIOTBASE} \ RIOTBOARD=$${RIOTBOARD} \ RIOTCPU=$${RIOTCPU} \ $(MAKE) -B clean all 2>&1 >/dev/null) ; \ if [ "$${?}" = "0" ]; then \ $${ECHO} "$${GREEN}success$${RESET}"; \ else \ $${ECHO} "$${RED}failed$${RESET}"; \ echo "$${LOG}" | grep -v -E '^make(\[[[:digit:]]])?:'; \ BUILDTESTFAILED=1; \ fi; \ done; \ if [ "$${BUILDTESTFAILED}" = "1" ]; then \ exit 1; \ fi