3 -include Makefile.platform
4 -include .Makefile.options.cache
5 include common_arm
/Makefile.hal
7 # preserve relative DESTDIR path for subdir makes
9 # realpath needs the directory to exist
10 $(shell $(MKDIR
) $(DESTDIR
))
11 MYDESTDIR
:=$(realpath
$(DESTDIR
))
13 $(error Can
't create $(DESTDIR))
17 all clean install uninstall check: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% mf_nonce_brute/% fpga_compress/%
18 # hitag2crack toolsuite is not yet integrated in "all", it must be called explicitly: "make hitag2crack"
19 #all clean install uninstall check: %: hitag2crack/%
21 INSTALLTOOLS=pm3_eml2lower.sh pm3_eml2upper.sh pm3_mfdread.py pm3_mfd2eml.py pm3_eml2mfd.py findbits.py rfidtest.pl xorcheck.py
22 INSTALLSIMFW=sim011.bin sim011.sha512.txt
23 INSTALLSCRIPTS=pm3 pm3-flash pm3-flash-all pm3-flash-bootrom pm3-flash-fullimage
24 INSTALLSHARES=tools/jtag_openocd traces
25 INSTALLDOCS=doc/*.md doc/md
27 install: all common/install
30 $(info [@] Installing common resources to $(MYDESTDIR)$(PREFIX)...)
31 ifneq (,$(INSTALLSCRIPTS))
32 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)
33 $(Q)$(CP) $(INSTALLSCRIPTS) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)
35 ifneq (,$(INSTALLSHARES))
36 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
37 $(Q)$(CP) $(INSTALLSHARES) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
39 ifneq (,$(INSTALLDOCS))
40 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLDOCSRELPATH)
41 $(Q)$(CP) $(INSTALLDOCS) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLDOCSRELPATH)
43 ifneq (,$(INSTALLTOOLS))
44 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
45 $(Q)$(CP) $(foreach tool,$(INSTALLTOOLS),tools/$(tool)) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
47 ifneq (,$(INSTALLSIMFW))
48 $(Q)$(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)
49 $(Q)$(CP) $(foreach fw,$(INSTALLSIMFW),client/resources/$(fw)) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)
51 ifeq ($(platform),Linux)
52 $(Q)$(MKDIR) $(DESTDIR)$(UDEV_PREFIX)
53 $(Q)$(CP) driver/77-pm3-usb-device-blacklist.rules $(DESTDIR)$(UDEV_PREFIX)/77-pm3-usb-device-blacklist.rules
56 uninstall: common/uninstall
59 $(info [@] Uninstalling common resources from $(MYDESTDIR)$(PREFIX)...)
60 ifneq (,$(INSTALLSCRIPTS))
61 $(Q)$(RM) $(foreach script,$(INSTALLSCRIPTS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)$(PATHSEP)$(notdir $(script)))
63 ifneq (,$(INSTALLSHARES))
64 $(Q)$(RMDIR) $(foreach share,$(INSTALLSHARES),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)$(PATHSEP)$(notdir $(share)))
66 ifneq (,$(INSTALLDOCS))
67 $(Q)$(RMDIR) $(foreach doc,$(INSTALLDOCS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLDOCSRELPATH)$(PATHSEP)$(notdir $(doc)))
68 $(Q)$(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLDOCSRELPATH)
70 ifneq (,$(INSTALLTOOLS))
71 $(Q)$(RM) $(foreach tool,$(INSTALLTOOLS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)$(PATHSEP)$(notdir $(tool)))
73 $(Q)$(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
74 ifneq (,$(INSTALLSIMFW))
75 $(Q)$(RM) $(foreach fw,$(INSTALLSIMFW),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)$(PATHSEP)$(notdir $(fw)))
77 $(Q)$(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)
78 ifeq ($(platform),Linux)
79 $(Q)$(RM) $(DESTDIR)$(UDEV_PREFIX)/77-pm3-usb-device-blacklist.rules
81 $(Q)$(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
85 $(info [*] CHECK $(patsubst %/check,%,$@))
86 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
87 nonce2key/check: FORCE
88 $(info [*] CHECK $(patsubst %/check,%,$@))
89 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
90 mf_nonce_brute/check: FORCE
91 $(info [*] CHECK $(patsubst %/check,%,$@))
92 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
93 fpga_compress/check: FORCE
94 $(info [*] CHECK $(patsubst %/check,%,$@))
95 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
97 $(info [*] CHECK $(patsubst %/check,%,$@))
98 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
100 $(info [*] CHECK $(patsubst %/check,%,$@))
101 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
103 $(info [*] CHECK $(patsubst %/check,%,$@))
104 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
105 recovery/check: FORCE
106 $(info [*] CHECK $(patsubst %/check,%,$@))
107 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
108 hitag2crack/check: FORCE
109 $(info [*] CHECK $(patsubst %/check,%,$@))
110 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
112 $(info [*] CHECK $(patsubst %/check,%,$@))
113 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
115 $(info [*] ALL CHECKS DONE)
119 $(Q)$(MAKE) --no-print-directory -C tools/mfkey $(patsubst mfkey/%,%,$@) DESTDIR=$(MYDESTDIR)
122 $(Q)$(MAKE) --no-print-directory -C tools/nonce2key $(patsubst nonce2key/%,%,$@) DESTDIR=$(MYDESTDIR)
123 mf_nonce_brute/%: FORCE
125 $(Q)$(MAKE) --no-print-directory -C tools/mf_nonce_brute $(patsubst mf_nonce_brute/%,%,$@) DESTDIR=$(MYDESTDIR)
126 fpga_compress/%: FORCE
128 $(Q)$(MAKE) --no-print-directory -C tools/fpga_compress $(patsubst fpga_compress/%,%,$@) DESTDIR=$(MYDESTDIR)
129 bootrom/%: FORCE cleanifplatformchanged
131 $(Q)$(MAKE) --no-print-directory -C bootrom $(patsubst bootrom/%,%,$@) DESTDIR=$(MYDESTDIR)
132 armsrc/%: FORCE cleanifplatformchanged fpga_compress/%
134 $(Q)$(MAKE) --no-print-directory -C armsrc $(patsubst armsrc/%,%,$@) DESTDIR=$(MYDESTDIR)
137 $(Q)$(MAKE) --no-print-directory -C client $(patsubst client/%,%,$@) DESTDIR=$(MYDESTDIR)
138 recovery/all: bootrom/all armsrc/all
139 recovery/install: bootrom/all armsrc/all
140 recovery/%: FORCE cleanifplatformchanged
142 $(Q)$(MAKE) --no-print-directory -C recovery $(patsubst recovery/%,%,$@) DESTDIR=$(MYDESTDIR)
145 $(Q)$(MAKE) --no-print-directory -C tools/hitag2crack $(patsubst hitag2crack/%,%,$@) DESTDIR=$(MYDESTDIR)
146 FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites
)
148 .PHONY
: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key mf_nonce_brute hitag2crack style miscchecks release FORCE udev accessrights cleanifplatformchanged
151 @echo
"Multi-OS Makefile"
153 @echo
"Possible targets:"
154 @echo
"+ all - Make all targets: bootrom, fullimage and OS-specific host tools"
155 @echo
"+ clean - Clean in all targets"
156 @echo
"+ .../clean - Clean in specified target and its deps, e.g. bootrom/clean"
157 @echo
"+ (un)install - Install/uninstall Proxmark files in the system, default to /usr/local/share,"
158 @echo
" else provide a PREFIX. See Maintainers.md for more options"
160 @echo
"+ bootrom - Make bootrom"
161 @echo
"+ fullimage - Make armsrc fullimage (includes fpga)"
162 @echo
"+ recovery - Make bootrom and fullimage files for JTAG flashing"
164 @echo
"+ client - Make only the OS-specific host client"
165 @echo
"+ mfkey - Make tools/mfkey"
166 @echo
"+ nonce2key - Make tools/nonce2key"
167 @echo
"+ mf_nonce_brute - Make tools/mf_nonce_brute"
168 @echo
"+ hitag2crack - Make tools/hitag2crack"
169 @echo
"+ fpga_compress - Make tools/fpga_compress"
171 @echo
"+ style - Apply some automated source code formatting rules"
172 @echo
"+ check - Run offline tests. Set CHECKARGS to pass arguments to the test script"
173 @echo
"+ .../check - Run offline tests against specific target. See above."
174 @echo
"+ miscchecks - Detect various encoding issues in source code"
176 @echo
"+ udev - Sets udev rules on *nix"
177 @echo
"+ accessrights - Ensure user belongs to correct group on *nix"
179 @echo
"Possible platforms: try \"make PLATFORM=\" for more info, default is PM3RDV4"
180 @echo
"To activate verbose mode, use make V=1"
186 # aliases fullimage = armsrc
188 fullimage
: armsrc
/all
190 fullimage
/all: armsrc
/all
192 fullimage
/clean: armsrc
/clean
194 fullimage
/install: armsrc
/install
196 fullimage
/uninstall: armsrc
/uninstall
198 recovery
: recovery
/all
202 nonce2key
: nonce2key
/all
204 mf_nonce_brute
: mf_nonce_brute
/all
206 fpga_compress
: fpga_compress
/all
208 hitag2crack
: hitag2crack
/all
211 $(RM
) proxmark3-
$(platform
)-bin.
tar proxmark3-
$(platform
)-bin.
tar.gz
212 @touch proxmark3-
$(platform
)-bin.
tar
214 tarbin
: newtarbin client
/tarbin armsrc
/tarbin bootrom
/tarbin
215 $(info GEN proxmark3-
$(platform
)-bin.
tar)
216 $(Q
)$(GZIP
) proxmark3-
$(platform
)-bin.
tar
218 # detect if there were changes in the platform definitions, requiring a clean
219 cleanifplatformchanged
:
220 ifeq ($(PLATFORM_CHANGED
),true
)
221 $(info [!] Platform definitions changed
, cleaning bootrom
/armsrc
/recovery first...
)
222 $(Q
)$(MAKE
) --no-print-directory
-C bootrom
clean
223 $(Q
)$(MAKE
) --no-print-directory
-C armsrc
clean
224 $(Q
)$(MAKE
) --no-print-directory
-C recovery
clean
225 $(Q
)echo CACHED_PLATFORM
=$(PLATFORM
) > .Makefile.options.cache
226 $(Q
)echo CACHED_PLATFORM_EXTRAS
=$(PLATFORM_EXTRAS
) >> .Makefile.options.cache
227 $(Q
)echo CACHED_PLATFORM_DEFS
=$(PLATFORM_DEFS
) >> .Makefile.options.cache
230 # configure system to ignore PM3 device as a modem (ModemManager blacklist, effective *only* if ModemManager is not using _strict_ policy)
231 # Read doc/md/ModemManager-Must-Be-Discarded.md for more info
233 sudo cp
-rf driver
/77-pm3-usb-device-blacklist.rules
/etc
/udev
/rules.d
/77-pm3-usb-device-blacklist.rules
234 sudo udevadm control
--reload-rules
236 # configure system to add user to the dialout group
237 # you need to logout, relogin to get this access right correct.
238 # Finally, you might need to run the proxmark3 client under SUDO on some systems
240 ifneq ($(wildcard /etc
/arch-release
),) #If user is running ArchLinux
241 sudo usermod
-aG uucp
$(USER
) #Use specific command and group
242 sudo usermod
-aG bluetooth
$(USER
) #Use specific command and group
244 sudo adduser
$(USER
) dialout
245 sudo adduser
$(USER
) bluetooth
248 # easy printing of MAKE VARIABLES
249 print-
%: ; @echo
$* = $($*)
252 # Make sure astyle is installed
253 @which astyle
>/dev
/null ||
( echo
"Please install 'astyle' package first" ; exit
1 )
254 # Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.cpp. *.lua, *.py, *.pl, Makefile, *.v, pm3
255 find . \
( -not
-path
"./cov-int/*" -and
-not
-path
"./fpga/xst/*" -and \
( -name
"*.[ch]" -or \
( -name
"*.cpp" -and
-not
-name
"*.moc.cpp" \
) -or
-name
"*.lua" -or
-name
"*.py" -or
-name
"*.pl" -or
-name
"Makefile" -or
-name
"*.v" -or
-name
"pm3" \
) \
) \
256 -exec perl
-pi
-e
's/[ \t]+$$//' {} \
; \
257 -exec sh
-c
"tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a$$" \
; \
258 -exec sh
-c
"echo >> {}" \
;
259 # Apply astyle on *.c, *.h, *.cpp
260 find . \
( -not
-path
"./cov-int/*" -and \
( \
( -name
"*.[ch]" -and
-not
-name
"ui_overlays.h" \
) -or \
( -name
"*.cpp" -and
-not
-name
"*.moc.cpp" \
) \
) \
) -exec astyle
--formatted
--mode
=c
--suffix=none \
261 --indent
=spaces
=4 --indent-switches \
262 --keep-one-line-blocks
--max-instatement-indent
=60 \
263 --style
=google
--pad-oper
--unpad-paren
--pad-header \
264 --align-pointer
=name
{} \
;
266 [ -x client
/proxmark3
] && client
/proxmark3
-m
> doc
/commands.md
267 # Make sure python3 is installed
268 @which python3
>/dev
/null ||
( echo
"Please install 'python3' package first" ; exit
1 )
269 # Update commands.json
270 [ -x client
/proxmark3
] && client
/proxmark3
--fulltext | python3 client
/pyscripts
/pm3_help2json.py
- doc
/commands.json
272 # Detecting weird codepages and tabs.
273 ifeq ($(platform
),Darwin
)
274 miscchecks
: TABSCMD
=egrep
-l
'\t' {}
276 miscchecks
: TABSCMD
=grep
-lP
'\t' {}
279 miscchecks
: TABSCMD
+= && vi
{} -c
':set tabstop=4' -c
':set et|retab' -c
':wq'
282 # Make sure recode is installed
283 @which recode
>/dev
/null ||
( echo
"Please install 'recode' package first" ; exit
1 )
284 @echo
"Files with suspicious chars:"
285 @find . \
( -not
-path
"./cov-int/*" -and
-not
-path
"./client/deps/*" -and \
( -name
"*.[ch]" -or
-name
"*.cpp" -or
-name
"*.lua" -or
-name
"*.py" -or
-name
"*.pl" -or
-name
"Makefile" -or
-name
"*.v" -or
-name
"pm3" \
) \
) \
286 -exec sh
-c
"cat {} |recode utf8.. >/dev/null || echo {}" \
;
288 @echo
"Files with tabs: (EDIT enabled, files will be rewritten!)"
290 @echo
"Files with tabs: (rerun with EDIT=1 if you want to convert them with vim)"
292 # to remove tabs within lines, one can try with: vi $file -c ':set tabstop=4' -c ':set et|retab' -c ':wq'
293 @find . \
( -not
-path
"./cov-int/*" -and
-not
-path
"./client/deps/*" -and \
( -name
"*.[ch]" -or \
( -name
"*.cpp" -and
-not
-name
"*.moc.cpp" \
) -or
-name
"*.lua" -or
-name
"*.py" -or
-name
"*.pl" -or
-name
"*.md" -or
-name
"*.txt" -or
-name
"*.awk" -or
-name
"*.v" -or
-name
"pm3" \
) \
) \
294 -exec sh
-c
"$(TABSCMD)" \
;
295 # @echo "Files with printf \\\\t:"
296 # @find . \( -name "*.[ch]" -or \( -name "*.cpp" -and -not -name "*.moc.cpp" \) -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "*.md" -or -name "*.txt" -or -name "*.awk" -or -name "*.v" \) \
297 # -exec grep -lP '\\t' {} \;
299 release
: VERSION
="v4.$(shell git log --oneline master | wc -l)"
301 $(if
$(findstring master
,$(shell git rev-parse
--abbrev-ref HEAD
)),,$(error
"!!! you are not on master branch, aborting"))
302 $(if
$(findstring dirty
,$(shell git describe
--dirty
--always
)),$(error
"!!! you have pending changes, aborting"))
303 $(if
$(RELEASE_NAME
),,$(error
"!!! missing RELEASE_NAME, aborting"))
304 # Preparing a commit for release tagging, to be reverted after tagging.
305 @echo
"# - Release Tag: $(VERSION)"
306 @echo
"# - Release Name: $(RELEASE_NAME)"
307 # - Removing -Werror...
308 @find . \
( -path
"./Makefile.defs" -or
-path
"./client/Makefile" -or
-path
"./common_arm/Makefile.common" -or
-path
"./tools/hitag2crack/*/Makefile" \
) -exec sed
-i
's/ -Werror//' {} \
;
309 @find . \
( -path
"./client/deps/*.cmake" -or
-path
"./client/CMakeLists.txt" \
) -exec sed
-i
's/ -Werror//' {} \
;
310 # - Changing banner...
311 @sed
-i
"s/^#define BANNERMSG3 .*/#define BANNERMSG3 \"Release $(VERSION) - $(RELEASE_NAME)\"/" client
/src
/proxmark3.c
312 @echo
-n
"# ";grep
"^#define BANNERMSG3" client
/src
/proxmark3.c
313 # - Committing temporarily...
314 @git commit
-a
-m
"Release $(VERSION) - $(RELEASE_NAME)"
315 # - Tagging temporarily...
316 @git tag
-a
-m
"Release $(VERSION) - $(RELEASE_NAME)" $(VERSION
)
317 # - Changing default version information based on new tag
318 @
$(SH
) tools
/mkversion.sh
> common
/default_version_pm3.c.tmp
&& $(MV
) common
/default_version_pm3.c.tmp common
/default_version_pm3.c
319 # - Removing mkversion calls
320 @sed
-i
's#^.*\.\./tools/mkversion.sh.*|| #\t$$(Q)#' client
/Makefile bootrom
/Makefile armsrc
/Makefile
321 @sed
-i
'/COMMAND/s/sh .*|| //' client
/CMakeLists.txt
323 @git tag
-d
$(VERSION
)
324 # - Amending commit...
325 @git commit
-a
--amend
-m
"Release $(VERSION) - $(RELEASE_NAME)"
327 @git tag
-a
-m
"Release $(VERSION) - $(RELEASE_NAME)" $(VERSION
)
328 # - Reverting tagged commit...
329 @git revert
--no-edit HEAD
330 @echo
"==================================================================="
331 @echo
"Done! You can now execute 'git push && git push origin $(VERSION)'"
333 # Dummy target to test for GNU make availability