Merge branch 'parallelize-builds' of https://github.com/GeorgeHahn/Sensor-Watch

This commit is contained in:
Joey Castillo 2022-05-22 19:46:43 -04:00
commit 040267fe3d
2 changed files with 33 additions and 4 deletions

26
make.mk
View File

@ -9,12 +9,38 @@ endif
############################################################################## ##############################################################################
.PHONY: all directory clean size .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) ifeq ($(OS), Windows_NT)
MKDIR = gmkdir MKDIR = gmkdir
else else
MKDIR = mkdir MKDIR = mkdir
endif 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 ifndef EMSCRIPTEN
CC = arm-none-eabi-gcc CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy OBJCOPY = arm-none-eabi-objcopy

View File

@ -7,9 +7,9 @@ SUBMODULES = tinyusb
COBRA = cobra -f COBRA = cobra -f
ifndef EMSCRIPTEN ifndef EMSCRIPTEN
all: directory $(SUBMODULES) $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size all: $(BUILD)/$(BIN).elf $(BUILD)/$(BIN).hex $(BUILD)/$(BIN).bin $(BUILD)/$(BIN).uf2 size
else else
all: directory $(SUBMODULES) $(BUILD)/$(BIN).html all: $(BUILD)/$(BIN).html
endif endif
$(BUILD)/$(BIN).html: $(OBJS) $(BUILD)/$(BIN).html: $(OBJS)
@ -35,13 +35,14 @@ $(BUILD)/$(BIN).uf2: $(BUILD)/$(BIN).bin
@echo UF2CONV $@ @echo UF2CONV $@
@$(UF2) $^ -co $@ @$(UF2) $^ -co $@
.phony: $(SUBMODULES)
$(SUBMODULES): $(SUBMODULES):
git submodule update --init git submodule update --init
install: install:
@$(UF2) -D $(BUILD)/$(BIN).uf2 @$(UF2) -D $(BUILD)/$(BIN).uf2
%.o: $(BUILD)/%.o: | $(SUBMODULES) directory
@echo CC $@ @echo CC $@
@$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@ @$(CC) $(CFLAGS) $(filter %/$(subst .o,.c,$(notdir $@)), $(SRCS)) -c -o $@
@ -59,4 +60,6 @@ clean:
analyze: analyze:
@$(COBRA) basic $(INCLUDES) $(DEFINES) $(SRCS) @$(COBRA) basic $(INCLUDES) $(DEFINES) $(SRCS)
-include $(wildcard $(BUILD)/*.d) DEPFILES := $(SRCS:%.c=$(BUILD)/%.d)
-include $(wildcard $(DEPFILES))