am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / python10.sh
1 #! /bin/sh
2 # Copyright (C) 2004-2013 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Test _PYTHON with conditionals.
18
19 required=python
20 . test-init.sh
21
22 cat >>configure.ac <<'EOF'
23 AM_PATH_PYTHON
24 AM_CONDITIONAL([ONE], [test "x$one" = x1])
25 AC_OUTPUT
26 EOF
27
28 cat > Makefile.am <<'END'
29 if ONE
30 mydir=$(prefix)/my
31 my_PYTHON = one.py
32 else
33 yourdir=$(prefix)/your
34 your_PYTHON = two.py
35 endif
36
37 one.py:
38         echo 'def one(): return 1' >$@
39 two.py:
40         echo 'def two(): return 1' >$@
41
42 .PHONY: disttest
43 disttest: distdir
44         ls -l $(distdir)
45         test -f $(distdir)/one.py
46         test -f $(distdir)/two.py
47 END
48
49 $ACLOCAL
50 $AUTOCONF
51 $AUTOMAKE --add-missing
52
53 inst=inst_
54 mkdir inst_ build_
55 cd build_
56
57 cwd=$(pwd) || fatal_ "getting current working directory"
58
59 ../configure --prefix="$cwd/$inst" one=0
60 $MAKE install
61 test -f            "$inst/your/two.py"
62 py_installed       "$inst/your/two.pyc"
63 py_installed       "$inst/your/two.pyo"
64 py_installed --not "$inst/my/one.py"
65 py_installed --not "$inst/my/one.pyc"
66 py_installed --not "$inst/my/one.pyo"
67 $MAKE uninstall
68 py_installed --not "$inst/your/two.py"
69 py_installed --not "$inst/your/two.pyc"
70 py_installed --not "$inst/your/two.pyo"
71
72 ../configure --prefix=$cwd/"$inst" one=1
73 $MAKE install
74 py_installed --not "$inst/your/two.py"
75 py_installed --not "$inst/your/two.pyc"
76 py_installed --not "$inst/your/two.pyo"
77 test -f            "$inst/my/one.py"
78 py_installed       "$inst/my/one.pyc"
79 py_installed       "$inst/my/one.pyo"
80 $MAKE uninstall
81 py_installed --not "$inst/my/one.py"
82 py_installed --not "$inst/my/one.pyc"
83 py_installed --not "$inst/my/one.pyo"
84
85 $MAKE disttest
86
87 :