lhr-solar / Embedded-Sharepoint

This repository contains files that can be shared among us, the embedded design teams.
MIT License
3 stars 0 forks source link

Add functionality for defines to be overridden when calling make #55

Open Lakshay983 opened 1 month ago

Lakshay983 commented 1 month ago

In my top level makefile I should be able to add a DEFINE while making my project. This can be to add defines or to override defines

For example, in BPS I may want to set the NUM_BATTERY_MODULES define to 34 In the BPS repo you can run make test=Voltage DEFINES=NUM_BATTERY_MODULES=34 https://github.com/lhr-solar/BPS/blob/master/BSP/STM32F413/Makefile


ifneq ($(DEFINES), none)
# need to split defines
PREFIXED = $(addprefix -D,$(DEFINES))
SPLIT = $(subst /, -D, $(PREFIXED))

CFLAGS += $(SPLIT)
endif