]> git.zerfleddert.de Git - proxmark3-svn/blame_incremental - client/Makefile
Fix clock_gettime() for Apple OSX
[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 ../uart
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../uart -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_posix.c \
82 uart_win32.c \
83 util.c \
84 util_posix.c
85
86CMDSRCS = crapto1/crapto1.c\
87 crapto1/crypto1.c\
88 polarssl/des.c \
89 polarssl/aes.c\
90 mfkey.c\
91 loclass/cipher.c \
92 loclass/cipherutils.c \
93 loclass/ikeys.c \
94 loclass/elite_crack.c\
95 loclass/fileutils.c\
96 whereami.c\
97 mifarehost.c\
98 parity.c\
99 crc.c \
100 crc16.c \
101 crc64.c \
102 iso14443crc.c \
103 iso15693tools.c \
104 data.c \
105 graph.c \
106 ui.c \
107 cmddata.c \
108 lfdemod.c \
109 cmdhf.c \
110 cmdhf14a.c \
111 cmdhf14b.c \
112 cmdhf15.c \
113 cmdhfepa.c \
114 cmdhflegic.c \
115 cmdhficlass.c \
116 cmdhfmf.c \
117 cmdhfmfu.c \
118 cmdhfmfhard.c \
119 hardnested/hardnested_bruteforce.c \
120 cmdhftopaz.c \
121 cmdhw.c \
122 cmdlf.c \
123 cmdlfawid.c \
124 cmdlfcotag.c\
125 cmdlfem4x.c \
126 cmdlffdx.c \
127 cmdlfgproxii.c \
128 cmdlfhid.c \
129 cmdlfhitag.c \
130 cmdlfio.c \
131 cmdlfindala.c \
132 cmdlfjablotron.c \
133 cmdlfnexwatch.c \
134 cmdlfnoralsy.c \
135 cmdlfparadox.c \
136 cmdlfpcf7931.c \
137 cmdlfpresco.c \
138 cmdlfpyramid.c \
139 cmdlfsecurakey.c \
140 cmdlft55xx.c \
141 cmdlfti.c \
142 cmdlfviking.c\
143 cmdlfvisa2000.c\
144 cmdlfpac.c\
145 cmdparser.c \
146 cmdmain.c \
147 scripting.c\
148 cmdscript.c\
149 pm3_binlib.c\
150 pm3_bitlib.c\
151 protocols.c\
152 sha1.c\
153 cmdcrc.c\
154 reveng/reveng.c\
155 reveng/cli.c\
156 reveng/bmpbit.c\
157 reveng/model.c\
158 reveng/poly.c\
159 reveng/getopt.c\
160
161cpu_arch = $(shell uname -m)
162ifneq ($(findstring 86, $(cpu_arch)), )
163 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
164endif
165ifneq ($(findstring amd64, $(cpu_arch)), )
166 MULTIARCHSRCS = hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
167endif
168ifeq ($(MULTIARCHSRCS), )
169 CMDSRCS += hardnested/hardnested_bf_core.c hardnested/hardnested_bitarray_core.c
170endif
171
172ZLIBSRCS = deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
173ZLIBFLAGS = -DZ_SOLO -DZ_PREFIX -DNO_GZIP -DZLIB_PM3_TUNED
174#-DDEBUG -Dverbose=1
175
176QTGUISRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp guidummy.cpp
177
178COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
179CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
180ZLIBOBJS = $(ZLIBSRCS:%.c=$(OBJDIR)/%.o)
181MULTIARCHOBJS = $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_NOSIMD.o) \
182 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_MMX.o) \
183 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_SSE2.o) \
184 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX.o) \
185 $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX2.o)
186
187GCC_VERSION := $(shell gcc --version | awk '/gcc/{print $$NF;}' | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
188CLANG_VERSION := $(shell gcc --version | awk '/Apple LLVM version/{print $$4;}' | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
189ifneq ($(CLANG_VERSION), )
190 SUPPORTS_AVX512 := $(shell [ $(CLANG_VERSION) -ge 80000 ] && echo "True" )
191endif
192ifneq ($(GCC_VERSION), )
193 SUPPORTS_AVX512 := $(shell [ $(GCC_VERSION) -ge 40900 ] && echo "True" )
194endif
195HARD_SWITCH_NOSIMD = -mno-mmx -mno-sse2 -mno-avx -mno-avx2
196HARD_SWITCH_MMX = -mmmx -mno-sse2 -mno-avx -mno-avx2
197HARD_SWITCH_SSE2 = -mmmx -msse2 -mno-avx -mno-avx2
198HARD_SWITCH_AVX = -mmmx -msse2 -mavx -mno-avx2
199HARD_SWITCH_AVX2 = -mmmx -msse2 -mavx -mavx2
200HARD_SWITCH_AVX512 = -mmmx -msse2 -mavx -mavx2 -mavx512f
201ifeq "$(SUPPORTS_AVX512)" "True"
202 HARD_SWITCH_NOSIMD += -mno-avx512f
203 HARD_SWITCH_MMX += -mno-avx512f
204 HARD_SWITCH_SSE2 += -mno-avx512f
205 HARD_SWITCH_AVX += -mno-avx512f
206 HARD_SWITCH_AVX2 += -mno-avx512f
207 MULTIARCHOBJS += $(MULTIARCHSRCS:%.c=$(OBJDIR)/%_AVX512.o)
208endif
209
210BINS = proxmark3 flasher fpga_compress
211WINBINS = $(patsubst %, %.exe, $(BINS))
212CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h
213
214# need to assign dependancies to build these first...
215all: lua_build $(BINS)
216
217all-static: LDLIBS:=-static $(LDLIBS)
218all-static: proxmark3 flasher fpga_compress
219
220proxmark3: LDLIBS+=$(LUALIB) $(QTLDLIBS)
221proxmark3: $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) lualibs/usb_cmd.lua
222 $(LD) $(LDFLAGS) $(OBJDIR)/proxmark3.o $(COREOBJS) $(CMDOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(ZLIBOBJS) $(LDLIBS) -o $@
223
224flasher: $(OBJDIR)/flash.o $(OBJDIR)/flasher.o $(COREOBJS)
225 $(LD) $(LDFLAGS) $^ $(LDLIBS) -o $@
226
227fpga_compress: $(OBJDIR)/fpga_compress.o $(ZLIBOBJS)
228 $(LD) $(LDFLAGS) $(ZLIBFLAGS) $^ $(LDLIBS) -o $@
229
230proxgui.cpp: ui/ui_overlays.h
231
232proxguiqt.moc.cpp: proxguiqt.h
233 $(MOC) -o$@ $^
234
235ui/ui_overlays.h: ui/overlays.ui
236 $(UIC) $^ > $@
237
238lualibs/usb_cmd.lua: ../include/usb_cmd.h
239 awk -f usb_cmd_h2lua.awk $^ > $@
240
241clean:
242 $(RM) $(CLEAN)
243 cd ../liblua && make clean
244
245tarbin: $(BINS)
246 $(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
247
248lua_build:
249 @echo Compiling liblua, using platform $(LUAPLATFORM)
250 cd ../liblua && make $(LUAPLATFORM)
251
252.PHONY: all clean
253
254$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%.d
255 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
256
257$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%.d
258 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
259
260$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%.d
261 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
262
263$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%.d
264 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
265
266$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%.d
267 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
268
269$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%.d
270 $(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
271
272%.o: %.c
273$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
274 $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
275 $(POSTCOMPILE)
276
277%.o: %.cpp
278$(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
279 $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(QTINCLUDES) -c -o $@ $<
280 $(POSTCOMPILE)
281
282
283#$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
284# $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
285# $(POSTCOMPILE)
286
287#$(ZLIBOBJS): $(notdir $(%.c)) %.d
288# $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
289# $(POSTCOMPILE)
290
291#$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
292# $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
293# $(POSTCOMPILE)
294
295DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(CORESRCS) $(CMDSRCS) $(ZLIBSRCS) $(MULTIARCHSRCS)) \
296 $(patsubst %.cpp, $(OBJDIR)/%.d, $(QTGUISRCS)) \
297 $(OBJDIR)/proxmark3.d $(OBJDIR)/flash.d $(OBJDIR)/flasher.d $(OBJDIR)/fpga_compress.d
298
299$(DEPENDENCY_FILES): ;
300.PRECIOUS: $(DEPENDENCY_FILES)
301
302-include $(DEPENDENCY_FILES)
303
Impressum, Datenschutz