3 ms·
The question isn't "do we need makefiles". The question is, what is the problem you're trying to solve? There are lots of cases where make and makefiles are a
by dwheeler 4y ago
The question isn't "do we need makefiles". The question is, what is the problem you're trying to solve?
There are lots of cases where make and makefiles are a great solution.
A few pointers though:
* In most cases, just use GNU make, don't try to stick to just POSIX make. POSIX make is too feature-poor for many situations.
* If you have more than a few files, automatically generate the dependencies (e.g., in deps/DIRS/FILE.d files). In practice that often means you need to use GNU make (or automake). Doing that by hand for a few files is fine, but if you try to scale that up, it will become a large always-wrong mess. It's pretty easy to do once you know how - it's just a few lines - but it will save endless headaches. Many compilers already have built-in support for make, so in many cases make is the easy path.
* Don't use recursive make (re-execute make in each subdirectory). Run "make" once, and give it all the correct info. It seems like this would be slow, but it's faster & easier to maintain. I routinely get executions of 0.07 seconds on 1000 files when there's no work to do (a really tiny overhead).
There are definitely alternatives. I routinely use rake, which calls ruby instead of shell as the command language. Rake can be quite useful, but I don't think it's an automatic win over make at all.