0b87ca0cf7abd8032c83cee99a69957488f299ef
[platform/upstream/automake.git] / t / vala4.sh
1 #! /bin/sh
2 # Copyright (C) 2008-2012 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 AM_PROG_VALAC.
18
19 . ./defs || exit 1
20
21 cat >> configure.ac << 'END'
22 AC_PROG_CC
23 AM_PROG_VALAC([1.2.3])
24 AC_OUTPUT
25 END
26
27 cat > Makefile.am << 'END'
28 has-valac:
29         case '$(VALAC)' in *valac) exit 0;; *) exit 1;; esac
30 no-valac:
31         test x'$(VALAC)' = x':'
32 END
33
34 mkdir bin
35 cat > bin/valac << 'END'
36 #! /bin/sh
37 if test "x$1" = x--version; then
38   echo "${vala_version-1.2.3}"
39 fi
40 exit 0
41 END
42 chmod +x bin/valac
43
44 cat > bin/valac.old << 'END'
45 #! /bin/sh
46 if test "x$1" = x--version; then
47   echo 0.1
48 fi
49 exit 0
50 END
51 chmod +x bin/valac.old
52
53 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
54
55 # Avoid interferences from the environment.
56 VALAC= vala_version=; unset VALAC vala_version
57
58 $ACLOCAL
59 $AUTOMAKE -a
60 $AUTOCONF
61
62 # The "|| exit 1" are required here even if 'set -e' is active,
63 # because ./configure might exit with status 77, and in that case
64 # we want to FAIL, not to SKIP.
65 ./configure || exit 1
66 $MAKE has-valac
67 vala_version=99.9 ./configure || exit 1
68 $MAKE has-valac
69
70 st=0; vala_version=0.1.2 ./configure 2>stderr || st=$?
71 cat stderr >&2
72 test $st -eq 77 || exit 1
73 #$MAKE no-valac
74
75 st=0; ./configure VALAC="$(pwd)/bin/valac.old" 2>stderr || st=$?
76 cat stderr >&2
77 test $st -eq 77 || exit 1
78 #$MAKE no-valac
79
80 sed 's/^\(AM_PROG_VALAC\).*/\1([1], [: > ok], [: > ko])/' <configure.ac >t
81 mv -f t configure.ac
82 rm -rf autom4te*.cache
83 $ACLOCAL
84 $AUTOCONF
85
86 ./configure
87 test -f ok
88 test ! -e ko
89 $MAKE has-valac
90 rm -f ok ko
91
92 vala_version=0.1.2 ./configure
93 test ! -e ok
94 test -f ko
95 $MAKE no-valac
96 rm -f ok ko
97
98 ./configure VALAC="$(pwd)/bin/valac.old"
99 test ! -e ok
100 test -f ko
101 $MAKE no-valac
102 rm -f ok ko
103
104 :