summaryrefslogtreecommitdiffstats
path: root/make.mk
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-05-22 19:46:43 -0400
committerJoey Castillo <joeycastillo@utexas.edu>2022-05-22 19:46:43 -0400
commit040267fe3d8606591c3a27f9bf0a1a4805a6850d (patch)
treea3549820fdb7a9c7345883519c36f4b59b986dad /make.mk
parent6ed757af2b7778e6944a5a8761672bc8d03620e2 (diff)
parentc40d75b8765a2972bb6a80a7c6f56865b52063e4 (diff)
downloadSensor-Watch-040267fe3d8606591c3a27f9bf0a1a4805a6850d.tar.gz
Sensor-Watch-040267fe3d8606591c3a27f9bf0a1a4805a6850d.tar.bz2
Sensor-Watch-040267fe3d8606591c3a27f9bf0a1a4805a6850d.zip
Merge branch 'parallelize-builds' of https://github.com/GeorgeHahn/Sensor-Watch
Diffstat (limited to 'make.mk')
-rw-r--r--make.mk26
1 files changed, 26 insertions, 0 deletions
diff --git a/make.mk b/make.mk
index ac5be775..d8e2bf8a 100644
--- a/make.mk
+++ b/make.mk
@@ -9,12 +9,38 @@ endif
##############################################################################
.PHONY: all directory clean size
+# OS detection, adapted from https://gist.github.com/sighingnow/deee806603ec9274fd47
+DETECTED_OS :=
+ifeq ($(OS),Windows_NT)
+ DETECTED_OS = WINDOWS
+else
+ UNAME_S := $(shell uname -s)
+ ifeq ($(UNAME_S),Linux)
+ DETECTED_OS = LINUX
+ endif
+ ifeq ($(UNAME_S),Darwin)
+ DETECTED_OS = OSX
+ endif
+endif
+$(if ${VERBOSE},$(info OS detected: $(DETECTED_OS)))
+
ifeq ($(OS), Windows_NT)
MKDIR = gmkdir
else
MKDIR = mkdir
endif
+ifeq ($(DETECTED_OS), LINUX)
+ MAKEFLAGS += -j `nproc`
+endif
+ifeq ($(DETECTED_OS), OSX)
+ NPROCS = $(shell sysctl hw.ncpu | grep -o '[0-9]\+')
+ MAKEFLAGS += -j $(NPROCS)
+endif
+ifeq ($(DETECTED_OS), WINDOWS)
+ MAKEFLAGS += -j $(NUMBER_OF_PROCESSORS)
+endif
+
ifndef EMSCRIPTEN
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy