Merge branch 'master' of github.com:RfidResearchGroup/proxmark3
[RRG-proxmark3.git] / Makefile
blob35cbae7ea6ab0cf39b762819a4e1379ffe172d6e
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 -include Makefile.platform
18 -include .Makefile.options.cache
19 include Makefile.defs
20 include common_arm/Makefile.hal
22 # preserve relative DESTDIR path for subdir makes
23 ifneq (,$(DESTDIR))
24 # realpath needs the directory to exist
25 $(shell $(MKDIR) $(DESTDIR))
26 MYDESTDIR:=$(realpath $(DESTDIR))
27 ifeq (,$(MYDESTDIR))
28 $(error Can't create $(DESTDIR))
29 endif
30 endif
32 all clean install uninstall check: %: client/% bootrom/% armsrc/% recovery/% mfkey/% nonce2key/% mf_nonce_brute/% mfd_aes_brute/% fpga_compress/% cryptorf/%
33 # hitag2crack toolsuite is not yet integrated in "all", it must be called explicitly: "make hitag2crack"
34 #all clean install uninstall check: %: hitag2crack/%
36 INSTALLTOOLS=pm3_eml2lower.sh pm3_eml2upper.sh pm3_mfdread.py pm3_mfd2eml.py pm3_eml2mfd.py pm3_amii_bin2eml.pl pm3_reblay-emulating.py pm3_reblay-reading.py
37 INSTALLSIMFW=sim011.bin sim011.sha512.txt sim013.bin sim013.sha512.txt sim014.bin sim014.sha512.txt
38 INSTALLSCRIPTS=pm3 pm3-flash pm3-flash-all pm3-flash-bootrom pm3-flash-fullimage
39 INSTALLSHARES=tools/jtag_openocd traces
40 INSTALLDOCS=doc/*.md doc/md
42 install: common/install
44 common/install:
45 $(info [@] Installing common resources to $(MYDESTDIR)$(PREFIX)...)
46 ifneq (,$(INSTALLSCRIPTS))
47 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)
48 $(Q)$(INSTALLSUDO) $(CP) $(INSTALLSCRIPTS) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)
49 endif
50 ifneq (,$(INSTALLSHARES))
51 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
52 $(Q)$(INSTALLSUDO) $(CP) $(INSTALLSHARES) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
53 endif
54 ifneq (,$(INSTALLDOCS))
55 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLDOCSRELPATH)
56 $(Q)$(INSTALLSUDO) $(CP) $(INSTALLDOCS) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLDOCSRELPATH)
57 endif
58 ifneq (,$(INSTALLTOOLS))
59 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
60 $(Q)$(INSTALLSUDO) $(CP) $(foreach tool,$(INSTALLTOOLS),tools/$(tool)) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
61 endif
62 ifneq (,$(INSTALLSIMFW))
63 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)
64 $(Q)$(INSTALLSUDO) $(CP) $(foreach fw,$(INSTALLSIMFW),client/resources/$(fw)) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)
65 endif
66 ifeq ($(platform),Linux)
67 $(Q)$(INSTALLSUDO) $(MKDIR) $(DESTDIR)$(UDEV_PREFIX)
68 # If user is running ArchLinux, use group 'uucp'
69 # Else, use group 'dialout'
70 ifneq ($(wildcard /etc/arch-release),)
71 $(Q)$(INSTALLSUDO) $(CP) driver/77-pm3-usb-device-blacklist-uucp.rules $(DESTDIR)$(UDEV_PREFIX)/77-pm3-usb-device-blacklist.rules
72 else
73 $(Q)$(INSTALLSUDO) $(CP) driver/77-pm3-usb-device-blacklist-dialout.rules $(DESTDIR)$(UDEV_PREFIX)/77-pm3-usb-device-blacklist.rules
74 endif
75 endif
77 uninstall: common/uninstall
79 common/uninstall:
80 $(info [@] Uninstalling common resources from $(MYDESTDIR)$(PREFIX)...)
81 ifneq (,$(INSTALLSCRIPTS))
82 $(Q)$(INSTALLSUDO) $(RM) $(foreach script,$(INSTALLSCRIPTS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLBINRELPATH)$(PATHSEP)$(notdir $(script)))
83 endif
85 ifneq (,$(INSTALLSHARES))
86 $(Q)$(INSTALLSUDO) $(RMDIR) $(foreach share,$(INSTALLSHARES),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)$(PATHSEP)$(notdir $(share)))
87 endif
89 ifneq (,$(INSTALLDOCS))
90 $(Q)$(INSTALLSUDO) $(RMDIR) $(foreach doc,$(INSTALLDOCS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLDOCSRELPATH)$(PATHSEP)$(notdir $(doc)))
91 $(Q)-$(INSTALLSUDO) $(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLDOCSRELPATH)
92 endif
94 ifneq (,$(INSTALLTOOLS))
95 $(Q)$(INSTALLSUDO) $(RM) $(foreach tool,$(INSTALLTOOLS),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)$(PATHSEP)$(notdir $(tool)))
96 endif
98 $(Q)-$(INSTALLSUDO) $(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLTOOLSRELPATH)
100 ifneq (,$(INSTALLSIMFW))
101 $(Q)$(INSTALLSUDO) $(RM) $(foreach fw,$(INSTALLSIMFW),$(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)$(PATHSEP)$(notdir $(fw)))
102 endif
104 $(Q)-$(INSTALLSUDO) $(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLFWRELPATH)
106 ifeq ($(platform),Linux)
107 $(Q)$(INSTALLSUDO) $(RM) $(DESTDIR)$(UDEV_PREFIX)/77-pm3-usb-device-blacklist.rules
108 endif
109 $(Q)-$(INSTALLSUDO) $(RMDIR_SOFT) $(DESTDIR)$(PREFIX)$(PATHSEP)$(INSTALLSHARERELPATH)
111 # tests
112 cryptorf/check: FORCE
113 $(info [*] CHECK $(patsubst %/check,%,$@))
114 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
115 mfkey/check: FORCE
116 $(info [*] CHECK $(patsubst %/check,%,$@))
117 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
118 nonce2key/check: FORCE
119 $(info [*] CHECK $(patsubst %/check,%,$@))
120 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
121 mf_nonce_brute/check: FORCE
122 $(info [*] CHECK $(patsubst %/check,%,$@))
123 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
124 mfd_aes_brute/check: FORCE
125 $(info [*] CHECK $(patsubst %/check,%,$@))
126 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
127 fpga_compress/check: FORCE
128 $(info [*] CHECK $(patsubst %/check,%,$@))
129 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
130 bootrom/check: FORCE
131 $(info [*] CHECK $(patsubst %/check,%,$@))
132 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
133 armsrc/check: FORCE
134 $(info [*] CHECK $(patsubst %/check,%,$@))
135 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
136 client/check: FORCE
137 $(info [*] CHECK $(patsubst %/check,%,$@))
138 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
139 recovery/check: FORCE
140 $(info [*] CHECK $(patsubst %/check,%,$@))
141 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
142 hitag2crack/check: FORCE
143 $(info [*] CHECK $(patsubst %/check,%,$@))
144 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
145 common/check: FORCE
146 $(info [*] CHECK $(patsubst %/check,%,$@))
147 $(Q)$(BASH) tools/pm3_tests.sh $(CHECKARGS) $(patsubst %/check,%,$@)
148 check: common/check
149 $(info [*] ALL CHECKS DONE)
151 cryptorf/%: FORCE
152 $(info [*] MAKE $@)
153 $(Q)$(MAKE) --no-print-directory -C tools/cryptorf $(patsubst cryptorf/%,%,$@) DESTDIR=$(MYDESTDIR)
154 mfkey/%: FORCE
155 $(info [*] MAKE $@)
156 $(Q)$(MAKE) --no-print-directory -C tools/mfkey $(patsubst mfkey/%,%,$@) DESTDIR=$(MYDESTDIR)
157 nonce2key/%: FORCE
158 $(info [*] MAKE $@)
159 $(Q)$(MAKE) --no-print-directory -C tools/nonce2key $(patsubst nonce2key/%,%,$@) DESTDIR=$(MYDESTDIR)
160 mf_nonce_brute/%: FORCE
161 $(info [*] MAKE $@)
162 $(Q)$(MAKE) --no-print-directory -C tools/mf_nonce_brute $(patsubst mf_nonce_brute/%,%,$@) DESTDIR=$(MYDESTDIR)
163 mfd_aes_brute/%: FORCE
164 $(info [*] MAKE $@)
165 $(Q)$(MAKE) --no-print-directory -C tools/mfd_aes_brute $(patsubst mfd_aes_brute/%,%,$@) DESTDIR=$(MYDESTDIR)
166 fpga_compress/%: FORCE cleanifplatformchanged
167 $(info [*] MAKE $@)
168 $(Q)$(MAKE) --no-print-directory -C tools/fpga_compress $(patsubst fpga_compress/%,%,$@) DESTDIR=$(MYDESTDIR)
169 bootrom/%: FORCE cleanifplatformchanged
170 $(info [*] MAKE $@)
171 $(Q)$(MAKE) --no-print-directory -C bootrom $(patsubst bootrom/%,%,$@) DESTDIR=$(MYDESTDIR)
172 armsrc/%: FORCE cleanifplatformchanged fpga_compress/%
173 $(info [*] MAKE $@)
174 $(Q)$(MAKE) --no-print-directory -C armsrc $(patsubst armsrc/%,%,$@) DESTDIR=$(MYDESTDIR)
175 client/%: FORCE cleanifplatformchanged
176 $(info [*] MAKE $@)
177 $(Q)$(MAKE) --no-print-directory -C client $(patsubst client/%,%,$@) DESTDIR=$(MYDESTDIR)
178 recovery/all: bootrom/all armsrc/all
179 recovery/install: bootrom/install armsrc/install
180 recovery/%: FORCE cleanifplatformchanged
181 $(info [*] MAKE $@)
182 $(Q)$(MAKE) --no-print-directory -C recovery $(patsubst recovery/%,%,$@) DESTDIR=$(MYDESTDIR)
183 hitag2crack/%: FORCE
184 $(info [*] MAKE $@)
185 $(Q)$(MAKE) --no-print-directory -C tools/hitag2crack $(patsubst hitag2crack/%,%,$@) DESTDIR=$(MYDESTDIR)
186 FORCE: # Dummy target to force remake in the subdirectories, even if files exist (this Makefile doesn't know about the prerequisites)
188 .PHONY: all clean install uninstall help _test bootrom fullimage recovery client mfkey nonce2key mf_nonce_brute mfd_aes_brute hitag2crack style miscchecks release FORCE udev accessrights cleanifplatformchanged
190 help:
191 @echo "Multi-OS Makefile"
192 @echo
193 @echo "Possible targets:"
194 @echo "+ all - Make all targets: bootrom, fullimage and OS-specific host tools"
195 @echo "+ clean - Clean in all targets"
196 @echo "+ .../clean - Clean in specified target and its deps, e.g. bootrom/clean"
197 @echo "+ (un)install - Install/uninstall Proxmark files in the system, default to /usr/local/share,"
198 @echo " else provide a PREFIX. See Maintainers.md for more options"
199 @echo
200 @echo "+ bootrom - Make bootrom"
201 @echo "+ fullimage - Make armsrc fullimage (includes fpga)"
202 @echo "+ recovery - Make bootrom and fullimage files for JTAG flashing"
203 @echo
204 @echo "+ client - Make only the OS-specific host client"
205 @echo "+ cryptorf - Make tools/cryptorf"
206 @echo "+ mfkey - Make tools/mfkey"
207 @echo "+ nonce2key - Make tools/nonce2key"
208 @echo "+ mf_nonce_brute - Make tools/mf_nonce_brute"
209 @echo "+ mfd_aes_brute - Make tools/mfd_aes_brute"
210 @echo "+ hitag2crack - Make tools/hitag2crack"
211 @echo "+ fpga_compress - Make tools/fpga_compress"
212 @echo
213 @echo "+ style - Apply some automated source code formatting rules"
214 @echo "+ check - Run offline tests. Set CHECKARGS to pass arguments to the test script"
215 @echo "+ .../check - Run offline tests against specific target. See above."
216 @echo "+ miscchecks - Detect various encoding issues in source code"
217 @echo
218 @echo "+ udev - Sets udev rules on *nix"
219 @echo "+ accessrights - Ensure user belongs to correct group on *nix"
220 @echo
221 @echo "To see possible platforms. default is PM3RDV4"
222 @echo " make PLATFORM="
223 @echo
224 @echo "For verbose mode"
225 @echo " make V=1"
226 @echo
228 client: client/all
230 bootrom: bootrom/all
232 # aliases fullimage = armsrc
234 fullimage: armsrc/all
236 fullimage/all: armsrc/all
238 fullimage/clean: armsrc/clean
240 fullimage/install: armsrc/install
242 fullimage/uninstall: armsrc/uninstall
244 recovery: recovery/all
246 cryptorf: cryptorf/all
248 mfkey: mfkey/all
250 nonce2key: nonce2key/all
252 mf_nonce_brute: mf_nonce_brute/all
254 mfd_aes_brute: mfd_aes_brute/all
256 fpga_compress: fpga_compress/all
258 hitag2crack: hitag2crack/all
260 newtarbin:
261 $(RM) proxmark3-$(platform)-bin.tar proxmark3-$(platform)-bin.tar.gz
262 @touch proxmark3-$(platform)-bin.tar
264 tarbin: newtarbin client/tarbin armsrc/tarbin bootrom/tarbin
265 $(info GEN proxmark3-$(platform)-bin.tar)
266 $(Q)$(GZIP) proxmark3-$(platform)-bin.tar
268 # detect if there were changes in the platform definitions, requiring a clean
269 cleanifplatformchanged:
270 ifeq ($(PLATFORM_CHANGED),true)
271 $(info [!] Platform definitions changed, cleaning bootrom/armsrc/recovery first...)
272 $(Q)$(MAKE) --no-print-directory -C bootrom clean
273 $(Q)$(MAKE) --no-print-directory -C armsrc clean
274 $(Q)$(MAKE) --no-print-directory -C recovery clean
275 $(Q)$(MAKE) --no-print-directory -C client clean
276 $(Q)$(MAKE) --no-print-directory -C tools/fpga_compress clean
277 $(Q)$(ECHO) CACHED_PLATFORM=$(PLATFORM) > .Makefile.options.cache
278 $(Q)$(ECHO) CACHED_PLATFORM_EXTRAS=$(PLATFORM_EXTRAS) >> .Makefile.options.cache
279 $(Q)$(ECHO) CACHED_PLATFORM_DEFS=$(PLATFORM_DEFS) >> .Makefile.options.cache
280 endif
282 # configure system to ignore PM3 device as a modem (ModemManager blacklist, effective *only* if ModemManager is not using _strict_ policy)
283 # Read doc/md/ModemManager-Must-Be-Discarded.md for more info
284 udev:
285 ifneq ($(wildcard /etc/arch-release),)
286 # If user is running ArchLinux, use group 'uucp'
287 $(SUDO) cp -rf driver/77-pm3-usb-device-blacklist-uucp.rules $(DESTDIR)$(UDEV_PREFIX)/77-pm3-usb-device-blacklist.rules
288 else
289 # Else, use group 'dialout'
290 $(SUDO) cp -rf driver/77-pm3-usb-device-blacklist-dialout.rules $(DESTDIR)$(UDEV_PREFIX)/77-pm3-usb-device-blacklist.rules
291 endif
292 $(SUDO) udevadm control --reload-rules
293 $(SUDO) udevadm trigger --action=change
295 # configure system to add user to the dialout group and if bluetooth group exists, add user to it
296 # you need to logout, relogin to get this access right correct.
297 # Finally, you might need to run the proxmark3 client under SUDO on some systems
298 accessrights:
299 ifneq ($(wildcard /etc/arch-release),)
300 #If user is running ArchLinux, use specific command and group
301 $(Q)$(SUDO) $(USERMOD) uucp $(USER)
302 $(Q)$(GETENT_BL) >/dev/null && $(SUDO) $(USERMOD) bluetooth $(USER) || true
303 else ifneq ($(wildcard /etc/fedora-release),)
304 # If the user is running Fedora, use `usermod` with the dialout group
305 $(Q)$(SUDO) $(USERMOD) dialout $(USER)
306 $(Q)$(GETENT_BL) >/dev/null && $(SUDO) $(USERMOD) bluetooth $(USER) || true
307 else
308 $(Q)$(SUDO) $(ADDUSER) $(USER) dialout
309 $(Q)$(GETENT_BL) >/dev/null && $(SUDO) $(ADDUSER) $(USER) bluetooth || true
310 endif
312 # easy printing of MAKE VARIABLES
313 print-%: ; @echo $* = $($*)
315 style:
316 # Make sure astyle is installed
317 @command -v astyle >/dev/null || ( echo "Please install 'astyle' package first" ; exit 1 )
318 # Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.cpp. *.lua, *.py, *.pl, Makefile, *.v, pm3
319 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" \) \) \
320 -exec perl -pi -e 's/[ \t]+$$//' {} \; \
321 -exec sh -c "tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a$$" \; \
322 -exec sh -c "echo >> {}" \;
323 # Apply astyle on *.c, *.h, *.cpp
324 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 \
325 --indent=spaces=4 --indent-switches \
326 --keep-one-line-blocks --max-instatement-indent=60 \
327 --style=google --pad-oper --unpad-paren --pad-header \
328 --align-pointer=name {} \;
329 # Update commands.md
330 [ -x client/proxmark3 ] && client/proxmark3 -m | tr -d '\r' > doc/commands.md
331 # Make sure python3 is installed
332 @command -v python3 >/dev/null || ( echo "Please install 'python3' package first" ; exit 1 )
333 # Update commands.json, patch port in case it was run under Windows
334 [ -x client/proxmark3 ] && client/proxmark3 --fulltext | sed 's#com[0-9]#/dev/ttyACM0#'|python3 client/pyscripts/pm3_help2json.py - - | tr -d '\r' > doc/commands.json
336 # Update the readline autocomplete autogenerated code
337 [ -x client/proxmark3 ] && client/proxmark3 --fulltext | python3 client/pyscripts/pm3_help2list.py - - | tr -d '\r' > client/src/pm3line_vocabulary.h
340 # Detecting weird codepages and tabs.
341 ifeq ($(platform),Darwin)
342 miscchecks: TABSCMD=egrep -l '\t' {}
343 else
344 miscchecks: TABSCMD=grep -lP '\t' {}
345 endif
346 ifneq (,$(EDIT))
347 miscchecks: TABSCMD+= && vi {} -c ':set tabstop=4' -c ':set et|retab' -c ':wq'
348 endif
349 miscchecks:
350 # Make sure recode is installed
351 @command -v recode >/dev/null || ( echo "Please install 'recode' package first" ; exit 1 )
352 @echo "Files with suspicious chars:"
353 @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" \) \) \
354 -exec sh -c "cat {} |recode utf8.. >/dev/null || echo {}" \;
355 ifneq (,$(EDIT))
356 @echo "Files with tabs: (EDIT enabled, files will be rewritten!)"
357 else
358 @echo "Files with tabs: (rerun with EDIT=1 if you want to convert them with vim)"
359 endif
360 # to remove tabs within lines, one can try with: vi $file -c ':set tabstop=4' -c ':set et|retab' -c ':wq'
361 @find . \( -not -path "./cov-int/*" -and -not -path "./client/deps/*" -and -not -wholename "./client/src/pm3_*wrap.c" -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" \) \) \
362 -exec sh -c "$(TABSCMD)" \;
363 # @echo "Files with printf \\\\t:"
364 # @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" \) \
365 # -exec grep -lP '\\t' {} \;
367 release: VERSION="v4.$(shell git log --oneline master | wc -l)"
368 release:
369 $(if $(findstring master,$(shell git rev-parse --abbrev-ref HEAD)),,$(error "!!! you are not on master branch, aborting"))
370 $(if $(findstring dirty,$(shell git describe --dirty --always)),$(error "!!! you have pending changes, aborting"))
371 $(if $(RELEASE_NAME),,$(error "!!! missing RELEASE_NAME, aborting"))
372 # Preparing a commit for release tagging, to be reverted after tagging.
373 @echo "# - Release Tag: $(VERSION)"
374 @echo "# - Release Name: $(RELEASE_NAME)"
375 # - Removing -Werror...
376 @find . \( -path "./Makefile.defs" -or -path "./client/Makefile" -or -path "./common_arm/Makefile.common" -or -path "./tools/hitag2crack/*/Makefile" \) -exec sed -i 's/ -Werror//' {} \;
377 @find . \( -path "./client/deps/*.cmake" -or -path "./client/CMakeLists.txt" \) -exec sed -i 's/ -Werror//' {} \;
378 # - Changing banner...
379 @sed -i "s/^#define BANNERMSG3 .*/#define BANNERMSG3 \"Release $(VERSION) - $(RELEASE_NAME)\"/" client/src/proxmark3.c
380 @echo -n "# ";grep "^#define BANNERMSG3" client/src/proxmark3.c
381 # - Committing temporarily...
382 @git commit -a -m "Release $(VERSION) - $(RELEASE_NAME)"
383 # - Tagging temporarily...
384 @git tag -a -m "Release $(VERSION) - $(RELEASE_NAME)" $(VERSION)
385 # - Changing default version information based on new tag
386 @$(SH) tools/mkversion.sh --force common/default_version_pm3.c
387 # - Removing mkversion calls
388 @sed -i 's#^.*\.\./tools/mkversion.sh.*|| #\t$$(Q)#' client/Makefile bootrom/Makefile armsrc/Makefile
389 @sed -i '/COMMAND/s/sh .*|| //' client/CMakeLists.txt client/experimental_lib/CMakeLists.txt
390 # - Deleting tag...
391 @git tag -d $(VERSION)
392 # - Amending commit...
393 @git commit -a --amend -m "Release $(VERSION) - $(RELEASE_NAME)"
394 # - Tagging again...
395 @git tag -a -m "Release $(VERSION) - $(RELEASE_NAME)" $(VERSION)
396 # - Reverting tagged commit...
397 @git revert --no-edit HEAD
398 @echo "==================================================================="
399 @echo "Done! You can now execute 'git push && git push origin $(VERSION)'"
401 # Dummy target to test for GNU make availability
402 _test: