On 2012-04-23 16:53 +0200, Дилян Палаузов wrote: > that is the point. I want to include "Mfilename" in the very beginning > of Makefile.in . You said, that Automake automatically makes sure, that > all variables are defined, before they are used, but Automake has not > idea what Mfilename contains (Mfilename does not exist when Automake is > run). So how can it make sure, that the variables defined in Mfilename > are defined at the time they are used, when "-include Mfilename" is put > near the end of Makefile.in (after _SOURCES is defined) and Automake has > no idea what Mfilename contains? > > I cannot insert "-include Mfilename" before using any variable, because > Automake inserts "-include Mfilename" after I have used the variables in > "_SOURCES" and "_LDADD".
First note that Automake needs to know exactly the value of mumble_SOURCES upfront in order to work correctly, so assigning something defined in an included fragment that Automake cannot see is unlikely to end well. I think that doing this with mumble_LDADD should be fine, though. Now with respect to Automake moving macro definitions to the start of them Makefile, this shouldn't actually affect things too much, because make expands macros lazily when they are used, not when they are defined. That is, in the following makefile fragment: FOO = $(BAR) # BAR is not expanded here at the assignment of FOO... BAR = baz quux: $(FOO) # ... but it is expanded here: quux depends on baz echo wheee > $@ contrast with the following: FOO = $(BAR) # BAR is not expanded here at the assignment of FOO... quux: $(FOO) # ... but it is expanded here: $(FOO) expands to nothing. echo wheee > $@ BAR = baz # too late for the previous expansion Further note that (at least on all the make implementations I can test), macro expansions within a rule's commands are performed after the entire Makefile has been read, so the following will actually work: FOO = $(BAR) quux: echo $(FOO) > $@ # $(FOO) expands to baz here. BAR = baz Though by a quick skim I don't see anything in POSIX which requires this behaviour. However, since you're presumably only supporting GNU make, I think you can rely on this (section 3.9: "How make Reads a Makefile" of the GNU make manual appears to explicitly specify that this deferred expansion of FOO occurs). > So how can I include Mfilename at the beginning of Makefile.in? Nevertheless, if you still need it at the beginning, the most obvious way to do it is to directly add it to Makefile.in file after running automake by postprocessing Automake's output. Hope that helps, -- Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)