Using GNU Make's 'define' and '$(eval)' to automate rule creation
1–10 of 11 posts
Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#2Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#3One of these options today is the tup[1] build system.
It seems to be a relatively modest/new effort, and is already far better than Make.
Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#4Make should really be superceded by a build system that is both faster and more correct. One of these options today is the tup[1] build system. It seems to be a relatively modest/new effort, and is already far better than Make. [1]: http://gittup.org/tup/
I have just looked at tup, and it looks interesting, except I don't really understand why the auto-dependancy only kind-of works. If building X.c uses header.h, and header.h is created by script.sh, why do I have to tell tup about that ordering? Why can't it just see it has to run script.sh to get header.h, before building X.c?
Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#5Make should really be superceded by a build system that is both faster and more correct. One of these options today is the tup[1] build system. It seems to be a relatively modest/new effort, and is already far better than Make. [1]: http://gittup.org/tup/
The big advantage of Make of course is that you can assume it is basically everywhere. I have just looked at tup, and it looks interesting, except I don't really understand why the auto-dependancy only kind-of works. If building X.c uses header.h, and header.h is created by script.sh, why do I have to tell tup about that ordering? Why can't it just see it has to run script.sh to get header.h, before building X.c?
However, once you've compiled a .c file the first time (or run the script the first time), the build system can remember which inputs and outputs were involved (either because gcc tells it which files it used, or by going lower-level and intercepting the file-opens of the program) and reuse that information in subsequent builds.
Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#6Oh god, this way lies madness. :) It really does. Once you get beyond a fairly low level of complexity, there will be maintainence problems: It will take you too long to get it right, it will be impossible to figure out when something goes wrong, and you'll drive the next poor developer crazy if he doesn't have a complete knowlege of make (which is most of us). Yes, sometimes it may be neccesary to do this if you wan…
(I'm not saying generating the rules from code in a real build system wouldn't be a good idea, jut that it isn't with make.)
Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#7Oh god, this way lies madness. :) It really does. Once you get beyond a fairly low level of complexity, there will be maintainence problems: It will take you too long to get it right, it will be impossible to figure out when something goes wrong, and you'll drive the next poor developer crazy if he doesn't have a complete knowlege of make (which is most of us). Yes, sometimes it may be neccesary to do this if you wan…
I used this mechanism to automate a pipeline for scientific data. The template (the "define...endef" block) held several rules needed to re-make results for one granule of data. When you ran make, it looked for all source granules, and a foreach() mapping the template across the source granules, just as in the OP, set up rules for each one.
Then you could dump a new source granule in a directory, run make -j 8, and get parallel "builds" of the results for free.
As long as it's documented, it can save a lot of repetition.
Not coincidentally, jgc has a nice article on make debugging ;-)
Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#8http://www.gnu.org/software/make/manual/make.html#Eval-Funct...
Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#9Oh god, this way lies madness. :) It really does. Once you get beyond a fairly low level of complexity, there will be maintainence problems: It will take you too long to get it right, it will be impossible to figure out when something goes wrong, and you'll drive the next poor developer crazy if he doesn't have a complete knowlege of make (which is most of us). Yes, sometimes it may be neccesary to do this if you wan…
Re: Using GNU Make's 'define' and '$(eval)' to automate rule creation
#10Make should really be superceded by a build system that is both faster and more correct. One of these options today is the tup[1] build system. It seems to be a relatively modest/new effort, and is already far better than Make. [1]: http://gittup.org/tup/
The big advantage of Make of course is that you can assume it is basically everywhere. I have just looked at tup, and it looks interesting, except I don't really understand why the auto-dependancy only kind-of works. If building X.c uses header.h, and header.h is created by script.sh, why do I have to tell tup about that ordering? Why can't it just see it has to run script.sh to get header.h, before building X.c?
1) Only executes stuff after their actual dependencies changed (over-specified dependencies are ignored here)
2) Yell if dependencies are under-specified (can't access files not specified as dependencies)
3) Correctly handle parallelism -- this is where overspecifying dependencies may hurt somewhat, because it can under-parallelize. However, if inputs change -- the dependencies can also change, so if you use previous dependency lists you will also get parallelism wrong. So parallelism makes it a harder problem.
If you don't care that much about fine-grained parallelism, you can simply over-specify your dependencies, and tup will do the right thing.