diff --git a/Makefile.include b/Makefile.include index 319ae29d7..3578730eb 100644 --- a/Makefile.include +++ b/Makefile.include @@ -46,11 +46,6 @@ UPPERCASE = _ABCDEFGHIJKLMNOPQRSTUVWXYZ_ TARGET_UPPERCASE := ${strip ${shell echo $(TARGET) | sed y!$(LOWERCASE)!$(UPPERCASE)!}} CFLAGS += -DCONTIKI=1 -DCONTIKI_TARGET_$(TARGET_UPPERCASE)=1 CFLAGS += -DCONTIKI_TARGET_STRING=\"$(TARGET)\" -ifneq ($(BOARD),) -TARGET_BOARD_UPPERCASE := ${strip ${shell echo $(BOARD) | sed y!$(LOWERCASE)!$(UPPERCASE)!}} -CFLAGS += -DCONTIKI_BOARD_$(TARGET_BOARD_UPPERCASE)=1 -CFLAGS += -DCONTIKI_BOARD_STRING=\"$(BOARD)\" -endif CFLAGS += -Wno-unused-const-variable @@ -129,6 +124,12 @@ endif # $(BOARD) not empty PLATFORM_ACTION ?= build +ifneq ($(BOARD),) + TARGET_BOARD_UPPERCASE := ${strip ${shell echo $(BOARD) | sed y!$(LOWERCASE)!$(UPPERCASE)!}} + CFLAGS += -DCONTIKI_BOARD_$(TARGET_BOARD_UPPERCASE)=1 + CFLAGS += -DCONTIKI_BOARD_STRING=\"$(BOARD)\" +endif + # Configure MAC layer # The different options diff --git a/arch/cpu/native/Makefile.native b/arch/cpu/native/Makefile.native index d7832d358..30883622d 100644 --- a/arch/cpu/native/Makefile.native +++ b/arch/cpu/native/Makefile.native @@ -20,6 +20,30 @@ endif CFLAGSNO = -Wall -g -I/usr/local/include $(CFLAGSWERROR) CFLAGS += $(CFLAGSNO) +### Are we building with code size optimisations? +SMALL ?= 0 + +# The optimizations on native platform cannot be enabled in GCC (not Clang) versions less than 7.2 +GCC_IS_CLANG := $(shell gcc --version 2> /dev/null | grep clang) +ifneq ($(GCC_IS_CLANG),) + NATIVE_CAN_OPTIIMIZE = 1 +else + GCC_VERSION := $(shell gcc -dumpfullversion -dumpversion | cut -b1-3) + ifeq ($(shell expr $(GCC_VERSION) \>= 7.2), 1) + NATIVE_CAN_OPTIIMIZE = 1 + else + NATIVE_CAN_OPTIIMIZE = 0 + endif +endif + +ifeq ($(NATIVE_CAN_OPTIIMIZE),1) + ifeq ($(SMALL),1) + CFLAGS += -Os + else + CFLAGS += -O2 + endif +endif + ifeq ($(HOST_OS),Darwin) AROPTS = -rc LDFLAGS_WERROR := -Wl,-fatal_warnings diff --git a/tests/compile-all/build.sh b/tests/compile-all/build.sh index fcbbd7bd7..81441816e 100755 --- a/tests/compile-all/build.sh +++ b/tests/compile-all/build.sh @@ -40,17 +40,21 @@ # To invoke the building for a specific platform, run: # $ PLATFORMS=zoul ./build.sh # +CONTIKI_NG_TOP_DIR="../.." +EXAMPLES_DIR=$CONTIKI_NG_TOP_DIR/examples if [[ "$PLATFORMS" == "" ]] then - PLATFORMS=`ls ../../arch/platform` + PLATFORMS=`ls $CONTIKI_NG_TOP_DIR/arch/platform` fi if [[ "$MAKEFILES" == "" ]] then - MAKEFILES=`find ../../examples/ -name Makefile` + MAKEFILES=`find $EXAMPLES_DIR -name Makefile` fi +HELLO_WORLD=$EXAMPLES_DIR/hello-world + # Set the make goal the first argument of the script or to "all" if called w/o arguments if [[ $# -gt 0 ]] then @@ -97,22 +101,14 @@ do continue fi - if [[ "$platform" == "srf06-cc26xx" ]] + # Detect all boards for the current platform by calling + # make TARGET=$platform boards + # in the hello-world dir. + BOARDS=`make -s -C $HELLO_WORLD TARGET=$platform boards \ + | grep -v "no boards" | rev | cut -f3- -d" " | rev` + + if [[ -z $BOARDS ]] then - # srf06-cc26xx has multiple boards - BOARDS="srf06/cc26xx srf06/cc13xx launchpad/cc2650 launchpad/cc1310 launchpad/cc1350 sensortag/cc2650 sensortag/cc1350" - elif [[ "$platform" == "simplelink" ]] - then - # SimpleLink has multiple boards - BOARDS="launchpad/cc1310 launchpad/cc1350 launchpad/cc1350-4 launchpad/cc2650 \ - sensortag/cc1350 sensortag/cc2650 srf06/cc13x0 srf06/cc26x0 \ - launchpad/cc1312r1 launchpad/cc1352r1 launchpad/cc1352p1 launchpad/cc1352p-2 launchpad/cc1352p-4 launchpad/cc26x2r1" - elif [[ "$platform" == "zoul" ]] - then - # Zoul has multiple boards - BOARDS="remote-reva remote-revb firefly-reva firefly orion" - else - # Other platforms have just a single board BOARDS="default" fi