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