Add Smartcard functions (RDV4.0) (#646)
[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\
4cb4b588 109 mfkey.c\
db2b81ba 110 loclass/cipher.c \
111 loclass/cipherutils.c \
db2b81ba 112 loclass/ikeys.c \
113 loclass/elite_crack.c\
114 loclass/fileutils.c\
4197a3f6 115 whereami.c\
f397b5cc 116 mifarehost.c\
1f065e1d 117 parity.c\
9f7bbd24 118 crc.c \
91c38cf7 119 crc16.c \
d730878d 120 crc64.c \
91c38cf7 121 iso14443crc.c \
9455b51c 122 iso15693tools.c \
7fe9b0b7 123 graph.c \
7fe9b0b7 124 cmddata.c \
eb191de6 125 lfdemod.c \
d03fb293
OM
126 emv/crypto_polarssl.c\
127 emv/crypto.c\
128 emv/emv_pk.c\
129 emv/emv_pki.c\
130 emv/emv_pki_priv.c\
131 emv/test/cryptotest.c\
fe346768 132 emv/apduinfo.c\
a2bb2735 133 emv/dump.c\
134 emv/tlv.c\
135 emv/emv_tags.c\
3c5fce2b 136 emv/dol.c\
a2bb2735 137 emv/emvcore.c\
d03fb293
OM
138 emv/test/crypto_test.c\
139 emv/test/sda_test.c\
140 emv/test/dda_test.c\
141 emv/test/cda_test.c\
3c5fce2b 142 emv/cmdemv.c\
7fe9b0b7 143 cmdhf.c \
4f131b53 144 cmdhflist.c \
7fe9b0b7 145 cmdhf14a.c \
146 cmdhf14b.c \
147 cmdhf15.c \
5acd09bd 148 cmdhfepa.c \
7fe9b0b7 149 cmdhflegic.c \
cee5a30d 150 cmdhficlass.c \
9ca155ba 151 cmdhfmf.c \
fe81b478 152 cmdhfmfu.c \
c48c4d78 153 cmdhfmfhard.c \
154 hardnested/hardnested_bruteforce.c \
db2b81ba 155 cmdhftopaz.c \
7fe9b0b7 156 cmdhw.c \
157 cmdlf.c \
dbf6e824 158 cmdlfawid.c \
8b6abef5 159 cmdlfcotag.c\
28fdb04f 160 cmdlfem4x.c \
4db6f3bb 161 cmdlffdx.c \
946a84c3 162 cmdlfgproxii.c \
8b6abef5 163 cmdlfhid.c \
db09cb3a 164 cmdlfhitag.c \
8b6abef5 165 cmdlfio.c \
0fb65a26 166 cmdlfindala.c \
a9968da3 167 cmdlfjablotron.c \
5bce72d5 168 cmdlfnexwatch.c \
a9968da3 169 cmdlfnoralsy.c \
5bce72d5 170 cmdlfparadox.c \
c3caf040 171 cmdlfpcf7931.c \
172 cmdlfpresco.c \
173 cmdlfpyramid.c \
174 cmdlfsecurakey.c \
8b6abef5 175 cmdlft55xx.c \
176 cmdlfti.c \
177 cmdlfviking.c\
178 cmdlfvisa2000.c\
48d41dc3 179 cmdlfpac.c\
8b6abef5 180 cmdparser.c \
181 cmdmain.c \
a0655c45 182 scripting.c\
806dc075 183 cmdscript.c\
8b6abef5 184 pm3_binlib.c\
77cd612f 185 pm3_bitlib.c\
ad939de5 186 protocols.c
28fdb04f 187
af7a1f70 188cpu_arch = $(shell uname -m)
189ifneq ($(findstring 86, $(cpu_arch)), )
190 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
191endif
6b758d65 192ifneq ($(findstring amd64, $(cpu_arch)), )
af7a1f70 193 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
194endif
195ifeq ($(MULTIARCHSRCS), )
196 CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
197endif
c48c4d78 198
4b3f6d79 199ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
fb9acd45 200ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
8e074056 201#-DDEBUG -Dverbose=1
0fa01ec7 202
fb9acd45 203QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
a0655c45 204
759c16b3 205COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
46cd4046 206CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
f3919878 207ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
c48c4d78 208MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
209 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
210 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
211 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX.o) \
5dd5bfb2 212 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX2.o)
213
1ff75f16 214SUPPORTS_AVX512 := $(shell echo | gcc -E -mavx512f - > /dev/null 2>&1 && echo "True" )
5dd5bfb2 215HARD_SWITCH_NOSIMD = -mno-mmx -mno-sse2 -mno-avx -mno-avx2
216HARD_SWITCH_MMX = -mmmx -mno-sse2 -mno-avx -mno-avx2
217HARD_SWITCH_SSE2 = -mmmx -msse2 -mno-avx -mno-avx2
218HARD_SWITCH_AVX = -mmmx -msse2 -mavx -mno-avx2
219HARD_SWITCH_AVX2 = -mmmx -msse2 -mavx -mavx2
220HARD_SWITCH_AVX512 = -mmmx -msse2 -mavx -mavx2 -mavx512f
de1e68d3 221ifeq "$(SUPPORTS_AVX512)" "True"
5dd5bfb2 222 HARD_SWITCH_NOSIMD += -mno-avx512f
223 HARD_SWITCH_MMX += -mno-avx512f
224 HARD_SWITCH_SSE2 += -mno-avx512f
225 HARD_SWITCH_AVX += -mno-avx512f
226 HARD_SWITCH_AVX2 += -mno-avx512f
227 MULTIARCHOBJS += $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX512.o)
228endif
c48c4d78 229
fb9acd45 230BINS = proxmark3 flasher fpga_compress
231WINBINS = $(patsubst %, %.exe, $(BINS))
c48c4d78 232CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h
940a2012 233
3fc4596f 234# need to assign dependancies to build these first...
5dd5bfb2 235all: lua_build $(BINS)
6658905f 236
709b784c 237all-static: LDLIBS:=-static $(LDLIBS)
fb9acd45 238all-static: proxmark3 flasher fpga_compress
f3919878 239
dc20a1f6 240proxmark3: LDLIBS+=$(LUALIB) $(QTLDLIBS)
7f9e4c25 241proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/usb_cmd.lua
242 $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@
db917a16 243
759c16b3 244flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS)
fb9acd45 245 $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
46cd4046 246
f3919878 247fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
fb9acd45 248 $(LD) $(LDFLAGS) $(ZLIBFLAGS) $^ $(LDLIBS) -o $@
06735128 249
5dd5bfb2 250proxgui.cpp: ui/ui_overlays.h
251
6658905f 252proxguiqt.moc.cpp: proxguiqt.h
253 $(MOC) -o$@ $^
254
3fc4596f 255ui/ui_overlays.h: ui/overlays.ui
256 $(UIC) $^ > $@
27882d37 257
fb9acd45 258lualibs/usb_cmd.lua: ../include/usb_cmd.h
259 awk -f usb_cmd_h2lua.awk $^ > $@
260
6658905f 261clean:
940a2012 262 $(RM) $(CLEAN)
3a4c72fe 263 cd ../liblua && make clean
6658905f 264
bd846386 265tarbin: $(BINS)
fb9acd45 266 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
bd846386 267
806dc075 268lua_build:
30a46ed8 269 @echo Compiling liblua, using platform $(LUAPLATFORM)
270 cd ../liblua && make $(LUAPLATFORM)
806dc075 271
6658905f 272.PHONY: all clean
fb9acd45 273
c48c4d78 274$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
5dd5bfb2 275 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
c48c4d78 276
277$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 278 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
c48c4d78 279
280$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 281 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
c48c4d78 282
283$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 284 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
c48c4d78 285
286$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 287 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
c48c4d78 288
289$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
5dd5bfb2 290 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
c48c4d78 291
fb9acd45 292%.o: %.c
293$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
294 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
295 $(POSTCOMPILE)
296
297%.o: %.cpp
298$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
3472ebe5 299 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
fb9acd45 300 $(POSTCOMPILE)
301
302
303#$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
304# $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
305# $(POSTCOMPILE)
306
307#$(ZLIBOBJS): $(notdir $(%.c)) %.d
308# $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
309# $(POSTCOMPILE)
310
311#$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
312# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
313# $(POSTCOMPILE)
314
1985eb7c 315DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
fb9acd45 316 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
317 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
318
319$(DEPENDENCY_FILES): ;
320.PRECIOUS: $(DEPENDENCY_FILES)
321
322-include $(DEPENDENCY_FILES)
Impressum, Datenschutz