tests: work around strangeness in MSYS
[automake.git] / tests / cond39.test
blobac64be3642a3db522256ef84ddda51490acb4037
1 #!/bin/sh
2 # Copyright (C) 2008, 2010, 2011 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 <http://www.gnu.org/licenses/>.
17 # Build either as CONFIG_FILE or as PROGRAM.
19 required=cc
20 . ./defs || Exit 1
22 mkdir sub
24 cat >>configure.in <<'END'
25 AC_PROG_CC
26 AM_CONDITIONAL([COND], [test "$COND" = true])
27 AM_COND_IF([COND], [],
28 [AC_CONFIG_FILES([prog1], [chmod 755 prog1])
29 AC_CONFIG_FILES([sub/prog2], [chmod 755 sub/prog2])])
30 AC_CONFIG_FILES([sub/Makefile])
31 AC_OUTPUT
32 END
34 cat >Makefile.am <<'END'
35 SUBDIRS = sub
36 if COND
37 bin_PROGRAMS = prog1
38 prog1_SOURCES = prog.c
39 else
40 bin_SCRIPTS = prog1
41 CLEANFILES = prog1
42 endif
44 sure-exist:
45 test -f prog1 || test -f prog1$(EXEEXT)
46 test -f sub/prog2 || test -f sub/prog2$(EXEEXT)
48 sure-not-exist:
49 test ! -f prog1 && test ! -f prog1$(EXEEXT)
50 test ! -f sub/prog2 && test ! -f sub/prog2$(EXEEXT)
51 END
53 cat >sub/Makefile.am <<'END'
54 if COND
55 bin_PROGRAMS = prog2
56 prog2_SOURCES = prog.c
57 else
58 bin_SCRIPTS = prog2
59 CLEANFILES = prog2
60 endif
61 END
63 cat >prog.c <<'END'
64 int main () { return 42; }
65 END
67 cat >prog1.in <<'END'
68 #! /bin/sh
69 bindir='@bindir@'
70 echo "hi, this is $0, and bindir is $bindir"
71 END
73 cp prog.c sub
74 cp prog1.in sub/prog2.in
76 $ACLOCAL
77 $AUTOCONF
78 $AUTOMAKE --add-missing
80 ./configure COND=true
81 $MAKE 2>stderr || { cat stderr >&2; Exit 1; }
82 cat stderr >&2
83 grep 'overriding commands' stderr && Exit 1
84 $MAKE sure-exist
85 ./prog1 && Exit 1
86 ./sub/prog2 && Exit 1
87 $MAKE clean
88 $MAKE sure-not-exist
89 $MAKE
90 $MAKE sure-exist
91 ./prog1 && Exit 1
92 ./sub/prog2 && Exit 1
93 $MAKE distclean
95 ./configure COND=false
96 $MAKE 2>stderr || { cat stderr >&2; Exit 1; }
97 cat stderr >&2
98 grep 'overriding commands' stderr && Exit 1
99 ./prog1
100 ./sub/prog2
101 $MAKE clean
102 $MAKE sure-not-exist
103 $MAKE
104 ./prog1
105 ./sub/prog2