Hi William, * William Pursell wrote on Sun, May 10, 2009 at 09:09:23AM CEST: > Ralf Wildenhues wrote: > > You can just write one in your Makefile.am, as a plain 'make' rule. > > For reusability, you can also put it in a fragment file and include it > > in your Makefile.am. > > I have a "best practice" question about this. For awhile, > I've had generic targets that I like to include in all of > my projects, but rather than including the fragment in > each Makefile.am, I use the following hack^h^h^h^htechnique: > configure.ac invokes my initialization macro (which I > install on my dev box in /usr/local/share/aclocal rather > than putting in a subdir of each project), this creates > the make rule file snippets in a new subdir of the builddir > at configure time and AC_SUBST_FILES them so that the Makefile.am > can contain: > > @MY_DEFAULT_RULES@ > > This mostly works, but there are a few cases where I need to > have the generated snippet file be just the rule, so I can do > things like: > > check-local: > @MY_LOCAL_RULES@ > > > The question is: is that a reliable technique, or is it a > ridiculous hack that will someday come to haunt me?
Yes, it is reliable in the sense of that I think it will always substitute things into the Makefile as you desire. However, the technique completely hides the rules from automake, so it cannot adjust its output to your additions. For example, automake will not let 'check' depend on or invoke the 'check-local' target when it has not seen a 'check-local' rule. Similarly with other stuff, where automake does not output bits that it thinks are unneeded in this Makefile.in. Not doing this would probably blow up the files by a few times. Cheers, Ralf
