test init: refactor: new function 'am_setup_testdir'
[automake.git] / t / subst3.sh
blob8ee3324f3943300b858c49180947ab68eec12395
1 #! /bin/sh
2 # Copyright (C) 2001-2012 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 # Test installation with substitutions. This test is based on nobase.test.
19 required=cc
20 . ./defs || exit 1
22 cat >> configure.ac <<'EOF'
23 AC_PROG_CC
24 AM_PROG_AR
25 AC_PROG_RANLIB
26 if test x"$doit" = x"yes"; then
27 AC_SUBST([basehdr], [sub/base.h])
28 AC_SUBST([nobasehdr], [sub/nobase.h])
29 AC_SUBST([basedata], [sub/base.dat])
30 AC_SUBST([nobasedata], [sub/nobase.dat])
31 AC_SUBST([basescript], [sub/base.sh])
32 AC_SUBST([nobasescript], [sub/nobase.sh])
33 AC_SUBST([baseprog], ['sub/base$(EXEEXT)'])
34 AC_SUBST([nobaseprog], ['sub/nobase$(EXEEXT)'])
35 AC_SUBST([baselib], [sub/libbase.a])
36 AC_SUBST([nobaselib], [sub/libnobase.a])
38 AC_OUTPUT
39 EOF
41 cat > Makefile.am << 'EOF'
42 foodir = $(prefix)/foo
43 fooexecdir = $(prefix)/foo
45 foo_HEADERS = @basehdr@
46 nobase_foo_HEADERS = @nobasehdr@
47 EXTRA_HEADERS = sub/base.h sub/nobase.h
49 dist_foo_DATA = @basedata@
50 nobase_dist_foo_DATA = @nobasedata@
52 dist_fooexec_SCRIPTS = @basescript@
53 nobase_dist_fooexec_SCRIPTS = @nobasescript@
54 EXTRA_SCRIPTS = sub/base.sh sub/nobase.sh
56 fooexec_PROGRAMS = @baseprog@
57 nobase_fooexec_PROGRAMS = @nobaseprog@
58 EXTRA_PROGRAMS = sub/base sub/nobase
59 sub_base_SOURCES = source.c
60 sub_nobase_SOURCES = source.c
62 fooexec_LIBRARIES = @baselib@
63 nobase_fooexec_LIBRARIES = @nobaselib@
64 EXTRA_LIBRARIES = sub/libbase.a sub/libnobase.a
65 sub_libbase_a_SOURCES = source.c
66 sub_libnobase_a_SOURCES = source.c
68 test-install-data: install-data
69 test -f inst/foo/sub/nobase.h
70 test ! -f inst/foo/nobase.h
71 test -f inst/foo/base.h
72 test -f inst/foo/sub/nobase.dat
73 test ! -f inst/foo/nobase.dat
74 test -f inst/foo/base.dat
75 test ! -f inst/foo/sub/pnobase.sh
76 test ! -f inst/foo/pbase.sh
77 test ! -f inst/foo/sub/pnobase$(EXEEXT)
78 test ! -f inst/foo/pbase$(EXEEXT)
79 test ! -f inst/foo/sub/libnobase.a
80 test ! -f inst/foo/libbase.a
82 test-install-exec: install-exec
83 test -f inst/foo/sub/pnobase.sh
84 test ! -f inst/foo/pnobase.sh
85 test -f inst/foo/pbase.sh
86 test -f inst/foo/sub/pnobase$(EXEEXT)
87 test ! -f inst/foo/pnobase$(EXEEXT)
88 test -f inst/foo/pbase$(EXEEXT)
89 test -f inst/foo/sub/libnobase.a
90 test ! -f inst/foo/libnobase.a
91 test -f inst/foo/libbase.a
93 test-install-nothing-data: install-data
94 test ! -f inst/foo/sub/nobase.h
95 test ! -f inst/foo/nobase.h
96 test ! -f inst/foo/base.h
97 test ! -f inst/foo/sub/nobase.dat
98 test ! -f inst/foo/nobase.dat
99 test ! -f inst/foo/base.dat
100 test ! -f inst/foo/sub/pnobase.sh
101 test ! -f inst/foo/pbase.sh
102 test ! -f inst/foo/sub/pnobase$(EXEEXT)
103 test ! -f inst/foo/pbase$(EXEEXT)
104 test ! -f inst/foo/sub/libnobase.a
105 test ! -f inst/foo/libbase.a
107 test-install-nothing-exec: install-exec
108 test ! -f inst/foo/sub/pnobase.sh
109 test ! -f inst/foo/pnobase.sh
110 test ! -f inst/foo/pbase.sh
111 test ! -f inst/foo/sub/pnobase$(EXEEXT)
112 test ! -f inst/foo/pnobase$(EXEEXT)
113 test ! -f inst/foo/pbase$(EXEEXT)
114 test ! -f inst/foo/sub/libnobase.a
115 test ! -f inst/foo/libnobase.a
116 test ! -f inst/foo/libbase.a
119 mkdir sub
121 : > sub/base.h
122 : > sub/nobase.h
123 : > sub/base.dat
124 : > sub/nobase.dat
125 : > sub/base.sh
126 : > sub/nobase.sh
128 cat >source.c <<'EOF'
130 main (int argc, char *argv[])
132 return 0;
135 cp source.c source2.c
137 rm -f install-sh
139 $ACLOCAL
140 $AUTOCONF
141 $AUTOMAKE -a --copy
142 ./configure --prefix "$(pwd)/inst" --program-prefix=p doit=yes
144 $MAKE
145 $MAKE test-install-data
146 $MAKE test-install-exec
147 $MAKE uninstall
148 $MAKE clean
150 test $(find inst/foo -type f -print | wc -l) -eq 0
152 ./configure --prefix "$(pwd)/inst" --program-prefix=p doit=no
154 $MAKE
155 $MAKE test-install-nothing-data
156 $MAKE test-install-nothing-exec
157 $MAKE uninstall
160 # Likewise, in a VPATH build.
162 $MAKE distclean
163 mkdir build
164 cd build
165 ../configure --prefix "$(pwd)/inst" --program-prefix=p doit=yes
166 $MAKE
167 $MAKE test-install-data
168 $MAKE test-install-exec
169 $MAKE uninstall
170 test $(find inst/foo -type f -print | wc -l) -eq 0
172 ../configure --prefix "$(pwd)/inst" --program-prefix=p doit=no
173 $MAKE
174 $MAKE test-install-nothing-data
175 $MAKE test-install-nothing-exec