Merge branch 'msvc' into maint
[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 AM_PROG_AR
28 AC_PROG_RANLIB
29 if test -n "$doit"; then
30   AC_SUBST([basehdr], [sub/base.h])
31   AC_SUBST([nobasehdr], [sub/nobase.h])
32   AC_SUBST([basedata], [sub/base.dat])
33   AC_SUBST([nobasedata], [sub/nobase.dat])
34   AC_SUBST([basescript], [sub/base.sh])
35   AC_SUBST([nobasescript], [sub/nobase.sh])
36   AC_SUBST([baseprog], ['sub/base$(EXEEXT)'])
37   AC_SUBST([nobaseprog], ['sub/nobase$(EXEEXT)'])
38   AC_SUBST([baselib], [sub/libbase.a])
39   AC_SUBST([nobaselib], [sub/libnobase.a])
40 fi
41 AC_OUTPUT
42 EOF
43
44 cat > Makefile.am << 'EOF'
45 foodir = $(prefix)/foo
46 fooexecdir = $(prefix)/foo
47
48 foo_HEADERS = @basehdr@
49 nobase_foo_HEADERS = @nobasehdr@
50 EXTRA_HEADERS = sub/base.h sub/nobase.h
51
52 dist_foo_DATA = @basedata@
53 nobase_dist_foo_DATA = @nobasedata@
54
55 dist_fooexec_SCRIPTS = @basescript@
56 nobase_dist_fooexec_SCRIPTS = @nobasescript@
57 EXTRA_SCRIPTS = sub/base.sh sub/nobase.sh
58
59 fooexec_PROGRAMS = @baseprog@
60 nobase_fooexec_PROGRAMS = @nobaseprog@
61 EXTRA_PROGRAMS = sub/base sub/nobase
62 sub_base_SOURCES = source.c
63 sub_nobase_SOURCES = source.c
64
65 fooexec_LIBRARIES = @baselib@
66 nobase_fooexec_LIBRARIES = @nobaselib@
67 EXTRA_LIBRARIES = sub/libbase.a sub/libnobase.a
68 sub_libbase_a_SOURCES = source.c
69 sub_libnobase_a_SOURCES = source.c
70
71 test-install-data: install-data
72         test   -f inst/foo/sub/nobase.h
73         test ! -f inst/foo/nobase.h
74         test   -f inst/foo/base.h
75         test   -f inst/foo/sub/nobase.dat
76         test ! -f inst/foo/nobase.dat
77         test   -f inst/foo/base.dat
78         test ! -f inst/foo/sub/pnobase.sh
79         test ! -f inst/foo/pbase.sh
80         test ! -f inst/foo/sub/pnobase$(EXEEXT)
81         test ! -f inst/foo/pbase$(EXEEXT)
82         test ! -f inst/foo/sub/libnobase.a
83         test ! -f inst/foo/libbase.a
84
85 test-install-exec: install-exec
86         test   -f inst/foo/sub/pnobase.sh
87         test ! -f inst/foo/pnobase.sh
88         test   -f inst/foo/pbase.sh
89         test   -f inst/foo/sub/pnobase$(EXEEXT)
90         test ! -f inst/foo/pnobase$(EXEEXT)
91         test   -f inst/foo/pbase$(EXEEXT)
92         test   -f inst/foo/sub/libnobase.a
93         test ! -f inst/foo/libnobase.a
94         test   -f inst/foo/libbase.a
95
96 test-install-nothing-data: install-data
97         test ! -f inst/foo/sub/nobase.h
98         test ! -f inst/foo/nobase.h
99         test ! -f inst/foo/base.h
100         test ! -f inst/foo/sub/nobase.dat
101         test ! -f inst/foo/nobase.dat
102         test ! -f inst/foo/base.dat
103         test ! -f inst/foo/sub/pnobase.sh
104         test ! -f inst/foo/pbase.sh
105         test ! -f inst/foo/sub/pnobase$(EXEEXT)
106         test ! -f inst/foo/pbase$(EXEEXT)
107         test ! -f inst/foo/sub/libnobase.a
108         test ! -f inst/foo/libbase.a
109
110 test-install-nothing-exec: install-exec
111         test ! -f inst/foo/sub/pnobase.sh
112         test ! -f inst/foo/pnobase.sh
113         test ! -f inst/foo/pbase.sh
114         test ! -f inst/foo/sub/pnobase$(EXEEXT)
115         test ! -f inst/foo/pnobase$(EXEEXT)
116         test ! -f inst/foo/pbase$(EXEEXT)
117         test ! -f inst/foo/sub/libnobase.a
118         test ! -f inst/foo/libnobase.a
119         test ! -f inst/foo/libbase.a
120 EOF
121
122 mkdir sub
123
124 : > sub/base.h
125 : > sub/nobase.h
126 : > sub/base.dat
127 : > sub/nobase.dat
128 : > sub/base.sh
129 : > sub/nobase.sh
130
131 cat >source.c <<'EOF'
132 int
133 main (int argc, char *argv[])
134 {
135   return 0;
136 }
137 EOF
138 cp source.c source2.c
139
140 rm -f install-sh
141
142 $ACLOCAL
143 $AUTOCONF
144 $AUTOMAKE -a --copy
145 ./configure --prefix "`pwd`/inst" --program-prefix=p doit=yes
146
147 $MAKE
148 $MAKE test-install-data
149 $MAKE test-install-exec
150 $MAKE uninstall
151 $MAKE clean
152
153 test `find inst/foo -type f -print | wc -l` = 0
154
155 ./configure --prefix "`pwd`/inst" --program-prefix=p doit=
156
157 $MAKE
158 $MAKE test-install-nothing-data
159 $MAKE test-install-nothing-exec
160 $MAKE uninstall
161
162
163 # Likewise, in a VPATH build.
164
165 $MAKE distclean
166 mkdir build
167 cd build
168 ../configure --prefix "`pwd`/inst" --program-prefix=p doit=yes
169 $MAKE
170 $MAKE test-install-data
171 $MAKE test-install-exec
172 $MAKE uninstall
173 test `find inst/foo -type f -print | wc -l` = 0
174
175 ../configure --prefix "`pwd`/inst" --program-prefix=p doit=
176 $MAKE
177 $MAKE test-install-nothing-data
178 $MAKE test-install-nothing-exec