news: add entry about recent 'ar-lib' changes
[automake.git] / tests / maken3.test
blob27494cc3dc0f97958094dbc690395670d670667c
1 #! /bin/sh
2 # Copyright (C) 2009, 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 `make -n' for various targets, to ensure that:
19 # 1. no files or directories are created or removed, and
21 # 2. if using GNU make, stdout output is sufficiently complete.
23 # FIXME: The checks in (2) should also work with BSD make implementations
24 # FIXME: that support the `.MAKE' special target, but currently we don't
25 # FIXME: explicitly test that this is truly the case.
27 # This test exercises the GCS-mandated targets (except for dist)
28 # as well as tags, TAGS.
30 . ./defs || Exit 1
32 set -e
34 mkdir sub sub2
36 cat >> configure.in << 'END'
37 AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
38 AC_OUTPUT
39 END
41 cat > Makefile.am <<'END'
42 TESTS = foo.test
43 SUBDIRS = sub sub2
44 ##BUILT_SOURCES = foo
45 foo:
46 foo.test:
47 all-local:
48 @: > stamp-all
49 install-data-local:
50 @: > stamp-install
51 uninstall-local:
52 @: > stamp-uninstall
53 clean-local:
54 @: > stamp-clean
55 distclean-local:
56 @: > stamp-distclean
57 info-local:
58 @: > stamp-info
59 html-local:
60 @: > stamp-html
61 dvi-local:
62 @: > stamp-dvi
63 ps-local:
64 @: > stamp-ps
65 pdf-local:
66 @: > stamp-pdf
67 check-local:
68 @: > stamp-check
69 installcheck-local:
70 @: > stamp-installcheck
71 mostlyclean-local:
72 @: > stamp-mostlyclean
73 maintainer-clean-local:
74 @: > stamp-maintainer-clean
75 END
76 cat >sub/Makefile.am <<'END'
77 all-local:
78 @: > stamp-all-sub
79 install-data-local:
80 @: > stamp-install-sub
81 uninstall-local:
82 @: > stamp-uninstall-sub
83 clean-local:
84 @: > stamp-clean-sub
85 distclean-local:
86 @: > stamp-distclean-sub
87 info-local:
88 @: > stamp-info-sub
89 html-local:
90 @: > stamp-html-sub
91 dvi-local:
92 @: > stamp-dvi-sub
93 ps-local:
94 @: > stamp-ps-sub
95 pdf-local:
96 @: > stamp-pdf-sub
97 check-local:
98 @: > stamp-check-sub
99 installcheck-local:
100 @: > stamp-installcheck-sub
101 tags:
102 @: > stamp-tags-sub
103 TAGS:
104 @: > stamp-TAGS-sub
105 mostlyclean-local:
106 @: > stamp-mostlyclean-sub
107 maintainer-clean-local:
108 @: > stamp-maintainer-clean-sub
110 cat >sub2/Makefile.am <<'END'
111 all install uninstall clean check:
112 @: > sub2-$@-should-not-be-executed
113 info dvi pdf ps:
114 @: > sub2-$@-should-not-be-executed
115 html:
116 @: > sub2-$@-should-not-be-executed
117 install-info install-html install-dvi install-pdf install-ps:
118 @: > sub2-$@-should-not-be-executed
119 installcheck installdirs tags TAGS mostlyclean:
120 @: > sub2-$@-should-not-be-executed
121 ## These targets cannot be overridden like this:
122 ## install-strip distclean maintainer-clean
125 $ACLOCAL
126 $AUTOCONF
128 check_targets ()
130 set -e
131 for target in \
132 all install install-strip uninstall clean distclean check \
133 info html dvi pdf ps \
134 install-info install-html install-dvi install-pdf install-ps \
135 installcheck installdirs tags TAGS mostlyclean maintainer-clean
137 $MAKE -n $target >stdout || { cat stdout; Exit 1; }
138 cat stdout
139 case $target in
140 install-* | installdirs | tags | TAGS ) ;;
142 if using_gmake; then
143 grep "stamp-$target$" stdout || Exit 1
145 test ! -f "stamp-$target$" || Exit 1
147 esac
148 case $target in
149 install-* | installdirs ) ;;
151 if using_gmake; then
152 grep "stamp-$target-sub" stdout || Exit 1
154 test ! -f "sub/stamp-$target-sub" || Exit 1
156 esac
157 case $target in
158 distclean | maintainer-clean ) ;;
160 if using_gmake; then
161 grep "should-not-be-executed" stdout || Exit 1
163 test ! -f "sub2/sub2-$target-should-not-be-executed" || Exit 1
165 esac
166 done
169 $AUTOMAKE -Wno-override
170 ./configure
171 check_targets || Exit 1
173 # Now, introduce BUILT_SOURCES into the toplevel Makefile
174 # TODO: add BUILT_SOURCES to sub2, fix fallout.
175 sed 's/##//' < Makefile.am > t
176 mv -f t Makefile.am
177 $AUTOMAKE -Wno-override --force Makefile
178 ./configure
179 check_targets || Exit 1
181 Exit 0