Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / gnits2.test
1 #! /bin/sh
2 # Copyright (C) 2002, 2003, 2004, 2007  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 to ensure std-options checking is correct.
18
19 required=gcc
20 . ./defs || Exit 1
21
22 cat >> configure.in << 'END'
23 AC_PROG_CC
24 AC_OUTPUT
25 END
26
27 cat > Makefile.am << 'END'
28 AUTOMAKE_OPTIONS = gnits
29 noinst_PROGRAMS = fubar2
30 bin_PROGRAMS = fubar sub/fine
31 nobase_bin_PROGRAMS = sub/fubar3
32 fubar_SOURCES = fubar.c
33 fubar2_SOURCES = fubar.c
34 sub_fubar3_SOURCES = fubar.c
35 sub_fine_SOURCES = fine.c
36 bin_SCRIPTS = sub/scriptok.sh sub/scriptnok.sh
37
38 grep-stderr:
39         grep 'pfubar$(EXEEXT) does not support' stderr
40         grep 'pfubar3$(EXEEXT) does not support' stderr
41         grep 'pscriptnok.sh does not support' stderr
42 ## Only three failures please.
43         test `grep 'does not support --help' stderr | wc -l` = 3
44         test `grep 'does not support --version' stderr | wc -l` = 3
45
46 test-install: install
47         test -f ../inst-dir/bin/pfine$(EXEEXT)
48         test ! -f ../inst-dir/bin/fine$(EXEEXT)
49 END
50
51 echo 'int main () { return 0; }' > fubar.c
52
53 cat > fine.c << 'END'
54 #include <stdio.h>
55 int
56 main ()
57 {
58   puts ("Which version? Which usage?");
59   return 0;
60 }
61 END
62
63 mkdir sub
64
65 cat >sub/scriptok.sh <<EOF
66 #!/bin/sh
67 echo "Which version? Which usage?"
68 EOF
69
70 # Not only does this script not support --help/--version, but
71 # it will also hang when run without input.
72 cat >sub/scriptnok.sh <<EOF
73 #!/bin/sh
74 cat
75 EOF
76
77 chmod +x sub/scriptok.sh
78 chmod +x sub/scriptnok.sh
79
80 # Files required by Gnits.
81 : > INSTALL
82 : > NEWS
83 : > README
84 : > COPYING
85 : > AUTHORS
86 : > ChangeLog
87 : > THANKS
88
89 # The following file should not be distributed.
90 # (alpha.test checks the case where it must be distributed.)
91 : > README-alpha
92
93 set -e
94
95 $ACLOCAL
96 $AUTOCONF
97 $AUTOMAKE -a
98
99 grep README-alpha Makefile.in && Exit 1
100
101 mkdir build
102 cd build
103
104 # Use --program-prefix to make sure the std-options check honors it.
105 ../configure "--prefix=`pwd`/../inst-dir" --program-prefix=p
106 $MAKE all
107 $MAKE test-install
108 $MAKE -k installcheck 2>stderr || : # Never trust the exit status of make -k.
109 cat stderr
110 $MAKE grep-stderr