Summary
This is mostly a Makefile cleanup diff, but it does address a few specific issues:
- All makefile targets (in .\GNUMakefile) happen to be "phony targets" (as defined by the GNU make manual), but only target all was marked as such. Not marking a target as "phony" means that make attempts to delete a file with the target's name whenever the target's recipe either fails or is interrupted. It is unlikely a file with one of these names exists in the source directory, but as it's possible, this is technically a fix.
- The makefile makes rather extensive use of targets as modal options, but this concept was neither pointed out clearly, nor given a name. I decided to name them "pseudo-targets" as I had used this name in other projects previously. I clearly spelled out in the comments what these are and how they work... which relates directly to the next item:
- I added hopefully much more clear comments indicating how the makefile functions in hopes of making it easier to read for developers less familiar with more advanced features of GNU Make.
- I switched "pseudo-target" detection to use $(filter ...) within a function with a meaningful name, instead of $(findstring ...). The function encapsulation is intended for readability, while the switch to filter is intended to not get false-positives from substrings. (With the current list of targets this is only a theoretical problem.)
- I changed the behavior of "pseudo-targets" slightly, so they no longer imply the default goal, unless only pseudo-targets are specified. This allows specifying something like make debug test which will build and run the tests in debug mode, without building all. Previously specifying any pseudo-target automatically built all as a hard dependancy.
- I found that make fails with an error when running make clean on a non-existent build directory. I avoided this error condition.
Goals
The intent of this diff is simply to cleanup the existing GNUMakefile and not implement anything new. My primary goal for this diff is to increase clarity and readability of the makefile.
Feedback
As my main goal is clarity, feedback from other developers is really the only valid measure of success of this diff. I'm especially interested in your feedback if you are not a GNU Make expert, and something I added was unclear. (Also please speak up if you notice somewhere I was in error.)
Origin
Be advised that these changes originated as unrelated parts of https://developer.blender.org/D15529