Re: multi-line AC_SUBSTs as targets in Makefile.am

2007-10-08 Thread Ralf Wildenhues
Hello William,

* William Pursell wrote on Mon, Oct 08, 2007 at 12:11:59PM CEST:
> Andreas Schwab wrote:
>> William Pursell <[EMAIL PROTECTED]> writes:
>>
>>> I'd like to get away from AC_SUBST_FILE, but I don't see a way
>>> around the manner in which automake is building the Makefile.
>>> Is there a way to construct a generic target via AC_SUBST?
>>
>> How about using AM_CONDITIONAL instead?
>
> How so?  What I'm hoping to do is to have a set of generic targets
> so that I can have a template Makefile.am that simply includes
> the line @MY_TARGETS@
>
> I currently have it working with AC_SUBST_FILE, but I'm copying the
> template target files into each of my project directory trees.
> I would rather install my macros in /usr/share/aclocal, but I
> notice that none of the packages I have ever seen invoke
> AC_SUBST_FILE, and I suspect the reason is that there's no
> good place to put the target file.

Well,  with Autoconf 2.60 or newer, AC_SUBSTed values can contain
newlines, so in principle you could
  AC_PREREQ([2.60])
  AC_SUBST([MY_TARGETS], [# this assignment line is ignored
  target1:
[...]
  ...])

and it will have roughly the same effect as your previous AC_SUBST_FILE.

However, in both cases (AC_SUBST or AC_SUBST_FILE), you put stuff in a
Makefile which automake won't see, and all its magic variables, its
machinery to let you override its default-provided targets, and so on,
won't work as expected.  This may in some cases be what you want, but
mostly I would guess it shouldn't, unless you are working around some
bug in Automake.

Instead, I suggest you just use Automake's `include' feature to put the
fragment file in the Makefile.am where it is used.  This won't relieve
you from having to copy the fragment into your projects, but it will
cause a readable error message from `automake' if you forgot to.  You
could provide a `bootstrap' script that does the copying for you.

Hope that helps.

Cheers,
Ralf




Re: multi-line AC_SUBSTs as targets in Makefile.am

2007-10-08 Thread William Pursell

Andreas Schwab wrote:

William Pursell <[EMAIL PROTECTED]> writes:


I'd like to get away from AC_SUBST_FILE, but I don't see a way
around the manner in which automake is building the Makefile.
Is there a way to construct a generic target via AC_SUBST?


How about using AM_CONDITIONAL instead?


How so?  What I'm hoping to do is to have a set of generic targets
so that I can have a template Makefile.am that simply includes
the line @MY_TARGETS@

I currently have it working with AC_SUBST_FILE, but I'm copying the
template target files into each of my project directory trees.
I would rather install my macros in /usr/share/aclocal, but I
notice that none of the packages I have ever seen invoke
AC_SUBST_FILE, and I suspect the reason is that there's no
good place to put the target file.




Re: multi-line AC_SUBSTs as targets in Makefile.am

2007-10-08 Thread Andreas Schwab
William Pursell <[EMAIL PROTECTED]> writes:

> I'd like to get away from AC_SUBST_FILE, but I don't see a way
> around the manner in which automake is building the Makefile.
> Is there a way to construct a generic target via AC_SUBST?

How about using AM_CONDITIONAL instead?

Andreas.

-- 
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




multi-line AC_SUBSTs as targets in Makefile.am

2007-10-08 Thread William Pursell


I've been using AC_SUBST_FILE to put common targets into my
makefile.am's.  eg, Makefile.am contains:

@FOO_TARGET@

where configure.ac contains
FOO_TARGET=foo_target
AC_SUBST_FILE(FOO_TARGET)

and foo_target contains:

foo:
echo foo

I would like to do this via AC_SUBST, but this completely hoses
the Makefile.  For example, if configure.ac instead contains:

BAR_TARGET="bar:
echo bar"
AC_SUBST( BAR_TARGET)

Then Make bails since Makefile now contains the invalid construct:
BAR_TARGET = bar:
echo bar

I'd like to get away from AC_SUBST_FILE, but I don't see a way
around the manner in which automake is building the Makefile.
Is there a way to construct a generic target via AC_SUBST?