Automate make clean when platform definitions are changed

This commit is contained in:
Philippe Teuwen 2019-06-01 01:37:02 +02:00
commit 355319e36a
4 changed files with 34 additions and 4 deletions

2
.gitignore vendored
View file

@ -24,6 +24,8 @@ version.c
# new build file for add-ons. # new build file for add-ons.
Makefile.platform Makefile.platform
# Cache for detecting platform def changes
.Makefile.options.cache
!client/hardnested/*.bin !client/hardnested/*.bin
!client/hardnested/tables/*.z !client/hardnested/tables/*.z

View file

@ -25,6 +25,7 @@ endif
ifeq ($(PLATFORM),) ifeq ($(PLATFORM),)
-include Makefile.platform -include Makefile.platform
-include .Makefile.options.cache
ifeq ($(PLATFORM),) ifeq ($(PLATFORM),)
PLATFORM=PM3RDV4 PLATFORM=PM3RDV4
else else
@ -54,17 +55,17 @@ mfkey/%: FORCE
$(MAKE) -C tools/mfkey $(patsubst mfkey/%,%,$@) $(MAKE) -C tools/mfkey $(patsubst mfkey/%,%,$@)
nonce2key/%: FORCE nonce2key/%: FORCE
$(MAKE) -C tools/nonce2key $(patsubst nonce2key/%,%,$@) $(MAKE) -C tools/nonce2key $(patsubst nonce2key/%,%,$@)
bootrom/%: FORCE bootrom/%: FORCE cleanifplatformchanged
$(MAKE) -C bootrom $(patsubst bootrom/%,%,$@) $(MAKE) -C bootrom $(patsubst bootrom/%,%,$@)
armsrc/%: FORCE armsrc/%: FORCE cleanifplatformchanged
$(MAKE) -C armsrc $(patsubst armsrc/%,%,$@) $(MAKE) -C armsrc $(patsubst armsrc/%,%,$@)
client/%: FORCE client/%: FORCE
$(MAKE) -C client $(patsubst client/%,%,$@) $(MAKE) -C client $(patsubst client/%,%,$@)
recovery/%: FORCE bootrom/% armsrc/% recovery/%: FORCE cleanifplatformchanged bootrom/% armsrc/%
$(MAKE) -C recovery $(patsubst recovery/%,%,$@) $(MAKE) -C recovery $(patsubst recovery/%,%,$@)
FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites) FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites)
.PHONY: all clean help _test bootrom flash-bootrom os flash-os flash-all recovery client mfkey nounce2key style checks FORCE udev accessrights .PHONY: all clean help _test bootrom flash-bootrom os flash-os flash-all recovery client mfkey nounce2key style checks FORCE udev accessrights cleanifplatformchanged
help: help:
@echo "Multi-OS Makefile" @echo "Multi-OS Makefile"
@ -117,6 +118,18 @@ newtarbin:
tarbin: newtarbin client/tarbin armsrc/tarbin bootrom/tarbin tarbin: newtarbin client/tarbin armsrc/tarbin bootrom/tarbin
$(GZIP) proxmark3-$(platform)-bin.tar $(GZIP) proxmark3-$(platform)-bin.tar
# detect if there were changes in the platform definitions, requiring a clean
cleanifplatformchanged:
ifeq ($(PLATFORM_CHANGED), true)
echo "Platform definitions changed, cleaning bootrom/armsrc/recovery first..."
$(MAKE) -C bootrom clean
$(MAKE) -C armsrc clean
$(MAKE) -C recovery clean
@echo CACHED_PLATFORM=$(PLATFORM) > .Makefile.options.cache
@echo CACHED_PLATFORM_EXTRAS=$(PLATFORM_EXTRAS) >> .Makefile.options.cache
@echo CACHED_PLATFORM_DEFS=$(PLATFORM_DEFS) >> .Makefile.options.cache
endif
# configure system to ignore PM3 device as a modem (ModemManager blacklist, effective *only* if ModemManager is not using _strict_ policy) # configure system to ignore PM3 device as a modem (ModemManager blacklist, effective *only* if ModemManager is not using _strict_ policy)
# Read doc/md/ModemManager-Must-Be-Discarded.md for more info # Read doc/md/ModemManager-Must-Be-Discarded.md for more info
udev: udev:

View file

@ -11,6 +11,7 @@ APP_INCLUDES = apps.h
# This Makefile might have been called directly, not via the root Makefile, so: # This Makefile might have been called directly, not via the root Makefile, so:
ifeq ($(PLTNAME),) ifeq ($(PLTNAME),)
-include ../Makefile.platform -include ../Makefile.platform
-include ../.Makefile.options.cache
ifeq ($(PLATFORM),) ifeq ($(PLATFORM),)
PLATFORM=PM3RDV4 PLATFORM=PM3RDV4
else else
@ -30,6 +31,11 @@ ifeq ($(PLTNAME),)
$(info Included options: $(PLATFORM_DEFS_INFO)) $(info Included options: $(PLATFORM_DEFS_INFO))
$(info Standalone mode: $(PLATFORM_DEFS_INFO_STANDALONE)) $(info Standalone mode: $(PLATFORM_DEFS_INFO_STANDALONE))
$(info ===================================================================) $(info ===================================================================)
# detect if there were changes in the platform definitions, requiring a clean
ifeq ($(PLATFORM_CHANGED), true)
$(error platform definitions have been changed, please "make clean" at the root of the project)
endif
endif endif
#remove one of the following defines and comment out the relevant line #remove one of the following defines and comment out the relevant line

View file

@ -163,3 +163,12 @@ export MCU
export PLATFORM_DEFS export PLATFORM_DEFS
export PLATFORM_DEFS_INFO export PLATFORM_DEFS_INFO
export PLATFORM_DEFS_INFO_STANDALONE export PLATFORM_DEFS_INFO_STANDALONE
PLATFORM_CHANGED=false
ifneq ($(PLATFORM), $(CACHED_PLATFORM))
PLATFORM_CHANGED=true
else ifneq ($(PLATFORM_EXTRAS), $(CACHED_PLATFORM_EXTRAS))
PLATFORM_CHANGED=true
else ifneq ($(PLATFORM_DEFS), $(CACHED_PLATFORM_DEFS))
PLATFORM_CHANGED=true
endif