Alexandre Duret-Lutz <[EMAIL PROTECTED]> writes: Hi Alexandre!
> Roger Leigh wrote: > | In a project, I am preprocessing the C++ source and headers. That is: > | foo.ccg -> foo.cc > | foo.hg -> foo.h > | > | Some custom m4 I wrote processes the files with some simple rules: > | > | $(top_builddir)/build/classgen.m4f: $(top_srcdir)/build/classgen.m4 > | $(M4) -P -F $@ $^ > > $^ is not portable. > > Please forgive me if you are assuming GNU Make, but as Automake > strives to produce portable Makefiles and many people > unconsciously break this portability when writing custom rules, > I don't want someone who read the archives to blindingly copy > the above... No problem. In this case I've made GNU make as a requirement, since I have no means to do portability testing with non-GNU makes, so I don't have to worry about portability. However, some of your suggested alternatives are much more concise, so I'll doubtless convert to using them. > | libfoo_la_post_sources = \ > | $(addsuffix .cc,$(basename $(filter %.ccg,$(libfoo_la_pre_sources)))) \ > | $(addsuffix .h,$(basename $(filter %.hg,$(libfoo_la_pre_sources)))) > > In POSIX words: > > libfoo_la_post_sources = $(libfoo_la_pre_sources:g=) Yes :-) I think this is a lot easier to understand!! > | libfoo_la_SOURCES = \ > | $(libfoo_la_pre_sources) \ > | $(libfoo_la_post_sources) \ > | bar.cc \ > | bar.h \ > | > | If I touch foo.ccg, foo.cc is regenerated and foo.lo rebuilt. > | However, if I touch foo.hg, foo.h is not rebuilt, which is causing > | problems (I need to do a manual "make foo.h" every time I alter > | foo.hg). > > One issue with this setup is that foo.h doesn't exist the first > time you try to compile the *.cc files that include it, and as > dependency information is not available yet make won't help. > Hence you have type `make foo.h'. On the following runs, > however, dependency information is there, so I'd expect foo.h to > be rebuilt before anything that depends on it is compiled. > > It doesn't exactly correspond to you description, so maybe I'm > missing something. This is exactly my problem. > The `Built sources' section of the manual discusses the above > problem at lengths, and offer several solutions. The more > common is to use BUILT_SOURCES. Thanks. I've made the changes you suggested, and it did the trick. BUILT_SOURCES triggers the source generation prior to the actual compile. The POSIX inference rules look very handy too, but I've not had a chance to test them yet. Many thanks, Roger -- Roger Leigh Printing on GNU/Linux? http://gimp-print.sourceforge.net/ GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.