On 06/25/2014 05:35 PM, Sylvain BERTRAND wrote: > > Using a makefile is overkill. Should be a sh script. > > Makefiles should be used only when there are too many source > files to recompile for a build increment.
Huh. Make strikes me as one of the more suckless tools out there. It does exactly what it says it does, and nothing else. It doesn't "reach inside" the tools you tell it to use (except for the fact that it more or less intrinsically knows the workflow 99% of C compilation projects use, but you can also make it forget that easily). It doesn't complain if you use it for something outside of its intended scope -- I'm a sysadmin, not a "real" programmer, and I've used make in just about every aspect of sysadmining, one way or another. It even works as a fairly usable rc / daemon control system (it could be init itself, for that matter). But it does none of those things by bloating; it does them by staying out of the way as much as possible. It does one thing well (running commands based on a supplied command definition and dependency file), liberally reads a plaintext human-readable file as input, places no artificial limitations on its usability, and acts deterministically and predictably*. That's what sucking less is, really. Now, a downside of being a good tool is that it gets misused a lot. You could say the same thing of a good power drill. Make is the medium into which GNU's autohell gets translated, but that's mostly because it's one of the few systems both simple and powerful enough to survive that monstrosity and still mostly function. But, back to your point, I don't know that a custom shellscript is "more lightweight" in any important sense than a makefile. Make is on basically any system with a compiler -- if you're using simple, portable makefiles (and you should), then it's actually a more stable API to work with than trying to work around all the various shells and their versions that might be out there. Using a shellscript opens you up to "oh, that doesn't work in bash < 4.1" and "wait, what if somebody has /bin/sh linked to csh?" (to say nothing of "where do the semicolons go in a bash for loop, again?"). To me, make should be used when you need a specific set of commands run in a dependency relationship, particularly one involving file mtimes. Many, many builds work that way, even simple ones. If you'd prefer, look at make as a rather clever sed/awk script that transforms a yaml file into a series of sh commands. * Having behavior tied to mtimes of files in the environment makes it somewhat less than deterministic, in fairness. Weldon