30e87632f3e24ecce47f9971df4292ea881a9ea7
[platform/upstream/automake.git] / t / check-subst-prog.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 # Check @substituted@ TESTS, some of which are also PROGRAMS.
18 # See also sister test 'check-subst.test'.
19
20 required='cc native'
21 . ./defs || Exit 1
22
23 cat >> configure.ac << 'END'
24 AC_PROG_CC
25 AC_SUBST([script_tests],
26          ['subst-pass-script.test subst-xfail-script.test'])
27 AC_SUBST([prog_tests],
28          ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
29 AC_SUBST([xfail_tests],
30          ['xfail-script.test subst-xfail-script.test]dnl
31          [ xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
32 AC_OUTPUT
33 END
34
35 cat > Makefile.am << 'END'
36 TESTS = pass-script.test xfail-script.test @script_tests@ $(check_PROGRAMS)
37 XFAIL_TESTS = @xfail_tests@
38 check_PROGRAMS = pass-prog xfail-prog @prog_tests@
39 EXTRA_PROGRAMS = subst-pass-prog.test subst-xfail-prog.test
40 END
41
42 cat > pass-script.test <<'END'
43 #! /bin/sh
44 exit 0
45 END
46 cat > xfail-script.test <<'END'
47 #! /bin/sh
48 exit 1
49 END
50 chmod a+x pass-script.test xfail-script.test
51 cp pass-script.test subst-pass-script.test
52 cp xfail-script.test subst-xfail-script.test
53
54 cat > pass-prog.c <<'END'
55 int main (void) { return 0; }
56 END
57 cat > xfail-prog.c <<'END'
58 #include <stdlib.h>
59 int main (void) { return EXIT_FAILURE; }
60 END
61 # The .test extension is removed for the default source file name:
62 cp pass-prog.c subst-pass-prog.c
63 cp xfail-prog.c subst-xfail-prog.c
64
65 $ACLOCAL
66 $AUTOCONF
67 $AUTOMAKE -a
68
69 ./configure
70 $MAKE all
71 $MAKE check
72 $MAKE distclean
73
74 mkdir build
75 cd build
76 ../configure
77 $MAKE all
78 $MAKE check
79 $MAKE distclean
80
81 :