Release v4.14434 - crimson
[RRG-proxmark3.git] / client / Makefile
blob48d7760fd632f066859113803e9d02ccf4848aea
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 #-----------------------------------------------------------------------------
7 ifeq ($(PLTNAME),)
8 -include ../Makefile.platform
9 -include ../.Makefile.options.cache
10 ifneq ($(PLATFORM), $(CACHED_PLATFORM))
11 $(error platform definitions have been changed, please "make clean" at the root of the project)
12 endif
13 endif
14 include ../Makefile.defs
16 ifeq ($(PLATFORM),PM3ICOPYX)
17 INCLUDES += -DICOPYX
18 endif
20 INSTALLBIN = proxmark3
21 INSTALLSHARE = cmdscripts lualibs luascripts pyscripts resources dictionaries
23 VPATH = ../common src
24 vpath %.dic dictionaries
25 OBJDIR = obj
27 ifeq ($(USE_BREW),1)
28 INCLUDES += -I$(BREW_PREFIX)/include
29 LDLIBS += -L$(BREW_PREFIX)/lib
30 PKG_CONFIG_ENV := PKG_CONFIG_PATH=$(BREW_PREFIX)/opt/qt/lib/pkgconfig
31 PKG_CONFIG_ENV := PKG_CONFIG_PATH=$(BREW_PREFIX)/opt/qt5/lib/pkgconfig
32 endif
34 ifdef ($(USE_MACPORTS),1)
35 INCLUDES += -I$(MACPORTS_PREFIX)/include
36 LDLIBS += -L$(MACPORTS_PREFIX)/lib
37 PKG_CONFIG_ENV := PKG_CONFIG_PATH=$(MACPORTS_PREFIX)/lib/pkgconfig
38 endif
41 PM3INCLUDES =
43 ###################
44 # local libraries #
45 ###################
47 ## Amiibo
48 AMIIBOLIBPATH = ./deps/amiitool
49 AMIIBOLIBINC = -I$(AMIIBOLIBPATH)
50 AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
51 AMIIBOLIBLD =
53 ## Cliparser / Argtable3
54 CLIPARSERLIBPATH = ./deps/cliparser
55 CLIPARSERLIBINC = -I$(CLIPARSERLIBPATH)
56 CLIPARSERLIB = $(CLIPARSERLIBPATH)/libcliparser.a
57 CLIPARSERLIBLD =
59 ## Hardnested
60 HARDNESTEDLIBPATH = ./deps/hardnested
61 HARDNESTEDLIBINC = -I$(HARDNESTEDLIBPATH)
62 HARDNESTEDLIB = $(HARDNESTEDLIBPATH)/libhardnested.a
63 HARDNESTEDLIBLD =
65 ## Jansson
66 JANSSONLIBPATH = ./deps/jansson
67 JANSSONLIBINC = -I$(JANSSONLIBPATH)
68 JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
69 JANSSONLIBLD =
71 ## Lua
72 LUALIBPATH = ./deps/liblua
73 LUALIBINC = -I$(LUALIBPATH)
74 LUALIB = $(LUALIBPATH)/liblua.a
75 LUALIBLD =
76 LUAPLATFORM = generic
77 ifneq (,$(findstring MINGW,$(platform)))
78 LUAPLATFORM = mingw
79 else
80 ifeq ($(platform),Darwin)
81 LUAPLATFORM = macosx
82 else
83 LUALIBLD += -ldl
84 LUAPLATFORM = linux
85 endif
86 endif
88 ## Reveng
89 REVENGLIBPATH = ./deps/reveng
90 REVENGLIBINC = -I$(REVENGLIBPATH)
91 REVENGLIB = $(REVENGLIBPATH)/libreveng.a
92 REVENGLIBLD =
94 ## Tinycbor
95 TINYCBORLIBPATH = ./deps/tinycbor
96 TINYCBORLIBINC = -I$(TINYCBORLIBPATH)
97 TINYCBORLIB = $(TINYCBORLIBPATH)/tinycbor.a
98 TINYCBORLIBLD =
100 ## Whereami
101 WHEREAMILIBPATH = ./deps/whereami
102 WHEREAMILIBINC = -I$(WHEREAMILIBPATH)
103 WHEREAMILIB = $(WHEREAMILIBPATH)/libwhereami.a
104 WHEREAMILIBLD =
106 ##########################
107 # common local libraries #
108 ##########################
110 ## mbed TLS
111 MBEDTLSLIBPATH = ../common/mbedtls
112 MBEDTLSLIBINC = -I$(MBEDTLSLIBPATH)
113 MBEDTLSLIB = $(OBJDIR)/libmbedtls.a
114 MBEDTLSLIBCLIENTRELPATH = ../../client
116 ########################################################
117 # optional system libraries to replace local libraries #
118 ########################################################
120 ## Amiibo
121 # not distributed as system library
122 STATICLIBS += $(AMIIBOLIB)
123 LDLIBS += $(AMIIBOLIBLD)
124 PM3INCLUDES += $(AMIIBOLIBINC)
126 ## Cliparser / Argtable3
127 # not distributed as system library
128 STATICLIBS += $(CLIPARSERLIB)
129 LDLIBS += $(CLIPARSERLIBLD)
130 PM3INCLUDES += $(CLIPARSERLIBINC)
132 ## Hardnested
133 # not distributed as system library
134 STATICLIBS += $(HARDNESTEDLIB)
135 LDLIBS +=$(HARDNESTEDLIBLD)
136 PM3INCLUDES += $(HARDNESTEDLIBINC)
138 ## Lua
139 ifneq ($(SKIPLUASYSTEM),1)
140 ifdef MACPORTS_PREFIX
141 LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua-5.2 2>/dev/null)
142 LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua-5.2 2>/dev/null)
143 else
144 LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua5.2 2>/dev/null)
145 LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua5.2 2>/dev/null)
146 endif
147 ifneq ($(LUALDLIBS),)
148 LUALIB =
149 LUALIBLD = $(LUALDLIBS)
150 LUALIBINC = $(LUAINCLUDES)
151 LUA_FOUND = 1
152 endif
153 endif
154 STATICLIBS += $(LUALIB)
155 LDLIBS += $(LUALIBLD)
156 PM3INCLUDES += $(LUALIBINC)
158 ## Jansson
159 # Jansson section needs to be after Lua to avoid interferences on macOS if a locally incompatible Lua was available, see PR 1155
160 ifneq ($(SKIPJANSSONSYSTEM),1)
161 JANSSONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags jansson 2>/dev/null)
162 JANSSONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs jansson 2>/dev/null)
163 ifneq ($(JANSSONLDLIBS),)
164 JANSSONLIB =
165 JANSSONLIBLD = $(JANSSONLDLIBS)
166 JANSSONLIBINC = $(JANSSONINCLUDES)
167 JANSSON_FOUND = 1
168 endif
169 endif
170 STATICLIBS += $(JANSSONLIB)
171 LDLIBS += $(JANSSONLIBLD)
172 PM3INCLUDES += $(JANSSONLIBINC)
174 ## mbed TLS
175 # system library cannot be used because it is compiled by default without CMAC support
176 STATICLIBS += $(MBEDTLSLIB)
177 LDLIBS += $(MBEDTLSLIBLD)
178 PM3INCLUDES += $(MBEDTLSLIBINC)
180 ## Reveng
181 # not distributed as system library
182 STATICLIBS += $(REVENGLIB)
183 LDLIBS += $(REVENGLIBLD)
184 PM3INCLUDES += $(REVENGLIBINC)
186 ## Tinycbor
187 # not distributed as system library
188 STATICLIBS += $(TINYCBORLIB)
189 LDLIBS += $(TINYCBORLIBLD)
190 PM3INCLUDES += $(TINYCBORLIBINC)
192 ## Whereami
193 ifneq ($(SKIPWHEREAMISYSTEM),1)
194 ifneq (,$(wildcard /usr/include/whereami.h))
195 WHEREAMILIB =
196 WHEREAMILIBLD = -lwhereami
197 WHEREAMILIBINC =
198 WHEREAMI_FOUND = 1
199 endif
200 endif
201 STATICLIBS += $(WHEREAMILIB)
202 LDLIBS += $(WHEREAMILIBLD)
203 PM3INCLUDES += $(WHEREAMILIBINC)
205 ####################
206 # system libraries #
207 ####################
209 ## Atomic
210 # RPi Zero gcc requires -latomic
211 # but MacOSX /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
212 # doesn't recognize option --as-needed
213 ifneq ($(platform),Darwin)
214 LDLIBS += -Wl,--as-needed -latomic -Wl,--no-as-needed
215 endif
217 ## BZIP2
218 LDLIBS += -lbz2
220 ## Bluez (optional)
221 ifneq ($(SKIPBT),1)
222 BTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags bluez 2>/dev/null)
223 BTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs bluez 2>/dev/null)
224 ifneq ($(BTLDLIBS),)
225 BTLIBLD = $(BTLDLIBS)
226 BTLIBINC = $(BTINCLUDES)
227 BT_FOUND = 1
228 endif
229 endif
230 LDLIBS += $(BTLIBLD)
231 PM3INCLUDES += $(BTLIBINC)
233 ## Math
234 LDLIBS += -lm
236 ## Pthread
237 # Some have no pthread, e.g. termux
238 ifneq ($(SKIPPTHREAD),1)
239 LDLIBS += -lpthread
240 endif
242 ## Python3 (optional)
243 ifneq ($(SKIPPYTHON),1)
244 PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3 2>/dev/null)
245 PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3 2>/dev/null)
246 ifneq ($(PYTHONLDLIBS),)
247 PYTHONLIBLD = $(PYTHONLDLIBS)
248 PYTHONLIBINC = $(PYTHONINCLUDES)
249 PYTHON_FOUND = 1
250 else
251 # since python3.8, applications willing to embed python must use -embed:
252 PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3-embed 2>/dev/null)
253 PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3-embed 2>/dev/null)
254 ifneq ($(PYTHONLDLIBS),)
255 PYTHONLIBLD = $(PYTHONLDLIBS)
256 PYTHONLIBINC = $(PYTHONINCLUDES)
257 PYTHON_FOUND = 1
258 endif
259 endif
260 endif
261 LDLIBS += $(PYTHONLIBLD)
262 PM3INCLUDES += $(PYTHONLIBINC)
264 ## QT5 (or QT4 fallback) (optional)
265 ifneq ($(SKIPQT),1)
266 # Check for correctly configured Qt5
267 QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
268 QTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs Qt5Core Qt5Widgets 2>/dev/null)
269 MOC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=host_bins Qt5Core)/moc
270 UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=host_bins Qt5Core)/uic
271 ifneq ($(QTLDLIBS),)
272 QT5_FOUND = 1
273 else
274 # if Qt5 not found check for correctly configured Qt4
275 QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags QtCore QtGui 2>/dev/null)
276 QTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs QtCore QtGui 2>/dev/null)
277 MOC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=moc_location QtCore)
278 UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=uic_location QtCore)
279 endif
280 ifeq ($(QTLDLIBS),)
281 # if both pkg-config commands failed, search in common places
282 ifneq ($(QTDIR),)
283 ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
284 # QT5
285 QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I$(QTDIR)/include/QtWidgets
286 QTLDLIBS = -L$(QTDIR)/lib -lQt5Core -lQt5Gui -lQt5Widgets
287 QT5_FOUND = 1
288 else
289 # QT4
290 QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
291 QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4
292 endif
293 MOC = $(QTDIR)/bin/moc
294 UIC = $(QTDIR)/bin/uic
295 endif
296 endif
297 ifneq ($(QTLDLIBS),)
298 QT_FOUND = 1
299 endif
300 endif
301 LDLIBS += $(QTLDLIBS)
302 CXXINCLUDES += $(QTINCLUDES)
304 ## Readline
305 ifneq ($(SKIPREADLINE),1)
306 ifeq ($(USE_BREW),1)
307 LDLIBS += -L$(BREW_PREFIX)/opt/readline/lib
308 PM3INCLUDES += -I$(BREW_PREFIX)/opt/readline/include
309 endif
311 ifeq ($(USE_MACPORTS),1)
312 PM3INCLUDES += -I$(MACPORTS_PREFIX)/include/readline
313 endif
315 LDLIBS += -lreadline
316 READLINE_FOUND = 1
317 endif
319 ########
320 # SWIG #
321 ########
323 ifneq ("$(wildcard src/pm3_luawrap.c)","")
324 SWIG_LUA_FOUND = 1
325 endif
326 ifeq ($(PYTHON_FOUND),1)
327 ifneq ("$(wildcard src/pm3_pywrap.c)","")
328 SWIG_PYTHON_FOUND = 1
329 endif
330 endif
332 #######################################################################################################
333 CFLAGS ?= $(DEFCFLAGS)
334 # We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
335 PM3CFLAGS = $(CFLAGS)
336 PM3CFLAGS += -I./src -I./include -I../include -I../common -I../common_fpga $(PM3INCLUDES) $(INCLUDES)
337 # WIP Testing
338 #PM3CFLAGS += -std=c11 -pedantic
340 PREFIX ?= /usr/local
341 ifneq (,$(findstring MINGW,$(platform)))
342 # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
343 # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
344 # FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
345 # but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
346 PM3CFLAGS += -D_ISOC99_SOURCE
347 PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
348 endif
350 ifeq ($(READLINE_FOUND),1)
351 PM3CFLAGS += -DHAVE_READLINE
352 endif
354 ifeq ($(BT_FOUND),1)
355 PM3CFLAGS += -DHAVE_BLUEZ
356 endif
358 ifeq ($(PYTHON_FOUND),1)
359 PM3CFLAGS += -DHAVE_PYTHON
360 endif
362 ifeq ($(SWIG_LUA_FOUND),1)
363 PM3CFLAGS += -DHAVE_LUA_SWIG
364 endif
365 ifeq ($(SWIG_PYTHON_FOUND),1)
366 PM3CFLAGS += -DHAVE_PYTHON_SWIG
367 endif
369 CXXFLAGS ?= -Wall -O3
370 PM3CXXFLAGS = $(CXXFLAGS)
371 PM3CXXFLAGS += -I../include -I./include
373 ifeq ($(QT_FOUND),1)
374 PM3CFLAGS += -DHAVE_GUI
375 PM3CXXFLAGS += -DQT_NO_DEBUG
376 ifeq ($(QT5_FOUND),1)
377 # On OSX Qt5 is claiming for a C++11 compiler (gnu++14 works too, but if nothing it fails)
378 PM3CXXFLAGS += -fPIC -std=c++11
379 endif
380 endif
382 LDFLAGS ?= $(DEFLDFLAGS)
383 PM3LDFLAGS = $(LDFLAGS)
384 ifeq ($(platform),Darwin)
385 PM3LDFLAGS += -framework Foundation -framework AppKit
386 endif
388 ###################
389 # printing status #
390 ###################
392 $(info ===================================================================)
393 $(info Version info: $(shell ../tools/mkversion.sh --short 2>/dev/null))
394 $(info Client platform: $(platform))
396 ifeq ($(SKIPQT),1)
397 $(info GUI support: skipped)
398 else
399 ifeq ($(QT_FOUND),1)
400 ifeq ($(QT5_FOUND),1)
401 $(info GUI support: QT5 found, enabled ($(shell QT_SELECT=5 qmake -v 2>/dev/null|grep -o 'Qt version.*')))
402 else
403 $(info GUI support: QT4 found, enabled ($(shell QT_SELECT=4 qmake -v 2>/dev/null|grep -o 'Qt version.*')))
404 endif
405 else
406 $(info GUI support: QT not found, disabled)
407 endif
408 endif
410 ifeq ($(SKIPBT),1)
411 $(info native BT support: skipped)
412 else
413 ifeq ($(BT_FOUND),1)
414 $(info native BT support: Bluez found, enabled)
415 else
416 $(info native BT support: Bluez not found, disabled)
417 endif
418 endif
420 ifeq ($(SKIPJANSSONSYSTEM),1)
421 $(info Jansson library: local library forced)
422 else ifeq ($(JANSSON_FOUND),1)
423 $(info Jansson library: system library found)
424 else
425 $(info Jansson library: system library not found, using local library)
426 endif
428 ifeq ($(SKIPLUASYSTEM),1)
429 $(info Lua library: local library forced)
430 else
431 ifeq ($(LUA_FOUND),1)
432 $(info Lua library: system library found)
433 else
434 $(info Lua library: system library not found, using local library)
435 endif
436 endif
438 ifeq ($(SKIPPYTHON),1)
439 $(info Python3 library: skipped)
440 else
441 ifeq ($(PYTHON_FOUND),1)
442 $(info Python3 library: Python3 v$(shell pkg-config --modversion python3) found, enabled)
443 else
444 $(info Python3 library: Python3 not found, disabled)
445 endif
446 endif
448 ifeq ($(SKIPREADLINE),1)
449 $(info Readline library: skipped)
450 else
451 ifeq ($(READLINE_FOUND),1)
452 $(info Readline library: enabled)
453 else
454 $(info Readline library: Readline not found, disabled)
455 endif
456 endif
458 ifeq ($(SKIPWHEREAMISYSTEM),1)
459 $(info Whereami library: local library forced)
460 else
461 ifeq ($(WHEREAMI_FOUND),1)
462 $(info Whereami library: system library found)
463 else
464 $(info Whereami library: system library not found, using local library)
465 endif
466 endif
468 ifeq ($(SWIG_LUA_FOUND),1)
469 $(info Lua SWIG: wrapper found)
470 endif
471 ifeq ($(SWIG_PYTHON_FOUND),1)
472 $(info Python SWIG: wrapper found)
473 endif
475 $(info compiler version: $(shell $(CC) --version|head -n 1))
476 $(info ===================================================================)
478 ################
479 # dependencies #
480 ################
482 # Flags to generate temporary dependency files
483 DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
484 # make temporary to final dependency files after successful compilation
485 POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d && $(TOUCH) $@
487 ################
488 # enumerations #
489 ################
491 SRCS = mifare/aiddesfire.c \
492 aidsearch.c \
493 cmdanalyse.c \
494 cmdcrc.c \
495 cmddata.c \
496 cmdflashmem.c \
497 cmdflashmemspiffs.c \
498 cmdhf.c \
499 cmdhf14a.c \
500 cmdhf14b.c \
501 cmdhf15.c \
502 cmdhfcryptorf.c \
503 cmdhfepa.c \
504 cmdhfemrtd.c \
505 cmdhffelica.c \
506 cmdhffido.c \
507 cmdhfcipurse.c \
508 cmdhficlass.c \
509 cmdhflegic.c \
510 cmdhfjooki.c \
511 cmdhflist.c \
512 cmdhflto.c \
513 cmdhfmf.c \
514 cmdhfmfdes.c \
515 cmdhfmfhard.c \
516 cmdhfmfu.c \
517 cmdhfmfp.c \
518 cmdhfseos.c \
519 cmdhfst.c \
520 cmdhfst25ta.c \
521 cmdhfthinfilm.c \
522 cmdhftopaz.c \
523 cmdhfwaveshare.c \
524 cmdhw.c \
525 cmdlf.c \
526 cmdlfawid.c \
527 cmdlfcotag.c \
528 cmdlfdestron.c \
529 cmdlfem.c \
530 cmdlfem410x.c \
531 cmdlfem4x05.c \
532 cmdlfem4x50.c \
533 cmdlfem4x70.c \
534 cmdlffdxb.c \
535 cmdlfguard.c \
536 cmdlfgallagher.c \
537 cmdlfhid.c \
538 cmdlfhitag.c \
539 cmdlfidteck.c \
540 cmdlfindala.c \
541 cmdlfio.c \
542 cmdlfjablotron.c \
543 cmdlfkeri.c \
544 cmdlfmotorola.c \
545 cmdlfnedap.c \
546 cmdlfnexwatch.c \
547 cmdlfnoralsy.c \
548 cmdlfpac.c \
549 cmdlfparadox.c \
550 cmdlfpcf7931.c \
551 cmdlfpresco.c \
552 cmdlfpyramid.c \
553 cmdlfsecurakey.c \
554 cmdlft55xx.c \
555 cmdlfti.c \
556 cmdlfviking.c \
557 cmdlfvisa2000.c \
558 cmdmain.c \
559 cmdnfc.c \
560 cmdparser.c \
561 cmdscript.c \
562 cmdsmartcard.c \
563 cmdtrace.c \
564 cmdusart.c \
565 cmdwiegand.c \
566 comms.c \
567 crypto/asn1dump.c \
568 crypto/asn1utils.c\
569 crypto/libpcrypto.c\
570 emv/cmdemv.c \
571 emv/crypto.c\
572 emv/crypto_polarssl.c\
573 emv/dol.c \
574 emv/emv_pk.c\
575 emv/emv_pki.c\
576 emv/emv_pki_priv.c\
577 emv/emv_roca.c \
578 emv/emv_tags.c \
579 emv/emvcore.c \
580 emv/emvjson.c\
581 emv/tlv.c \
582 emv/test/crypto_test.c\
583 emv/test/cryptotest.c\
584 emv/test/cda_test.c\
585 emv/test/dda_test.c\
586 emv/test/sda_test.c\
587 fido/additional_ca.c \
588 fido/cose.c \
589 fido/cbortools.c \
590 fido/fidocore.c \
591 cipurse/cipursecore.c \
592 cipurse/cipursecrypto.c \
593 cipurse/cipursetest.c \
594 fileutils.c \
595 flash.c \
596 generator.c \
597 graph.c \
598 jansson_path.c \
599 iso7816/apduinfo.c \
600 iso7816/iso7816core.c \
601 loclass/cipher.c \
602 loclass/cipherutils.c \
603 loclass/elite_crack.c \
604 loclass/ikeys.c \
605 mifare/lrpcrypto.c \
606 mifare/desfirecrypto.c \
607 mifare/desfirecore.c \
608 mifare/desfiresecurechan.c \
609 mifare/desfiretest.c \
610 mifare/mad.c \
611 mifare/mfkey.c \
612 mifare/mifare4.c \
613 mifare/mifaredefault.c \
614 mifare/mifarehost.c \
615 nfc/ndef.c \
616 pm3.c \
617 pm3_binlib.c \
618 pm3_bitlib.c \
619 preferences.c \
620 prng.c \
621 proxmark3.c \
622 scandir.c \
623 uart/uart_posix.c \
624 uart/uart_win32.c \
625 scripting.c \
626 tea.c \
627 ui.c \
628 util.c \
629 version_pm3.c \
630 wiegand_formats.c \
631 wiegand_formatutils.c
633 # common
634 SRCS += bucketsort.c \
635 cardhelper.c \
636 crapto1/crapto1.c \
637 crapto1/crypto1.c \
638 crc.c \
639 crc16.c \
640 crc32.c \
641 crc64.c \
642 commonutil.c \
643 iso15693tools.c \
644 legic_prng.c \
645 lfdemod.c \
646 parity.c \
647 util_posix.c
649 # swig
651 SWIGSRCS =
652 ifeq ($(SWIG_LUA_FOUND),1)
653 SWIGSRCS += pm3_luawrap.c
654 endif
655 ifeq ($(SWIG_PYTHON_FOUND),1)
656 SWIGSRCS += pm3_pywrap.c
657 endif
659 # gui
660 ifeq ($(QT_FOUND),1)
661 CXXSRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp
662 else
663 CXXSRCS = guidummy.cpp
664 endif
666 # OS X
667 ifeq ($(platform),Darwin)
668 OBJCSRCS = util_darwin.m
669 endif
671 OBJS = $(SRCS:%.c=$(OBJDIR)/%.o)
672 OBJS += $(SWIGSRCS:%.c=$(OBJDIR)/%.o)
673 OBJS += $(CXXSRCS:%.cpp=$(OBJDIR)/%.o)
674 OBJS += $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
676 BINS = proxmark3
678 CLEAN = $(BINS) src/version_pm3.c src/*.moc.cpp src/ui/ui_overlays.h src/ui/ui_image.h lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
679 # transition: cleaning also old path stuff
680 CLEAN += flasher *.moc.cpp ui/ui_overlays.h ui/ui_image.h
682 ###########
683 # targets #
684 ###########
686 # need to assign dependancies to build these first...
687 all: $(BINS)
689 all-static: LDLIBS:=-static $(LDLIBS)
690 all-static: $(BINS)
692 proxmark3: $(OBJS) $(STATICLIBS) lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
693 $(info [=] LD $@)
694 $(Q)$(LD) $(PM3LDFLAGS) $(OBJS) $(STATICLIBS) $(LDLIBS) -o $@
696 src/proxgui.cpp: src/ui/ui_overlays.h src/ui/ui_image.h
698 src/proxguiqt.moc.cpp: src/proxguiqt.h
699 $(info [-] MOC $@)
700 $(Q)$(MOC) -o$@ $^
702 src/ui/ui_overlays.h: src/ui/overlays.ui
703 $(info [-] UIC $@)
704 $(Q)$(UIC) $^ > $@
706 src/ui/ui_image.h: src/ui/image.ui
707 $(info [-] UIC $@)
708 $(Q)$(UIC) $^ > $@
710 lualibs/pm3_cmd.lua: ../include/pm3_cmd.h
711 $(info [=] GEN $@)
712 $(Q)awk -f pm3_cmd_h2lua.awk $^ > $@
714 lualibs/mfc_default_keys.lua : mfc_default_keys.dic
715 $(info [=] GEN $@)
716 $(Q)awk -f default_keys_dic2lua.awk $^ > $@
718 clean:
719 $(Q)$(RM) $(CLEAN)
720 $(Q)$(RMDIR) $(OBJDIR)
721 $(Q)$(MAKE) --no-print-directory -C $(AMIIBOLIBPATH) clean
722 $(Q)$(MAKE) --no-print-directory -C $(CLIPARSERLIBPATH) clean
723 $(Q)$(MAKE) --no-print-directory -C $(HARDNESTEDLIBPATH) clean
724 $(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) clean
725 $(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) clean
726 $(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) clean
727 $(Q)$(MAKE) --no-print-directory -C $(TINYCBORLIBPATH) clean
728 $(Q)$(MAKE) --no-print-directory -C $(WHEREAMILIBPATH) clean
729 @# Just in case someone compiled within these dirs:
730 $(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) clean
732 install: all
733 $(info [@] Installing client to $(DESTDIR)$(PREFIX)...)
734 ifneq (,$(INSTALLBIN))
735 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)
736 $(Q)$(CP) $(INSTALLBIN) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)
737 endif
738 ifneq (,$(INSTALLSHARE))
739 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
740 $(Q)$(CP) $(INSTALLSHARE) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
741 $(Q)$(CP) src/pm3.py $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)/pyscripts
742 endif
743 @true
745 uninstall:
746 $(info [@] Uninstalling client from $(DESTDIR)$(PREFIX)...)
747 ifneq (,$(INSTALLBIN))
748 $(Q)$(RM) $(foreach tool,$(INSTALLBIN),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)$(PATHSEP)$(notdir $(tool)))
749 endif
750 ifneq (,$(INSTALLSHARE))
751 $(Q)$(RMDIR) $(foreach tool,$(INSTALLSHARE),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)$(PATHSEP)$(notdir $(tool)))
752 endif
753 @true
755 tarbin: $(BINS)
756 $(info [=] TAR ../proxmark3-$(platform)-bin.tar)
757 $(Q)$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
759 ###########################
760 # local libraries targets #
761 ###########################
762 $(AMIIBOLIB): .FORCE
763 $(info [*] MAKE $@)
764 $(Q)$(MAKE) --no-print-directory -C $(AMIIBOLIBPATH) all
766 $(CLIPARSERLIB): .FORCE
767 $(info [*] MAKE $@)
768 $(Q)$(MAKE) --no-print-directory -C $(CLIPARSERLIBPATH) all
770 $(HARDNESTEDLIB): .FORCE
771 $(info [*] MAKE $@)
772 $(Q)$(MAKE) --no-print-directory -C $(HARDNESTEDLIBPATH) all
774 $(JANSSONLIB): .FORCE
775 ifneq ($(JANSSON_FOUND),1)
776 $(info [*] MAKE $@)
777 $(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) all
778 endif
780 $(LUALIB): .FORCE
781 ifneq ($(LUA_FOUND),1)
782 $(info [*] MAKE $@ for $(LUAPLATFORM))
783 $(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) $(LUAPLATFORM)
784 endif
786 $(MBEDTLSLIB): .FORCE
787 $(info [*] MAKE $@)
788 $(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) OBJDIR=$(MBEDTLSLIBCLIENTRELPATH)/$(OBJDIR)/mbedtls BINDIR=$(MBEDTLSLIBCLIENTRELPATH)/$(OBJDIR) all
790 $(REVENGLIB): .FORCE
791 $(info [*] MAKE $@)
792 $(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) all
794 $(TINYCBORLIB): .FORCE
795 $(info [*] MAKE $@)
796 $(Q)$(MAKE) --no-print-directory -C $(TINYCBORLIBPATH) all
798 $(WHEREAMILIB): .FORCE
799 ifneq ($(WHEREAMI_FOUND),1)
800 $(info [*] MAKE $@)
801 $(Q)$(MAKE) --no-print-directory -C $(WHEREAMILIBPATH) all
802 endif
804 ########
805 # SWIG #
806 ########
808 src/pm3_luawrap.c: pm3.i
809 $(info [=] GEN $@)
810 $(Q)$(SWIG) -lua -o $@ $<
812 src/pm3_pywrap.c: pm3.i
813 $(info [=] GEN $@)
814 $(Q)$(SWIG) -python -o $@ $<
816 ########
817 # misc #
818 ########
820 .PHONY: all clean install uninstall tarbin .FORCE
822 # version_pm3.c should be remade on every compilation
823 src/version_pm3.c: default_version_pm3.c
824 $(info [=] GEN $@)
825 $(Q)$(CP) $< $@
827 # easy printing of MAKE VARIABLES
828 print-%: ; @echo $* = $($*)
830 # SWIG files emit a number of warnings, we've to ignore them
831 %wrap.o: %wrap.c
832 $(OBJDIR)/%wrap.o : %wrap.c $(OBJDIR)/%.d
833 $(info [-] CC $<)
834 $(Q)$(MKDIR) $(dir $@)
835 $(Q)$(CC) $(DEPFLAGS) $(PM3CFLAGS) -Wno-missing-prototypes -Wno-missing-declarations -Wno-missing-field-initializers -c -o $@ $<
836 $(Q)$(POSTCOMPILE)
838 %.o: %.c
839 $(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
840 $(info [-] CC $<)
841 $(Q)$(MKDIR) $(dir $@)
842 $(Q)$(CC) $(DEPFLAGS) $(PM3CFLAGS) -c -o $@ $<
843 $(Q)$(POSTCOMPILE)
845 %.o: %.cpp
846 $(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
847 $(info [-] CXX $<)
848 $(Q)$(MKDIR) $(dir $@)
849 $(Q)$(CXX) $(DEPFLAGS) $(PM3CXXFLAGS) $(CXXINCLUDES) -c -o $@ $<
850 $(Q)$(POSTCOMPILE)
852 %.o: %.m
853 $(OBJDIR)/%.o : %.m $(OBJDIR)/%.d
854 $(info [-] CC $<)
855 $(Q)$(MKDIR) $(dir $@)
856 $(Q)$(CC) $(DEPFLAGS) $(PM3CFLAGS) -c -o $@ $<
857 $(Q)$(POSTCOMPILE)
859 DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(SRCS)) \
860 $(patsubst %wrap.c, $(OBJDIR)/%.d, $(SWIGSRCS)) \
861 $(patsubst %.cpp, $(OBJDIR)/%.d, $(CXXSRCS)) \
862 $(patsubst %.m, $(OBJDIR)/%.d, $(OBJCSRCS))
864 $(DEPENDENCY_FILES): ;
865 .PRECIOUS: $(DEPENDENCY_FILES)
867 -include $(DEPENDENCY_FILES)