]> git.zerfleddert.de Git - proxmark3-svn/blob - client/Makefile
81b46f235a7e817ec88c9bde5dba6e9fc2f4cace
[proxmark3-svn] / client / Makefile
1 #-----------------------------------------------------------------------------
2 # This code is licensed to you under the terms of the GNU GPL, version 2 or,
3 # at your option, any later version. See the LICENSE.txt file for the text of
4 # the license.
5 #-----------------------------------------------------------------------------
6
7 CC = gcc
8 CXX = g++
9 LD = g++
10 TAR = tar
11 TARFLAGS = -C .. --ignore-failed-read -rvf
12 RM = rm -f
13 MV = mv
14
15 ENV_LDFLAGS := $(LDFLAGS)
16 ENV_CFLAGS := $(CFLAGS)
17 VPATH = ../common ../zlib ../uart
18 OBJDIR = obj
19
20 LDLIBS = -L/opt/local/lib -L/usr/local/lib -lreadline -lpthread -lm
21 LUALIB = ../liblua/liblua.a
22 JANSSONLIBPATH = ./jansson
23 JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
24 MBEDTLSLIBPATH = ../common/mbedtls
25 MBEDTLSLIB = $(MBEDTLSLIBPATH)/libmbedtls.a
26 CBORLIBPATH = ./tinycbor
27 CBORLIB = $(CBORLIBPATH)/tinycbor.a
28 LIBINCLUDES = -I../zlib -I../uart -I../liblua -I$(MBEDTLSLIBPATH) -I$(JANSSONLIBPATH) -I$(CBORLIBPATH)
29 INCLUDES_CLIENT = -I. -I../include -I../common -I/opt/local/include $(LIBINCLUDES)
30 LDFLAGS = $(ENV_LDFLAGS)
31 CFLAGS = $(ENV_CFLAGS) -std=c99 -D_ISOC99_SOURCE $(INCLUDES_CLIENT) -Wall -g -O3
32 CXXFLAGS = -I../include -Wall -O3
33
34 APP_CFLAGS =
35 include ../common/Makefile_Enabled_Options.common
36 CFLAGS += $(APP_CFLAGS)
37 ifneq (,$(findstring WITH_SMARTCARD,$(APP_CFLAGS)))
38 SRC_SMARTCARD = cmdsmartcard.c
39 else
40 SRC_SMARTCARD =
41 endif
42
43 LUAPLATFORM = generic
44 platform = $(shell uname)
45 ifneq (,$(findstring MINGW,$(platform)))
46 LUAPLATFORM = mingw
47 else
48 ifeq ($(platform),Darwin)
49 LUAPLATFORM = macosx
50 OBJCSRCS = util_darwin.m
51 LDFLAGS += -framework Foundation -framework AppKit
52 else
53 LUALIB += -ldl
54 LDLIBS += -ltermcap -lncurses
55 LUAPLATFORM = linux
56 endif
57 endif
58
59 ifneq (,$(findstring WITH_GUI,$(APP_CFLAGS)))
60 # Check for correctly configured Qt5
61 QTINCLUDES = $(shell pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
62 QTLDLIBS = $(shell pkg-config --libs Qt5Core Qt5Widgets 2>/dev/null)
63 MOC = $(shell pkg-config --variable=host_bins Qt5Core)/moc
64 UIC = $(shell pkg-config --variable=host_bins Qt5Core)/uic
65 ifeq ($(QTINCLUDES), )
66 # if Qt5 not found check for correctly configured Qt4
67 QTINCLUDES = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null)
68 QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
69 MOC = $(shell pkg-config --variable=moc_location QtCore)
70 UIC = $(shell pkg-config --variable=uic_location QtCore)
71 else
72 CXXFLAGS += -std=c++11 -fPIC
73 endif
74 ifeq ($(QTINCLUDES), )
75 # if both pkg-config commands failed, search in common places
76 ifneq ($(QTDIR), )
77 QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
78 QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4
79 ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
80 QTINCLUDES += -I$(QTDIR)/include/QtWidgets
81 QTLDLIBS = -L$(QTDIR)/lib -lQt5Widgets -lQt5Gui -lQt5Core
82 CXXFLAGS += -std=c++11 -fPIC
83 endif
84 MOC = $(QTDIR)/bin/moc
85 UIC = $(QTDIR)/bin/uic
86 endif
87 endif
88 endif
89
90
91 ifneq ($(QTLDLIBS), )
92 QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
93 CFLAGS += -DHAVE_GUI
94 else
95 QTGUIOBJS = $(OBJDIR)/guidummy.o
96 endif
97
98 # Flags to generate temporary dependency files
99 DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
100 # make temporary to final dependeny files after successful compilation
101 POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d
102
103
104 CORESRCS = uart_posix.c \
105 uart_win32.c \
106 util.c \
107 util_posix.c \
108 ui.c \
109 comms.c
110
111 CMDSRCS = $(SRC_SMARTCARD) \
112 crapto1/crapto1.c\
113 crapto1/crypto1.c\
114 crypto/libpcrypto.c\
115 crypto/asn1utils.c\
116 crypto/asn1dump.c\
117 cliparser/argtable3.c\
118 cliparser/cliparser.c\
119 fido/additional_ca.c \
120 fido/cose.c \
121 fido/cbortools.c \
122 fido/fidocore.c \
123 mfkey.c \
124 loclass/cipher.c \
125 loclass/cipherutils.c \
126 loclass/ikeys.c \
127 loclass/elite_crack.c\
128 loclass/fileutils.c\
129 whereami.c\
130 mifarehost.c\
131 mifare4.c\
132 parity.c\
133 crc.c \
134 crc16.c \
135 crc64.c \
136 iso14443crc.c \
137 iso15693tools.c \
138 graph.c \
139 cmddata.c \
140 lfdemod.c \
141 emv/crypto_polarssl.c\
142 emv/crypto.c\
143 emv/emv_pk.c\
144 emv/emv_pki.c\
145 emv/emv_pki_priv.c\
146 emv/test/cryptotest.c\
147 emv/apduinfo.c\
148 emv/dump.c\
149 emv/tlv.c\
150 emv/emv_tags.c\
151 emv/dol.c\
152 emv/emvjson.c\
153 emv/emvcore.c\
154 emv/test/crypto_test.c\
155 emv/test/sda_test.c\
156 emv/test/dda_test.c\
157 emv/test/cda_test.c\
158 emv/cmdemv.c\
159 emv/emv_roca.c \
160 cmdhf.c \
161 cmdhflist.c \
162 cmdhf14a.c \
163 cmdhf14b.c \
164 cmdhf15.c \
165 cmdhfepa.c \
166 cmdhflegic.c \
167 cmdhficlass.c \
168 cmdhfmf.c \
169 cmdhfmfp.c \
170 cmdhfmfu.c \
171 cmdhfmfhard.c \
172 hardnested/hardnested_bruteforce.c \
173 cmdhftopaz.c \
174 cmdhffido.c \
175 cmdhw.c \
176 cmdlf.c \
177 cmdlfawid.c \
178 cmdlfcotag.c\
179 cmdlfem4x.c \
180 cmdlffdx.c \
181 cmdlfgproxii.c \
182 hidcardformatutils.c\
183 hidcardformats.c\
184 cmdlfhid.c \
185 cmdlfhitag.c \
186 cmdlfio.c \
187 cmdlfindala.c \
188 cmdlfjablotron.c \
189 cmdlfnexwatch.c \
190 cmdlfnoralsy.c \
191 cmdlfparadox.c \
192 cmdlfpcf7931.c \
193 cmdlfpresco.c \
194 cmdlfpyramid.c \
195 cmdlfsecurakey.c \
196 cmdlft55xx.c \
197 cmdlfti.c \
198 cmdlfviking.c\
199 cmdlfvisa2000.c\
200 cmdlfpac.c\
201 cmdparser.c \
202 cmdmain.c \
203 scripting.c\
204 cmdscript.c\
205 pm3_binlib.c\
206 pm3_bitlib.c\
207 protocols.c
208
209 cpu_arch = $(shell uname -m)
210 ifneq ($(findstring 86, $(cpu_arch)), )
211 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
212 endif
213 ifneq ($(findstring amd64, $(cpu_arch)), )
214 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
215 endif
216 ifeq ($(MULTIARCHSRCS), )
217 CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
218 endif
219
220 ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
221 ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
222 #-DDEBUG -Dverbose=1
223
224 QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
225
226 COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
227 CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
228 OBJCOBJS = $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
229 ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
230 MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
231 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
232 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
233 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX.o) \
234 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX2.o)
235
236 SUPPORTS_AVX512 := $(shell echo | gcc -E -mavx512f - > /dev/null 2>&1 && echo "True" )
237 HARD_SWITCH_NOSIMD = -mno-mmx -mno-sse2 -mno-avx -mno-avx2
238 HARD_SWITCH_MMX = -mmmx -mno-sse2 -mno-avx -mno-avx2
239 HARD_SWITCH_SSE2 = -mmmx -msse2 -mno-avx -mno-avx2
240 HARD_SWITCH_AVX = -mmmx -msse2 -mavx -mno-avx2
241 HARD_SWITCH_AVX2 = -mmmx -msse2 -mavx -mavx2
242 HARD_SWITCH_AVX512 = -mmmx -msse2 -mavx -mavx2 -mavx512f
243 ifeq "$(SUPPORTS_AVX512)" "True"
244 HARD_SWITCH_NOSIMD += -mno-avx512f
245 HARD_SWITCH_MMX += -mno-avx512f
246 HARD_SWITCH_SSE2 += -mno-avx512f
247 HARD_SWITCH_AVX += -mno-avx512f
248 HARD_SWITCH_AVX2 += -mno-avx512f
249 MULTIARCHOBJS += $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX512.o)
250 endif
251
252 BINS = proxmark3 flasher fpga_compress
253 WINBINS = $(patsubst %, %.exe, $(BINS))
254 CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h lualibs/usb_cmd.lua
255
256 # need to assign dependancies to build these first...
257 all: lua_build jansson_build mbedtls_build cbor_build $(BINS)
258
259 all-static: LDLIBS:=-static $(LDLIBS)
260 all-static: proxmark3 flasher fpga_compress
261
262 proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(QTLDLIBS)
263 proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/usb_cmd.lua
264 $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@
265
266 flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS) $(OBJCOBJS)
267 $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
268
269 fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
270 $(LD) $(LDFLAGS) $(ZLIBFLAGS) $^ $(LDLIBS) -o $@
271
272 proxgui.cpp: ui/ui_overlays.h
273
274 proxguiqt.moc.cpp: proxguiqt.h
275 $(MOC) -o$@ $^
276
277 ui/ui_overlays.h: ui/overlays.ui
278 $(UIC) $^ > $@
279
280 lualibs/usb_cmd.lua: ../include/usb_cmd.h
281 awk -f usb_cmd_h2lua.awk $^ > $@
282
283 clean:
284 $(RM) $(CLEAN)
285 cd ../liblua && make clean
286 cd $(JANSSONLIBPATH) && make clean
287 cd $(MBEDTLSLIBPATH) && make clean
288 cd $(CBORLIBPATH) && make clean
289
290 tarbin: $(BINS)
291 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
292
293 lua_build:
294 @echo Compiling liblua, using platform $(LUAPLATFORM)
295 cd ../liblua && make $(LUAPLATFORM)
296
297 jansson_build:
298 @echo Compiling jansson
299 cd $(JANSSONLIBPATH) && make all
300
301 mbedtls_build:
302 @echo Compiling mbedtls
303 cd $(MBEDTLSLIBPATH) && make all
304
305 cbor_build:
306 @echo Compiling tinycbor
307 cd $(CBORLIBPATH) && make all
308
309 .PHONY: all clean
310
311 $(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
312 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
313
314 $(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
315 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
316
317 $(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
318 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
319
320 $(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
321 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
322
323 $(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
324 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
325
326 $(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
327 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
328
329 %.o: %.c
330 $(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
331 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
332 $(POSTCOMPILE)
333
334 %.o: %.cpp
335 $(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
336 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
337 $(POSTCOMPILE)
338
339 %.o: %.m
340 $(OBJDIR)/%.o : %.m $(OBJDIR)/%.d
341 $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
342 $(POSTCOMPILE)
343
344 #$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
345 # $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
346 # $(POSTCOMPILE)
347
348 #$(ZLIBOBJS): $(notdir $(%.c)) %.d
349 # $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
350 # $(POSTCOMPILE)
351
352 #$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
353 # $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
354 # $(POSTCOMPILE)
355
356 DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
357 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
358 $(patsubst %.m, $(OBJDIR)/%.d, $(OBJCSRCS)) \
359 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
360
361 $(DEPENDENCY_FILES): ;
362 .PRECIOUS: $(DEPENDENCY_FILES)
363
364 -include $(DEPENDENCY_FILES)
Impressum, Datenschutz