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