1 #-----------------------------------------------------------------------------
2 # Copyright (C) Jonathan Westhues, Mar 2006
3 # Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # See LICENSE.txt for the text of the license.
16 #-----------------------------------------------------------------------------
17 # Makefile for armsrc, see ../common_arm/Makefile.common for common settings
18 #-----------------------------------------------------------------------------
20 # This Makefile might have been called directly, not via the root Makefile, so:
22 -include ..
/Makefile.platform
23 -include ..
/.Makefile.options.cache
24 include ..
/common_arm
/Makefile.hal
25 # detect if there were changes in the platform definitions, requiring a clean
26 ifeq ($(PLATFORM_CHANGED
), true
)
27 $(error platform definitions have been changed
, please
"make clean" at the root of the project
)
31 #remove one of the following defines and comment out the relevant line
32 #in the next section to remove that particular feature from compilation.
33 # NO space,TABs after the "\" sign.
34 APP_CFLAGS
= $(PLATFORM_DEFS
) \
35 -ffunction-sections
-fdata-sections
37 SRC_LF
= lfops.c lfsampling.c pcf7931.c lfdemod.c lfadc.c
39 SRC_ISO15693
= iso15693.c iso15693tools.c
40 SRC_ISO14443a
= iso14443a.c mifareutil.c mifarecmd.c epa.c mifaresim.c sam_mfc.c sam_seos.c
41 #UNUSED: mifaresniff.c
42 SRC_ISO14443b
= iso14443b.c
44 SRC_CRAPTO1
= crypto1.c des.c desfire_crypto.c mifaredesfire.c aes.c platform_util.c
45 SRC_CRC
= crc.c crc16.c crc32.c
46 SRC_ICLASS
= iclass.c optimized_cipherutils.c optimized_ikeys.c optimized_elite.c optimized_cipher.c sam_picopass.c
47 SRC_LEGIC
= legicrf.c legicrfsim.c legic_prng.c
48 SRC_NFCBARCODE
= thinfilm.c
52 # RDV40 related hardware support
53 ifneq (,$(findstring WITH_FLASH
,$(APP_CFLAGS
)))
54 SRC_FLASH
= flashmem.c
55 SRC_SPIFFS
= spiffs.c spiffs_cache.c spiffs_check.c spiffs_gc.c spiffs_nucleus.c spiffs_hydrogen.c
61 ifneq (,$(findstring WITH_SMARTCARD
,$(APP_CFLAGS
)))
67 ifneq (,$(findstring WITH_FPC_USART
,$(APP_CFLAGS
)))
73 ifneq (,$(findstring WITH_HITAG
,$(APP_CFLAGS
)))
74 SRC_HITAG
= hitag2_crypto.c hitag2.c hitagS.c hitag2_crack.c
75 APP_CFLAGS
+= -I..
/common
/hitag2
80 ifneq (,$(findstring WITH_EM4x50
,$(APP_CFLAGS
)))
81 SRC_EM4x50
= em4x50.c bruteforce.c
86 ifneq (,$(findstring WITH_EM4x70
,$(APP_CFLAGS
)))
92 ifneq (,$(findstring WITH_LCD
,$(APP_CFLAGS
)))
93 SRC_LCD
= fonts.c LCD.c
98 ifneq (,$(findstring WITH_ZX8211
,$(APP_CFLAGS
)))
104 # Generic standalone Mode injection of source code
105 include Standalone
/Makefile.inc
107 #the lz4 source files required for decompressing the fpga config at run time
109 #additional defines required to compile lz4
110 LZ4_CFLAGS
= -DLZ4_MEMORY_USAGE
=8
111 APP_CFLAGS
+= $(LZ4_CFLAGS
)
113 APP_CFLAGS
+= -I..
/common
/lz4
115 # stdint.h provided locally until GCC 4.5 becomes C99 compliant,
116 # stack-protect , no-pie reduces size on Gentoo Hardened 8.2 gcc
117 APP_CFLAGS
+= -I.
-fno-stack-protector
-fno-pie
119 # Compile these in thumb mode (small size)
157 # These are to be compiled in ARM mode
158 ARMSRC
= fpgaloader.c \
162 VERSIONSRC
= version_pm3.c \
165 # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
166 include ..
/common_arm
/Makefile.common
168 INSTALLFW
= $(OBJDIR
)/fullimage.elf
170 INSTALLFWTAG
= $(notdir $(INSTALLFW
:%.elf
=%-$(FWTAG
).elf
))
172 INSTALLFWTAG
= $(notdir $(INSTALLFW
))
175 OBJS
= $(OBJDIR
)/fullimage.s19
176 FPGA_COMPRESSOR
= ..
/tools
/fpga_compress
/fpga_compress
178 all: showinfo
$(OBJS
)
181 $(info compiler version
: $(shell $(CROSS_CC
) --version|head
-n
1))
185 # version_pm3.c should be checked on every time fullimage.stage1.elf should be remade
186 version_pm3.c
: default_version_pm3.c
$(OBJDIR
)/fpga_version_info.o
$(OBJDIR
)/fpga_all.o
$(THUMBOBJ
) $(ARMOBJ
) .FORCE
188 $(Q
)$(SH
) ..
/tools
/mkversion.sh
$@ ||
$(CP
) $< $@
190 fpga_version_info.c
: $(FPGA_BITSTREAMS
) $(FPGA_COMPRESSOR
)
192 $(Q
)$(FPGA_COMPRESSOR
) -v
$(filter %.bit
,$^
) $@
194 $(OBJDIR
)/fpga_all.o
: $(OBJDIR
)/fpga_all.bit.z
196 $(Q
)$(CROSS_OBJCOPY
) -O elf32-littlearm
-I binary
-B arm
--prefix-sections
=fpga_all_bit
$^
$@
198 $(OBJDIR
)/fpga_all.bit.z
: $(FPGA_BITSTREAMS
) |
$(FPGA_COMPRESSOR
)
201 @
$(FPGA_COMPRESSOR
) $(filter %.bit
,$^
) $@
>/dev
/null
203 $(FPGA_COMPRESSOR
) $(filter %.bit
,$^
) $@
207 $(error
[!] MISSING
$@
=> To build it
, go the root of the repo and do
"make $(notdir $@)")
208 $(error
[!] MISSING
$@
)
210 $(OBJDIR
)/fullimage.stage1.elf
: $(VERSIONOBJ
) $(OBJDIR
)/fpga_all.o
$(THUMBOBJ
) $(ARMOBJ
)
212 $(Q
)$(CROSS_LD
) $(CROSS_LDFLAGS
) -Wl
,-T
,ldscript
,-Map
,$(patsubst %.elf
,%.map
,$@
) -o
$@
$^
$(LIBS
)
214 $(OBJDIR
)/fullimage.data.bin
: $(OBJDIR
)/fullimage.stage1.elf
216 $(Q
)$(CROSS_OBJCOPY
) -O binary
-I elf32-littlearm
--only-section .data
$^
$@
218 $(OBJDIR
)/fullimage.data.bin.z
: $(OBJDIR
)/fullimage.data.bin |
$(FPGA_COMPRESSOR
)
221 @
$(FPGA_COMPRESSOR
) $(filter %.bin
,$^
) $@
>/dev
/null
223 $(FPGA_COMPRESSOR
) $(filter %.bin
,$^
) $@
226 $(OBJDIR
)/fullimage.elf
: $(OBJDIR
)/fullimage.stage1.elf
$(OBJDIR
)/fullimage.data.bin.z
227 ifneq (,$(findstring WITH_COMPRESSION
,$(APP_CFLAGS
)))
229 $(Q
)$(CROSS_OBJCOPY
) -O elf32-littlearm
-I elf32-littlearm
--strip-all
--update-section .data
=$(OBJDIR
)/fullimage.data.bin.z
$(OBJDIR
)/fullimage.stage1.elf
$@
231 $(Q
)$(CP
) $(OBJDIR
)/fullimage.stage1.elf
$@
236 $(Q
)$(TAR
) $(TARFLAGS
) ..
/proxmark3-
$(platform
)-bin.
tar $(OBJS
:%=armsrc
/%) $(OBJS
:%.s19
=armsrc
/%.elf
)
239 $(Q
)$(RM
) $(DEPENDENCY_FILES
)
240 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.o
241 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.elf
242 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.s19
243 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.map
244 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.d
245 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.z
246 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.bin
247 $(Q
)$(RM
) version_pm3.c version.c fpga_version_info.c
250 $(info [@
] Installing fullimage to
$(DESTDIR
)$(PREFIX
)...
)
251 $(Q
)$(INSTALLSUDO
) $(MKDIR
) $(DESTDIR
)$(PREFIX
)$(PATHSEP
)$(INSTALLFWRELPATH
)
252 $(Q
)$(INSTALLSUDO
) $(CP
) $(INSTALLFW
) $(DESTDIR
)$(PREFIX
)$(PATHSEP
)$(INSTALLFWRELPATH
)$(PATHSEP
)$(INSTALLFWTAG
)
255 $(info [@
] Uninstalling fullimage from
$(DESTDIR
)$(PREFIX
)...
)
256 $(Q
)$(INSTALLSUDO
) $(RM
) $(DESTDIR
)$(PREFIX
)$(PATHSEP
)$(INSTALLFWRELPATH
)$(PATHSEP
)$(INSTALLFWTAG
)
258 .PHONY
: all clean help
install uninstall .FORCE
260 @echo Multi-OS Makefile
, you are running on
$(DETECTED_OS
)
261 @echo Possible targets
:
262 @echo
+ all - Build the full image
$(OBJDIR
)/fullimage.s19
263 @echo
+ clean - Clean
$(OBJDIR
)