]> git.zerfleddert.de Git - proxmark3-svn/blame - client/Makefile
added EMV tag #9F6E (#676)
[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
f53eb07d 24LDFLAGS = $(ENV_LDFLAGS)
556826b5 25CFLAGS = $(ENV_CFLAGS) -std=c99 -D_ISOC99_SOURCE -I. -I../include -I../common -I../common/polarssl -I../zlib -I../uart -I/opt/local/include -I../liblua -I$(JANSSONLIBPATH) -Wall -g -O3
3851172d 26CXXFLAGS = -I../include -Wall -O3
8c04722d 27
5125e426 28APP_CFLAGS =
29include ../common/Makefile_Enabled_Options.common
30CFLAGS += $(APP_CFLAGS)
43591e64 31ifneq (,$(findstring WITH_SMARTCARD,$(APP_CFLAGS)))
32 SRC_SMARTCARD = cmdsmartcard.c
33else
34 SRC_SMARTCARD =
35endif
5125e426 36
3472ebe5 37LUAPLATFORM = generic
fb9acd45 38platform = $(shell uname)
8691f5b7 39ifneq (,$(findstring MINGW,$(platform)))
fb9acd45 40 LUAPLATFORM = mingw
8691f5b7 41else
fb9acd45 42 ifeq ($(platform),Darwin)
43 LUAPLATFORM = macosx
44 else
45 LUALIB += -ldl
46 LDLIBS += -ltermcap -lncurses
47 LUAPLATFORM = linux
48 endif
62b1302c 49endif
50
5125e426 51ifneq (,$(findstring WITH_GUI,$(APP_CFLAGS)))
52 # Check for correctly configured Qt5
53 QTINCLUDES = $(shell pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
54 QTLDLIBS = $(shell pkg-config --libs Qt5Core Qt5Widgets 2>/dev/null)
55 MOC = $(shell pkg-config --variable=host_bins Qt5Core)/moc
56 UIC = $(shell pkg-config --variable=host_bins Qt5Core)/uic
57 ifeq ($(QTINCLUDES), )
58 # if Qt5 not found check for correctly configured Qt4
59 QTINCLUDES = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null)
60 QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
61 MOC = $(shell pkg-config --variable=moc_location QtCore)
62 UIC = $(shell pkg-config --variable=uic_location QtCore)
63 else
64 CXXFLAGS += -std=c++11 -fPIC
65 endif
66 ifeq ($(QTINCLUDES), )
67 # if both pkg-config commands failed, search in common places
68 ifneq ($(QTDIR), )
69 QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
70 QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4
71 ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
72 QTINCLUDES += -I$(QTDIR)/include/QtWidgets
73 QTLDLIBS = -L$(QTDIR)/lib -lQt5Widgets -lQt5Gui -lQt5Core
74 CXXFLAGS += -std=c++11 -fPIC
75 endif
76 MOC = $(QTDIR)/bin/moc
77 UIC = $(QTDIR)/bin/uic
3472ebe5 78 endif
3472ebe5 79 endif
80endif
81
82
83ifneq ($(QTLDLIBS), )
fb9acd45 84 QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
8c04722d 85 CFLAGS += -DHAVE_GUI
245e844e 86else
fb9acd45 87 QTGUIOBJS = $(OBJDIR)/guidummy.o
245e844e 88endif
62b1302c 89
fb9acd45 90# Flags to generate temporary dependency files
91DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
92# make temporary to final dependeny files after successful compilation
93POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d
759c16b3 94
5125e426 95
067bfc8b
MF
96CORESRCS = uart_posix.c \
97 uart_win32.c \
ec9c7112 98 util.c \
ad939de5 99 util_posix.c \
100 ui.c \
101 comms.c
759c16b3 102
43591e64 103CMDSRCS = $(SRC_SMARTCARD) \
104 crapto1/crapto1.c\
33443e7c 105 crapto1/crypto1.c\
930763e8 106 polarssl/des.c \
107 polarssl/aes.c\
d03fb293
OM
108 polarssl/bignum.c\
109 polarssl/rsa.c\
110 polarssl/sha1.c\
6e3d8d67
OM
111 cliparser/argtable3.c\
112 cliparser/cliparser.c\
4cb4b588 113 mfkey.c\
db2b81ba 114 loclass/cipher.c \
115 loclass/cipherutils.c \
db2b81ba 116 loclass/ikeys.c \
117 loclass/elite_crack.c\
118 loclass/fileutils.c\
4197a3f6 119 whereami.c\
f397b5cc 120 mifarehost.c\
1f065e1d 121 parity.c\
9f7bbd24 122 crc.c \
91c38cf7 123 crc16.c \
d730878d 124 crc64.c \
91c38cf7 125 iso14443crc.c \
9455b51c 126 iso15693tools.c \
7fe9b0b7 127 graph.c \
7fe9b0b7 128 cmddata.c \
eb191de6 129 lfdemod.c \
d03fb293
OM
130 emv/crypto_polarssl.c\
131 emv/crypto.c\
132 emv/emv_pk.c\
133 emv/emv_pki.c\
134 emv/emv_pki_priv.c\
135 emv/test/cryptotest.c\
fe346768 136 emv/apduinfo.c\
a2bb2735 137 emv/dump.c\
138 emv/tlv.c\
139 emv/emv_tags.c\
3c5fce2b 140 emv/dol.c\
a2bb2735 141 emv/emvcore.c\
d03fb293
OM
142 emv/test/crypto_test.c\
143 emv/test/sda_test.c\
144 emv/test/dda_test.c\
145 emv/test/cda_test.c\
3c5fce2b 146 emv/cmdemv.c\
7fe9b0b7 147 cmdhf.c \
4f131b53 148 cmdhflist.c \
7fe9b0b7 149 cmdhf14a.c \
150 cmdhf14b.c \
151 cmdhf15.c \
5acd09bd 152 cmdhfepa.c \
7fe9b0b7 153 cmdhflegic.c \
cee5a30d 154 cmdhficlass.c \
9ca155ba 155 cmdhfmf.c \
fe81b478 156 cmdhfmfu.c \
c48c4d78 157 cmdhfmfhard.c \
158 hardnested/hardnested_bruteforce.c \
db2b81ba 159 cmdhftopaz.c \
7fe9b0b7 160 cmdhw.c \
161 cmdlf.c \
dbf6e824 162 cmdlfawid.c \
8b6abef5 163 cmdlfcotag.c\
28fdb04f 164 cmdlfem4x.c \
4db6f3bb 165 cmdlffdx.c \
946a84c3 166 cmdlfgproxii.c \
8b6abef5 167 cmdlfhid.c \
db09cb3a 168 cmdlfhitag.c \
8b6abef5 169 cmdlfio.c \
0fb65a26 170 cmdlfindala.c \
a9968da3 171 cmdlfjablotron.c \
5bce72d5 172 cmdlfnexwatch.c \
a9968da3 173 cmdlfnoralsy.c \
5bce72d5 174 cmdlfparadox.c \
c3caf040 175 cmdlfpcf7931.c \
176 cmdlfpresco.c \
177 cmdlfpyramid.c \
178 cmdlfsecurakey.c \
8b6abef5 179 cmdlft55xx.c \
180 cmdlfti.c \
181 cmdlfviking.c\
182 cmdlfvisa2000.c\
48d41dc3 183 cmdlfpac.c\
8b6abef5 184 cmdparser.c \
185 cmdmain.c \
a0655c45 186 scripting.c\
806dc075 187 cmdscript.c\
8b6abef5 188 pm3_binlib.c\
77cd612f 189 pm3_bitlib.c\
ad939de5 190 protocols.c
28fdb04f 191
af7a1f70 192cpu_arch = $(shell uname -m)
193ifneq ($(findstring 86, $(cpu_arch)), )
194 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
195endif
6b758d65 196ifneq ($(findstring amd64, $(cpu_arch)), )
af7a1f70 197 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
198endif
199ifeq ($(MULTIARCHSRCS), )
200 CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
201endif
c48c4d78 202
4b3f6d79 203ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
fb9acd45 204ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
8e074056 205#-DDEBUG -Dverbose=1
0fa01ec7 206
fb9acd45 207QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
a0655c45 208
759c16b3 209COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
46cd4046 210CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
f3919878 211ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
c48c4d78 212MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
213 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
214 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
215 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX.o) \
5dd5bfb2 216 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX2.o)
217
1ff75f16 218SUPPORTS_AVX512 := $(shell echo | gcc -E -mavx512f - > /dev/null 2>&1 && echo "True" )
5dd5bfb2 219HARD_SWITCH_NOSIMD = -mno-mmx -mno-sse2 -mno-avx -mno-avx2
220HARD_SWITCH_MMX = -mmmx -mno-sse2 -mno-avx -mno-avx2
221HARD_SWITCH_SSE2 = -mmmx -msse2 -mno-avx -mno-avx2
222HARD_SWITCH_AVX = -mmmx -msse2 -mavx -mno-avx2
223HARD_SWITCH_AVX2 = -mmmx -msse2 -mavx -mavx2
224HARD_SWITCH_AVX512 = -mmmx -msse2 -mavx -mavx2 -mavx512f
de1e68d3 225ifeq "$(SUPPORTS_AVX512)" "True"
5dd5bfb2 226 HARD_SWITCH_NOSIMD += -mno-avx512f
227 HARD_SWITCH_MMX += -mno-avx512f
228 HARD_SWITCH_SSE2 += -mno-avx512f
229 HARD_SWITCH_AVX += -mno-avx512f
230 HARD_SWITCH_AVX2 += -mno-avx512f
231 MULTIARCHOBJS += $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX512.o)
232endif
c48c4d78 233
fb9acd45 234BINS = proxmark3 flasher fpga_compress
235WINBINS = $(patsubst %, %.exe, $(BINS))
c48c4d78 236CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h
940a2012 237
3fc4596f 238# need to assign dependancies to build these first...
556826b5 239all: lua_build jansson_build $(BINS)
6658905f 240
709b784c 241all-static: LDLIBS:=-static $(LDLIBS)
fb9acd45 242all-static: proxmark3 flasher fpga_compress
f3919878 243
556826b5 244proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(QTLDLIBS)
7f9e4c25 245proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/usb_cmd.lua
246 $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@
db917a16 247
759c16b3 248flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS)
fb9acd45 249 $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
46cd4046 250
f3919878 251fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
fb9acd45 252 $(LD) $(LDFLAGS) $(ZLIBFLAGS) $^ $(LDLIBS) -o $@
06735128 253
5dd5bfb2 254proxgui.cpp: ui/ui_overlays.h
255
6658905f 256proxguiqt.moc.cpp: proxguiqt.h
257 $(MOC) -o$@ $^
258
3fc4596f 259ui/ui_overlays.h: ui/overlays.ui
260 $(UIC) $^ > $@
27882d37 261
fb9acd45 262lualibs/usb_cmd.lua: ../include/usb_cmd.h
263 awk -f usb_cmd_h2lua.awk $^ > $@
264
6658905f 265clean:
940a2012 266 $(RM) $(CLEAN)
3a4c72fe 267 cd ../liblua && make clean
556826b5 268 cd ./jansson && make clean
6658905f 269
bd846386 270tarbin: $(BINS)
fb9acd45 271 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
bd846386 272
806dc075 273lua_build:
30a46ed8 274 @echo Compiling liblua, using platform $(LUAPLATFORM)
275 cd ../liblua && make $(LUAPLATFORM)
556826b5
OM
276
277jansson_build:
278 @echo Compiling jansson
279 cd ./jansson && make all
806dc075 280
6658905f 281.PHONY: all clean
fb9acd45 282
c48c4d78 283$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
5dd5bfb2 284 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
c48c4d78 285
286$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 287 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
c48c4d78 288
289$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 290 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
c48c4d78 291
292$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 293 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
c48c4d78 294
295$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 296 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
c48c4d78 297
298$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
5dd5bfb2 299 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
c48c4d78 300
fb9acd45 301%.o: %.c
302$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
303 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
304 $(POSTCOMPILE)
305
306%.o: %.cpp
307$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
3472ebe5 308 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
fb9acd45 309 $(POSTCOMPILE)
310
311
312#$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
313# $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
314# $(POSTCOMPILE)
315
316#$(ZLIBOBJS): $(notdir $(%.c)) %.d
317# $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
318# $(POSTCOMPILE)
319
320#$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
321# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
322# $(POSTCOMPILE)
323
1985eb7c 324DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
fb9acd45 325 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
326 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
327
328$(DEPENDENCY_FILES): ;
329.PRECIOUS: $(DEPENDENCY_FILES)
330
331-include $(DEPENDENCY_FILES)
Impressum, Datenschutz