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