# 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 # if you want to publish the board into the sources as an uppercase #define BB = $(shell echo $(BOARD)|tr 'a-z' 'A-Z') CPUDEF = $(shell echo $(CPU)|tr 'a-z' 'A-Z') CFLAGS += -DBOARD=$(BB) -DCPU_$(CPUDEF) # Add `-fno-delete-null-pointer-checks` flag iff the compiler supports it. # GCC removes moves tests whether `x == NULL`, if previously `x` or even `x->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; \ \ for BOARD in $$(find $(RIOTBOARD) -mindepth 1 -maxdepth 1 -type d \! -name \*-common -printf '%f\n' ); do \ $${ECHO} -n "Building for $${BOARD} .. "; \ env -i \ HOME=$${HOME} \ PATH=$${PATH} \ BOARD=$${BOARD} \ RIOTBASE=$${RIOTBASE} \ RIOTBOARD=$${RIOTBOARD} \ RIOTCPU=$${RIOTCPU} \ $(MAKE) -B clean all >/dev/null 2>&1 ; \ if [ "$${?}" = "0" ]; then \ $${ECHO} "$${GREEN}success$${RESET}"; \ else \ $${ECHO} "$${RED}failed$${RESET}"; \ BUILDTESTFAILED=1; \ fi; \ done; \ if [ "$${BUILDTESTFAILED}" = "1" ]; then \ exit 1; \ fi