]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/Makefile
Merge branch 'master' of https://github.com/Proxmark/proxmark3
[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 \
b5a5fc4d 167 hidcardformatutils.c\
168 hidcardformats.c\
8b6abef5 169 cmdlfhid.c \
db09cb3a 170 cmdlfhitag.c \
8b6abef5 171 cmdlfio.c \
0fb65a26 172 cmdlfindala.c \
a9968da3 173 cmdlfjablotron.c \
5bce72d5 174 cmdlfnexwatch.c \
a9968da3 175 cmdlfnoralsy.c \
5bce72d5 176 cmdlfparadox.c \
c3caf040 177 cmdlfpcf7931.c \
178 cmdlfpresco.c \
179 cmdlfpyramid.c \
180 cmdlfsecurakey.c \
8b6abef5 181 cmdlft55xx.c \
182 cmdlfti.c \
183 cmdlfviking.c\
184 cmdlfvisa2000.c\
48d41dc3 185 cmdlfpac.c\
8b6abef5 186 cmdparser.c \
187 cmdmain.c \
a0655c45 188 scripting.c\
806dc075 189 cmdscript.c\
8b6abef5 190 pm3_binlib.c\
77cd612f 191 pm3_bitlib.c\
ad939de5 192 protocols.c
28fdb04f 193
af7a1f70 194cpu_arch = $(shell uname -m)
195ifneq ($(findstring 86, $(cpu_arch)), )
196 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
197endif
6b758d65 198ifneq ($(findstring amd64, $(cpu_arch)), )
af7a1f70 199 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
200endif
201ifeq ($(MULTIARCHSRCS), )
202 CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
203endif
c48c4d78 204
4b3f6d79 205ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
fb9acd45 206ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
8e074056 207#-DDEBUG -Dverbose=1
0fa01ec7 208
fb9acd45 209QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
a0655c45 210
759c16b3 211COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
46cd4046 212CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
f3919878 213ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
c48c4d78 214MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
215 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
216 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
217 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX.o) \
5dd5bfb2 218 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX2.o)
219
1ff75f16 220SUPPORTS_AVX512 := $(shell echo | gcc -E -mavx512f - > /dev/null 2>&1 && echo "True" )
5dd5bfb2 221HARD_SWITCH_NOSIMD = -mno-mmx -mno-sse2 -mno-avx -mno-avx2
222HARD_SWITCH_MMX = -mmmx -mno-sse2 -mno-avx -mno-avx2
223HARD_SWITCH_SSE2 = -mmmx -msse2 -mno-avx -mno-avx2
224HARD_SWITCH_AVX = -mmmx -msse2 -mavx -mno-avx2
225HARD_SWITCH_AVX2 = -mmmx -msse2 -mavx -mavx2
226HARD_SWITCH_AVX512 = -mmmx -msse2 -mavx -mavx2 -mavx512f
de1e68d3 227ifeq "$(SUPPORTS_AVX512)" "True"
5dd5bfb2 228 HARD_SWITCH_NOSIMD += -mno-avx512f
229 HARD_SWITCH_MMX += -mno-avx512f
230 HARD_SWITCH_SSE2 += -mno-avx512f
231 HARD_SWITCH_AVX += -mno-avx512f
232 HARD_SWITCH_AVX2 += -mno-avx512f
233 MULTIARCHOBJS += $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX512.o)
234endif
c48c4d78 235
fb9acd45 236BINS = proxmark3 flasher fpga_compress
237WINBINS = $(patsubst %, %.exe, $(BINS))
c48c4d78 238CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h
940a2012 239
3fc4596f 240# need to assign dependancies to build these first...
556826b5 241all: lua_build jansson_build $(BINS)
6658905f 242
709b784c 243all-static: LDLIBS:=-static $(LDLIBS)
fb9acd45 244all-static: proxmark3 flasher fpga_compress
f3919878 245
556826b5 246proxmark3: LDLIBS+=$(LUALIB) $(JANSSONLIB) $(QTLDLIBS)
7f9e4c25 247proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/usb_cmd.lua
248 $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@
db917a16 249
759c16b3 250flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS)
fb9acd45 251 $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
46cd4046 252
f3919878 253fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
fb9acd45 254 $(LD) $(LDFLAGS) $(ZLIBFLAGS) $^ $(LDLIBS) -o $@
06735128 255
5dd5bfb2 256proxgui.cpp: ui/ui_overlays.h
257
6658905f 258proxguiqt.moc.cpp: proxguiqt.h
259 $(MOC) -o$@ $^
260
3fc4596f 261ui/ui_overlays.h: ui/overlays.ui
262 $(UIC) $^ > $@
27882d37 263
fb9acd45 264lualibs/usb_cmd.lua: ../include/usb_cmd.h
265 awk -f usb_cmd_h2lua.awk $^ > $@
266
6658905f 267clean:
940a2012 268 $(RM) $(CLEAN)
3a4c72fe 269 cd ../liblua && make clean
556826b5 270 cd ./jansson && make clean
6658905f 271
bd846386 272tarbin: $(BINS)
fb9acd45 273 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
bd846386 274
806dc075 275lua_build:
30a46ed8 276 @echo Compiling liblua, using platform $(LUAPLATFORM)
277 cd ../liblua && make $(LUAPLATFORM)
556826b5
OM
278
279jansson_build:
280 @echo Compiling jansson
281 cd ./jansson && make all
806dc075 282
6658905f 283.PHONY: all clean
fb9acd45 284
c48c4d78 285$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
5dd5bfb2 286 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
c48c4d78 287
288$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 289 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
c48c4d78 290
291$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 292 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
c48c4d78 293
294$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
5dd5bfb2 295 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
c48c4d78 296
297$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
5dd5bfb2 298 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
c48c4d78 299
300$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
5dd5bfb2 301 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
c48c4d78 302
fb9acd45 303%.o: %.c
304$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
305 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
306 $(POSTCOMPILE)
307
308%.o: %.cpp
309$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
3472ebe5 310 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
fb9acd45 311 $(POSTCOMPILE)
312
313
314#$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
315# $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
316# $(POSTCOMPILE)
317
318#$(ZLIBOBJS): $(notdir $(%.c)) %.d
319# $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
320# $(POSTCOMPILE)
321
322#$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
323# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
324# $(POSTCOMPILE)
325
1985eb7c 326DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
fb9acd45 327 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
328 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
329
330$(DEPENDENCY_FILES): ;
331.PRECIOUS: $(DEPENDENCY_FILES)
332
333-include $(DEPENDENCY_FILES)
Impressum, Datenschutz