[build] Use variants

- Move helpers functions into build/helpers.mak
- Move official warning into official targets only
This commit is contained in:
Romain Goyet
2020-04-02 15:38:08 -04:00
committed by Ecco
parent 8d621e4dce
commit ada205b1a7
31 changed files with 294 additions and 242 deletions

View File

@@ -1,16 +1,5 @@
# Define standard compilation rules
.PHONY: official_authorization
ifeq ($(ACCEPT_OFFICIAL_TOS),1)
official_authorization:
else
official_authorization:
@echo "CAUTION: You are trying to build an official NumWorks firmware."
@echo "Distribution of such firmware by a third party is prohibited."
@echo "Please set the ACCEPT_OFFICIAL_TOS environment variable to proceed."
@exit -1
endif
$(eval $(call rule_for, \
AS, %.o, %.s, \
$$(CC) $$(SFLAGS) -c $$< -o $$@ \
@@ -22,12 +11,34 @@ $(eval $(call rule_for, \
with_local_version \
))
$(eval $(call rule_for, \
CPP, %, %.inc, \
$$(CPP) -P $$< $$@ \
))
$(eval $(call rule_for, \
CXX, %.o, %.cpp, \
$$(CXX) $$(CXXFLAGS) $$(SFLAGS) -c $$< -o $$@, \
with_local_version \
))
$(eval $(call rule_for, \
DFUSE, %.dfu, %.elf, \
$$(PYTHON) build/device/elf2dfu.py $$< $$@, \
with_local_version \
))
$(eval $(call rule_for, \
OBJCOPY, %.hex, %.elf, \
$$(OBJCOPY) -O ihex $$< $$@ \
))
$(eval $(call rule_for, \
OBJCOPY, %.bin, %.elf, \
$$(OBJCOPY) -O binary $$< $$@, \
with_local_version \
))
$(eval $(call rule_for, \
OCC, %.o, %.m, \
$$(CC) $$(CFLAGS) $$(SFLAGS) -c $$< -o $$@ \
@@ -39,8 +50,8 @@ $(eval $(call rule_for, \
))
$(eval $(call rule_for, \
CPP, %, %.inc, \
$$(CPP) -P $$< $$@ \
WINDRES, %.o, %.rc, \
$$(WINDRES) $$< -O coff -o $$@ \
))
ifdef EXE
@@ -61,8 +72,3 @@ $(eval $(call rule_for, \
))
endif
endif
$(eval $(call rule_for, \
WINDRES, %.o, %.rc, \
$$(WINDRES) $$< -O coff -o $$@ \
))