Doesn't work: blah_PROGRAMS = $(EXTRA_PROGRAMS)

2009-03-26 Thread Daniel Richard G.
This is the bug I was going to submit originally, before the whole 
shift-on-HP-UX issue got me distracted :-)

I have a Makefile.am with programs that are conditionally compiled, e.g.

EXTRA_PROGRAMS = foo bar

if ENABLE_STUFF
bin_PROGRAMS = foo bar
endif

Which works as advertised. Now, I'm looking at that, and figure, hey, there's 
a bit of redundancy we can eliminate here...

EXTRA_PROGRAMS = foo bar

if ENABLE_STUFF
bin_PROGRAMS = $(EXTRA_PROGRAMS)
endif

I go to regenerate the makefile, and, what's all this then?

automake: bar_OBJECTS should not be defined
Makefile.am:1:   while processing program `bar'
automake: foo_OBJECTS should not be defined
Makefile.am:1:   while processing program `foo'

bar_OBJECTS? foo_OBJECTS? Where?? And I got all confused and thought I should 
bring it to the attention of this list.


--Daniel


-- 
Daniel Richard G. || dani...@teragram.com || Software Developer
Teragram Linguistic Technologies (a division of SAS)
http://www.teragram.com/







Re: Doesn't work: blah_PROGRAMS = $(EXTRA_PROGRAMS)

2009-03-26 Thread Daniel Herring

On Fri, 27 Mar 2009, Daniel Richard G. wrote:


I have a Makefile.am with programs that are conditionally compiled, e.g.

EXTRA_PROGRAMS = foo bar

if ENABLE_STUFF
bin_PROGRAMS = foo bar
endif



I don't think you need to use EXTRA_PROGRAMS if you use the idiom

bin_PROGRAMS =
if ENABLE_STUFF
bin_PROGRAMS += foo bar
endif


EXTRA_PROGRAMS was designed for cases like

== in configure.ac ==
if test X; then
  PROGS="foo bar"
else
  PROGS="baz"
fi
AC_SUBST(PROGS)

== in Makefile.am ==
EXTRA_PROGRAMS=foo bar baz
bin_PROGRAMS=quux $(PROGS)


Without the EXTRA_PROGRAMS, automake wouldn't know what to do with things 
like foo_SOURCES since foo is otherwise missing from Makefile.am.


- Daniel H





RE: Doesn't work: blah_PROGRAMS = $(EXTRA_PROGRAMS)

2009-03-26 Thread Daniel Richard G.
> -Original Message-
>
> I don't think you need to use EXTRA_PROGRAMS if you
> use the idiom
>
>   bin_PROGRAMS =
>   if ENABLE_STUFF
>   bin_PROGRAMS += foo bar
>   endif

That works too, but with EXTRA_PROGRAMS, you still get the targets---that is, 
you can still do "make foo bar" if you wanted. The use case here is optionally 
saving time needed to compile a bunch of sample programs (specified as 
noinst_PROGRAMS), not disabling targets that would otherwise fail horribly.


--Daniel







Re: Doesn't work: blah_PROGRAMS = $(EXTRA_PROGRAMS)

2009-03-26 Thread Ralf Wildenhues
Hello Daniel,

* Daniel Richard G. wrote on Fri, Mar 27, 2009 at 05:07:49AM CET:
>   EXTRA_PROGRAMS = foo bar
> 
>   if ENABLE_STUFF
>   bin_PROGRAMS = $(EXTRA_PROGRAMS)
>   endif
> 
> I go to regenerate the makefile, and, what's all this then?
> 
>   automake: bar_OBJECTS should not be defined
>   Makefile.am:1:   while processing program `bar'
>   automake: foo_OBJECTS should not be defined
>   Makefile.am:1:   while processing program `foo'
> 
> bar_OBJECTS? foo_OBJECTS? Where?? And I got all confused and thought I
> should bring it to the attention of this list.

Looks like automake is as confused as you are.  For now, here's a simple
workaround, using a helper variable that is not special to automake:

  progs = foo bar
  EXTRA_PROGRAMS = $(progs)

  if ENABLE_STUFF
  bin_PROGRAMS = $(progs)
  endif

Cheers,
Ralf




RE: Doesn't work: blah_PROGRAMS = $(EXTRA_PROGRAMS)

2009-03-27 Thread Daniel Richard G.
> -Original Message-
>
> Looks like automake is as confused as you are.  For
> now, here's a simple
> workaround, using a helper variable that is not
> special to automake:

Oh, a workaround's not a problem; the bug is very narrow. In my case, I just 
assigned the same literal value to noinst_PROGRAMS, as only one or two program 
names were ever involved.

Just wanted to bring the bogus error message to your attention, not least 
because it seems remarkable that this corner case has never been addressed 
before!


--Daniel







Re: Doesn't work: blah_PROGRAMS = $(EXTRA_PROGRAMS)

2009-04-13 Thread Ralf Wildenhues
Helol Daniel,

> * Daniel Richard G. wrote on Fri, Mar 27, 2009 at 05:07:49AM CET:
> > EXTRA_PROGRAMS = foo bar
> > 
> > if ENABLE_STUFF
> > bin_PROGRAMS = $(EXTRA_PROGRAMS)
> > endif
> > 
> > I go to regenerate the makefile, and, what's all this then?
> > 
> > automake: bar_OBJECTS should not be defined
> > Makefile.am:1:   while processing program `bar'
> > automake: foo_OBJECTS should not be defined
> > Makefile.am:1:   while processing program `foo'
> > 
> > bar_OBJECTS? foo_OBJECTS? Where?? And I got all confused and thought I
> > should bring it to the attention of this list.

Fixed with the patch below.  Pushed to master, added you to THANKS.

Cheers,
Ralf

bin_PROGRAMS = $(EXTRA_PROGRAMS) should work.

* automake.in (am_install_var): For `PROGRAMS' primary, strip
`$(EXEEXT)' here already, so the name uniquifying works even
when we look at names repeatedly, with inconsistent executable
extension; through variable references, we might have added
the extension ourselves earlier.
(handle_programs): No need to strip `$(EXEEXT)' here any more.
* tests/extra8.test: New test.
* tests/Makefile.am: Update.
* THANKS: Update.
Report by Daniel Richard G.

diff --git a/automake.in b/automake.in
index cdbe24a..3549bdb 100755
--- a/automake.in
+++ b/automake.in
@@ -2471,11 +2471,6 @@ sub handle_programs
   my $seen_libobjs = 0;
   my $obj = get_object_extension '.$(OBJEXT)';
 
-  # Strip any $(EXEEXT) suffix the user might have added, or this
-  # will confuse &handle_source_transform and &check_canonical_spelling.
-  # We'll add $(EXEEXT) back later anyway.
-  $one_file =~ s/\$\(EXEEXT\)$//;
-
   $known_programs{$one_file} = $where;
 
   # Canonicalize names and check for misspellings.
@@ -7144,6 +7139,14 @@ sub am_install_var
}
  else
{
+ # Strip any $(EXEEXT) suffix the user might have added, or this
+ # will confuse &handle_source_transform and 
&check_canonical_spelling.
+ # We'll add $(EXEEXT) back later anyway.
+ # Do it here rather than in handle_programs so the uniquifying at 
the
+ # end of this function works.
+ ${$locvals}[1] =~ s/\$\(EXEEXT\)$//
+   if $primary eq 'PROGRAMS';
+
  push (@result, $locvals);
}
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 027e3f5..9af8512 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -263,6 +263,7 @@ extra4.test \
 extra5.test \
 extra6.test \
 extra7.test \
+extra8.test \
 f90only.test \
 flibs.test \
 fn99.test \
diff --git a/tests/extra8.test b/tests/extra8.test
new file mode 100755
index 000..02272d4
--- /dev/null
+++ b/tests/extra8.test
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Copyright (C) 2009  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Ensure defining bin_PROGRAMS in terms of EXTRA_PROGRAMS works,
+# and that referring to the same program with inconsistent addition
+# of $(EXEEXT) works, too.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >>configure.in <<'END'
+AC_PROG_CC
+AC_OUTPUT
+END
+cat >Makefile.am <<'END'
+EXTRA_PROGRAMS = foo bar
+bin_PROGRAMS = $(EXTRA_PROGRAMS) baz
+noinst_PROGRAMS = baz$(EXEEXT)
+END
+
+$ACLOCAL
+$AUTOMAKE
+
+: