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