1 # This code is licensed to you under the terms of the GNU GPL, version 2 or,
2 # at your option, any later version. See the LICENSE.txt file for the text of
4 #-----------------------------------------------------------------------------
5 # Makefile for armsrc, see ../common_arm/Makefile.common for common settings
6 #-----------------------------------------------------------------------------
8 # This Makefile might have been called directly, not via the root Makefile, so:
10 -include ..
/Makefile.platform
11 -include ..
/.Makefile.options.cache
12 include ..
/common_arm
/Makefile.hal
13 # detect if there were changes in the platform definitions, requiring a clean
14 ifeq ($(PLATFORM_CHANGED
), true
)
15 $(error platform definitions have been changed
, please
"make clean" at the root of the project
)
19 #remove one of the following defines and comment out the relevant line
20 #in the next section to remove that particular feature from compilation.
21 # NO space,TABs after the "\" sign.
22 APP_CFLAGS
= $(PLATFORM_DEFS
) \
23 -ffunction-sections
-fdata-sections
25 SRC_LF
= lfops.c lfsampling.c pcf7931.c lfdemod.c lfadc.c
26 SRC_ISO15693
= iso15693.c iso15693tools.c
27 SRC_ISO14443a
= iso14443a.c mifareutil.c mifarecmd.c epa.c mifaresim.c
28 #UNUSED: mifaresniff.c
29 SRC_ISO14443b
= iso14443b.c
31 SRC_CRAPTO1
= crypto1.c des.c desfire_crypto.c mifaredesfire.c aes.c platform_util.c
32 SRC_CRC
= crc.c crc16.c crc32.c
33 SRC_ICLASS
= iclass.c optimized_cipherutils.c optimized_ikeys.c optimized_elite.c optimized_cipher.c
34 SRC_LEGIC
= legicrf.c legicrfsim.c legic_prng.c
35 SRC_NFCBARCODE
= thinfilm.c
39 # RDV40 related hardware support
40 ifneq (,$(findstring WITH_FLASH
,$(APP_CFLAGS
)))
41 SRC_FLASH
= flashmem.c
42 SRC_SPIFFS
= spiffs.c spiffs_cache.c spiffs_check.c spiffs_gc.c spiffs_nucleus.c spiffs_hydrogen.c
48 ifneq (,$(findstring WITH_SMARTCARD
,$(APP_CFLAGS
)))
54 ifneq (,$(findstring WITH_FPC_USART
,$(APP_CFLAGS
)))
60 ifneq (,$(findstring WITH_HITAG
,$(APP_CFLAGS
)))
61 SRC_HITAG
= hitag2_crypto.c hitag2.c hitagS.c
66 ifneq (,$(findstring WITH_EM4x50
,$(APP_CFLAGS
)))
72 ifneq (,$(findstring WITH_EM4x70
,$(APP_CFLAGS
)))
78 ifneq (,$(findstring WITH_LCD
,$(APP_CFLAGS
)))
79 SRC_LCD
= fonts.c LCD.c
84 # Generic standalone Mode injection of source code
85 include Standalone
/Makefile.inc
87 #the FPGA bitstream files. Note: order matters!
88 FPGA_BITSTREAMS
= fpga_lf.bit fpga_hf.bit fpga_felica.bit
90 #the lz4 source files required for decompressing the fpga config at run time
92 #additional defines required to compile lz4
93 LZ4_CFLAGS
= -DLZ4_MEMORY_USAGE
=8
94 APP_CFLAGS
+= $(LZ4_CFLAGS
)
96 APP_CFLAGS
+= -I..
/common
/lz4
98 # stdint.h provided locally until GCC 4.5 becomes C99 compliant,
99 # stack-protect , no-pie reduces size on Gentoo Hardened 8.2 gcc
100 APP_CFLAGS
+= -I.
-fno-stack-protector
-fno-pie
102 # Compile these in thumb mode (small size)
137 # These are to be compiled in ARM mode
138 ARMSRC
= fpgaloader.c \
143 VERSIONSRC
= version_pm3.c \
146 # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
147 include ..
/common_arm
/Makefile.common
149 INSTALLFW
= $(OBJDIR
)/fullimage.elf
151 INSTALLFWTAG
= $(notdir $(INSTALLFW
:%.elf
=%-$(FWTAG
).elf
))
153 INSTALLFWTAG
= $(notdir $(INSTALLFW
))
156 OBJS
= $(OBJDIR
)/fullimage.s19
157 FPGA_COMPRESSOR
= ..
/tools
/fpga_compress
/fpga_compress
159 all: showinfo
$(OBJS
)
162 $(info compiler version
: $(shell $(CC
) --version|head
-n
1))
166 # version_pm3.c should be remade on every time fullimage.stage1.elf should be remade
167 version_pm3.c
: default_version_pm3.c
$(OBJDIR
)/fpga_version_info.o
$(OBJDIR
)/fpga_all.o
$(THUMBOBJ
) $(ARMOBJ
)
169 $(Q
)$(SH
) ..
/tools
/mkversion.sh
> $@ ||
$(PERL
) ..
/tools
/mkversion.pl
> $@ ||
$(CP
) $< $@
171 fpga_version_info.c
: $(FPGA_BITSTREAMS
) $(FPGA_COMPRESSOR
)
173 $(Q
)$(FPGA_COMPRESSOR
) -v
$(filter %.bit
,$^
) $@
175 $(OBJDIR
)/fpga_all.o
: $(OBJDIR
)/fpga_all.bit.z
177 $(Q
)$(OBJCOPY
) -O elf32-littlearm
-I binary
-B arm
--prefix-sections
=fpga_all_bit
$^
$@
179 $(OBJDIR
)/fpga_all.bit.z
: $(FPGA_BITSTREAMS
) |
$(FPGA_COMPRESSOR
)
182 @
$(FPGA_COMPRESSOR
) $(filter %.bit
,$^
) $@
>/dev
/null
184 $(FPGA_COMPRESSOR
) $(filter %.bit
,$^
) $@
188 $(error
[!] MISSING
$@
=> To build it
, go the root of the repo and do
"make $(notdir $@)")
189 $(error
[!] MISSING
$@
)
191 $(OBJDIR
)/fullimage.stage1.elf
: $(VERSIONOBJ
) $(OBJDIR
)/fpga_all.o
$(THUMBOBJ
) $(ARMOBJ
)
193 $(Q
)$(CC
) $(CROSS_LDFLAGS
) -Wl
,-T
,ldscript
,-Map
,$(patsubst %.elf
,%.map
,$@
) -o
$@
$^
$(LIBS
)
195 $(OBJDIR
)/fullimage.nodata.bin
: $(OBJDIR
)/fullimage.stage1.elf
197 $(Q
)$(OBJCOPY
) -O binary
-I elf32-littlearm
--remove-section .data
$^
$@
199 $(OBJDIR
)/fullimage.nodata.o
: $(OBJDIR
)/fullimage.nodata.bin
201 $(Q
)$(OBJCOPY
) -O elf32-littlearm
-I binary
-B arm
--rename-section .data
=stage1_image
$^
$@
203 $(OBJDIR
)/fullimage.data.bin
: $(OBJDIR
)/fullimage.stage1.elf
205 $(Q
)$(OBJCOPY
) -O binary
-I elf32-littlearm
--only-section .data
$^
$@
207 $(OBJDIR
)/fullimage.data.bin.z
: $(OBJDIR
)/fullimage.data.bin |
$(FPGA_COMPRESSOR
)
210 @
$(FPGA_COMPRESSOR
) $(filter %.bin
,$^
) $@
>/dev
/null
212 $(FPGA_COMPRESSOR
) $(filter %.bin
,$^
) $@
215 $(OBJDIR
)/fullimage.data.o
: $(OBJDIR
)/fullimage.data.bin.z
217 $(Q
)$(OBJCOPY
) -O elf32-littlearm
-I binary
-B arm
--rename-section .data
=compressed_data
$^
$@
219 $(OBJDIR
)/fullimage.elf
: $(OBJDIR
)/fullimage.nodata.o
$(OBJDIR
)/fullimage.data.o
220 ifeq (,$(findstring WITH_NO_COMPRESSION
,$(APP_CFLAGS
)))
222 $(Q
)$(CC
) $(CROSS_LDFLAGS
) -Wl
,-T
,ldscript
,-e
,_osimage_entry
,-Map
,$(patsubst %.elf
,%.map
,$@
) -o
$@
$^
224 $(Q
)$(CP
) $(OBJDIR
)/fullimage.stage1.elf
$@
229 $(Q
)$(TAR
) $(TARFLAGS
) ..
/proxmark3-
$(platform
)-bin.
tar $(OBJS
:%=armsrc
/%) $(OBJS
:%.s19
=armsrc
/%.elf
)
232 $(Q
)$(RM
) $(DEPENDENCY_FILES
)
233 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.o
234 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.elf
235 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.s19
236 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.map
237 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.d
238 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.z
239 $(Q
)$(RM
) $(OBJDIR
)$(PATHSEP
)*.bin
240 $(Q
)$(RM
) version_pm3.c version.c
243 $(info [@
] Installing fullimage to
$(DESTDIR
)$(PREFIX
)...
)
244 $(Q
)$(MKDIR
) $(DESTDIR
)$(PREFIX
)$(PATHSEP
)$(INSTALLFWRELPATH
)
245 $(Q
)$(CP
) $(INSTALLFW
) $(DESTDIR
)$(PREFIX
)$(PATHSEP
)$(INSTALLFWRELPATH
)$(PATHSEP
)$(INSTALLFWTAG
)
248 $(info [@
] Uninstalling fullimage from
$(DESTDIR
)$(PREFIX
)...
)
249 $(Q
)$(RM
) $(DESTDIR
)$(PREFIX
)$(PATHSEP
)$(INSTALLFWRELPATH
)$(PATHSEP
)$(INSTALLFWTAG
)
251 .PHONY
: all clean help
install uninstall
253 @echo Multi-OS Makefile
, you are running on
$(DETECTED_OS
)
254 @echo Possible targets
:
255 @echo
+ all - Build the full image
$(OBJDIR
)/fullimage.s19
256 @echo
+ clean - Clean
$(OBJDIR
)