Hi, This can be done and we have tried something similar for exactly the same reasons.
It wasn´t utterly trivial for us for a number of reasons but in your case you might not have the same problems. We were trying to pre-parse the makefile in parallel then read the parsed version. We didn try to use make for everything since our frontend is Python anyhow and there was no need to try to do anything complicated in make itself. The option you need is: -p, --print-data-base Print make's internal database. With a bit of preprocessing, to remove any $(info) output, this should be directly re-readable. Regards, Tim 2012/2/18 Torbjörn Svensson <az...@svenskalinuxforeningen.se>: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hello list, > > > The short version > Is there any way to make make dump it's database to a makefile and > then reuse that dumped makefile to build the source? > > > > The long version > In one of our projects at work, we use a rather complex set of > macros[1] to make it easier for the developers to define how a > component is to be built. The developer creates a file called > 'makerules.mk' and enters data into a few predefined variable names, > like $(component1_SRCS), $(component1_INCL), $(component1_LIBS) where > "component1" is the name of the resulting executable of library. When > invoking make, the macros are expanded based on the data in those > variables to a set of rules and then make just does it's magic on > those. As the source code usually is put in a tree, the number of > makerules.mk files that the developers are entering data into can be > rather large and as a result, the part of the build process that > expands the macros takes a lot of time. For example, for one of our > components, the expansion takes roughly 40 seconds even as there is > nothing to left to do. > > To save some time, I'm now thinking that our build process could be > divided into a few stages. > > Stage 1 > Verify the timestamps on each and every makerules.mk file and if any > of the timestamps is newer than the complete makefile, it needs to be > regenerated. > Possible way to implement: Could be resolved with another temporary > makefile that just sets the complete makefile as target and have all > the makerules.mk files as dependencies. > > Stage 2 > Generate the complete makefile and expand all the macros. > Possible way to implement: The option -p sounds interesting. The > problem with -p is that the dumped database also includes -p in MFLAGS > and MAKEFLAGS so it's not possible to just invoke make on the complete > makefile without first stripping of this option. At first glans, I > would like an option like -p but it should not be added to the dumped > database, but I'm a bit worried that not adding it there would screw > up recursive make. I also would like the option to print to a file > rather than stdout as stdout could be used in the makefile that you > build and thus make will be confused if invoked on the dumped file. > > Stage 3 > Execute make on the complete makefile. > > > To sum up this question, is it possible to do this without patching > make? If not, is it something that you would be interested in > including in an official version of make? > > > Thank you in advance. > > // Torbjörn > > > [1] http://gitorious.org/bobuild/bob/trees/master > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.17 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ > > iEYEARECAAYFAk8/3CUACgkQeY7jmtvbDP2S6gCgyOrwVsZVUy2x0gQ4gDb6G4qd > 2coAoI2QgDNAHX84hNy2RArrPd7liSE4 > =rnlv > -----END PGP SIGNATURE----- > > _______________________________________________ > Bug-make mailing list > Bug-make@gnu.org > https://lists.gnu.org/mailman/listinfo/bug-make -- You could help some brave and decent people to have access to uncensored news by making a donation at: http://www.thezimbabwean.co.uk/friends/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make