tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / python-vars.sh
blob51107be48e8882564bf654a729333a2c47760015
1 #! /bin/sh
2 # Copyright (C) 2011-2018 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)
7 # any later version.
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.
20 required=python
21 . test-init.sh
23 # In case the user's config.site defines pythondir or pyexecdir.
24 CONFIG_SITE=/dev/null; export CONFIG_SITE
26 # Update the definition below if the documentation changes.
27 # Note that the value of the 'pythondir' and 'pyexecdir' variables can
28 # vary among different python installations, so we need more relaxed
29 # and ad-hoc checks for them. Also, more proper "functional" checks
30 # on them should be done in the 'python-virtualenv.sh' test.
31 PYTHON_VERSION=$($PYTHON -c 'import sys; print(sys.version[:3])') || exit 1
32 PYTHON_PLATFORM=$($PYTHON -c 'import sys; print(sys.platform)') || exit 1
33 PYTHON_EXEC_PREFIX='${exec_prefix}'
34 PYTHON_PREFIX='${prefix}'
35 pkgpythondir="\${pythondir}/$me"
36 pkgpyexecdir="\${pyexecdir}/$me"
38 pyvars='PYTHON_VERSION PYTHON_PLATFORM PYTHON_PREFIX PYTHON_EXEC_PREFIX
39 pkgpythondir pkgpyexecdir'
41 cat >> configure.ac << 'END'
42 AC_CONFIG_FILES([vars-got pythondir pyexecdir])
43 AM_PATH_PYTHON
44 AC_OUTPUT
45 END
47 cat > my.py << 'END'
48 def my():
49 return 1
50 END
52 cat > Makefile.am << 'END'
54 python_PYTHON = my.py
56 EXTRA_DIST = vars-exp
58 check-local: test-in test-am
59 .PHONY: test-in test-am
61 test-in:
62 cat pythondir
63 case `cat pythondir` in '$${prefix}'/*);; *) exit 1;; esac
64 cat pyexecdir
65 case `cat pyexecdir` in '$${exec_prefix}'/*);; *) exit 1;; esac
66 cat $(srcdir)/vars-exp
67 cat $(builddir)/vars-got
68 diff $(srcdir)/vars-exp $(builddir)/vars-got
70 ## Note: this target's rules will be extended in the "for" loop below.
71 test-am:
72 case '$(pythondir)' in '$(prefix)'/*);; *) exit 1;; esac
73 case '$(pyexecdir)' in '$(exec_prefix)'/*);; *) exit 1;; esac
74 END
76 echo @pythondir@ > pythondir.in
77 echo @pyexecdir@ > pyexecdir.in
79 : > vars-exp
80 : > vars-got.in
82 for var in $pyvars; do
83 eval val=\$$var
84 echo "var=$val" >> vars-exp
85 echo "var=@$var@" >> vars-got.in
86 echo "${tab}test x'\$($var)' = x'$val'" >> Makefile.am
87 done
89 cat Makefile.am
90 cat vars-got.in
92 $ACLOCAL
93 $AUTOMAKE --add-missing
95 for var in pythondir pyexecdir $pyvars; do
96 grep "^$var *=" Makefile.in
97 done
99 $AUTOCONF
100 ./configure PYTHON="$PYTHON"
102 $MAKE test-in test-am
103 $MAKE distcheck