Mostly for my amusement, I created a makefile
in my $HOME/bin
directory called rebuild.mk
, and made it executable, and the first lines of the file read:
#!/bin/make -f
#
# Comments on what the makefile is for
...
all: ${SCRIPTS} ${LINKS} ...
...
I can now type:
rebuild.mk
and this causes make
to execute.
What are the reasons for not exploiting this on a permanent basis, other than this:
bin
directory.Has anyone ever seen the trick exploited before?
Collecting some comments, and providing a bit more background information.
rebuild.mk
for this question (it has another name on my machine).make -f rebuild.mk
' by using 'rebuild.mk
' instead.make
utility is problematic across platforms.#!/usr/bin/env make -f
technique is likely to work, though I believe the official rules of engagement are that the line must be less than 32 characters and may only have one argument to the command.As stated, it was mostly for my amusement. I may keep it for this particular job; it is most unlikely that I'd use it in distributed work. And if I did, I'd supply and apply a 'fixin
' script to fix the pathname of the interpreter; indeed, I did that already on my machine. That script is a relic from the first edition of the Camel book ('Programming Perl' by Larry Wall).
One problem with this for generally distributable Makefiles is that the location of make
is not always consistent across platforms. Also, some systems might require an alternate name like gmake
.
Of course one can always run the appropriate command manually, but this sort of defeats the whole purpose of making the Makefile executable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With