From c010f59b8c61312ee4c96b3553159f86db1113e7 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Thu, 17 Oct 2019 09:51:49 +0200 Subject: [PATCH 1/4] Makefile.include: remove repeated OS declaration - OS := $(shell uname) is already declared in `Makefile.include` re-declaring it means it will be re-evalauted multiple times uselessly. --- Makefile.include | 2 +- boards/common/remote/Makefile.include | 1 - boards/openmote-b/Makefile.include | 1 - makefiles/tools/bossa.inc.mk | 1 - makefiles/tools/serial.inc.mk | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Makefile.include b/Makefile.include index 02f5d81f07..3878d92b6b 100644 --- a/Makefile.include +++ b/Makefile.include @@ -103,7 +103,7 @@ CLEAN = $(filter clean, $(MAKECMDGOALS)) include $(RIOTMAKE)/utils/variables.mk include $(RIOTMAKE)/utils/strings.mk -# get host operating system +# OS is always needed so use simple variable expansion so only evaluated once OS := $(shell uname) # set python path, e.g. for tests diff --git a/boards/common/remote/Makefile.include b/boards/common/remote/Makefile.include index 4d5c2a9944..4e3cf15fed 100644 --- a/boards/common/remote/Makefile.include +++ b/boards/common/remote/Makefile.include @@ -2,7 +2,6 @@ export PROGRAMMER ?= cc2538-bsl ifeq ($(PROGRAMMER),cc2538-bsl) - OS := $(shell uname) ifeq ($(OS),Linux) PORT_BSL ?= $(PORT_LINUX) else ifeq ($(OS),Darwin) diff --git a/boards/openmote-b/Makefile.include b/boards/openmote-b/Makefile.include index 5f37a86536..d88914ce57 100644 --- a/boards/openmote-b/Makefile.include +++ b/boards/openmote-b/Makefile.include @@ -6,7 +6,6 @@ PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial*))) export PROGRAMMER ?= cc2538-bsl ifeq ($(PROGRAMMER),cc2538-bsl) - OS := $(shell uname) ifeq ($(OS),Linux) PORT_BSL ?= $(PORT_LINUX) else ifeq ($(OS),Darwin) diff --git a/makefiles/tools/bossa.inc.mk b/makefiles/tools/bossa.inc.mk index 725ba1583d..5297f0ff18 100644 --- a/makefiles/tools/bossa.inc.mk +++ b/makefiles/tools/bossa.inc.mk @@ -5,7 +5,6 @@ FFLAGS ?= -p $(PORT) -e -i -w -v -b -R $(FLASHFILE) # some arduino boards need to toggle the serial interface a little bit to get # them ready for flashing... ifneq (,$(BOSSA_ARDUINO_PREFLASH)) - OS := $(shell uname) ifeq ($(OS),Linux) STTY_FLAG = -F else ifeq ($(OS),Darwin) diff --git a/makefiles/tools/serial.inc.mk b/makefiles/tools/serial.inc.mk index 84144166e0..c6934b0618 100644 --- a/makefiles/tools/serial.inc.mk +++ b/makefiles/tools/serial.inc.mk @@ -1,5 +1,4 @@ # set default port depending on operating system -OS := $(shell uname) ifeq ($(OS),Linux) PORT ?= $(call ensure_value,$(PORT_LINUX),No port set) else ifeq ($(OS),Darwin) From de2ba4ff1ae4d24444fb4fe08a029e42696dd271 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Thu, 17 Oct 2019 11:04:31 +0200 Subject: [PATCH 2/4] Makefile.include: get OS and OS_ARCH from UNAME --- Makefile.include | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile.include b/Makefile.include index 3878d92b6b..7a61f22f0c 100644 --- a/Makefile.include +++ b/Makefile.include @@ -103,8 +103,11 @@ CLEAN = $(filter clean, $(MAKECMDGOALS)) include $(RIOTMAKE)/utils/variables.mk include $(RIOTMAKE)/utils/strings.mk -# OS is always needed so use simple variable expansion so only evaluated once -OS := $(shell uname) + +# UNAME is always needed so use simple variable expansion so only evaluated once +UNAME := $(OS -m) +OS = $(word 1, $(UNAME)) +OS_ARCH = $(word 2, $(UNAME)) # set python path, e.g. for tests PYTHONPATH := $(RIOTBASE)/dist/pythonlibs/:$(PYTHONPATH) From f3482de2775d740d6f9ef9da6d91d7fcf3835af1 Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 18 Oct 2019 08:23:02 +0200 Subject: [PATCH 3/4] REMOVEME: add OS and OS_ARCH variable --- boards/native/Makefile.dep | 3 ++- boards/native/Makefile.include | 34 +++++++++++++++++++++++----------- cpu/native/Makefile | 3 ++- pkg/fatfs/Makefile.include | 3 ++- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/boards/native/Makefile.dep b/boards/native/Makefile.dep index 8eec472da0..72fdb74096 100644 --- a/boards/native/Makefile.dep +++ b/boards/native/Makefile.dep @@ -6,8 +6,9 @@ ifneq (,$(filter mtd,$(USEMODULE))) USEMODULE += mtd_native endif +OS := $(shell uname -s) ifneq (,$(filter can,$(USEMODULE))) - ifeq ($(shell uname -s),Linux) + ifeq ($(OS),Linux) USEMODULE += can_linux CFLAGS += -DCAN_DLL_NUMOF=2 endif diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index 8fb4b53300..220d930943 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -5,7 +5,9 @@ export NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/ USEMODULE += native-drivers -ifeq ($(shell uname -s),Darwin) +OS := $(shell uname -s) + +ifeq ($(OS),Darwin) DEBUGGER ?= lldb else DEBUGGER ?= gdb @@ -27,18 +29,22 @@ ifeq (,$(filter -std=%, $(CFLAGS))) CFLAGS += -std=gnu99 endif -ifeq ($(shell uname -m),x86_64) +OS_ARCH := $(shell uname -m) +ifeq ($(OS_ARCH),x86_64) CFLAGS += -m32 endif ifneq (,$(filter -DDEVELHELP,$(CFLAGS))) CFLAGS += -fstack-protector-all endif -ifeq ($(shell uname -s),FreeBSD) - ifeq ($(shell uname -m),amd64) +OS := $(shell uname -s) +ifeq ($(OS),FreeBSD) + OS_ARCH := $(shell uname -m) + ifeq ($(OS_ARCH),amd64) CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32 endif endif -ifeq ($(shell uname -s),Darwin) +OS := $(shell uname -s) +ifeq ($(OS),Darwin) CFLAGS += -Wno-deprecated-declarations endif @@ -46,11 +52,14 @@ endif CXXUWFLAGS += CXXEXFLAGS += -ifeq ($(shell uname -m),x86_64) +OS_ARCH := $(shell uname -m) +ifeq ($(OS_ARCH),x86_64) export LINKFLAGS += -m32 endif -ifeq ($(shell uname -s),FreeBSD) - ifeq ($(shell uname -m),amd64) +OS := $(shell uname -s) +ifeq ($(OS),FreeBSD) + OS_ARCH := $(shell uname -m) + ifeq ($(OS_ARCH),amd64) export LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32 endif export LINKFLAGS += -L $(BINDIR) @@ -60,7 +69,8 @@ endif # clean up unused functions CFLAGS += -ffunction-sections -fdata-sections -ifeq ($(shell uname -s),Darwin) +OS := $(shell uname -m) +ifeq ($(OS),Darwin) export LINKFLAGS += -Wl,-dead_strip else export LINKFLAGS += -Wl,--gc-sections @@ -113,7 +123,8 @@ endif # backward compatability with glibc <= 2.17 for native ifeq ($(CPU),native) - ifeq ($(shell uname -s),Linux) + OS := $(shell uname -s) + ifeq ($(OS),Linux) ifeq ($(shell ldd --version | awk '/^ldd/{if ($$NF < 2.17) {print "yes"} else {print "no"} }'),yes) LINKFLAGS += -lrt endif @@ -123,7 +134,8 @@ endif # clumsy way to enable building native on osx: BUILDOSXNATIVE = 0 ifeq ($(CPU),native) - ifeq ($(shell uname -s),Darwin) + OS := $(shell uname -s) + ifeq ($(OS),Darwin) BUILDOSXNATIVE = 1 endif endif diff --git a/cpu/native/Makefile b/cpu/native/Makefile index 9c2b87b709..7d3fd6190c 100644 --- a/cpu/native/Makefile +++ b/cpu/native/Makefile @@ -3,7 +3,8 @@ MODULE = cpu DIRS += periph DIRS += vfs -ifeq ($(shell uname -s),Darwin) +OS := $(shell uname -s) +ifeq ($(OS),Darwin) CFLAGS += -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE endif diff --git a/pkg/fatfs/Makefile.include b/pkg/fatfs/Makefile.include index 7fe6cb9347..56a6daf0a1 100644 --- a/pkg/fatfs/Makefile.include +++ b/pkg/fatfs/Makefile.include @@ -16,6 +16,7 @@ else CFLAGS += -DFATFS_FFCONF_OPT_FS_NORTC=1 endif -ifeq ($(shell uname -s),Darwin) +OS := $(shell uname -s) +ifeq ($(OS),Darwin) CFLAGS += -Wno-empty-body endif From 45c8eafd42fb6f73adf7693a140b474fc492810a Mon Sep 17 00:00:00 2001 From: Francisco Molina Date: Fri, 18 Oct 2019 08:07:37 +0200 Subject: [PATCH 4/4] Makefile.include: remove repeated OS declaration --- Makefile.include | 2 +- boards/native/Makefile.dep | 1 - boards/native/Makefile.include | 12 ------------ cpu/native/Makefile | 1 - pkg/fatfs/Makefile.include | 1 - 5 files changed, 1 insertion(+), 16 deletions(-) diff --git a/Makefile.include b/Makefile.include index 7a61f22f0c..12feb826d0 100644 --- a/Makefile.include +++ b/Makefile.include @@ -105,7 +105,7 @@ include $(RIOTMAKE)/utils/strings.mk # UNAME is always needed so use simple variable expansion so only evaluated once -UNAME := $(OS -m) +UNAME := $(shell uname -m -s) OS = $(word 1, $(UNAME)) OS_ARCH = $(word 2, $(UNAME)) diff --git a/boards/native/Makefile.dep b/boards/native/Makefile.dep index 72fdb74096..fb4182b31a 100644 --- a/boards/native/Makefile.dep +++ b/boards/native/Makefile.dep @@ -6,7 +6,6 @@ ifneq (,$(filter mtd,$(USEMODULE))) USEMODULE += mtd_native endif -OS := $(shell uname -s) ifneq (,$(filter can,$(USEMODULE))) ifeq ($(OS),Linux) USEMODULE += can_linux diff --git a/boards/native/Makefile.include b/boards/native/Makefile.include index 220d930943..213c3f6e53 100644 --- a/boards/native/Makefile.include +++ b/boards/native/Makefile.include @@ -5,8 +5,6 @@ export NATIVEINCLUDES += -I$(RIOTBASE)/drivers/include/ USEMODULE += native-drivers -OS := $(shell uname -s) - ifeq ($(OS),Darwin) DEBUGGER ?= lldb else @@ -29,21 +27,17 @@ ifeq (,$(filter -std=%, $(CFLAGS))) CFLAGS += -std=gnu99 endif -OS_ARCH := $(shell uname -m) ifeq ($(OS_ARCH),x86_64) CFLAGS += -m32 endif ifneq (,$(filter -DDEVELHELP,$(CFLAGS))) CFLAGS += -fstack-protector-all endif -OS := $(shell uname -s) ifeq ($(OS),FreeBSD) - OS_ARCH := $(shell uname -m) ifeq ($(OS_ARCH),amd64) CFLAGS += -m32 -DCOMPAT_32BIT -B/usr/lib32 endif endif -OS := $(shell uname -s) ifeq ($(OS),Darwin) CFLAGS += -Wno-deprecated-declarations endif @@ -52,13 +46,10 @@ endif CXXUWFLAGS += CXXEXFLAGS += -OS_ARCH := $(shell uname -m) ifeq ($(OS_ARCH),x86_64) export LINKFLAGS += -m32 endif -OS := $(shell uname -s) ifeq ($(OS),FreeBSD) - OS_ARCH := $(shell uname -m) ifeq ($(OS_ARCH),amd64) export LINKFLAGS += -m32 -DCOMPAT_32BIT -L/usr/lib32 -B/usr/lib32 endif @@ -69,7 +60,6 @@ endif # clean up unused functions CFLAGS += -ffunction-sections -fdata-sections -OS := $(shell uname -m) ifeq ($(OS),Darwin) export LINKFLAGS += -Wl,-dead_strip else @@ -123,7 +113,6 @@ endif # backward compatability with glibc <= 2.17 for native ifeq ($(CPU),native) - OS := $(shell uname -s) ifeq ($(OS),Linux) ifeq ($(shell ldd --version | awk '/^ldd/{if ($$NF < 2.17) {print "yes"} else {print "no"} }'),yes) LINKFLAGS += -lrt @@ -134,7 +123,6 @@ endif # clumsy way to enable building native on osx: BUILDOSXNATIVE = 0 ifeq ($(CPU),native) - OS := $(shell uname -s) ifeq ($(OS),Darwin) BUILDOSXNATIVE = 1 endif diff --git a/cpu/native/Makefile b/cpu/native/Makefile index 7d3fd6190c..cc0605cc5f 100644 --- a/cpu/native/Makefile +++ b/cpu/native/Makefile @@ -3,7 +3,6 @@ MODULE = cpu DIRS += periph DIRS += vfs -OS := $(shell uname -s) ifeq ($(OS),Darwin) CFLAGS += -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE endif diff --git a/pkg/fatfs/Makefile.include b/pkg/fatfs/Makefile.include index 56a6daf0a1..a59773a8d4 100644 --- a/pkg/fatfs/Makefile.include +++ b/pkg/fatfs/Makefile.include @@ -16,7 +16,6 @@ else CFLAGS += -DFATFS_FFCONF_OPT_FS_NORTC=1 endif -OS := $(shell uname -s) ifeq ($(OS),Darwin) CFLAGS += -Wno-empty-body endif