recover_pk.py: replace secp192r1 by prime192v1
[RRG-proxmark3.git] / armsrc / Makefile
blobdedccd3e0ab076c55476aec448f141b2fa2168ce
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 sam_mfc.c sam_seos.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 sam_picopass.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 hitag2_crack.c
75 APP_CFLAGS += -I../common/hitag2
76 else
77 SRC_HITAG =
78 endif
80 ifneq (,$(findstring WITH_EM4x50,$(APP_CFLAGS)))
81 SRC_EM4x50 = em4x50.c bruteforce.c
82 else
83 SRC_EM4x50 =
84 endif
86 ifneq (,$(findstring WITH_EM4x70,$(APP_CFLAGS)))
87 SRC_EM4x70 = em4x70.c
88 else
89 SRC_EM4x70 =
90 endif
92 ifneq (,$(findstring WITH_LCD,$(APP_CFLAGS)))
93 SRC_LCD = fonts.c LCD.c
94 else
95 SRC_LCD =
96 endif
98 ifneq (,$(findstring WITH_ZX8211,$(APP_CFLAGS)))
99 SRC_ZX = lfzx.c
100 else
101 SRC_ZX =
102 endif
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
108 SRC_LZ4 = lz4.c
109 #additional defines required to compile lz4
110 LZ4_CFLAGS = -DLZ4_MEMORY_USAGE=8
111 APP_CFLAGS += $(LZ4_CFLAGS)
112 # lz4 includes:
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)
120 THUMBSRC = start.c \
121 $(SRC_LCD) \
122 $(SRC_ISO15693) \
123 $(SRC_NFCBARCODE) \
124 $(SRC_LF) \
125 $(SRC_LZ4) \
126 $(SRC_LEGIC) \
127 $(SRC_FLASH) \
128 $(SRC_SMARTCARD) \
129 $(SRC_FPC) \
130 $(SRC_HITAG) \
131 $(SRC_EM4x50) \
132 $(SRC_EM4x70) \
133 $(SRC_SPIFFS) \
134 $(SRC_HF) \
135 $(SRC_ISO14443a) \
136 $(SRC_ISO14443b) \
137 $(SRC_CRAPTO1) \
138 $(SRC_ICLASS) \
139 $(SRC_EMV) \
140 $(SRC_CRC) \
141 $(SRC_FELICA) \
142 $(SRC_STANDALONE) \
143 $(SRC_ZX) \
144 appmain.c \
145 printf.c \
146 dbprint.c \
147 commonutil.c \
148 util.c \
149 string.c \
150 BigBuf.c \
151 ticks.c \
152 clocks.c \
153 hfsnoop.c \
154 generator.c
157 # These are to be compiled in ARM mode
158 ARMSRC = fpgaloader.c \
159 usb_cdc.c \
160 cmd.c
162 VERSIONSRC = version_pm3.c \
163 fpga_version_info.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
169 ifneq (,$(FWTAG))
170 INSTALLFWTAG = $(notdir $(INSTALLFW:%.elf=%-$(FWTAG).elf))
171 else
172 INSTALLFWTAG = $(notdir $(INSTALLFW))
173 endif
175 OBJS = $(OBJDIR)/fullimage.s19
176 FPGA_COMPRESSOR = ../tools/fpga_compress/fpga_compress
178 all: showinfo $(OBJS)
180 showinfo:
181 $(info compiler version: $(shell $(CROSS_CC) --version|head -n 1))
183 .DELETE_ON_ERROR:
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
187 $(info [-] CHECK $@)
188 $(Q)$(SH) ../tools/mkversion.sh $@ || $(CP) $< $@
190 fpga_version_info.c: $(FPGA_BITSTREAMS) $(FPGA_COMPRESSOR)
191 $(info [-] GEN $@)
192 $(Q)$(FPGA_COMPRESSOR) -v $(filter %.bit,$^) $@
194 $(OBJDIR)/fpga_all.o: $(OBJDIR)/fpga_all.bit.z
195 $(info [-] GEN $@)
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)
199 $(info [-] GEN $@)
200 ifeq ($(Q),@)
201 @$(FPGA_COMPRESSOR) $(filter %.bit,$^) $@ >/dev/null
202 else
203 $(FPGA_COMPRESSOR) $(filter %.bit,$^) $@
204 endif
206 $(FPGA_COMPRESSOR):
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)
211 $(info [=] LD $@)
212 $(Q)$(CROSS_LD) $(CROSS_LDFLAGS) -Wl,-T,ldscript,-Map,$(patsubst %.elf,%.map,$@) -o $@ $^ $(LIBS)
214 $(OBJDIR)/fullimage.data.bin: $(OBJDIR)/fullimage.stage1.elf
215 $(info [-] GEN $@)
216 $(Q)$(CROSS_OBJCOPY) -O binary -I elf32-littlearm --only-section .data $^ $@
218 $(OBJDIR)/fullimage.data.bin.z: $(OBJDIR)/fullimage.data.bin | $(FPGA_COMPRESSOR)
219 $(info [-] GEN $@)
220 ifeq ($(Q),@)
221 @$(FPGA_COMPRESSOR) $(filter %.bin,$^) $@ >/dev/null
222 else
223 $(FPGA_COMPRESSOR) $(filter %.bin,$^) $@
224 endif
226 $(OBJDIR)/fullimage.elf: $(OBJDIR)/fullimage.stage1.elf $(OBJDIR)/fullimage.data.bin.z
227 ifneq (,$(findstring WITH_COMPRESSION,$(APP_CFLAGS)))
228 $(info [=] LD $@)
229 $(Q)$(CROSS_OBJCOPY) -O elf32-littlearm -I elf32-littlearm --strip-all --update-section .data=$(OBJDIR)/fullimage.data.bin.z $(OBJDIR)/fullimage.stage1.elf $@
230 else
231 $(Q)$(CP) $(OBJDIR)/fullimage.stage1.elf $@
232 endif
234 tarbin: $(OBJS)
235 $(info TAR $@)
236 $(Q)$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(OBJS:%=armsrc/%) $(OBJS:%.s19=armsrc/%.elf)
238 clean:
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
249 install: all
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)
254 uninstall:
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
259 help:
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)