On 07/31/2013 03:23 PM, Adam Mercer wrote:
> Hi
> 
> In one of our projects we have several python scripts that we need to
> ensure that the python interpreter is set to the one found by
> configure. At the moment we are doing this by having the interpreter
> set to @PYTHONPROG@ and then using the following rule:
> 
> python_config.sed:
>   @-rm -f python_config.sed
>   @echo "s+@PYTHONPROG@+@PYTHON@+g" >> python_config.sed

This is an unsafe sed script, if configure found a version of PYTHON
that includes a '+' in its (possibly absolute) name.  Better would be
using something that has to be quoted for use in the shell, as that is
less likely to be the name of any PYTHON directory the user desires to
use, as in 's|@PYTHONPROG@|@PYTHON@|'.

> 
> script: $(srcdir)/script.in python_config.sed
>   $(AM_V_GEN)sed -f python_config.sed $(srcdir)/script.in > script
>   @chmod +x script
> 
> This has always seemed like an ugly hack to me, especially as the
> script is in the VCS as script.in instead of the actual name.
> 
> Can anyone offer any more sane ways of accomplishing this?

Why not add this to your configure.ac:

AC_SUBST([PYTHON], ...)
AC_CONFIG_FILES([script], [chmod +x script])

prior to the AC_OUTPUT, so that running config.status (as part of the
configure script itself) will automatically replace @PYTHON@ from the
script.in template into the output script without you repeating the work
in your makefile.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to