]> git.zerfleddert.de Git - proxmark3-svn/blame - client/Makefile
Fix client Makefile
[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
709b784c 15#COMMON_FLAGS = -m32
0ca9bc0e 16VPATH = ../common ../zlib
46cd4046 17OBJDIR = obj
7fe9b0b7 18
94e27a09 19LDLIBS = -L/opt/local/lib -L/usr/local/lib -lreadline -lpthread -lm
e6153040 20LUALIB = ../liblua/liblua.a
709b784c 21LDFLAGS = $(COMMON_FLAGS)
8aee1b84 22CFLAGS = -std=c99 -D_ISOC99_SOURCE -I. -I../include -I../common -I../zlib -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O3
f9e2c24b 23CXXFLAGS = -Wall -O3
8c04722d 24
3472ebe5 25LUAPLATFORM = generic
fb9acd45 26platform = $(shell uname)
8691f5b7 27ifneq (,$(findstring MINGW,$(platform)))
fb9acd45 28 LUAPLATFORM = mingw
8691f5b7 29else
fb9acd45 30 ifeq ($(platform),Darwin)
31 LUAPLATFORM = macosx
32 else
33 LUALIB += -ldl
34 LDLIBS += -ltermcap -lncurses
35 LUAPLATFORM = linux
36 endif
62b1302c 37endif
38
3472ebe5 39# Check for correctly configured Qt5
40QTINCLUDES = $(shell pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
41QTLDLIBS = $(shell pkg-config --libs Qt5Core Qt5Widgets 2>/dev/null)
42MOC = $(shell pkg-config --variable=host_bins Qt5Core)/moc
27882d37 43UIC = $(shell pkg-config --variable=host_bins Qt5Core)/uic
3472ebe5 44ifeq ($(QTINCLUDES), )
f9e2c24b 45# if Qt5 not found check for correctly configured Qt4
3472ebe5 46 QTINCLUDES = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null)
47 QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
48 MOC = $(shell pkg-config --variable=moc_location QtCore)
27882d37 49 UIC = $(shell pkg-config --variable=uic_location QtCore)
f9e2c24b 50else
51 CXXFLAGS += -std=c++11 -fPIC
3472ebe5 52endif
53ifeq ($(QTINCLUDES), )
54# if both pkg-config commands failed, search in common places
55 ifneq ($(QTDIR), )
56 QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
57 QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4
58 ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
59 QTINCLUDES += -I$(QTDIR)/include/QtWidgets
60 QTLDLIBS = -L$(QTDIR)/lib -lQt5Widgets -lQt5Gui -lQt5Core
f9e2c24b 61 CXXFLAGS += -std=c++11 -fPIC
3472ebe5 62 endif
63 MOC = $(QTDIR)/bin/moc
27882d37 64 UIC = $(QTDIR)/bin/uic
3472ebe5 65 endif
66endif
67
68
69ifneq ($(QTLDLIBS), )
fb9acd45 70 QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
8c04722d 71 CFLAGS += -DHAVE_GUI
245e844e 72else
fb9acd45 73 QTGUIOBJS = $(OBJDIR)/guidummy.o
245e844e 74endif
62b1302c 75
fb9acd45 76# Flags to generate temporary dependency files
77DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
78# make temporary to final dependeny files after successful compilation
79POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d
759c16b3 80
fb9acd45 81CORESRCS = uart.c \
82 util.c
759c16b3 83
33443e7c 84CMDSRCS = crapto1/crapto1.c\
85 crapto1/crypto1.c\
4cb4b588 86 mfkey.c\
db2b81ba 87 loclass/cipher.c \
88 loclass/cipherutils.c \
89 loclass/des.c \
90 loclass/ikeys.c \
91 loclass/elite_crack.c\
92 loclass/fileutils.c\
4197a3f6 93 whereami.c\
f397b5cc 94 mifarehost.c\
1f065e1d 95 parity.c\
9f7bbd24 96 crc.c \
91c38cf7 97 crc16.c \
d730878d 98 crc64.c \
91c38cf7 99 iso14443crc.c \
9455b51c 100 iso15693tools.c \
7fe9b0b7 101 data.c \
102 graph.c \
103 ui.c \
104 cmddata.c \
eb191de6 105 lfdemod.c \
7fe9b0b7 106 cmdhf.c \
107 cmdhf14a.c \
108 cmdhf14b.c \
109 cmdhf15.c \
5acd09bd 110 cmdhfepa.c \
7fe9b0b7 111 cmdhflegic.c \
cee5a30d 112 cmdhficlass.c \
9ca155ba 113 cmdhfmf.c \
fe81b478 114 cmdhfmfu.c \
c48c4d78 115 cmdhfmfhard.c \
116 hardnested/hardnested_bruteforce.c \
db2b81ba 117 cmdhftopaz.c \
7fe9b0b7 118 cmdhw.c \
119 cmdlf.c \
dbf6e824 120 cmdlfawid.c \
8b6abef5 121 cmdlfcotag.c\
28fdb04f 122 cmdlfem4x.c \
4db6f3bb 123 cmdlffdx.c \
946a84c3 124 cmdlfgproxii.c \
8b6abef5 125 cmdlfhid.c \
db09cb3a 126 cmdlfhitag.c \
8b6abef5 127 cmdlfio.c \
0fb65a26 128 cmdlfindala.c \
a9968da3 129 cmdlfjablotron.c \
5bce72d5 130 cmdlfnexwatch.c \
a9968da3 131 cmdlfnoralsy.c \
5bce72d5 132 cmdlfparadox.c \
c3caf040 133 cmdlfpcf7931.c \
134 cmdlfpresco.c \
135 cmdlfpyramid.c \
136 cmdlfsecurakey.c \
8b6abef5 137 cmdlft55xx.c \
138 cmdlfti.c \
139 cmdlfviking.c\
140 cmdlfvisa2000.c\
141 cmdparser.c \
142 cmdmain.c \
a0655c45 143 scripting.c\
806dc075 144 cmdscript.c\
8b6abef5 145 pm3_binlib.c\
77cd612f 146 pm3_bitlib.c\
1f6417a9 147 aes.c\
1defcf60 148 protocols.c\
1c4c0b06 149 sha1.c\
fe81b478 150 cmdcrc.c\
151 reveng/reveng.c\
152 reveng/cli.c\
153 reveng/bmpbit.c\
154 reveng/model.c\
155 reveng/poly.c\
156 reveng/getopt.c\
28fdb04f 157
c48c4d78 158MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
159
4b3f6d79 160ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
fb9acd45 161ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
8e074056 162#-DDEBUG -Dverbose=1
0fa01ec7 163
fb9acd45 164QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
a0655c45 165
759c16b3 166COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
46cd4046 167CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
f3919878 168ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
c48c4d78 169MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
170 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
171 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
172 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX.o) \
173 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX2.o) \
174 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX512.o)
175
fb9acd45 176BINS = proxmark3 flasher fpga_compress
177WINBINS = $(patsubst %, %.exe, $(BINS))
c48c4d78 178CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h
940a2012 179
3fc4596f 180# need to assign dependancies to build these first...
181all: ui/ui_overlays.h lua_build $(BINS)
6658905f 182
709b784c 183all-static: LDLIBS:=-static $(LDLIBS)
fb9acd45 184all-static: proxmark3 flasher fpga_compress
f3919878 185
dc20a1f6 186proxmark3: LDLIBS+=$(LUALIB) $(QTLDLIBS)
c48c4d78 187proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) lualibs/usb_cmd.lua
188 $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LDLIBS) -o $@
db917a16 189
759c16b3 190flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS)
fb9acd45 191 $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
46cd4046 192
f3919878 193fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
fb9acd45 194 $(LD) $(LDFLAGS) $(ZLIBFLAGS) $^ $(LDLIBS) -o $@
06735128 195
6658905f 196proxguiqt.moc.cpp: proxguiqt.h
197 $(MOC) -o$@ $^
198
3fc4596f 199ui/ui_overlays.h: ui/overlays.ui
200 $(UIC) $^ > $@
27882d37 201
fb9acd45 202lualibs/usb_cmd.lua: ../include/usb_cmd.h
203 awk -f usb_cmd_h2lua.awk $^ > $@
204
6658905f 205clean:
940a2012 206 $(RM) $(CLEAN)
3a4c72fe 207 cd ../liblua && make clean
6658905f 208
bd846386 209tarbin: $(BINS)
fb9acd45 210 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
bd846386 211
806dc075 212lua_build:
30a46ed8 213 @echo Compiling liblua, using platform $(LUAPLATFORM)
214 cd ../liblua && make $(LUAPLATFORM)
806dc075 215
6658905f 216.PHONY: all clean
fb9acd45 217
c48c4d78 218$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
219 $(CC) $(DEPFLAGS) $(CFLAGS) -mno-mmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f -c -o $@ $<
220
221$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
222 $(CC) $(DEPFLAGS) $(CFLAGS) -mmmx -mno-sse2 -mno-avx -mno-avx2 -mno-avx512f -c -o $@ $<
223
224$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
225 $(CC) $(DEPFLAGS) $(CFLAGS) -mmmx -msse2 -mno-avx -mno-avx2 -mno-avx512f -c -o $@ $<
226
227$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
228 $(CC) $(DEPFLAGS) $(CFLAGS) -mmmx -msse2 -mavx -mno-avx2 -mno-avx512f -c -o $@ $<
229
230$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
231 $(CC) $(DEPFLAGS) $(CFLAGS) -mmmx -msse2 -mavx -mavx2 -mno-avx512f -c -o $@ $<
232
233$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
234 $(CC) $(DEPFLAGS) $(CFLAGS) -mmmx -msse2 -mavx -mavx2 -mavx512f -c -o $@ $<
235
fb9acd45 236%.o: %.c
237$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
238 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
239 $(POSTCOMPILE)
240
241%.o: %.cpp
242$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
3472ebe5 243 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
fb9acd45 244 $(POSTCOMPILE)
245
246
247#$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
248# $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
249# $(POSTCOMPILE)
250
251#$(ZLIBOBJS): $(notdir $(%.c)) %.d
252# $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
253# $(POSTCOMPILE)
254
255#$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
256# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
257# $(POSTCOMPILE)
258
1985eb7c 259DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
fb9acd45 260 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
261 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
262
263$(DEPENDENCY_FILES): ;
264.PRECIOUS: $(DEPENDENCY_FILES)
265
266-include $(DEPENDENCY_FILES)
267
Impressum, Datenschutz