Never thought about executing a makefile until I saw one in a tarball, which was executable. It was a mistake since there was no Shebang, but I decided to add one to try it out:
That won’t work since make(1) says:
If no -f option is present, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.
And Shebang is actually running the makefile as:
That makes Makefile the target, the reason why make says:
make: Nothing to be done for `Makefile'.
If you run like ./Makefile all, it would work, although you would still see the message above, before all target is processed, since there are two targets Makefile and all.
To fix this, according to this answer, you need to use -f to specify the makefile:
The actual command becomes:
/usr/bin/make -f Makefile
This runs the first target of Makefile as we expect.
I’m not sure if there really is a benefit to make makefiles executable, for me typing make seem to be faster than ./M<TAB>.