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