]> git.zerfleddert.de Git - proxmark3-svn/blame - client/Makefile
fix 'hf iclass sim'
[proxmark3-svn] / client / Makefile
CommitLineData
a553f267 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#-----------------------------------------------------------------------------
bd846386 6
fb9acd45 7CC = gcc
8CXX = g++
9LD = g++
10TAR = tar
11TARFLAGS = -C .. --ignore-failed-read -rvf
12RM = rm -f
13MV = mv
806dc075 14
f53eb07d 15ENV_LDFLAGS := $(LDFLAGS)
16ENV_CFLAGS := $(CFLAGS)
067bfc8b 17VPATH = ../common ../zlib ../uart
46cd4046 18OBJDIR = obj
7fe9b0b7 19
94e27a09 20LDLIBS = -L/opt/local/lib -L/usr/local/lib -lreadline -lpthread -lm
e6153040 21LUALIB = ../liblua/liblua.a
556826b5
OM
22JANSSONLIBPATH = ./jansson
23JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
700d8687
OM
24MBEDTLSLIBPATH = ../common/mbedtls
25MBEDTLSLIB = $(MBEDTLSLIBPATH)/libmbedtls.a
0bb51450
OM
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)
f53eb07d 30LDFLAGS = $(ENV_LDFLAGS)
0bb51450 31CFLAGS = $(ENV_CFLAGS) -std=c99 -D_ISOC99_SOURCE $(INCLUDES_CLIENT) -Wall -g -O3
3851172d 32CXXFLAGS = -I../include -Wall -O3
8c04722d 33
5125e426 34APP_CFLAGS =
35include ../common/Makefile_Enabled_Options.common
36CFLAGS += $(APP_CFLAGS)
43591e64 37ifneq (,$(findstring WITH_SMARTCARD,$(APP_CFLAGS)))
a9104f7e 38 SRC_SMARTCARD = cmdsmartcard.c pcsc.c
43591e64 39else
40 SRC_SMARTCARD =
41endif
5125e426 42
fb9acd45 43platform = $(shell uname)
a9104f7e 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
8691f5b7 59ifneq (,$(findstring MINGW,$(platform)))
2a537311 60 LUAPLATFORM = mingw
8691f5b7 61else
fb9acd45 62 ifeq ($(platform),Darwin)
63 LUAPLATFORM = macosx
2a537311 64 OBJCSRCS = util_darwin.m
b742ab8c 65 LDFLAGS += -framework Foundation -framework AppKit
fb9acd45 66 else
67 LUALIB += -ldl
68 LDLIBS += -ltermcap -lncurses
69 LUAPLATFORM = linux
70 endif
62b1302c 71endif
72
5125e426 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
3472ebe5 100 endif
3472ebe5 101 endif
102endif
103
104
105ifneq ($(QTLDLIBS), )
fb9acd45 106 QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
8c04722d 107 CFLAGS += -DHAVE_GUI
245e844e 108else
fb9acd45 109 QTGUIOBJS = $(OBJDIR)/guidummy.o
245e844e 110endif
62b1302c 111
fb9acd45 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
759c16b3 116
5125e426 117
067bfc8b
MF
118CORESRCS = uart_posix.c \
119 uart_win32.c \
ec9c7112 120 util.c \
ad939de5 121 util_posix.c \
122 ui.c \
123 comms.c
759c16b3 124
43591e64 125CMDSRCS = $(SRC_SMARTCARD) \
126 crapto1/crapto1.c\
33443e7c 127 crapto1/crypto1.c\
700d8687
OM
128 crypto/libpcrypto.c\
129 crypto/asn1utils.c\
6b882a39 130 crypto/asn1dump.c\
6e3d8d67
OM
131 cliparser/argtable3.c\
132 cliparser/cliparser.c\
6b882a39 133 fido/additional_ca.c \
0bb51450
OM
134 fido/cose.c \
135 fido/cbortools.c \
136 fido/fidocore.c \
fdd9395d 137 mifare/mfkey.c \
db2b81ba 138 loclass/cipher.c \
139 loclass/cipherutils.c \
db2b81ba 140 loclass/ikeys.c \
141 loclass/elite_crack.c\
142 loclass/fileutils.c\
4197a3f6 143 whereami.c\
fdd9395d
OM
144 mifare/mifarehost.c\
145 mifare/mifare4.c\
146 mifare/mad.c \
147 mifare/ndef.c \
1f065e1d 148 parity.c\
9f7bbd24 149 crc.c \
91c38cf7 150 crc16.c \
d730878d 151 crc64.c \
91c38cf7 152 iso14443crc.c \
9455b51c 153 iso15693tools.c \
7fe9b0b7 154 graph.c \
7fe9b0b7 155 cmddata.c \
eb191de6 156 lfdemod.c \
d03fb293
OM
157 emv/crypto_polarssl.c\
158 emv/crypto.c\
159 emv/emv_pk.c\
160 emv/emv_pki.c\
161 emv/emv_pki_priv.c\
162 emv/test/cryptotest.c\
fe346768 163 emv/apduinfo.c\
a2bb2735 164 emv/dump.c\
165 emv/tlv.c\
166 emv/emv_tags.c\
3c5fce2b 167 emv/dol.c\
95b697f0 168 emv/emvjson.c\
a2bb2735 169 emv/emvcore.c\
d03fb293
OM
170 emv/test/crypto_test.c\
171 emv/test/sda_test.c\
172 emv/test/dda_test.c\
173 emv/test/cda_test.c\
3c5fce2b 174 emv/cmdemv.c\
1511ea28 175 emv/emv_roca.c \
7fe9b0b7 176 cmdhf.c \
4f131b53 177 cmdhflist.c \
7fe9b0b7 178 cmdhf14a.c \
179 cmdhf14b.c \
180 cmdhf15.c \
5acd09bd 181 cmdhfepa.c \
7fe9b0b7 182 cmdhflegic.c \
cee5a30d 183 cmdhficlass.c \
9ca155ba 184 cmdhfmf.c \
dc3e2acf 185 cmdhfmfp.c \
fe81b478 186 cmdhfmfu.c \
c48c4d78 187 cmdhfmfhard.c \
188 hardnested/hardnested_bruteforce.c \
db2b81ba 189 cmdhftopaz.c \
39cc1c87 190 cmdhffido.c \
7fe9b0b7 191 cmdhw.c \
192 cmdlf.c \
dbf6e824 193 cmdlfawid.c \
8b6abef5 194 cmdlfcotag.c\
28fdb04f 195 cmdlfem4x.c \
4db6f3bb 196 cmdlffdx.c \
946a84c3 197 cmdlfgproxii.c \
b5a5fc4d 198 hidcardformatutils.c\
199 hidcardformats.c\
8b6abef5 200 cmdlfhid.c \
db09cb3a 201 cmdlfhitag.c \
8b6abef5 202 cmdlfio.c \
0fb65a26 203 cmdlfindala.c \
a9968da3 204 cmdlfjablotron.c \
5bce72d5 205 cmdlfnexwatch.c \
a9968da3 206 cmdlfnoralsy.c \
5bce72d5 207 cmdlfparadox.c \
c3caf040 208 cmdlfpcf7931.c \
209 cmdlfpresco.c \
210 cmdlfpyramid.c \
211 cmdlfsecurakey.c \
8b6abef5 212 cmdlft55xx.c \
213 cmdlfti.c \
214 cmdlfviking.c\
215 cmdlfvisa2000.c\
48d41dc3 216 cmdlfpac.c\
8b6abef5 217 cmdparser.c \
218 cmdmain.c \
a0655c45 219 scripting.c\
806dc075 220 cmdscript.c\
8b6abef5 221 pm3_binlib.c\
77cd612f 222 pm3_bitlib.c\
1338d245 223 protocols.c\
224 taginfo.c
28fdb04f 225
af7a1f70 226cpu_arch = $(shell uname -m)
227ifneq ($(findstring 86, $(cpu_arch)), )
228 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
229endif
6b758d65 230ifneq ($(findstring amd64, $(cpu_arch)), )
af7a1f70 231 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
232endif
233ifeq ($(MULTIARCHSRCS), )
234 CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
235endif
c48c4d78 236
4b3f6d79 237ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
fb9acd45 238ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
8e074056 239#-DDEBUG -Dverbose=1
0fa01ec7 240
fb9acd45 241QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
a0655c45 242
759c16b3 243COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
46cd4046 244CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
2a537311 245OBJCOBJS = $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
f3919878 246ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
c48c4d78 247MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
248 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
249 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
250 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX.o) \
5dd5bfb2 251 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX2.o)
252
1ff75f16 253SUPPORTS_AVX512 := $(shell echo | gcc -E -mavx512f - > /dev/null 2>&1 && echo "True" )
5dd5bfb2 254HARD_SWITCH_NOSIMD = -mno-mmx -mno-sse2 -mno-avx -mno-avx2
255HARD_SWITCH_MMX = -mmmx -mno-sse2 -mno-avx -mno-avx2
256HARD_SWITCH_SSE2 = -mmmx -msse2 -mno-avx -mno-avx2
257HARD_SWITCH_AVX = -mmmx -msse2 -mavx -mno-avx2
258HARD_SWITCH_AVX2 = -mmmx -msse2 -mavx -mavx2
259HARD_SWITCH_AVX512 = -mmmx -msse2 -mavx -mavx2 -mavx512f
de1e68d3 260ifeq "$(SUPPORTS_AVX512)" "True"
5dd5bfb2 261 HARD_SWITCH_NOSIMD += -mno-avx512f
262 HARD_SWITCH_MMX += -mno-avx512f
263 HARD_SWITCH_SSE2 += -mno-avx512f
264 HARD_SWITCH_AVX += -mno-avx512f
265 HARD_SWITCH_AVX2 += -mno-avx512f
266 MULTIARCHOBJS += $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX512.o)
267endif
c48c4d78 268
fb9acd45 269BINS = proxmark3 flasher fpga_compress
270WINBINS = $(patsubst %, %.exe, $(BINS))
1511ea28 271CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h lualibs/usb_cmd.lua
940a2012 272
3fc4596f 273# need to assign dependancies to build these first...
0bb51450 274all: lua_build jansson_build mbedtls_build cbor_build $(BINS)
6658905f 275
709b784c 276all-static: LDLIBS:=-static $(LDLIBS)
fb9acd45 277all-static: proxmark3 flasher fpga_compress
f3919878 278
a9104f7e 279proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(MBEDTLSLIB) $(CBORLIB) $(QTLDLIBS) $(PCSC_LIBS)
2a537311
A
280proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/usb_cmd.lua
281 $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@
db917a16 282
2a537311 283flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS) $(OBJCOBJS)
fb9acd45 284 $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
46cd4046 285
f3919878 286fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
fb9acd45 287 $(LD) $(LDFLAGS) $(ZLIBFLAGS) $^ $(LDLIBS) -o $@
06735128 288
5dd5bfb2 289proxgui.cpp: ui/ui_overlays.h
290
6658905f 291proxguiqt.moc.cpp: proxguiqt.h
292 $(MOC) -o$@ $^
293
3fc4596f 294ui/ui_overlays.h: ui/overlays.ui
295 $(UIC) $^ > $@
27882d37 296
fb9acd45 297lualibs/usb_cmd.lua: ../include/usb_cmd.h
298 awk -f usb_cmd_h2lua.awk $^ > $@
299
6658905f 300clean:
940a2012 301 $(RM) $(CLEAN)
3a4c72fe 302 cd ../liblua && make clean
0bb51450 303 cd $(JANSSONLIBPATH) && make clean
700d8687 304 cd $(MBEDTLSLIBPATH) && make clean
0bb51450 305 cd $(CBORLIBPATH) && make clean
6658905f 306
bd846386 307tarbin: $(BINS)
fb9acd45 308 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
bd846386 309
806dc075 310lua_build:
30a46ed8 311 @echo Compiling liblua, using platform $(LUAPLATFORM)
312 cd ../liblua && make $(LUAPLATFORM)
556826b5
OM
313
314jansson_build:
315 @echo Compiling jansson
1511ea28 316 cd $(JANSSONLIBPATH) && make all
700d8687
OM
317
318mbedtls_build:
319 @echo Compiling mbedtls
320 cd $(MBEDTLSLIBPATH) && make all
0bb51450
OM
321
322cbor_build:
323 @echo Compiling tinycbor
324 cd $(CBORLIBPATH) && make all
325
6658905f 326.PHONY: all clean
fb9acd45 327
c48c4d78 328$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
5dd5bfb2 329 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
c48c4d78 330
331$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 332 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
c48c4d78 333
334$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 335 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
c48c4d78 336
337$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 338 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
c48c4d78 339
340$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 341 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
c48c4d78 342
343$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
5dd5bfb2 344 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
c48c4d78 345
fb9acd45 346%.o: %.c
347$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
a9104f7e 348 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) $(PCSC_INCLUDES) -c -o $@ $<
fb9acd45 349 $(POSTCOMPILE)
350
351%.o: %.cpp
352$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
3472ebe5 353 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
fb9acd45 354 $(POSTCOMPILE)
355
2a537311
A
356%.o: %.m
357$(OBJDIR)/%.o : %.m $(OBJDIR)/%.d
358 $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
359 $(POSTCOMPILE)
fb9acd45 360
361#$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
362# $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
363# $(POSTCOMPILE)
364
365#$(ZLIBOBJS): $(notdir $(%.c)) %.d
366# $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
367# $(POSTCOMPILE)
368
369#$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
370# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
371# $(POSTCOMPILE)
372
1985eb7c 373DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
fb9acd45 374 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
2a537311 375 $(patsubst %.m, $(OBJDIR)/%.d, $(OBJCSRCS)) \
fb9acd45 376 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
377
378$(DEPENDENCY_FILES): ;
379.PRECIOUS: $(DEPENDENCY_FILES)
380
381-include $(DEPENDENCY_FILES)
Impressum, Datenschutz