]> git.zerfleddert.de Git - proxmark3-svn/blame - client/Makefile
Adding new Kastle 32-bit format from @xilni
[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 \
b5a5fc4d 165 hidcardformatutils.c\
166 hidcardformats.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...
5dd5bfb2 239all: lua_build $(BINS)
6658905f 240
709b784c 241all-static: LDLIBS:=-static $(LDLIBS)
fb9acd45 242all-static: proxmark3 flasher fpga_compress
f3919878 243
dc20a1f6 244proxmark3: LDLIBS+=$(LUALIB) $(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
6658905f 268
bd846386 269tarbin: $(BINS)
fb9acd45 270 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
bd846386 271
806dc075 272lua_build:
30a46ed8 273 @echo Compiling liblua, using platform $(LUAPLATFORM)
274 cd ../liblua && make $(LUAPLATFORM)
806dc075 275
6658905f 276.PHONY: all clean
fb9acd45 277
c48c4d78 278$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
5dd5bfb2 279 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
c48c4d78 280
281$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 282 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
c48c4d78 283
284$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 285 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
c48c4d78 286
287$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 288 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
c48c4d78 289
290$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 291 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
c48c4d78 292
293$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
5dd5bfb2 294 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
c48c4d78 295
fb9acd45 296%.o: %.c
297$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
298 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
299 $(POSTCOMPILE)
300
301%.o: %.cpp
302$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
3472ebe5 303 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
fb9acd45 304 $(POSTCOMPILE)
305
306
307#$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
308# $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
309# $(POSTCOMPILE)
310
311#$(ZLIBOBJS): $(notdir $(%.c)) %.d
312# $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
313# $(POSTCOMPILE)
314
315#$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
316# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
317# $(POSTCOMPILE)
318
1985eb7c 319DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
fb9acd45 320 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
321 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
322
323$(DEPENDENCY_FILES): ;
324.PRECIOUS: $(DEPENDENCY_FILES)
325
326-include $(DEPENDENCY_FILES)
Impressum, Datenschutz