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
5 #-----------------------------------------------------------------------------
11 TARFLAGS
= -C ..
--ignore-failed-read
-rvf
15 ENV_LDFLAGS
:= $(LDFLAGS
)
16 ENV_CFLAGS
:= $(CFLAGS
)
17 VPATH
= ..
/common ..
/zlib ..
/uart
20 LDLIBS
= -L
/opt
/local
/lib
-L
/usr
/local
/lib
-lreadline
-lpthread
-lm
21 LUALIB
= ..
/liblua
/liblua.a
22 JANSSONLIBPATH
= .
/jansson
23 JANSSONLIB
= $(JANSSONLIBPATH
)/libjansson.a
24 MBEDTLSLIBPATH
= ..
/common
/mbedtls
25 MBEDTLSLIB
= $(MBEDTLSLIBPATH
)/libmbedtls.a
26 CBORLIBPATH
= .
/tinycbor
27 CBORLIB
= $(CBORLIBPATH
)/tinycbor.a
28 LIBINCLUDES
= -I..
/zlib
-I..
/uart
-I..
/liblua
-I
$(MBEDTLSLIBPATH
) -I
$(JANSSONLIBPATH
) -I
$(CBORLIBPATH
)
29 INCLUDES_CLIENT
= -I.
-I..
/include -I..
/common
-I
/opt
/local
/include $(LIBINCLUDES
)
30 LDFLAGS
= $(ENV_LDFLAGS
)
31 CFLAGS
= $(ENV_CFLAGS
) -std
=c99
-D_ISOC99_SOURCE
$(INCLUDES_CLIENT
) -Wall
-g
-O3
32 CXXFLAGS
= -I..
/include -Wall
-O3
35 include ..
/common
/Makefile_Enabled_Options.common
36 CFLAGS
+= $(APP_CFLAGS
)
37 ifneq (,$(findstring WITH_SMARTCARD
,$(APP_CFLAGS
)))
38 SRC_SMARTCARD
= cmdsmartcard.c pcsc.c
43 platform
= $(shell uname
)
45 ifneq (,$(findstring MINGW
,$(platform
)))
47 PCSC_LIBS
= -lwinscard
49 ifeq ($(platform
),Darwin
)
51 PCSC_LIBS
= -framework PCSC
53 PCSC_INCLUDES
:= $(shell pkg-config
--cflags libpcsclite
)
54 PCSC_LIBS
:= $(shell pkg-config
--libs libpcsclite
)
59 ifneq (,$(findstring MINGW
,$(platform
)))
62 ifeq ($(platform
),Darwin
)
64 OBJCSRCS
= util_darwin.m
65 LDFLAGS
+= -framework Foundation
-framework AppKit
68 LDLIBS
+= -ltermcap
-lncurses
73 ifneq (,$(findstring WITH_GUI
,$(APP_CFLAGS
)))
74 # Check for correctly configured Qt5
75 QTINCLUDES
= $(shell pkg-config
--cflags Qt5Core Qt5Widgets
2>/dev
/null
)
76 QTLDLIBS
= $(shell pkg-config
--libs Qt5Core Qt5Widgets
2>/dev
/null
)
77 MOC
= $(shell pkg-config
--variable
=host_bins Qt5Core
)/moc
78 UIC
= $(shell pkg-config
--variable
=host_bins Qt5Core
)/uic
79 ifeq ($(QTINCLUDES
), )
80 # if Qt5 not found check for correctly configured Qt4
81 QTINCLUDES
= $(shell pkg-config
--cflags QtCore QtGui
2>/dev
/null
)
82 QTLDLIBS
= $(shell pkg-config
--libs QtCore QtGui
2>/dev
/null
)
83 MOC
= $(shell pkg-config
--variable
=moc_location QtCore
)
84 UIC
= $(shell pkg-config
--variable
=uic_location QtCore
)
86 CXXFLAGS
+= -std
=c
++11 -fPIC
88 ifeq ($(QTINCLUDES
), )
89 # if both pkg-config commands failed, search in common places
91 QTINCLUDES
= -I
$(QTDIR
)/include -I
$(QTDIR
)/include/QtCore
-I
$(QTDIR
)/include/QtGui
92 QTLDLIBS
= -L
$(QTDIR
)/lib
-lQtCore4
-lQtGui4
93 ifneq ($(wildcard $(QTDIR
)/include/QtWidgets
),)
94 QTINCLUDES
+= -I
$(QTDIR
)/include/QtWidgets
95 QTLDLIBS
= -L
$(QTDIR
)/lib
-lQt5Widgets
-lQt5Gui
-lQt5Core
96 CXXFLAGS
+= -std
=c
++11 -fPIC
98 MOC
= $(QTDIR
)/bin
/moc
99 UIC
= $(QTDIR
)/bin
/uic
105 ifneq ($(QTLDLIBS
), )
106 QTGUIOBJS
= $(OBJDIR
)/proxgui.o
$(OBJDIR
)/proxguiqt.o
$(OBJDIR
)/proxguiqt.moc.o
109 QTGUIOBJS
= $(OBJDIR
)/guidummy.o
112 # Flags to generate temporary dependency files
113 DEPFLAGS
= -MT
$@
-MMD
-MP
-MF
$(OBJDIR
)/$*.Td
114 # make temporary to final dependeny files after successful compilation
115 POSTCOMPILE
= $(MV
) -f
$(OBJDIR
)/$*.Td
$(OBJDIR
)/$*.d
118 CORESRCS
= uart_posix.c \
125 CMDSRCS
= $(SRC_SMARTCARD
) \
131 cliparser
/argtable3.c\
132 cliparser
/cliparser.c\
133 fido
/additional_ca.c \
139 loclass
/cipherutils.c \
141 loclass
/elite_crack.c\
155 emv
/crypto_polarssl.c\
160 emv
/test/cryptotest.c\
168 emv
/test/crypto_test.c\
186 hardnested
/hardnested_bruteforce.c \
196 hidcardformatutils.c\
224 cpu_arch
= $(shell uname
-m
)
225 ifneq ($(findstring 86, $(cpu_arch
)), )
226 MULTIARCHSRCS
= hardnested
/hardnested_bf_core.c hardnested
/hardnested_bitarray_core.c
228 ifneq ($(findstring amd64
, $(cpu_arch
)), )
229 MULTIARCHSRCS
= hardnested
/hardnested_bf_core.c hardnested
/hardnested_bitarray_core.c
231 ifeq ($(MULTIARCHSRCS
), )
232 CMDSRCS
+= hardnested
/hardnested_bf_core.c hardnested
/hardnested_bitarray_core.c
235 ZLIBSRCS
= deflate.c adler32.c trees.c zutil.c inflate.c inffast.c inftrees.c
236 ZLIBFLAGS
= -DZ_SOLO
-DZ_PREFIX
-DNO_GZIP
-DZLIB_PM3_TUNED
239 QTGUISRCS
= proxgui.
cpp proxguiqt.
cpp proxguiqt.moc.
cpp guidummy.
cpp
241 COREOBJS
= $(CORESRCS
:%.c
=$(OBJDIR
)/%.o
)
242 CMDOBJS
= $(CMDSRCS
:%.c
=$(OBJDIR
)/%.o
)
243 OBJCOBJS
= $(OBJCSRCS
:%.m
=$(OBJDIR
)/%.o
)
244 ZLIBOBJS
= $(ZLIBSRCS
:%.c
=$(OBJDIR
)/%.o
)
245 MULTIARCHOBJS
= $(MULTIARCHSRCS
:%.c
=$(OBJDIR
)/%_NOSIMD.o
) \
246 $(MULTIARCHSRCS
:%.c
=$(OBJDIR
)/%_MMX.o
) \
247 $(MULTIARCHSRCS
:%.c
=$(OBJDIR
)/%_SSE2.o
) \
248 $(MULTIARCHSRCS
:%.c
=$(OBJDIR
)/%_AVX.o
) \
249 $(MULTIARCHSRCS
:%.c
=$(OBJDIR
)/%_AVX2.o
)
251 SUPPORTS_AVX512
:= $(shell echo | gcc
-E
-mavx512f
- > /dev
/null
2>&1 && echo
"True" )
252 HARD_SWITCH_NOSIMD
= -mno-mmx
-mno-sse2
-mno-avx
-mno-avx2
253 HARD_SWITCH_MMX
= -mmmx
-mno-sse2
-mno-avx
-mno-avx2
254 HARD_SWITCH_SSE2
= -mmmx
-msse2
-mno-avx
-mno-avx2
255 HARD_SWITCH_AVX
= -mmmx
-msse2
-mavx
-mno-avx2
256 HARD_SWITCH_AVX2
= -mmmx
-msse2
-mavx
-mavx2
257 HARD_SWITCH_AVX512
= -mmmx
-msse2
-mavx
-mavx2
-mavx512f
258 ifeq "$(SUPPORTS_AVX512)" "True"
259 HARD_SWITCH_NOSIMD
+= -mno-avx512f
260 HARD_SWITCH_MMX
+= -mno-avx512f
261 HARD_SWITCH_SSE2
+= -mno-avx512f
262 HARD_SWITCH_AVX
+= -mno-avx512f
263 HARD_SWITCH_AVX2
+= -mno-avx512f
264 MULTIARCHOBJS
+= $(MULTIARCHSRCS
:%.c
=$(OBJDIR
)/%_AVX512.o
)
267 BINS
= proxmark3 flasher fpga_compress
268 WINBINS
= $(patsubst %, %.exe
, $(BINS
))
269 CLEAN
= $(BINS
) $(WINBINS
) $(COREOBJS
) $(CMDOBJS
) $(OBJCOBJS
) $(ZLIBOBJS
) $(QTGUIOBJS
) $(MULTIARCHOBJS
) $(OBJDIR
)/*.o
*.moc.
cpp ui
/ui_overlays.h lualibs
/usb_cmd.lua
271 # need to assign dependancies to build these first...
272 all: lua_build jansson_build mbedtls_build cbor_build
$(BINS
)
274 all-static
: LDLIBS
:=-static
$(LDLIBS
)
275 all-static
: proxmark3 flasher fpga_compress
277 proxmark3
: LDLIBS
+=$(LUALIB
) $(JANSSONLIB
) $(MBEDTLSLIB
) $(CBORLIB
) $(QTLDLIBS
) $(PCSC_LIBS
)
278 proxmark3
: $(OBJDIR
)/proxmark3.o
$(COREOBJS
) $(CMDOBJS
) $(OBJCOBJS
) $(QTGUIOBJS
) $(MULTIARCHOBJS
) $(ZLIBOBJS
) lualibs
/usb_cmd.lua
279 $(LD
) $(LDFLAGS
) $(OBJDIR
)/proxmark3.o
$(COREOBJS
) $(CMDOBJS
) $(OBJCOBJS
) $(QTGUIOBJS
) $(MULTIARCHOBJS
) $(ZLIBOBJS
) $(LDLIBS
) -o
$@
281 flasher
: $(OBJDIR
)/flash.o
$(OBJDIR
)/flasher.o
$(COREOBJS
) $(OBJCOBJS
)
282 $(LD
) $(LDFLAGS
) $^
$(LDLIBS
) -o
$@
284 fpga_compress
: $(OBJDIR
)/fpga_compress.o
$(ZLIBOBJS
)
285 $(LD
) $(LDFLAGS
) $(ZLIBFLAGS
) $^
$(LDLIBS
) -o
$@
287 proxgui.
cpp: ui
/ui_overlays.h
289 proxguiqt.moc.
cpp: proxguiqt.h
292 ui
/ui_overlays.h
: ui
/overlays.ui
295 lualibs
/usb_cmd.lua
: ..
/include/usb_cmd.h
296 awk
-f usb_cmd_h2lua.awk
$^
> $@
300 cd ..
/liblua
&& make
clean
301 cd
$(JANSSONLIBPATH
) && make
clean
302 cd
$(MBEDTLSLIBPATH
) && make
clean
303 cd
$(CBORLIBPATH
) && make
clean
306 $(TAR
) $(TARFLAGS
) ..
/proxmark3-
$(platform
)-bin.
tar $(BINS
:%=client
/%) $(WINBINS
:%=client
/%)
309 @echo Compiling liblua
, using platform
$(LUAPLATFORM
)
310 cd ..
/liblua
&& make
$(LUAPLATFORM
)
313 @echo Compiling jansson
314 cd
$(JANSSONLIBPATH
) && make
all
317 @echo Compiling mbedtls
318 cd
$(MBEDTLSLIBPATH
) && make
all
321 @echo Compiling tinycbor
322 cd
$(CBORLIBPATH
) && make
all
326 $(OBJDIR
)/%_NOSIMD.o
: %.c
$(OBJDIR
)/%.d
327 $(CC
) $(DEPFLAGS
) $(CFLAGS
) $(HARD_SWITCH_NOSIMD
) -c
-o
$@
$<
329 $(OBJDIR
)/%_MMX.o
: %.c
$(OBJDIR
)/%.d
330 $(CC
) $(DEPFLAGS
) $(CFLAGS
) $(HARD_SWITCH_MMX
) -c
-o
$@
$<
332 $(OBJDIR
)/%_SSE2.o
: %.c
$(OBJDIR
)/%.d
333 $(CC
) $(DEPFLAGS
) $(CFLAGS
) $(HARD_SWITCH_SSE2
) -c
-o
$@
$<
335 $(OBJDIR
)/%_AVX.o
: %.c
$(OBJDIR
)/%.d
336 $(CC
) $(DEPFLAGS
) $(CFLAGS
) $(HARD_SWITCH_AVX
) -c
-o
$@
$<
338 $(OBJDIR
)/%_AVX2.o
: %.c
$(OBJDIR
)/%.d
339 $(CC
) $(DEPFLAGS
) $(CFLAGS
) $(HARD_SWITCH_AVX2
) -c
-o
$@
$<
341 $(OBJDIR
)/%_AVX512.o
: %.c
$(OBJDIR
)/%.d
342 $(CC
) $(DEPFLAGS
) $(CFLAGS
) $(HARD_SWITCH_AVX512
) -c
-o
$@
$<
345 $(OBJDIR
)/%.o
: %.c
$(OBJDIR
)/%.d
346 $(CC
) $(DEPFLAGS
) $(CFLAGS
) $(ZLIBFLAGS
) $(PCSC_INCLUDES
) -c
-o
$@
$<
350 $(OBJDIR
)/%.o
: %.
cpp $(OBJDIR
)/%.d
351 $(CXX
) $(DEPFLAGS
) $(CXXFLAGS
) $(QTINCLUDES
) -c
-o
$@
$<
355 $(OBJDIR
)/%.o
: %.m
$(OBJDIR
)/%.d
356 $(CC
) $(DEPFLAGS
) $(CFLAGS
) -c
-o
$@
$<
359 #$(CMDOBJS) $(COREOBJS): $(notdir $(%.c)) %.d
360 # $(CC) $(DEPFLAGS) $(CFLAGS) -c -o $@ $<
363 #$(ZLIBOBJS): $(notdir $(%.c)) %.d
364 # $(CC) $(DEPFLAGS) $(CFLAGS) $(ZLIBFLAGS) -c -o $@ $<
367 #$(QTGUIOBJS): $(notdir $(%.cpp)) %.d
368 # $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c -o $@ $<
371 DEPENDENCY_FILES
= $(patsubst %.c
, $(OBJDIR
)/%.d
, $(CORESRCS
) $(CMDSRCS
) $(ZLIBSRCS
) $(MULTIARCHSRCS
)) \
372 $(patsubst %.
cpp, $(OBJDIR
)/%.d
, $(QTGUISRCS
)) \
373 $(patsubst %.m
, $(OBJDIR
)/%.d
, $(OBJCSRCS
)) \
374 $(OBJDIR
)/proxmark3.d
$(OBJDIR
)/flash.d
$(OBJDIR
)/flasher.d
$(OBJDIR
)/fpga_compress.d
376 $(DEPENDENCY_FILES
): ;
377 .PRECIOUS
: $(DEPENDENCY_FILES
)
379 -include $(DEPENDENCY_FILES
)