| 1 | GZIP=gzip |
| 2 | # Windows' echo echos its input verbatim, on Posix there is some |
| 3 | # amount of shell command line parsing going on. echo "" on |
| 4 | # Windows yields literal "", on Linux yields an empty line |
| 5 | ifeq ($(shell echo ""),) |
| 6 | # This is probably a proper system, so we can use uname |
| 7 | DELETE=rm -rf |
| 8 | FLASH_TOOL=client/flasher |
| 9 | platform=$(shell uname) |
| 10 | ifneq (,$(findstring MINGW,$(platform))) |
| 11 | FLASH_PORT=com3 |
| 12 | PATHSEP=\\# |
| 13 | else |
| 14 | FLASH_PORT=/dev/ttyACM0 |
| 15 | PATHSEP=/ |
| 16 | endif |
| 17 | else |
| 18 | # Assume that we are running on native Windows |
| 19 | DELETE=del /q |
| 20 | FLASH_TOOL=client/flasher.exe |
| 21 | platform=Windows |
| 22 | FLASH_PORT=com3 |
| 23 | PATHSEP=\\# |
| 24 | endif |
| 25 | |
| 26 | all clean: %: client/% bootrom/% armsrc/% recovery/% mfkey/% |
| 27 | |
| 28 | bootrom/%: FORCE |
| 29 | $(MAKE) -C bootrom $(patsubst bootrom/%, %, $@) |
| 30 | armsrc/%: FORCE |
| 31 | $(MAKE) -C armsrc $(patsubst armsrc/%, %, $@) |
| 32 | client/%: FORCE |
| 33 | $(MAKE) -C client $(patsubst client/%, %, $@) |
| 34 | recovery/%: FORCE |
| 35 | $(MAKE) -C recovery $(patsubst recovery/%, %, $@) |
| 36 | mfkey/%: FORCE |
| 37 | $(MAKE) -C tools/mfkey $(patsubst mfkey/%, %, $@) |
| 38 | FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites) |
| 39 | |
| 40 | .PHONY: all clean help _test flash-bootrom flash-os flash-all FORCE |
| 41 | |
| 42 | help: |
| 43 | @echo Multi-OS Makefile, you are running on $(DETECTED_OS) |
| 44 | @echo Possible targets: |
| 45 | @echo + all - Make bootrom, armsrc and the OS-specific host directory |
| 46 | @echo + client - Make only the OS-specific host directory |
| 47 | @echo + flash-bootrom - Make bootrom and flash it |
| 48 | @echo + flash-os - Make armsrc and flash os \(includes fpga\) |
| 49 | @echo + flash-all - Make bootrom and armsrc and flash bootrom and os image |
| 50 | @echo + clean - Clean in bootrom, armsrc and the OS-specific host directory |
| 51 | |
| 52 | client: client/all |
| 53 | |
| 54 | mfkey: mfkey/all |
| 55 | |
| 56 | flash-bootrom: bootrom/obj/bootrom.elf $(FLASH_TOOL) |
| 57 | $(FLASH_TOOL) $(FLASH_PORT) -b $(subst /,$(PATHSEP),$<) |
| 58 | |
| 59 | flash-os: armsrc/obj/fullimage.elf $(FLASH_TOOL) |
| 60 | $(FLASH_TOOL) $(FLASH_PORT) $(subst /,$(PATHSEP),$<) |
| 61 | |
| 62 | flash-all: bootrom/obj/bootrom.elf armsrc/obj/fullimage.elf $(FLASH_TOOL) |
| 63 | $(FLASH_TOOL) $(FLASH_PORT) -b $(subst /,$(PATHSEP),$(filter-out $(FLASH_TOOL),$^)) |
| 64 | |
| 65 | newtarbin: |
| 66 | $(DELETE) proxmark3-$(platform)-bin.tar proxmark3-$(platform)-bin.tar.gz |
| 67 | @touch proxmark3-$(platform)-bin.tar |
| 68 | |
| 69 | tarbin: newtarbin client/tarbin armsrc/tarbin bootrom/tarbin |
| 70 | $(GZIP) proxmark3-$(platform)-bin.tar |
| 71 | |
| 72 | # Dummy target to test for GNU make availability |
| 73 | _test: |