Release v4.15864 - Radium
[RRG-proxmark3.git] / armsrc / Makefile
blob0d48037881cebed07d98b86a6b62bc521305934c
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:
21 ifeq ($(PLTNAME),)
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)
28 endif
29 endif
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
38 SRC_HF = hfops.c
39 SRC_ISO15693 = iso15693.c iso15693tools.c
40 SRC_ISO14443a = iso14443a.c mifareutil.c mifarecmd.c epa.c mifaresim.c
41 #UNUSED: mifaresniff.c
42 SRC_ISO14443b = iso14443b.c
43 SRC_FELICA = felica.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
47 SRC_LEGIC = legicrf.c legicrfsim.c legic_prng.c
48 SRC_NFCBARCODE = thinfilm.c
50 # SRC_BEE = bee.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
56 else
57 SRC_FLASH =
58 SRC_SPIFFS =
59 endif
61 ifneq (,$(findstring WITH_SMARTCARD,$(APP_CFLAGS)))
62 SRC_SMARTCARD = i2c.c
63 else
64 SRC_SMARTCARD =
65 endif
67 ifneq (,$(findstring WITH_FPC_USART,$(APP_CFLAGS)))
68 SRC_FPC = usart.c
69 else
70 SRC_FPC =
71 endif
73 ifneq (,$(findstring WITH_HITAG,$(APP_CFLAGS)))
74 SRC_HITAG = hitag2_crypto.c hitag2.c hitagS.c
75 else
76 SRC_HITAG =
77 endif
79 ifneq (,$(findstring WITH_EM4x50,$(APP_CFLAGS)))
80 SRC_EM4x50 = em4x50.c
81 else
82 SRC_EM4x50 =
83 endif
85 ifneq (,$(findstring WITH_EM4x70,$(APP_CFLAGS)))
86 SRC_EM4x70 = em4x70.c
87 else
88 SRC_EM4x70 =
89 endif
91 ifneq (,$(findstring WITH_LCD,$(APP_CFLAGS)))
92 SRC_LCD = fonts.c LCD.c
93 else
94 SRC_LCD =
95 endif
97 ifneq (,$(findstring WITH_ZX8211,$(APP_CFLAGS)))
98 SRC_ZX = lfzx.c
99 else
100 SRC_ZX =
101 endif
103 # Generic standalone Mode injection of source code
104 include Standalone/Makefile.inc
106 #the FPGA bitstream files. Note: order matters!
107 FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit fpga_felica.bit fpga_hf_15.bit
109 #the lz4 source files required for decompressing the fpga config at run time
110 SRC_LZ4 = lz4.c
111 #additional defines required to compile lz4
112 LZ4_CFLAGS = -DLZ4_MEMORY_USAGE=8
113 APP_CFLAGS += $(LZ4_CFLAGS)
114 # lz4 includes:
115 APP_CFLAGS += -I../common/lz4
117 # stdint.h provided locally until GCC 4.5 becomes C99 compliant,
118 # stack-protect , no-pie reduces size on Gentoo Hardened 8.2 gcc
119 APP_CFLAGS += -I. -fno-stack-protector -fno-pie
121 # Compile these in thumb mode (small size)
122 THUMBSRC = start.c \
123 $(SRC_LCD) \
124 $(SRC_ISO15693) \
125 $(SRC_NFCBARCODE) \
126 $(SRC_LF) \
127 $(SRC_LZ4) \
128 $(SRC_LEGIC) \
129 $(SRC_FLASH) \
130 $(SRC_SMARTCARD) \
131 $(SRC_FPC) \
132 $(SRC_HITAG) \
133 $(SRC_EM4x50) \
134 $(SRC_EM4x70) \
135 $(SRC_SPIFFS) \
136 $(SRC_HF) \
137 $(SRC_ISO14443a) \
138 $(SRC_ISO14443b) \
139 $(SRC_CRAPTO1) \
140 $(SRC_ICLASS) \
141 $(SRC_EMV) \
142 $(SRC_CRC) \
143 $(SRC_FELICA) \
144 $(SRC_STANDALONE) \
145 $(SRC_ZX) \
146 appmain.c \
147 printf.c \
148 dbprint.c \
149 commonutil.c \
150 util.c \
151 string.c \
152 BigBuf.c \
153 ticks.c \
154 clocks.c \
155 hfsnoop.c \
156 generator.c
159 # These are to be compiled in ARM mode
160 ARMSRC = fpgaloader.c \
161 usb_cdc.c \
162 cmd.c
164 VERSIONSRC = version_pm3.c \
165 fpga_version_info.c
167 # Do not move this inclusion before the definition of {THUMB,ASM,ARM}SRC
168 include ../common_arm/Makefile.common
170 INSTALLFW = $(OBJDIR)/fullimage.elf
171 ifneq (,$(FWTAG))
172 INSTALLFWTAG = $(notdir $(INSTALLFW:%.elf=%-$(FWTAG).elf))
173 else
174 INSTALLFWTAG = $(notdir $(INSTALLFW))
175 endif
177 OBJS = $(OBJDIR)/fullimage.s19
178 FPGA_COMPRESSOR = ../tools/fpga_compress/fpga_compress
180 all: showinfo $(OBJS)
182 showinfo:
183 $(info compiler version: $(shell $(CROSS_CC) --version|head -n 1))
185 .DELETE_ON_ERROR:
187 # version_pm3.c should be remade on every time fullimage.stage1.elf should be remade
188 version_pm3.c: default_version_pm3.c $(OBJDIR)/fpga_version_info.o $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ)
189 $(info [-] GEN $@)
190 $(Q)$(CP) $< $@
192 fpga_version_info.c: $(FPGA_BITSTREAMS) $(FPGA_COMPRESSOR)
193 $(info [-] GEN $@)
194 $(Q)$(FPGA_COMPRESSOR) -v $(filter %.bit,$^) $@
196 $(OBJDIR)/fpga_all.o: $(OBJDIR)/fpga_all.bit.z
197 $(info [-] GEN $@)
198 $(Q)$(CROSS_OBJCOPY) -O elf32-littlearm -I binary -B arm --prefix-sections=fpga_all_bit $^ $@
200 $(OBJDIR)/fpga_all.bit.z: $(FPGA_BITSTREAMS) | $(FPGA_COMPRESSOR)
201 $(info [-] GEN $@)
202 ifeq ($(Q),@)
203 @$(FPGA_COMPRESSOR) $(filter %.bit,$^) $@ >/dev/null
204 else
205 $(FPGA_COMPRESSOR) $(filter %.bit,$^) $@
206 endif
208 $(FPGA_COMPRESSOR):
209 $(error [!] MISSING $@ => To build it, go the root of the repo and do "make $(notdir $@)")
210 $(error [!] MISSING $@)
212 $(OBJDIR)/fullimage.stage1.elf: $(VERSIONOBJ) $(OBJDIR)/fpga_all.o $(THUMBOBJ) $(ARMOBJ)
213 $(info [=] LD $@)
214 $(Q)$(CROSS_LD) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)
216 $(OBJDIR)/fullimage.data.bin: $(OBJDIR)/fullimage.stage1.elf
217 $(info [-] GEN $@)
218 $(Q)$(CROSS_OBJCOPY) -O binary -I elf32-littlearm --only-section .data $^ $@
220 $(OBJDIR)/fullimage.data.bin.z: $(OBJDIR)/fullimage.data.bin | $(FPGA_COMPRESSOR)
221 $(info [-] GEN $@)
222 ifeq ($(Q),@)
223 @$(FPGA_COMPRESSOR) $(filter %.bin,$^) $@ >/dev/null
224 else
225 $(FPGA_COMPRESSOR) $(filter %.bin,$^) $@
226 endif
228 $(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.stage1.elf $(OBJDIR)/fullimage.data.bin.z
229 ifeq (,$(findstring WITH_NO_COMPRESSION,$(APP_CFLAGS)))
230 $(info [=] LD $@)
231 $(Q)$(CROSS_OBJCOPY) -O elf32-littlearm -I elf32-littlearm --strip-all --update-section .data=$(OBJDIR)/fullimage.data.bin.z $(OBJDIR)/fullimage.stage1.elf $@
232 else
233 $(Q)$(CP) $(OBJDIR)/fullimage.stage1.elf $@
234 endif
236 tarbin: $(OBJS)
237 $(info TAR $@)
238 $(Q)$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(OBJS:%=armsrc/%) $(OBJS:%.s19=armsrc/%.elf)
240 clean:
241 $(Q)$(RM) $(DEPENDENCY_FILES)
242 $(Q)$(RM) $(OBJDIR)$(PATHSEP)*.o
243 $(Q)$(RM) $(OBJDIR)$(PATHSEP)*.elf
244 $(Q)$(RM) $(OBJDIR)$(PATHSEP)*.s19
245 $(Q)$(RM) $(OBJDIR)$(PATHSEP)*.map
246 $(Q)$(RM) $(OBJDIR)$(PATHSEP)*.d
247 $(Q)$(RM) $(OBJDIR)$(PATHSEP)*.z
248 $(Q)$(RM) $(OBJDIR)$(PATHSEP)*.bin
249 $(Q)$(RM) version_pm3.c version.c fpga_version_info.c
251 install: all
252 $(info [@] Installing fullimage to $(DESTDIR)$(PREFIX)...)
253 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)
254 $(Q)$(INSTALLSUDO) $(CP) $(INSTALLFW) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)$(PATHSEP)$(INSTALLFWTAG)
256 uninstall:
257 $(info [@] Uninstalling fullimage from $(DESTDIR)$(PREFIX)...)
258 $(Q)$(INSTALLSUDO) $(RM) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)$(PATHSEP)$(INSTALLFWTAG)
260 .PHONY: all clean help install uninstall
261 help:
262 @echo Multi-OS Makefile, you are running on $(DETECTED_OS)
263 @echo Possible targets:
264 @echo + all - Build the full image $(OBJDIR)/fullimage.s19
265 @echo + clean - Clean $(OBJDIR)