fix missing gitignore
[RRG-proxmark3.git] / client / Makefile
blob2da13c683c4e2d82d611aecb253ef9b84b5c9931
1 #-----------------------------------------------------------------------------
2 # Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # See LICENSE.txt for the text of the license.
15 #-----------------------------------------------------------------------------
17 ifeq ($(PLTNAME),)
18 -include ../Makefile.platform
19 -include ../.Makefile.options.cache
20 ifneq ($(PLATFORM), $(CACHED_PLATFORM))
21 $(error platform definitions have been changed, please "make clean" at the root of the project)
22 endif
23 endif
24 include ../Makefile.defs
26 ifeq ($(PLATFORM),PM3ICOPYX)
27 INCLUDES += -DICOPYX
28 endif
30 INSTALLBIN = proxmark3
31 INSTALLSHARE = cmdscripts lualibs luascripts pyscripts resources dictionaries
33 VPATH = ../common src
34 vpath %.dic dictionaries
35 OBJDIR = obj
37 ifeq ($(USE_BREW),1)
38 INCLUDES += -I$(BREW_PREFIX)/include
39 LDLIBS += -L$(BREW_PREFIX)/lib
40 PKG_CONFIG_ENV := PKG_CONFIG_PATH=$(BREW_PREFIX)/lib/pkgconfig:$(BREW_PREFIX)/opt/qt@5/lib/pkgconfig:$(BREW_PREFIX)/opt/qt@5/lib/pkgconfig
41 endif
43 ifeq ($(USE_MACPORTS),1)
44 INCLUDES += -I$(MACPORTS_PREFIX)/include
45 LDLIBS += -L$(MACPORTS_PREFIX)/lib
46 PKG_CONFIG_ENV := PKG_CONFIG_PATH=$(MACPORTS_PREFIX)/lib/pkgconfig
47 endif
50 PM3INCLUDES =
52 ###################
53 # local libraries #
54 ###################
56 ## Amiibo
57 AMIIBOLIBPATH = ./deps/amiitool
58 AMIIBOLIBINC = -I$(AMIIBOLIBPATH)
59 AMIIBOLIB = $(AMIIBOLIBPATH)/libamiibo.a
60 AMIIBOLIBLD =
62 ## Cliparser / Argtable3
63 CLIPARSERLIBPATH = ./deps/cliparser
64 CLIPARSERLIBINC = -I$(CLIPARSERLIBPATH)
65 CLIPARSERLIB = $(CLIPARSERLIBPATH)/libcliparser.a
66 CLIPARSERLIBLD =
68 ## Hardnested
69 HARDNESTEDLIBPATH = ./deps/hardnested
70 HARDNESTEDLIBINC = -I$(HARDNESTEDLIBPATH)
71 HARDNESTEDLIB = $(HARDNESTEDLIBPATH)/libhardnested.a
72 HARDNESTEDLIBLD =
74 ## ID48
75 ID48LIBPATH = ./deps/id48
76 ID48LIBINC = -I$(ID48LIBPATH)
77 ID48LIB = $(ID48LIBPATH)/libid48.a
78 ID48LIBLD =
80 ## Jansson
81 JANSSONLIBPATH = ./deps/jansson
82 JANSSONLIBINC = -I$(JANSSONLIBPATH)
83 JANSSONLIB = $(JANSSONLIBPATH)/libjansson.a
84 JANSSONLIBLD =
86 ## Linenoise
87 # Can be used if Readline is unavailable or explicitely disabled
88 # Requires to be unpacked, see deps/get_linenoise.sh
89 LINENOISELIBPATH = ./deps/linenoise
90 LINENOISELIBINC = -I$(LINENOISELIBPATH)
91 LINENOISELIB = $(LINENOISELIBPATH)/liblinenoise.a
92 LINENOISELIBLD =
94 ## Lua
95 LUALIBPATH = ./deps/liblua
96 LUALIBINC = -I$(LUALIBPATH)
97 LUALIB = $(LUALIBPATH)/liblua.a
98 LUALIBLD =
99 LUAPLATFORM = generic
100 ifneq (,$(findstring MINGW,$(platform)))
101 LUAPLATFORM = mingw
102 else
103 ifeq ($(platform),Darwin)
104 LUAPLATFORM = macosx
105 else
106 LUALIBLD += -ldl
107 LUAPLATFORM = linux
108 endif
109 endif
111 ## Winsock2
112 ifneq (,$(findstring MINGW,$(platform)))
113 LDLIBS += -lws2_32
114 endif
116 ## Reveng
117 REVENGLIBPATH = ./deps/reveng
118 REVENGLIBINC = -I$(REVENGLIBPATH)
119 REVENGLIB = $(REVENGLIBPATH)/libreveng.a
120 REVENGLIBLD =
122 ## Tinycbor
123 TINYCBORLIBPATH = ./deps/tinycbor
124 TINYCBORLIBINC = -I$(TINYCBORLIBPATH)
125 TINYCBORLIB = $(TINYCBORLIBPATH)/tinycbor.a
126 TINYCBORLIBLD =
128 ## Whereami
129 WHEREAMILIBPATH = ./deps/whereami
130 WHEREAMILIBINC = -I$(WHEREAMILIBPATH)
131 WHEREAMILIB = $(WHEREAMILIBPATH)/libwhereami.a
132 WHEREAMILIBLD =
134 ##########################
135 # common local libraries #
136 ##########################
138 ## mbed TLS
139 MBEDTLSLIBPATH = ../common/mbedtls
140 MBEDTLSLIBINC = -I$(MBEDTLSLIBPATH)
141 MBEDTLSLIB = $(OBJDIR)/libmbedtls.a
142 MBEDTLSLIBCLIENTRELPATH = ../../client
144 ########################################################
145 # optional system libraries to replace local libraries #
146 ########################################################
148 ## Amiibo
149 # not distributed as system library
150 STATICLIBS += $(AMIIBOLIB)
151 LDLIBS += $(AMIIBOLIBLD)
152 PM3INCLUDES += $(AMIIBOLIBINC)
154 ## Cliparser / Argtable3
155 # not distributed as system library
156 STATICLIBS += $(CLIPARSERLIB)
157 LDLIBS += $(CLIPARSERLIBLD)
158 PM3INCLUDES += $(CLIPARSERLIBINC)
160 ## Hardnested
161 # not distributed as system library
162 STATICLIBS += $(HARDNESTEDLIB)
163 LDLIBS +=$(HARDNESTEDLIBLD)
164 PM3INCLUDES += $(HARDNESTEDLIBINC)
166 ## ID48
167 # not distributed as system library
168 STATICLIBS += $(ID48LIB)
169 LDLIBS += $(ID48LIBLD)
170 PM3INCLUDES += $(ID48LIBINC)
172 ## Linenoise
173 # wait to see if Readline is available
175 ## Lua
176 ifneq ($(SKIPLUASYSTEM),1)
177 ifdef MACPORTS_PREFIX
178 LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua-5.2 2>/dev/null)
179 LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua-5.2 2>/dev/null)
180 else
181 LUAINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags lua5.2 2>/dev/null)
182 LUALDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs lua5.2 2>/dev/null)
183 endif
184 ifneq ($(LUALDLIBS),)
185 LUALIB =
186 LUALIBLD = $(LUALDLIBS)
187 LUALIBINC = $(LUAINCLUDES)
188 LUA_FOUND = 1
189 endif
190 endif
191 STATICLIBS += $(LUALIB)
192 LDLIBS += $(LUALIBLD)
193 PM3INCLUDES += $(LUALIBINC)
195 ## Jansson
196 # Jansson section needs to be after Lua to avoid interferences on macOS if a locally incompatible Lua was available, see PR 1155
197 ifneq ($(SKIPJANSSONSYSTEM),1)
198 JANSSONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags jansson 2>/dev/null)
199 JANSSONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs jansson 2>/dev/null)
200 ifneq ($(JANSSONLDLIBS),)
201 JANSSONLIB =
202 JANSSONLIBLD = $(JANSSONLDLIBS)
203 JANSSONLIBINC = $(JANSSONINCLUDES)
204 JANSSON_FOUND = 1
205 endif
206 endif
207 STATICLIBS += $(JANSSONLIB)
208 LDLIBS += $(JANSSONLIBLD)
209 PM3INCLUDES += $(JANSSONLIBINC)
211 ## mbed TLS
212 # system library cannot be used because it is compiled by default without CMAC support
213 STATICLIBS += $(MBEDTLSLIB)
214 LDLIBS += $(MBEDTLSLIBLD)
215 PM3INCLUDES += $(MBEDTLSLIBINC)
217 ## Reveng
218 # not distributed as system library
219 STATICLIBS += $(REVENGLIB)
220 LDLIBS += $(REVENGLIBLD)
221 PM3INCLUDES += $(REVENGLIBINC)
223 ## Tinycbor
224 # not distributed as system library
225 STATICLIBS += $(TINYCBORLIB)
226 LDLIBS += $(TINYCBORLIBLD)
227 PM3INCLUDES += $(TINYCBORLIBINC)
229 ## Whereami
230 ifneq ($(SKIPWHEREAMISYSTEM),1)
231 ifneq (,$(wildcard /usr/include/whereami.h))
232 WHEREAMILIB =
233 WHEREAMILIBLD = -lwhereami
234 WHEREAMILIBINC =
235 WHEREAMI_FOUND = 1
236 endif
237 endif
238 STATICLIBS += $(WHEREAMILIB)
239 LDLIBS += $(WHEREAMILIBLD)
240 PM3INCLUDES += $(WHEREAMILIBINC)
242 ####################
243 # system libraries #
244 ####################
246 ## Atomic
247 # RPi Zero gcc requires -latomic
248 # but MacOSX /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
249 # doesn't recognize option --as-needed
250 ifneq ($(platform),Darwin)
251 LDLIBS += -Wl,--as-needed -latomic -Wl,--no-as-needed
252 endif
254 ## BZIP2
255 LDLIBS += -lbz2
257 ## LZ4
258 LDLIBS += -llz4
260 ## Bluez (optional)
261 ifneq ($(SKIPBT),1)
262 BTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags bluez 2>/dev/null)
263 BTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs bluez 2>/dev/null)
264 ifneq ($(BTLDLIBS),)
265 BTLIBLD = $(BTLDLIBS)
266 BTLIBINC = $(BTINCLUDES)
267 BT_FOUND = 1
268 endif
269 endif
270 LDLIBS += $(BTLIBLD)
271 PM3INCLUDES += $(BTLIBINC)
273 ## Math
274 LDLIBS += -lm
276 ## Pthread
277 # Some have no pthread, e.g. termux
278 ifneq ($(SKIPPTHREAD),1)
279 LDLIBS += -lpthread
280 endif
282 ## Python3 (optional)
283 ifneq ($(SKIPPYTHON),1)
284 # since python3.8, applications willing to embed python must use -embed:
285 PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3-embed 2>/dev/null)
286 PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3-embed 2>/dev/null)
287 ifneq ($(PYTHONLDLIBS),)
288 PYTHONLIBLD = $(PYTHONLDLIBS)
289 PYTHONLIBINC = $(subst -I,-isystem ,$(PYTHONINCLUDES))
290 PYTHON_FOUND = 1
291 else
292 PYTHONINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags python3 2>/dev/null)
293 PYTHONLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs python3 2>/dev/null)
294 ifneq ($(PYTHONLDLIBS),)
295 PYTHONLIBLD = $(PYTHONLDLIBS)
296 PYTHONLIBINC = $(subst -I,-isystem ,$(PYTHONINCLUDES))
297 PYTHON_FOUND = 1
298 endif
299 endif
300 endif
301 LDLIBS += $(PYTHONLIBLD)
302 PM3INCLUDES += $(PYTHONLIBINC)
304 ## QT5 (or QT4 fallback) (optional)
305 ifneq ($(SKIPQT),1)
306 # Check for correctly configured Qt5
307 QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags Qt5Core Qt5Widgets 2>/dev/null)
308 QTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs Qt5Core Qt5Widgets 2>/dev/null)
309 MOC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=host_bins Qt5Core)/moc
310 UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=host_bins Qt5Core)/uic
311 QMAKE = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=host_bins Qt5Core)/qmake
312 ifneq ($(QTLDLIBS),)
313 QT5_FOUND = 1
314 else
315 # if Qt5 not found check for correctly configured Qt4
316 QTINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags QtCore QtGui 2>/dev/null)
317 QTLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs QtCore QtGui 2>/dev/null)
318 MOC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=moc_location QtCore)
319 UIC = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=uic_location QtCore)
320 QMAKE = $(shell $(PKG_CONFIG_ENV) pkg-config --variable=exec_prefix QtCore)/bin/qmake
321 endif
322 ifeq ($(QTLDLIBS),)
323 # if both pkg-config commands failed, search in common places
324 ifneq ($(QTDIR),)
325 ifneq ($(wildcard $(QTDIR)/include/QtWidgets),)
326 # QT5
327 QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I$(QTDIR)/include/QtWidgets
328 QTLDLIBS = -L$(QTDIR)/lib -lQt5Core -lQt5Gui -lQt5Widgets
329 QT5_FOUND = 1
330 else
331 # QT4
332 QTINCLUDES = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui
333 QTLDLIBS = -L$(QTDIR)/lib -lQtCore4 -lQtGui4
334 endif
335 MOC = $(QTDIR)/bin/moc
336 UIC = $(QTDIR)/bin/uic
337 QMAKE = $(QTDIR)/bin/qmake
338 endif
339 endif
340 ifneq ($(QTLDLIBS),)
341 QT_FOUND = 1
342 endif
343 endif
344 LDLIBS += $(QTLDLIBS)
345 CXXINCLUDES += $(QTINCLUDES)
347 ## GD (optional)
348 ifneq ($(SKIPGD),1)
349 GDINCLUDES = $(shell $(PKG_CONFIG_ENV) pkg-config --cflags gdlib 2>/dev/null)
350 GDLDLIBS = $(shell $(PKG_CONFIG_ENV) pkg-config --libs gdlib 2>/dev/null)
351 ifneq ($(GDLDLIBS),)
352 LDLIBS += $(GDLDLIBS)
353 PM3INCLUDES += $(GDINCLUDES)
354 GD_FOUND = 1
355 endif
356 endif
358 ## Readline
359 ifneq ($(SKIPREADLINE),1)
360 ifeq ($(USE_BREW),1)
361 LDLIBS += -L$(BREW_PREFIX)/opt/readline/lib
362 PM3INCLUDES += -I$(BREW_PREFIX)/opt/readline/include
363 endif
365 ifeq ($(USE_MACPORTS),1)
366 PM3INCLUDES += -I$(MACPORTS_PREFIX)/include/readline
367 endif
369 LDLIBS += -lreadline
370 READLINE_FOUND = 1
371 else
372 ## Linenoise
373 ifneq ($(SKIPLINENOISE),1)
374 ifneq (,$(wildcard $(LINENOISELIBPATH)))
375 STATICLIBS += $(LINENOISELIB)
376 LDLIBS += $(LINENOISELIBLD)
377 PM3INCLUDES += $(LINENOISELIBINC)
378 LINENOISE_LOCAL_FOUND = 1
379 endif
380 endif
381 endif
383 ########
384 # SWIG #
385 ########
387 ifneq ("$(wildcard src/pm3_luawrap.c)","")
388 SWIG_LUA_FOUND = 1
389 endif
390 ifeq ($(PYTHON_FOUND),1)
391 ifneq ("$(wildcard src/pm3_pywrap.c)","")
392 SWIG_PYTHON_FOUND = 1
393 endif
394 endif
396 #######################################################################################################
397 # clang doesn't like this params
398 #MYCFLAGS += --param max-completely-peeled-insns=1000 --param max-completely-peel-times=10000
399 MYCFLAGS += -O3
401 CFLAGS ?= $(DEFCFLAGS)
402 CFLAGS += $(MYDEFS) $(MYCFLAGS) $(MYINCLUDES)
404 # We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
405 PM3CFLAGS = $(CFLAGS)
406 PM3CFLAGS += -I./src -I./include -I../include -I../common -I../common_fpga $(PM3INCLUDES) $(INCLUDES)
407 # WIP Testing
408 #PM3CFLAGS += -std=c11 -pedantic
410 PREFIX ?= /usr/local
411 ifneq (,$(findstring MINGW,$(platform)))
412 # Mingw uses by default Microsoft printf, we want the GNU printf (e.g. for %z)
413 # and setting _ISOC99_SOURCE sets internally __USE_MINGW_ANSI_STDIO=1
414 # FTR __USE_MINGW_ANSI_STDIO seems deprecated in Mingw32
415 # but not Mingw64 https://fr.osdn.net/projects/mingw/lists/archive/users/2019-January/000199.html
416 PM3CFLAGS += -D_ISOC99_SOURCE
417 PM3CFLAGS += -mno-ms-bitfields -fexec-charset=cp850
418 endif
420 ifeq ($(READLINE_FOUND),1)
421 PM3CFLAGS += -DHAVE_READLINE
422 endif
424 ifeq ($(LINENOISE_LOCAL_FOUND),1)
425 PM3CFLAGS += -DHAVE_LINENOISE
426 endif
428 ifeq ($(BT_FOUND),1)
429 PM3CFLAGS += -DHAVE_BLUEZ
430 endif
432 ifeq ($(PYTHON_FOUND),1)
433 PM3CFLAGS += -DHAVE_PYTHON
434 endif
436 ifeq ($(GD_FOUND),1)
437 PM3CFLAGS += -DHAVE_GD
438 endif
440 ifeq ($(SWIG_LUA_FOUND),1)
441 PM3CFLAGS += -DHAVE_LUA_SWIG
442 endif
443 ifeq ($(SWIG_PYTHON_FOUND),1)
444 PM3CFLAGS += -DHAVE_PYTHON_SWIG
445 endif
447 PM3CFLAGS += -DHAVE_SNPRINTF
449 CXXFLAGS ?= -Wall -Werror
450 CXXFLAGS += $(MYDEFS) $(MYCXXFLAGS) $(MYINCLUDES)
452 PM3CXXFLAGS = $(CXXFLAGS)
453 PM3CXXFLAGS += -I../include -I./include
455 ifeq ($(QT_FOUND),1)
456 PM3CFLAGS += -DHAVE_GUI
457 PM3CXXFLAGS += -DQT_NO_DEBUG
458 ifeq ($(QT5_FOUND),1)
459 # On OSX Qt5 is claiming for a C++11 compiler (gnu++14 works too, but if nothing it fails)
460 PM3CXXFLAGS += -fPIC -std=c++11
461 endif
462 endif
464 PM3CXXFLAGS += -DHAVE_SNPRINTF
466 LDFLAGS ?= $(DEFLDFLAGS)
467 LDFLAGS += $(MYLDFLAGS)
469 PM3LDFLAGS = $(LDFLAGS)
470 ifeq ($(platform),Darwin)
471 ifeq ($(shell uname -p),arm64)
472 # The platform is iOS
473 PM3LDFLAGS += -framework Foundation -framework UIKit
474 else
475 # M* macOS devices return arm
476 PM3LDFLAGS += -framework Foundation -framework AppKit
477 endif
478 endif
480 ###################
481 # printing status #
482 ###################
484 $(info ===================================================================)
485 $(info Version info: $(shell ../tools/mkversion.sh --short 2>/dev/null))
486 $(info Client platform: $(platform))
488 ifeq ($(SKIPQT),1)
489 $(info GUI support: skipped)
490 else
491 ifeq ($(QT_FOUND),1)
492 ifeq ($(QT5_FOUND),1)
493 $(info GUI support: QT5 found, enabled ($(shell QT_SELECT=5 $(QMAKE) -v 2>/dev/null|grep -o 'Qt version.*')))
494 else
495 $(info GUI support: QT4 found, enabled ($(shell QT_SELECT=4 $(QMAKE) -v 2>/dev/null|grep -o 'Qt version.*')))
496 endif
497 else
498 $(info GUI support: QT not found, disabled)
499 endif
500 endif
502 ifeq ($(SKIPBT),1)
503 $(info native BT support: skipped)
504 else
505 ifeq ($(BT_FOUND),1)
506 $(info native BT support: Bluez found, enabled)
507 else
508 $(info native BT support: Bluez not found, disabled)
509 endif
510 endif
512 ifeq ($(SKIPJANSSONSYSTEM),1)
513 $(info Jansson library: local library forced)
514 else ifeq ($(JANSSON_FOUND),1)
515 $(info Jansson library: system library found)
516 else
517 $(info Jansson library: system library not found, using local library)
518 endif
520 ifeq ($(SKIPLUASYSTEM),1)
521 $(info Lua library: local library forced)
522 else
523 ifeq ($(LUA_FOUND),1)
524 $(info Lua library: system library found)
525 else
526 $(info Lua library: system library not found, using local library)
527 endif
528 endif
530 ifeq ($(SKIPPYTHON),1)
531 $(info Python3 library: skipped)
532 else
533 ifeq ($(PYTHON_FOUND),1)
534 $(info Python3 library: Python3 v$(shell $(PKG_CONFIG_ENV) pkg-config --modversion python3) found, enabled)
535 else
536 $(info Python3 library: Python3 not found, disabled)
537 endif
538 endif
540 ifeq ($(SKIPGD),1)
541 $(info GD library: skipped)
542 else
543 ifeq ($(GD_FOUND),1)
544 $(info GD library: GD v$(shell $(PKG_CONFIG_ENV) pkg-config --modversion gdlib) found, enabled)
545 else
546 $(info GD library: GD not found, disabled)
547 endif
548 endif
550 ifeq ($(SKIPREADLINE),1)
551 $(info Readline library: skipped)
552 else
553 ifeq ($(READLINE_FOUND),1)
554 $(info Readline library: enabled)
555 else
556 $(info Readline library: Readline not found, disabled)
557 endif
558 endif
560 ifneq ($(READLINE_FOUND),1)
561 ifeq ($(SKIPLINENOISE),1)
562 $(info Linenoise library: skipped)
563 else
564 ifeq ($(LINENOISE_LOCAL_FOUND),1)
565 $(info Linenoise library: enabled)
566 else
567 $(info Linenoise library: Linenoise not found, disabled)
568 endif
569 endif
570 endif
572 ifeq ($(SKIPWHEREAMISYSTEM),1)
573 $(info Whereami library: local library forced)
574 else
575 ifeq ($(WHEREAMI_FOUND),1)
576 $(info Whereami library: system library found)
577 else
578 $(info Whereami library: system library not found, using local library)
579 endif
580 endif
582 ifeq ($(SWIG_LUA_FOUND),1)
583 $(info Lua SWIG: wrapper found)
584 endif
585 ifeq ($(SWIG_PYTHON_FOUND),1)
586 $(info Python SWIG: wrapper found)
587 endif
589 $(info compiler version: $(shell $(CC) --version|head -n 1))
590 $(info ===================================================================)
592 ################
593 # dependencies #
594 ################
596 # Flags to generate temporary dependency files
597 DEPFLAGS = -MT $@ -MMD -MP -MF $(OBJDIR)/$*.Td
598 # make temporary to final dependency files after successful compilation
599 POSTCOMPILE = $(MV) -f $(OBJDIR)/$*.Td $(OBJDIR)/$*.d && $(TOUCH) $@
601 ################
602 # enumerations #
603 ################
605 SRCS = mifare/aiddesfire.c \
606 aidsearch.c \
607 atrs.c \
608 cmdanalyse.c \
609 cmdcrc.c \
610 cmddata.c \
611 cmdflashmem.c \
612 cmdflashmemspiffs.c \
613 cmdhf.c \
614 cmdhf14a.c \
615 cmdhf14b.c \
616 cmdhf15.c \
617 cmdhfcryptorf.c \
618 cmdhfepa.c \
619 cmdhfemrtd.c \
620 cmdhffelica.c \
621 cmdhffido.c \
622 cmdhffudan.c \
623 cmdhfgallagher.c \
624 cmdhfksx6924.c \
625 cmdhfcipurse.c \
626 cmdhficlass.c \
627 cmdhfict.c \
628 cmdhflegic.c \
629 cmdhfjooki.c \
630 cmdhflist.c \
631 cmdhflto.c \
632 cmdhfmf.c \
633 cmdhfmfdes.c \
634 cmdhfmfhard.c \
635 cmdhfmfu.c \
636 cmdhfmfp.c \
637 cmdhfntag424.c \
638 cmdhfseos.c \
639 cmdhfst.c \
640 cmdhfst25ta.c \
641 cmdhftesla.c \
642 cmdhfthinfilm.c \
643 cmdhftopaz.c \
644 cmdhftexkom.c \
645 cmdhfvas.c \
646 cmdhfxerox.c \
647 cmdhw.c \
648 cmdlf.c \
649 cmdlfawid.c \
650 cmdlfcotag.c \
651 cmdlfdestron.c \
652 cmdlfem.c \
653 cmdlfem410x.c \
654 cmdlfem4x05.c \
655 cmdlfem4x50.c \
656 cmdlfem4x70.c \
657 cmdlffdxb.c \
658 cmdlfguard.c \
659 cmdlfgallagher.c \
660 cmdlfhid.c \
661 cmdlfhitag.c \
662 cmdlfhitaghts.c \
663 cmdlfidteck.c \
664 cmdlfindala.c \
665 cmdlfio.c \
666 cmdlfjablotron.c \
667 cmdlfkeri.c \
668 cmdlfmotorola.c \
669 cmdlfnedap.c \
670 cmdlfnexwatch.c \
671 cmdlfnoralsy.c \
672 cmdlfpac.c \
673 cmdlfparadox.c \
674 cmdlfpcf7931.c \
675 cmdlfpresco.c \
676 cmdlfpyramid.c \
677 cmdlfsecurakey.c \
678 cmdlft55xx.c \
679 cmdlfti.c \
680 cmdlfviking.c \
681 cmdlfvisa2000.c \
682 cmdlfzx8211.c \
683 cmdmain.c \
684 cmdnfc.c \
685 cmdparser.c \
686 cmdpiv.c \
687 cmdscript.c \
688 cmdsmartcard.c \
689 cmdtrace.c \
690 cmdusart.c \
691 cmdwiegand.c \
692 comms.c \
693 crypto/asn1dump.c \
694 crypto/asn1utils.c\
695 crypto/libpcrypto.c\
696 emv/cmdemv.c \
697 emv/crypto.c\
698 emv/crypto_polarssl.c\
699 emv/dol.c \
700 emv/emv_pk.c\
701 emv/emv_pki.c\
702 emv/emv_pki_priv.c\
703 emv/emv_roca.c \
704 emv/emv_tags.c \
705 emv/emvcore.c \
706 emv/emvjson.c\
707 emv/tlv.c \
708 emv/test/crypto_test.c\
709 emv/test/cryptotest.c\
710 emv/test/cda_test.c\
711 emv/test/dda_test.c\
712 emv/test/sda_test.c\
713 fido/additional_ca.c \
714 fido/cose.c \
715 fido/cbortools.c \
716 fido/fidocore.c \
717 ksx6924/ksx6924core.c \
718 cipurse/cipursecore.c \
719 cipurse/cipursecrypto.c \
720 cipurse/cipursetest.c \
721 fileutils.c \
722 flash.c \
723 generator.c \
724 graph.c \
725 jansson_path.c \
726 iso4217.c \
727 iso7816/apduinfo.c \
728 iso7816/iso7816core.c \
729 loclass/cipher.c \
730 loclass/cipherutils.c \
731 loclass/elite_crack.c \
732 loclass/ikeys.c \
733 mifare/lrpcrypto.c \
734 mifare/desfirecrypto.c \
735 mifare/desfirecore.c \
736 mifare/desfiresecurechan.c \
737 mifare/desfiretest.c \
738 mifare/gallaghercore.c \
739 mifare/mad.c \
740 mifare/mfkey.c \
741 mifare/mifare4.c \
742 mifare/mifaredefault.c \
743 mifare/mifarehost.c \
744 mifare/gen4.c \
745 nfc/ndef.c \
746 pm3.c \
747 pm3_binlib.c \
748 pm3_bitlib.c \
749 preferences.c \
750 pm3line.c \
751 proxmark3.c \
752 scandir.c \
753 uart/ringbuffer.c \
754 uart/uart_common.c \
755 uart/uart_posix.c \
756 uart/uart_win32.c \
757 scripting.c \
758 ui.c \
759 util.c \
760 version_pm3.c \
761 wiegand_formats.c \
762 wiegand_formatutils.c
764 # common
765 SRCS += bucketsort.c \
766 bruteforce.c \
767 cardhelper.c \
768 crapto1/crapto1.c \
769 crapto1/crypto1.c \
770 crc.c \
771 crc16.c \
772 crc32.c \
773 crc64.c \
774 commonutil.c \
775 hitag2/hitag2_crypto.c \
776 iso15693tools.c \
777 legic_prng.c \
778 lfdemod.c \
779 util_posix.c
781 ifeq ($(GD_FOUND),1)
782 # electronic shelf labels
783 SRCS += imgutils.c \
784 cmdhfwaveshare.c
785 endif
787 # swig
789 SWIGSRCS =
790 ifeq ($(SWIG_LUA_FOUND),1)
791 SWIGSRCS += pm3_luawrap.c
792 endif
793 ifeq ($(SWIG_PYTHON_FOUND),1)
794 SWIGSRCS += pm3_pywrap.c
795 endif
797 # gui
798 ifeq ($(QT_FOUND),1)
799 CXXSRCS = proxgui.cpp proxguiqt.cpp proxguiqt.moc.cpp
800 else
801 CXXSRCS = guidummy.cpp
802 endif
804 # OS X
805 ifeq ($(platform),Darwin)
806 OBJCSRCS = util_darwin.m
807 endif
809 OBJS = $(SRCS:%.c=$(OBJDIR)/%.o)
810 OBJS += $(SWIGSRCS:%.c=$(OBJDIR)/%.o)
811 OBJS += $(CXXSRCS:%.cpp=$(OBJDIR)/%.o)
812 OBJS += $(OBJCSRCS:%.m=$(OBJDIR)/%.o)
814 BINS = proxmark3
816 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
817 # transition: cleaning also old path stuff
818 CLEAN += flasher *.moc.cpp ui/ui_overlays.h ui/ui_image.h
820 ###########
821 # targets #
822 ###########
824 # need to assign dependancies to build these first...
825 all: $(BINS)
827 all-static: LDLIBS:=-static $(LDLIBS)
828 all-static: $(BINS)
830 proxmark3: $(OBJS) $(STATICLIBS) lualibs/pm3_cmd.lua lualibs/mfc_default_keys.lua
831 $(info [=] CXX $@)
832 # $(Q)$(CXX) $(PM3LDFLAGS) $(OBJS) $(STATICLIBS) $(LDLIBS) -o $@
833 $(Q)$(CXX) $(PM3CFLAGS) $(PM3LDFLAGS) $(OBJS) $(STATICLIBS) $(LDLIBS) -o $@
835 src/proxgui.cpp: src/ui/ui_overlays.h src/ui/ui_image.h
837 src/proxguiqt.cpp: src/proxguiqt.h
839 src/proxguiqt.moc.cpp: src/proxguiqt.h
840 $(info [-] MOC $@)
841 $(Q)$(MOC) -o$@ $^
843 src/proxguiqt.h: src/ui/ui_overlays.h src/ui/ui_image.h
845 src/ui/ui_overlays.h: src/ui/overlays.ui
846 $(info [-] UIC $@)
847 $(Q)$(UIC) $^ > $@
849 src/ui/ui_image.h: src/ui/image.ui
850 $(info [-] UIC $@)
851 $(Q)$(UIC) $^ > $@
853 lualibs/pm3_cmd.lua: ../include/pm3_cmd.h
854 $(info [=] GEN $@)
855 $(Q)awk -f pm3_cmd_h2lua.awk $^ > $@
857 lualibs/mfc_default_keys.lua : mfc_default_keys.dic
858 $(info [=] GEN $@)
859 $(Q)awk -f default_keys_dic2lua.awk $^ > $@
861 clean:
862 $(Q)$(RM) $(CLEAN)
863 $(Q)$(RMDIR) $(OBJDIR)
864 $(Q)$(MAKE) --no-print-directory -C $(AMIIBOLIBPATH) clean
865 $(Q)$(MAKE) --no-print-directory -C $(CLIPARSERLIBPATH) clean
866 $(Q)$(MAKE) --no-print-directory -C $(HARDNESTEDLIBPATH) clean
867 $(Q)$(MAKE) --no-print-directory -C $(ID48LIBPATH) clean
868 $(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) clean
869 ifeq ($(LINENOISE_LOCAL_FOUND), 1)
870 $(Q)$(MAKE) --no-print-directory -C $(LINENOISELIBPATH) clean
871 endif
872 $(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) clean
873 $(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) clean
874 $(Q)$(MAKE) --no-print-directory -C $(TINYCBORLIBPATH) clean
875 $(Q)$(MAKE) --no-print-directory -C $(WHEREAMILIBPATH) clean
876 @# Just in case someone compiled within these dirs:
877 $(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) clean
879 install: all
880 $(info [@] Installing client to $(DESTDIR)$(PREFIX)...)
881 ifneq (,$(INSTALLBIN))
882 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)
883 $(Q)$(INSTALLSUDO) $(CP) $(INSTALLBIN) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)
884 endif
885 ifneq (,$(INSTALLSHARE))
886 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
887 $(Q)$(INSTALLSUDO) $(CP) $(INSTALLSHARE) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
888 endif
889 @true
891 uninstall:
892 $(info [@] Uninstalling client from $(DESTDIR)$(PREFIX)...)
893 ifneq (,$(INSTALLBIN))
894 $(Q)$(INSTALLSUDO) $(RM) $(foreach tool,$(INSTALLBIN),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)$(PATHSEP)$(notdir $(tool)))
895 endif
896 ifneq (,$(INSTALLSHARE))
897 $(Q)$(INSTALLSUDO) $(RMDIR) $(foreach tool,$(INSTALLSHARE),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)$(PATHSEP)$(notdir $(tool)))
898 endif
899 @true
901 tarbin: $(BINS)
902 $(info [=] TAR ../proxmark3-$(platform)-bin.tar)
903 $(Q)$(TAR) $(TARFLAGS) ../proxmark3-$(platform)-bin.tar $(BINS:%=client/%) $(WINBINS:%=client/%)
905 ###########################
906 # local libraries targets #
907 ###########################
908 $(AMIIBOLIB): .FORCE
909 $(info [*] MAKE $@)
910 $(Q)$(MAKE) --no-print-directory -C $(AMIIBOLIBPATH) all
912 $(CLIPARSERLIB): .FORCE
913 $(info [*] MAKE $@)
914 $(Q)$(MAKE) --no-print-directory -C $(CLIPARSERLIBPATH) all
916 $(HARDNESTEDLIB): .FORCE
917 $(info [*] MAKE $@)
918 $(Q)$(MAKE) --no-print-directory -C $(HARDNESTEDLIBPATH) all
920 $(ID48LIB): .FORCE
921 $(info [*] MAKE $@)
922 $(Q)$(MAKE) --no-print-directory -C $(ID48LIBPATH) all
924 $(JANSSONLIB): .FORCE
925 ifneq ($(JANSSON_FOUND),1)
926 $(info [*] MAKE $@)
927 $(Q)$(MAKE) --no-print-directory -C $(JANSSONLIBPATH) all
928 endif
930 $(LINENOISELIB): .FORCE
931 ifeq ($(LINENOISE_LOCAL_FOUND), 1)
932 $(info [*] MAKE $@)
933 $(Q)$(MAKE) --no-print-directory -C $(LINENOISELIBPATH) all
934 endif
936 $(LUALIB): .FORCE
937 ifneq ($(LUA_FOUND),1)
938 $(info [*] MAKE $@ for $(LUAPLATFORM))
939 $(Q)$(MAKE) --no-print-directory -C $(LUALIBPATH) $(LUAPLATFORM)
940 endif
942 $(MBEDTLSLIB): .FORCE
943 $(info [*] MAKE $@)
944 $(Q)$(MAKE) --no-print-directory -C $(MBEDTLSLIBPATH) OBJDIR=$(MBEDTLSLIBCLIENTRELPATH)/$(OBJDIR)/mbedtls BINDIR=$(MBEDTLSLIBCLIENTRELPATH)/$(OBJDIR) all
946 $(REVENGLIB): .FORCE
947 $(info [*] MAKE $@)
948 $(Q)$(MAKE) --no-print-directory -C $(REVENGLIBPATH) all
950 $(TINYCBORLIB): .FORCE
951 $(info [*] MAKE $@)
952 $(Q)$(MAKE) --no-print-directory -C $(TINYCBORLIBPATH) all
954 $(WHEREAMILIB): .FORCE
955 ifneq ($(WHEREAMI_FOUND),1)
956 $(info [*] MAKE $@)
957 $(Q)$(MAKE) --no-print-directory -C $(WHEREAMILIBPATH) all
958 endif
960 ########
961 # SWIG #
962 ########
964 src/pm3_luawrap.c: pm3.i
965 $(info [=] GEN $@)
966 $(Q)$(SWIG) -lua -o $@ $<
968 src/pm3_pywrap.c: pm3.i
969 $(info [=] GEN $@)
970 $(Q)$(SWIG) -python -o $@ $<
972 ########
973 # misc #
974 ########
976 .PHONY: all clean install uninstall tarbin .FORCE
978 # version_pm3.c should be checked on every compilation
979 src/version_pm3.c: default_version_pm3.c .FORCE
980 $(info [=] CHECK $@)
981 $(Q)$(SH) ../tools/mkversion.sh $@ || $(CP) $< $@
983 # easy printing of MAKE VARIABLES
984 print-%: ; @echo $* = $($*)
986 # SWIG files emit a number of warnings, we've to ignore them
987 %wrap.o: %wrap.c
988 $(OBJDIR)/%wrap.o : %wrap.c $(OBJDIR)/%.d
989 $(info [-] CC $<)
990 $(Q)$(MKDIR) $(dir $@)
991 $(Q)$(CC) $(DEPFLAGS) $(PM3CFLAGS) -Wno-missing-prototypes -Wno-missing-declarations -Wno-missing-field-initializers -c -o $@ $<
992 $(Q)$(POSTCOMPILE)
994 %.o: %.c
995 $(OBJDIR)/%.o : %.c $(OBJDIR)/%.d
996 $(info [-] CC $<)
997 $(Q)$(MKDIR) $(dir $@)
998 $(Q)$(CC) $(DEPFLAGS) $(PM3CFLAGS) -c -o $@ $<
999 $(Q)$(POSTCOMPILE)
1001 %.o: %.cpp
1002 $(OBJDIR)/%.o : %.cpp $(OBJDIR)/%.d
1003 $(info [-] CXX $<)
1004 $(Q)$(MKDIR) $(dir $@)
1005 $(Q)$(CXX) $(DEPFLAGS) $(PM3CXXFLAGS) $(CXXINCLUDES) -c -o $@ $<
1006 $(Q)$(POSTCOMPILE)
1008 %.o: %.m
1009 $(OBJDIR)/%.o : %.m $(OBJDIR)/%.d
1010 $(info [-] CC $<)
1011 $(Q)$(MKDIR) $(dir $@)
1012 $(Q)$(CC) $(DEPFLAGS) $(PM3CFLAGS) -c -o $@ $<
1013 $(Q)$(POSTCOMPILE)
1015 DEPENDENCY_FILES = $(patsubst %.c, $(OBJDIR)/%.d, $(SRCS)) \
1016 $(patsubst %wrap.c, $(OBJDIR)/%.d, $(SWIGSRCS)) \
1017 $(patsubst %.cpp, $(OBJDIR)/%.d, $(CXXSRCS)) \
1018 $(patsubst %.m, $(OBJDIR)/%.d, $(OBJCSRCS))
1020 $(DEPENDENCY_FILES): ;
1021 .PRECIOUS: $(DEPENDENCY_FILES)
1023 -include $(DEPENDENCY_FILES)