Subject: Re: bug#10995: am__py_compile dose not get added to Makefile.in's

From: Stefano Lattarini <[email-masked]>
Date: Thu, 15 Mar 2012 09:23:20 +0100

tags 10995 patch
close 10995
thanks

On 03/15/2012 08:20 AM, Steven Drake wrote:
>
> Its possible to tell that it doesn't get defined by the line in 'install.log':
> "/bin/sh: line 15: --destdir: command not found"
> 
> The problem goes away if the attached patch is applied.
> 
Thanks, I can now reproduce the issue, and I agree yours is the right fix.

I've thus applied (to maint) a patch in my name exposing the bug in the automake
testsuite, and a patch in your name fixing it (see attachements).  I've then
merged maint into branch-1.11 and master.

Best regards, and thanks,
  Stefano
>From 463b6405380ac3ff266f980d30cfeeb55eb796ee Mon Sep 17 00:00:00 2001
Message-Id: <463b64053[email-masked]>
From: Stefano Lattarini <[email-masked]>
Date: Thu, 15 Mar 2012 09:00:12 +0100
Subject: [PATCH 1/2] python: expose automake bug#10995

* tests/python.test: Expose the bug in grepping tests.
* tests/python-noinst.test: New functional test to expose the
bug.
* tests/list-of-tests.mk: Add it.
* tests/Makefile.am (XFAIL_TESTS): Add the new test and the
extended one.
* THANKS: Update.

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 THANKS                    |    1 +
 tests/Makefile.am         |    2 +
 tests/list-of-tests.mk    |    1 +
 tests/python-pr10995.test |   60 +++++++++++++++++++++++++++++++++++++++++++++
 tests/python.test         |   11 ++++++-
 5 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100755 tests/python-pr10995.test

diff --git a/THANKS b/THANKS
index 418ad71..8363126 100644
--- a/THANKS
+++ b/THANKS
@@ -340,6 +340,7 @@ Stefano Lattarini	[email-masked]
 Stepan Kasal		[email-masked]
 Steve M. Robbins	[email-masked]
 Steve Goetze		[email-masked]
+Steven Drake		[email-masked]
 Steven G. Johnson	[email-masked]
 Sven Verdoolaege	[email-masked]
 Tamara L. Dahlgren	[email-masked]
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9cac904..005a1de 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -30,6 +30,8 @@ java-nobase.test \
 objext-pr10128.test \
 pr8365-remake-timing.test \
 lex-subobj-nodep.test \
+python.test \
+python-pr10995.test \
 remake-am-pr10111.test \
 remake-m4-pr10111.test \
 txinfo5.test
diff --git a/tests/list-of-tests.mk b/tests/list-of-tests.mk
index 0ee0711..b5a604c 100644
--- a/tests/list-of-tests.mk
+++ b/tests/list-of-tests.mk
@@ -728,6 +728,7 @@ python9.test \
 python10.test \
 python11.test \
 python12.test \
+python-pr10995.test \
 recurs.test \
 recurs2.test \
 remake.test \
diff --git a/tests/python-pr10995.test b/tests/python-pr10995.test
new file mode 100755
index 0000000..1b94cf9
--- /dev/null
+++ b/tests/python-pr10995.test
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This program 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 2, or (at your option)
+# any later version.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test automake bug#10995: am__py_compile doesn't get correctly defined
+# when there a 'noinst_PYTHON' declaration precedes a 'foo_PYTHON'
+# declaration.
+
+required=python
+. ./defs || Exit 1
+
+set -e
+
+cat >>configure.in <<'EOF'
+AM_PATH_PYTHON
+AC_OUTPUT
+EOF
+
+cat > Makefile.am <<'END'
+yesinstdir = $(prefix)/py
+noinst_PYTHON = no.py
+yesinst_PYTHON = yes.py
+disttest: distdir
+	test -f $(distdir)/no.py
+	test -f $(distdir)/yes.py
+END
+
+echo 'def foo(): return 1' > yes.py
+# no.py shouldn't be byte-compiled, so lets make it syntactically invalid.
+echo 'if' > no.py
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE --add-missing
+test -f py-compile
+
+inst=`pwd`/inst
+
+./configure --prefix="$inst"
+$MAKE install
+test -f "$inst/py/yes.py"
+test -f "$inst/py/yes.pyc"
+test ! -f "$inst/py/no.py"
+test ! -f "$inst/py/no.pyc"
+
+$MAKE disttest
+
+:
diff --git a/tests/python.test b/tests/python.test
index e7a6984..fe9d593 100755
--- a/tests/python.test
+++ b/tests/python.test
@@ -34,16 +34,23 @@ mydir = ${prefix}
 my_PYTHON = d.py
 END
 
+# For automake bug#10995.
+cat > Makefile3.am << 'END'
+noinst_PYTHON = un.py
+python_PYTHON = in.py
+END
+
 $ACLOCAL
 $AUTOMAKE -a
 
 test -f py-compile
 
 $AUTOMAKE Makefile2
+$AUTOMAKE Makefile3
 
-grep "py" Makefile.in Makefile2.in # For debugging.
+grep "py" Makefile.in Makefile2.in Makefile3.in # For debugging.
 
-for f in Makefile.in Makefile2.in; do
+for f in Makefile.in Makefile2.in Makefile3.in; do
   test `grep -c '^py_compile =' $f` -eq 1
   test `grep -c '^am__py_compile =' $f` -eq 1
 done
-- 
1.7.9

>From 819005ae2c86c3ef4b77bea7176bb6d8b67ebd64 Mon Sep 17 00:00:00 2001
Message-Id: <819005ae2[email-masked]>
In-Reply-To: <463b64053[email-masked]>
References: <463b64053[email-masked]>
From: Steven Drake <[email-masked]>
Date: Thu, 15 Mar 2012 09:12:00 +0100
Subject: [PATCH 2/2] python: avoid failures due to $(am__py_compile) being
 undefined

Fixes automake bug#10995, introduced in commit v1.11-372-gb46debf.

* lib/am/python.am: Move the definition of 'am__py_compile' to
ensure it is always emitted in the output Makefile.in.  Previously,
this wouldn't have happened if the input Makefile.am contained a
'noinst_PYTHON' declaration before a 'python_PYTHON' one.
* tests/Makefile.am (XFAIL_TESTS): Remove 'python-pr10995.test' and
'python.test'.
* NEWS: Update.

Copyright-paperwork-exempt: yes
Signed-off-by: Stefano Lattarini <[email-masked]>
---
 NEWS              |    3 +++
 lib/am/python.am  |    6 +++---
 tests/Makefile.am |    2 --
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/NEWS b/NEWS
index 3a6d2c4..b998ce4 100644
--- a/NEWS
+++ b/NEWS
@@ -129,6 +129,9 @@ Bugs fixed in 1.11.0a:
   - Automake now correctly recognizes the prefix/primary combination
    `pkglibexec_SCRIPTS' as valid.
 
+  - A definition of 'noinst_PYTHON' before 'python_PYTHON' (or similar)
+    don't cause spurious failures upon "make install" anymore.
+
 * Bugs introduced by 1.11:
 
   - The parallel-tests harness doesn't trip anymore on sed implementations
diff --git a/lib/am/python.am b/lib/am/python.am
index 427c95d..bb2748c 100644
--- a/lib/am/python.am
+++ b/lib/am/python.am
@@ -1,6 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 1999, 2001, 2003, 2004, 2006, 2007, 2008, 2009, 2011
-## Free Software Foundation, Inc.
+## Copyright (C) 1999-2012 Free Software Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -19,12 +18,13 @@ if %?INSTALL%
 include inst-vars.am
 endif %?INSTALL%
 
+?FIRST?am__py_compile = PYTHON=$(PYTHON) $(SHELL) $(py_compile)
+
 ## ------------ ##
 ## Installing.  ##
 ## ------------ ##
 
 if %?INSTALL%
-?FIRST?am__py_compile = PYTHON=$(PYTHON) $(SHELL) $(py_compile)
 am__installdirs += "$(DESTDIR)$(%NDIR%dir)"
 .PHONY install-%EXEC?exec:data%-am: install-%DIR%PYTHON
 install-%DIR%PYTHON: $(%DIR%_PYTHON)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 005a1de..9cac904 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -30,8 +30,6 @@ java-nobase.test \
 objext-pr10128.test \
 pr8365-remake-timing.test \
 lex-subobj-nodep.test \
-python.test \
-python-pr10995.test \
 remake-am-pr10111.test \
 remake-m4-pr10111.test \
 txinfo5.test
-- 
1.7.9