On Sat, 2005-12-31 at 14:22 +0100, Stepan Kasal wrote: > Hello, > > On Sat, Dec 31, 2005 at 02:51:30AM -0500, Braden McDaniel wrote: > > but the behavior is the same: the sources are regenerated every time, > > regardless of whether the antlr grammar has been modified. > > I can imagine several problems: > 1) there is a prerequisite which is always refreshed and causes this
I can't see how that could be happening. For instance, here's one of the rules that generates sources from a grammar: $(srcdir)/openvrml/Vrml97Parser.hpp $(srcdir)/openvrml/Vrml97Parser.cpp: $(srcdir)/openvrml/Vrml97Parser.g $(srcdir)/openvrml/Vrml97TokenTypes.txt $(ANTLR) -o $(srcdir)/openvrml $(srcdir)/openvrml/Vrml97Parser.g None of the prerequisites are getting updated. In fact, if I issue the command: $ make -C src/libopenvrml ../../../src/libopenvrml/openvrml/Vrml97Parser.cpp I get: make: Entering directory `/home/braden/src/openvrml/openvrml/build/src/libopenvrml' make: `../../../src/libopenvrml/openvrml/Vrml97Parser.cpp' is up to date. make: Leaving directory `/home/braden/src/openvrml/openvrml/build/src/libopenvrml' And yet if I then just issue "make", the source gets regenerated. > 2) If you use non-GNU make, it can may not understand that "./foo.c" and > "foo.c" is the same file. I am using GNU make 3.80. > 3) If you work on a networked drive, the target may have time stamp in the > future, and make decides to refresh it. Definitely not the issue. > I cannot guess more without seeing the makefile. Could you please post > (an URL to) a self-contained example? If you are able to cut some parts > and make the example smaller, that would definitely help. The problem Makefile.am is here: <http://cvs.sourceforge.net/viewcvs.py/openvrml/openvrml/src/libopenvrml/Makefile.am?rev=1.22&view=auto> Information for checking out the project from CVS is here: <http://sourceforge.net/cvs/?group_id=7151> The Makefile.am isn't terribly complex; but I imagine I can come up with a simple example project if necessary. > > I have some sources that are generated with antlr. I have custom make > > rules that generate the sources from the antlr grammar. I have tried > > listing the generated sources in both BUILT_SOURCES and _DEPENDENCIES, > > Overriding *_DEPENDENCIES is dangerous, it is better to let Automake > compute it. Yes; when trying that, I checked to see what was "normally" in *_DEPENDENCIES and I augmented it. > The BUILT_SOURCES hack is useful sometimes, but it's better to avoid it. Using BUILT_SOURCES works marginally worse than *_DEPENDENCIES: with BUILT_SOURCES, the generated sources are regenerated *twice*: make[3]: Entering directory `/home/braden/src/openvrml/openvrml/build/src/libopenvrml' /usr/bin/antlr -o ../../../src/libopenvrml/openvrml ../../../src/libopenvrml/openvrml/Vrml97Parser.g ANTLR Parser Generator Version 2.7.4 1989-2004 jGuru.com /usr/bin/antlr -o ../../../src/libopenvrml/openvrml -glib ../../../src/libopenvrml/openvrml/Vrml97Parser.g ../../../src/libopenvrml/openvrml/X3DVrmlParser.g ANTLR Parser Generator Version 2.7.4 1989-2004 jGuru.com make all-am make[4]: Entering directory `/home/braden/src/openvrml/openvrml/build/src/libopenvrml' /usr/bin/antlr -o ../../../src/libopenvrml/openvrml ../../../src/libopenvrml/openvrml/Vrml97Parser.g ANTLR Parser Generator Version 2.7.4 1989-2004 jGuru.com /usr/bin/antlr -o ../../../src/libopenvrml/openvrml -glib ../../../src/libopenvrml/openvrml/Vrml97Parser.g ../../../src/libopenvrml/openvrml/X3DVrmlParser.g ANTLR Parser Generator Version 2.7.4 1989-2004 jGuru.com make[4]: Leaving directory `/home/braden/src/openvrml/openvrml/build/src/libopenvrml' > Perhaps you could use a suffix rule > > antlr.c:. > custom commands > > and then add the antlr grammar file to *_SOURCES: > > myprog_SOURCES = ... foo.antlr ... I think the particulars of invoking antlr are such that a suffix rule won't work. Could the problem be related to the fact that I'm generating the sources in $(srcdir)? I'm doing that because I want to distribute them: I don't want users to have to rebuild them. Note also that my generated sources do not get listed in *_SOURCES. They are not compiled individually; rather, they are included by openvrml/browser.cpp. > Happy hacking in the New Year! You too! -- Braden McDaniel e-mail: <[EMAIL PROTECTED]> <http://endoframe.com> Jabber: <[EMAIL PROTECTED]>