2 # Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Check that AM_PATH_PYTHON correctly sets all the output variables
18 # advertised in the manual, both with the GNU prefix values and the
19 # Python sys.* prefix values.
24 # In case the user's config.site defines pythondir or pyexecdir.
25 CONFIG_SITE
=/dev
/null
; export CONFIG_SITE
27 # Update the definition below if the documentation changes. The values
28 # of the 'pythondir' and 'pyexecdir' variables vary among different
29 # python installations, so we need more relaxed and ad-hoc checks for
30 # them. Also, more proper "functional" checks on them should be done in
31 # the 'python-virtualenv.sh' test.
33 # This version identification is duplicated in python.m4 (and the manual).
34 PYTHON_VERSION
=$
($PYTHON -c 'import sys; print ("%u.%u" % sys.version_info[:2])') ||
exit 1
35 PYTHON_PLATFORM
=$
($PYTHON -c 'import sys; print (sys.platform)') ||
exit 1
36 PYTHON_EXEC_PREFIX
=$
($PYTHON -c 'import sys; print (sys.exec_prefix)') ||
exit 1
37 PYTHON_PREFIX
=$
($PYTHON -c 'import sys; print (sys.prefix)') ||
exit 1
38 pkgpythondir
="\${pythondir}/$me"
39 pkgpyexecdir
="\${pyexecdir}/$me"
41 pyvars
='PYTHON_VERSION PYTHON_PLATFORM PYTHON_PREFIX PYTHON_EXEC_PREFIX
42 pkgpythondir pkgpyexecdir'
44 cat >> configure.ac
<< 'END'
45 AC_CONFIG_FILES
([vars-got pythondir pyexecdir
])
55 cat > Makefile.am
<< 'END'
61 check-local
: test-in test-am
62 .PHONY
: test-in test-am
65 @
echo "> doing test-in"
66 @
echo ">> contents of pythondir:"
68 case `cat pythondir` in '$${PYTHON_PREFIX}'/*);; *) exit 1;; esac
69 @
echo ">> contents of pyexecdir:"
71 case `cat pyexecdir` in '$${PYTHON_EXEC_PREFIX}'/*);; *) exit 1;; esac
72 @
echo ">> contents of vars-exp:"
73 cat $
(srcdir
)/vars-exp
74 @
echo ">> contents of vars-got:"
75 cat $
(builddir
)/vars-got
76 diff $
(srcdir
)/vars-exp $
(builddir
)/vars-got
78 ## Note: this target's rules will be extended in the "for" loop below.
80 @
echo "> doing test-am"
81 case '$(pythondir)' in '$(PYTHON_PREFIX)'/*);; *) exit 1;; esac
82 case '$(pyexecdir)' in '$(PYTHON_EXEC_PREFIX)'/*);; *) exit 1;; esac
85 echo @pythondir@
> pythondir.
in
86 echo @pyexecdir@
> pyexecdir.
in
88 # This depends on whether we're doing GNU or Python values, per arg.
95 for var
in $pyvars; do
96 if test x
"$vartype" = xgnu
; then
97 # when not using Python sys.* values, PYTHON_*PREFIX will vary;
98 # the computed value will be (something like) "/usr",
99 # but the expected value will be "${prefix}".
100 if test x
"$var" = xPYTHON_PREFIX \
101 ||
test x
"$var" = xPYTHON_EXEC_PREFIX
; then
106 echo "var=$val #$var" >> vars-exp
107 echo "var=@$var@ #$var" >> vars-got.
in
108 echo "${tab}test x'\$($var)' = x'$val' || test \"\$NO_CHECK_PYTHON_PREFIX\"" >> Makefile.am
115 $AUTOMAKE --add-missing
117 # some debugging output.
118 for var
in pythondir pyexecdir
$pyvars; do
119 grep "^$var *=" Makefile.
in
125 .
/configure PYTHON
="$PYTHON"
126 $MAKE test-in test-am
130 setup_vars_file python
132 .
/configure PYTHON
="$PYTHON" --with-python-sys-prefix --prefix="$instdir"
133 $MAKE test-in test-am
135 # This tries to install to $PYTHON_PREFIX, which may not be writable.
136 # Override it to something safe, but then of course we have to skip
137 # checking that it is what we originally set it to.
139 PYTHON_PREFIX
="$instdir" \
140 NO_CHECK_PYTHON_PREFIX
=1 \
141 AM_DISTCHECK_CONFIGURE_FLAGS
=--with-python-sys-prefix