KoblentsBlog Photography
Contact About
Ches
Makefile prefixes
Another thing in a long list of things I wish I had known before:
Commands in makefiles can take prefixes:
-
,
@
, and
+
.
-
suppresses exit status. Great for a
make clean
that looks like:
123
clean:
	-rm -rf *.o
	-rm -rf $(TARGET)

This is lovely because often you don't care if a command fails - you don't care if your object files were already deleted, you want to make sure, and you don't want an exit with a failure just because there's nothing to delete.
@
simply means: don't print this command when you execute it. For example, when your command is to print something, you don't need to also print the command to print something.
+
basically negates the switches
-n
,
-t
, and
-q
which tell make not to actually run. So if you want to launch a make command with a flag telling it not to run, stick a + sign in front and it will, in fact, execute. Nifty way to take a debugging/testing command, test it, then actually run it if it looks good.
Follow External URL ...
Ches Koblents
June 26, 2014
 
« Newer Older »
© Copyright Koblents.com, 2012-2017