Beyond Makefiles: GNU make is For More Than Just Compiling - page 2
make and LaTex
Another possible use is to check a Perl script (or Apache config file, or...) for syntax errors:
all: checkperl checkperl: myscript.pl perl -Mstrict -wc $<This uses the 'strict' module to check your script, with warnings turned on. However, with this version, you'd have to edit the makefile to add a new dependency every time you add a new Perl file. To check all Perl files in that directory, you can use xargs:
checkperl: *.pl ls $? | xargs -L1 perl -Mstrict -wcThe implicit variable $? concatenates the names of all the source files (here everything ending .pl) with a space between them. The command then runs ls to pass these names into xargs, which then runs the perl checking command on each. (Note the -L1 option; without this, the command will run only on the first file.)
Other possibilities include emailing changed files to yourself for an informal backup. The variable $? lists only the files which have changed since the last time the target was generated, separated by a space. Remember that if you use a phony target (as with checkperl above), this will always list all files.
make is far more versatile and productive than you might have thought from only encountering it when building the odd piece of software from source. It's well worth experimenting with for any repetitive file-processing task you find yourself doing. Check out the GNU make manual for extensive further information, in particular the sections on variables and implicit rules.
- 1Linux Top 3: Alpine Linux 3.4, deepin 15.2 and Linux Lite 3.0
- 2Linux 4.7 Set to Boost Live Patching, Security and Power Management
- 3Linux 4.6 Charred Weasel adds USB 3.1 Support
- 4Linux Top 3: OpenIndiana 2016.04, Ubuntu 16.04 and Debian's New Leader
- 5Linux Top 3: KaOS 2016.04, TurnKey 14.1 and pfSense 2.3