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