Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / maken3.test
1 #! /bin/sh
2 # Copyright (C) 2009, 2012 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
17 # Test `make -n' for various targets, to ensure that:
18 #
19 #  1. no files or directories are created or removed, and
20 #
21 #  2. if using GNU make, stdout output is sufficiently complete.
22 #
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.
26 #
27 # This test exercises the GCS-mandated targets (except for dist)
28 # as well as tags, TAGS.
29
30 . ./defs || Exit 1
31
32 set -e
33
34 mkdir sub sub2
35
36 cat >> configure.in << 'END'
37 AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
38 AC_OUTPUT
39 END
40
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
109 END
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
123 END
124
125 $ACLOCAL
126 $AUTOCONF
127
128 check_targets ()
129 {
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
136   do
137     $MAKE -n $target >stdout || { cat stdout; Exit 1; }
138     cat stdout
139     case $target in
140     install-* | installdirs | tags | TAGS ) ;;
141     *)
142       if using_gmake; then
143         grep "stamp-$target$" stdout || Exit 1
144       fi
145       test ! -f "stamp-$target$" || Exit 1
146       ;;
147     esac
148     case $target in
149     install-* | installdirs ) ;;
150     *)
151       if using_gmake; then
152         grep "stamp-$target-sub" stdout || Exit 1
153       fi
154       test ! -f "sub/stamp-$target-sub" || Exit 1
155       ;;
156     esac
157     case $target in
158     distclean | maintainer-clean ) ;;
159     *)
160       if using_gmake; then
161         grep "should-not-be-executed" stdout || Exit 1
162       fi
163       test ! -f "sub2/sub2-$target-should-not-be-executed" || Exit 1
164       ;;
165     esac
166   done
167 }
168
169 $AUTOMAKE -Wno-override
170 ./configure
171 check_targets || Exit 1
172
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
180
181 Exit 0