Revert Automake license to GPLv2+.
[platform/upstream/automake.git] / tests / subst3.test
1 #! /bin/sh
2 # Copyright (C) 2001, 2002, 2004, 2005, 2006, 2007, 2008  Free Software
3 # Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Test installation with substitutions.  This test is based on nobase.test.
19
20 required='gcc'
21 . ./defs || Exit 1
22
23 set -e
24
25 cat >> configure.in <<'EOF'
26 AC_PROG_CC
27 AC_PROG_RANLIB
28 if test -n "$doit"; then
29   AC_SUBST([basehdr], [sub/base.h])
30   AC_SUBST([nobasehdr], [sub/nobase.h])
31   AC_SUBST([basedata], [sub/base.dat])
32   AC_SUBST([nobasedata], [sub/nobase.dat])
33   AC_SUBST([basescript], [sub/base.sh])
34   AC_SUBST([nobasescript], [sub/nobase.sh])
35   AC_SUBST([baseprog], ['sub/base$(EXEEXT)'])
36   AC_SUBST([nobaseprog], ['sub/nobase$(EXEEXT)'])
37   AC_SUBST([baselib], [sub/libbase.a])
38   AC_SUBST([nobaselib], [sub/libnobase.a])
39 fi
40 AC_OUTPUT
41 EOF
42
43 cat > Makefile.am << 'EOF'
44 foodir = $(prefix)/foo
45 fooexecdir = $(prefix)/foo
46
47 foo_HEADERS = @basehdr@
48 nobase_foo_HEADERS = @nobasehdr@
49 EXTRA_HEADERS = sub/base.h sub/nobase.h
50
51 dist_foo_DATA = @basedata@
52 nobase_dist_foo_DATA = @nobasedata@
53
54 dist_fooexec_SCRIPTS = @basescript@
55 nobase_dist_fooexec_SCRIPTS = @nobasescript@
56 EXTRA_SCRIPTS = sub/base.sh sub/nobase.sh
57
58 fooexec_PROGRAMS = @baseprog@
59 nobase_fooexec_PROGRAMS = @nobaseprog@
60 EXTRA_PROGRAMS = sub/base sub/nobase
61 sub_base_SOURCES = source.c
62 sub_nobase_SOURCES = source.c
63
64 fooexec_LIBRARIES = @baselib@
65 nobase_fooexec_LIBRARIES = @nobaselib@
66 EXTRA_LIBRARIES = sub/libbase.a sub/libnobase.a
67 sub_libbase_a_SOURCES = source.c
68 sub_libnobase_a_SOURCES = source.c
69
70 test-install-data: install-data
71         test   -f inst/foo/sub/nobase.h
72         test ! -f inst/foo/nobase.h
73         test   -f inst/foo/base.h
74         test   -f inst/foo/sub/nobase.dat
75         test ! -f inst/foo/nobase.dat
76         test   -f inst/foo/base.dat
77         test ! -f inst/foo/sub/pnobase.sh
78         test ! -f inst/foo/pbase.sh
79         test ! -f inst/foo/sub/pnobase$(EXEEXT)
80         test ! -f inst/foo/pbase$(EXEEXT)
81         test ! -f inst/foo/sub/libnobase.a
82         test ! -f inst/foo/libbase.a
83
84 test-install-exec: install-exec
85         test   -f inst/foo/sub/pnobase.sh
86         test ! -f inst/foo/pnobase.sh
87         test   -f inst/foo/pbase.sh
88         test   -f inst/foo/sub/pnobase$(EXEEXT)
89         test ! -f inst/foo/pnobase$(EXEEXT)
90         test   -f inst/foo/pbase$(EXEEXT)
91         test   -f inst/foo/sub/libnobase.a
92         test ! -f inst/foo/libnobase.a
93         test   -f inst/foo/libbase.a
94
95 test-install-nothing-data: install-data
96         test ! -f inst/foo/sub/nobase.h
97         test ! -f inst/foo/nobase.h
98         test ! -f inst/foo/base.h
99         test ! -f inst/foo/sub/nobase.dat
100         test ! -f inst/foo/nobase.dat
101         test ! -f inst/foo/base.dat
102         test ! -f inst/foo/sub/pnobase.sh
103         test ! -f inst/foo/pbase.sh
104         test ! -f inst/foo/sub/pnobase$(EXEEXT)
105         test ! -f inst/foo/pbase$(EXEEXT)
106         test ! -f inst/foo/sub/libnobase.a
107         test ! -f inst/foo/libbase.a
108
109 test-install-nothing-exec: install-exec
110         test ! -f inst/foo/sub/pnobase.sh
111         test ! -f inst/foo/pnobase.sh
112         test ! -f inst/foo/pbase.sh
113         test ! -f inst/foo/sub/pnobase$(EXEEXT)
114         test ! -f inst/foo/pnobase$(EXEEXT)
115         test ! -f inst/foo/pbase$(EXEEXT)
116         test ! -f inst/foo/sub/libnobase.a
117         test ! -f inst/foo/libnobase.a
118         test ! -f inst/foo/libbase.a
119 EOF
120
121 mkdir sub
122
123 : > sub/base.h
124 : > sub/nobase.h
125 : > sub/base.dat
126 : > sub/nobase.dat
127 : > sub/base.sh
128 : > sub/nobase.sh
129
130 cat >source.c <<'EOF'
131 int
132 main (int argc, char *argv[])
133 {
134   return 0;
135 }
136 EOF
137 cp source.c source2.c
138
139 rm -f install-sh
140
141 $ACLOCAL
142 $AUTOCONF
143 $AUTOMAKE -a --copy
144 ./configure --prefix "`pwd`/inst" --program-prefix=p doit=yes
145
146 $MAKE
147 $MAKE test-install-data
148 $MAKE test-install-exec
149 $MAKE uninstall
150 $MAKE clean
151
152 test `find inst/foo -type f -print | wc -l` = 0
153
154 ./configure --prefix "`pwd`/inst" --program-prefix=p doit=
155
156 $MAKE
157 $MAKE test-install-nothing-data
158 $MAKE test-install-nothing-exec
159 $MAKE uninstall
160
161
162 # Likewise, in a VPATH build.
163
164 $MAKE distclean
165 mkdir build
166 cd build
167 ../configure --prefix "`pwd`/inst" --program-prefix=p doit=yes
168 $MAKE
169 $MAKE test-install-data
170 $MAKE test-install-exec
171 $MAKE uninstall
172 test `find inst/foo -type f -print | wc -l` = 0
173
174 ../configure --prefix "`pwd`/inst" --program-prefix=p doit=
175 $MAKE
176 $MAKE test-install-nothing-data
177 $MAKE test-install-nothing-exec