4 ms·
I admittedly don't have a ton of experience with make, but what's the point of doing this vs just throwing the compile commands in a shell script?
by lhamil64 3y ago
I admittedly don't have a ton of experience with make, but what's the point of doing this vs just throwing the compile commands in a shell script?
- dpkirchner 3y agoThe biggest practical difference is that make can test to see if a file needs to be rebuilt before proceeding.
- adrian_b 3y agoYes, exactly this. When compiling a project once from a clean state make has no advantage over a shell script that would use a tool like "parallel" to distribute compilation jobs over all available CPU cores. However writing such a script for parallel compilation is more complex than writing a simple Makefile executed with "make -j N". As you say, the main reason of existence of "make" is the acceleration of the recompilation of a project after incremental changes in the source files, when only the files that depend on the changes are recompiled, saving time.
- f1shy 3y agoMake will automatically do all the steps, and stop if any one fails. Of course you van do manually, but is much more work.
- dagmx 3y agoThe irony is that the same argument would work against Make in the description further up vs other build systems like CMake etc. Not to take away from your correct answer of course
- gumby 3y agoThat’s because CMake calls make or an equivalent (ninja, xcodebuild…) that actually does all the dependency checking!
- nrclark 3y agoImagine you had all your build commands in a shell-script. Now imagine that you want to run individual steps from time-to-time, instead of running your whole script start to finish. So maybe you write functions that represent each group of commands, and call the function based on an input argument. Now imagine that some of your build-steps have dependencies on other build-steps, and you want to be able to say "run step X, plus whatever else you have to do first." Or maybe you want to retry a failed build from wherever it left off, instead of having to re-run the entire thing. Now imagine that you'd like to have some level of isolation between build-steps, so that one step doesn't mess the other one up. As you add more and more things to your build script, you'll find yourself writing an implementation of Make pretty quickly. Now - sometimes - your build fails halfway though, and you want to resume from where-ever it failed. S
- t43562 3y agoMake is declarative. You tell it how to make an A from a B and a B from a C or a D and it then works out that it needs to do "CBA" or "DBA" depending on whether it finds a D or a C in the filesystem. The more possible variations you have to cater for the worse build scripts get. If you try not to redo work that you did 5 minutes ago that's still valid then build scripts become even more complicated whereas the makefile doesn't change at all. Other tools do declarative even more than make does but as they get easier to understand they tend to lose abilities.