Subject: make install prefix inserted in source code with generated python files

From: "A.T.Hofkamp" <[email-masked]>
Date: Mon, 28 Mar 2011 09:36:45 +0200

Hello,

As far as I know, "make install prefix=/path/to/writable/dir" should only change the place where 
files are copied to, instead of injecting that new prefix into the source code. However, for Python 
source files that are generated/modified during installation, this does not seem to hold:

------------- Makefile.am
prefix=@prefix@
exec_prefix=@exec_prefix@
libexecdir = @libexecdir@
libdir = @libdir@

PYTHON_VERSION=@PYTHON_VERSION@
SITEPACKAGES=$(libdir)/python$(PYTHON_VERSION)/site-packages
SED=@sed@

prog_PYTHON=prog/__init__.py prog/x.py
progdir = $(SITEPACKAGES)/prog

prog/x.py: x.src
         $(SED) -e "s,%LIBEXEC%,$(libexecdir)," < x.src > prog/x.py
-------------

prog/x.py is generated from x.src by inserting the libexecdir path into it.

During install, the following happens at my system:
(/somewhere is a fake path for demonstration purposes only,
  also replaced irrelevant lengthy output lines by ... )

+ ./configure --prefix=/somewhere
checking for a BSD-compatible install... /usr/bin/install -c
...

+ make
make: Nothing to be done for `all'.

+ make prefix=/home/hat/tmp/p/installed install
...
sed -e "s,%LIBEXEC%,/home/hat/tmp/p/installed/libexec," < x.src > prog/x.py
...

The prog/x.py rule was run during 'make install' rather than 'make'. As a result, the wrong 
libexecdir got included.

Tested with autoconf 2.59, automake 1.9.6
and (by temporary install) autoconf 2.68, automake 1.11.1

Attached a demo directory 'p' that demonstrates the issue.