GNU Make Tips & Tricks
I have 2 little unique tricks that I use in make files and would like to share, here they are ...
Ask for "yes" before proceeding
install: do-install production-deploy
do-install: #... all deps
gcc ...
production-deploy: production-ask
rm -fr /
%-ask:
@python -c 'raise SystemExit(not raw_input("All Done! Are you sure you want to install to $(subst -ask,,$@)? (yes/NO) ") == "yes")'
Wait a few seconds before restarting, allows for operator cancel via Ctrl-C
install: do-install production-restart
do-install: #... all deps
gcc ...
production-restart: 5-rwait
sudo reboot
%-rwait:
@python -c 'import sys,time;n=$(subst -rwait,,$@);filter(lambda i: (sys.stdout.write("will restart system in %s\n" % (n-i)) or time.sleep(1)), range(n)) or sys.stdout.write("restarting ...\n")'
Written by Hatem Nassrat
Related protips
1 Response
Nice, but you can use $*
to get what the %
matched, instead of your $(subst -ask,,$@)
:)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#