]> git.zerfleddert.de Git - proxmark3-svn/blame_incremental - client/Makefile
Merge pull request #329 from marshmellow42/master
[proxmark3-svn] / client / Makefile
... / ...
CommitLineData
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#-----------------------------------------------------------------------------
6
7CC = gcc
8CXX = g++
9LD = g++
10TAR = tar
11TARFLAGS = -C .. --ignore-failed-read -rvf
12RM = rm -f
13MV = mv
14
15#COMMON_FLAGS = -m32
16VPATH = ../common ../zlib
17OBJDIR = obj
18
19LDLIBS = -L/opt/local/lib -L/usr/local/lib -lreadline -lpthread -lm
20LUALIB = ../liblua/liblua.a
21LDFLAGS = $(COMMON_FLAGS)
22CFLAGS = -std=c99 -D_ISOC99_SOURCE -I. -I../include -I../common -I../zlib -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O3
23CXXFLAGS = -I../include -Wall -O3
24
25LUAPLATFORM = generic
26platform = $(shell uname)
27ifneq (,$(findstring MINGW,$(platform)))
28 LUAPLATFORM = mingw
29else
30 ifeq ($(platform),Darwin)
31 LUAPLATFORM = macosx
32 else
33 LUALIB += -ldl
34 LDLIBS += -ltermcap -lncurses
35 LUAPLATFORM = linux
36 endif
37endif
38
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
43UIC = $(shell pkg-config --variable=host_bins Qt5Core)/uic
44ifeq ($(QTINCLUDES), )
45# if Qt5 not found check for correctly configured Qt4
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)
49 UIC = $(shell pkg-config --variable=uic_location QtCore)
50else
51 CXXFLAGS += -std=c++11 -fPIC
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
61 CXXFLAGS += -std=c++11 -fPIC
62 endif
63 MOC = $(QTDIR)/bin/moc
64 UIC = $(QTDIR)/bin/uic
65 endif
66endif
67
68
69ifneq ($(QTLDLIBS), )
70 QTGUIOBJS = $(OBJDIR)/proxgui.o $(OBJDIR)/proxguiqt.o $(OBJDIR)/proxguiqt.moc.o
71 CFLAGS += -DHAVE_GUI
72else
73 QTGUIOBJS = $(OBJDIR)/guidummy.o
74endif
75
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
80
81CORESRCS = uart.c \
82 util.c \
83 util_posix.c
84
85CMDSRCS = crapto1/crapto1.c\
86 crapto1/crypto1.c\
87 mfkey.c\
88 loclass/cipher.c \
89 loclass/cipherutils.c \
90 loclass/des.c \
91 loclass/ikeys.c \
92 loclass/elite_crack.c\
93 loclass/fileutils.c\
94 whereami.c\
95 mifarehost.c\
96 parity.c\
97 crc.c \
98 crc16.c \
99 crc64.c \
100 iso14443crc.c \
101 iso15693tools.c \
102 data.c \
103 graph.c \
104 ui.c \
105 cmddata.c \
106 lfdemod.c \
107 cmdhf.c \
108 cmdhf14a.c \
109 cmdhf14b.c \
110 cmdhf15.c \
111 cmdhfepa.c \
112 cmdhflegic.c \
113 cmdhficlass.c \
114 cmdhfmf.c \
115 cmdhfmfu.c \
116 cmdhfmfhard.c \
117 hardnested/hardnested_bruteforce.c \
118 cmdhftopaz.c \
119 cmdhw.c \
120 cmdlf.c \
121 cmdlfawid.c \
122 cmdlfcotag.c\
123 cmdlfem4x.c \
124 cmdlffdx.c \
125 cmdlfgproxii.c \
126 cmdlfhid.c \
127 cmdlfhitag.c \
128 cmdlfio.c \
129 cmdlfindala.c \
130 cmdlfjablotron.c \
131 cmdlfnexwatch.c \
132 cmdlfnoralsy.c \
133 cmdlfparadox.c \
134 cmdlfpcf7931.c \
135 cmdlfpresco.c \
136 cmdlfpyramid.c \
137 cmdlfsecurakey.c \
138 cmdlft55xx.c \
139 cmdlfti.c \
140 cmdlfviking.c\
141 cmdlfvisa2000.c\
142 cmdparser.c \
143 cmdmain.c \
144 scripting.c\
145 cmdscript.c\
146 pm3_binlib.c\
147 pm3_bitlib.c\
148 aes.c\
149 protocols.c\
150 sha1.c\
151 cmdcrc.c\
152 reveng/reveng.c\
153 reveng/cli.c\
154 reveng/bmpbit.c\
155 reveng/model.c\
156 reveng/poly.c\
157 reveng/getopt.c\
158
159cpu_arch = $(shell uname -m)
160ifneq ($(findstring 86, $(cpu_arch)), )
161 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
162endif
163ifneq ($(findstring 64, $(cpu_arch)), )
164 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
165endif
166ifeq ($(MULTIARCHSRCS), )
167 CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
168endif
169
170ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
171ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
172#-DDEBUG -Dverbose=1
173
174QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
175
176COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
177CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
178ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
179MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
180 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
181 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
182 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX.o) \
183 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX2.o)
184
185GCC_GTEQ_490 := $(shell expr `gcc -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/'` \>= 40900)
186HARD_SWITCH_NOSIMD = -mno-mmx -mno-sse2 -mno-avx -mno-avx2
187HARD_SWITCH_MMX = -mmmx -mno-sse2 -mno-avx -mno-avx2
188HARD_SWITCH_SSE2 = -mmmx -msse2 -mno-avx -mno-avx2
189HARD_SWITCH_AVX = -mmmx -msse2 -mavx -mno-avx2
190HARD_SWITCH_AVX2 = -mmmx -msse2 -mavx -mavx2
191HARD_SWITCH_AVX512 = -mmmx -msse2 -mavx -mavx2 -mavx512f
192ifeq "$(GCC_GTEQ_490)" "1"
193 HARD_SWITCH_NOSIMD += -mno-avx512f
194 HARD_SWITCH_MMX += -mno-avx512f
195 HARD_SWITCH_SSE2 += -mno-avx512f
196 HARD_SWITCH_AVX += -mno-avx512f
197 HARD_SWITCH_AVX2 += -mno-avx512f
198 MULTIARCHOBJS += $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX512.o)
199endif
200
201BINS = proxmark3 flasher fpga_compress
202WINBINS = $(patsubst %, %.exe, $(BINS))
203CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h
204
205# need to assign dependancies to build these first...
206all: lua_build $(BINS)
207
208all-static: LDLIBS:=-static $(LDLIBS)
209all-static: proxmark3 flasher fpga_compress
210
211proxmark3: LDLIBS+=$(LUALIB) $(QTLDLIBS)
212proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) lualibs/usb_cmd.lua
213 $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(LDLIBS) -o $@
214
215flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS)
216 $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
217
218fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
219 $(LD) $(LDFLAGS) $(ZLIBFLAGS) $^ $(LDLIBS) -o $@
220
221proxgui.cpp: ui/ui_overlays.h
222
223proxguiqt.moc.cpp: proxguiqt.h
224 $(MOC) -o$@ $^
225
226ui/ui_overlays.h: ui/overlays.ui
227 $(UIC) $^ > $@
228
229lualibs/usb_cmd.lua: ../include/usb_cmd.h
230 awk -f usb_cmd_h2lua.awk $^ > $@
231
232clean:
233 $(RM) $(CLEAN)
234 cd ../liblua && make clean
235
236tarbin: $(BINS)
237 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
238
239lua_build:
240 @echo Compiling liblua, using platform $(LUAPLATFORM)
241 cd ../liblua && make $(LUAPLATFORM)
242
243.PHONY: all clean
244
245$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
246 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
247
248$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
249 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
250
251$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
252 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
253
254$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
255 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
256
257$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
258 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
259
260$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
261 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
262
263%.o: %.c
264$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
265 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
266 $(POSTCOMPILE)
267
268%.o: %.cpp
269$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
270 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
271 $(POSTCOMPILE)
272
273
274#$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
275# $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
276# $(POSTCOMPILE)
277
278#$(ZLIBOBJS): $(notdir $(%.c)) %.d
279# $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
280# $(POSTCOMPILE)
281
282#$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
283# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
284# $(POSTCOMPILE)
285
286DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
287 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
288 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
289
290$(DEPENDENCY_FILES): ;
291.PRECIOUS: $(DEPENDENCY_FILES)
292
293-include $(DEPENDENCY_FILES)
294
Impressum, Datenschutz