compile: rewrite AC_PROG_CC with AM_PROG_CC_C_O contents
[platform/upstream/automake.git] / t / maken3.sh
1 #! /bin/sh
2 # Copyright (C) 2009-2013 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 or a make implementation supporting the .MAKE
22 #     special target, the output from make is sufficiently complete.
23 #
24 # This test exercises the GCS-mandated targets (except for dist)
25 # as well as tags.
26
27 # For gen-testsuite-part: ==> try-with-serial-tests <==
28 . test-init.sh
29
30 # Does $MAKE support the '.MAKE' special target?
31 have_dotmake=false
32 if using_gmake; then
33   have_dotmake=: # GNU make must support it.
34 else
35   unindent > mk.tmp << 'END'
36     targ.tmp:
37         : > $@
38     .MAKE: targ.tmp
39 END
40   if $MAKE -n -f mk.tmp targ.tmp && test -f targ.tmp; then
41     have_dotmake=:
42   fi
43 fi
44
45 mkdir sub sub2
46
47 cat >> configure.ac << 'END'
48 AC_CONFIG_FILES([sub/Makefile sub2/Makefile])
49 AC_OUTPUT
50 END
51
52 cat > Makefile.am <<'END'
53 TESTS = foo.test
54 SUBDIRS = sub sub2
55 ##BUILT_SOURCES = foo
56 foo:
57 foo.test:
58 all-local:
59         @: > stamp-all
60 install-data-local:
61         @: > stamp-install
62 uninstall-local:
63         @: > stamp-uninstall
64 clean-local:
65         @: > stamp-clean
66 distclean-local:
67         @: > stamp-distclean
68 info-local:
69         @: > stamp-info
70 html-local:
71         @: > stamp-html
72 dvi-local:
73         @: > stamp-dvi
74 ps-local:
75         @: > stamp-ps
76 pdf-local:
77         @: > stamp-pdf
78 check-local:
79         @: > stamp-check
80 installcheck-local:
81         @: > stamp-installcheck
82 mostlyclean-local:
83         @: > stamp-mostlyclean
84 maintainer-clean-local:
85         @: > stamp-maintainer-clean
86 END
87 cat >sub/Makefile.am <<'END'
88 all-local:
89         @: > stamp-all-sub
90 install-data-local:
91         @: > stamp-install-sub
92 uninstall-local:
93         @: > stamp-uninstall-sub
94 clean-local:
95         @: > stamp-clean-sub
96 distclean-local:
97         @: > stamp-distclean-sub
98 info-local:
99         @: > stamp-info-sub
100 html-local:
101         @: > stamp-html-sub
102 dvi-local:
103         @: > stamp-dvi-sub
104 ps-local:
105         @: > stamp-ps-sub
106 pdf-local:
107         @: > stamp-pdf-sub
108 check-local:
109         @: > stamp-check-sub
110 installcheck-local:
111         @: > stamp-installcheck-sub
112 tags:
113         @: > stamp-tags-sub
114 mostlyclean-local:
115         @: > stamp-mostlyclean-sub
116 maintainer-clean-local:
117         @: > stamp-maintainer-clean-sub
118 END
119 cat >sub2/Makefile.am <<'END'
120 all install uninstall clean check:
121         @: > sub2-$@-should-not-be-executed
122 info dvi pdf ps:
123         @: > sub2-$@-should-not-be-executed
124 html:
125         @: > sub2-$@-should-not-be-executed
126 install-info install-html install-dvi install-pdf install-ps:
127         @: > sub2-$@-should-not-be-executed
128 installcheck installdirs tags mostlyclean:
129         @: > sub2-$@-should-not-be-executed
130 ## These targets cannot be overridden like this:
131 ## install-strip distclean maintainer-clean
132 END
133
134 $ACLOCAL
135 $AUTOCONF
136
137 check_targets ()
138 {
139   for target in \
140     all install install-strip uninstall clean distclean check \
141     info html dvi pdf ps \
142     install-info install-html install-dvi install-pdf install-ps \
143     installcheck installdirs tags mostlyclean maintainer-clean
144   do
145     run_make -O -- -n $target
146     case $target in
147     install-* | installdirs | tags ) ;;
148     *)
149       if $have_dotmake; then
150         grep "stamp-$target$" stdout || exit 1
151       fi
152       test ! -e "stamp-$target" || exit 1
153       ;;
154     esac
155     case $target in
156     install-* | installdirs ) ;;
157     *)
158       if $have_dotmake; then
159         grep "stamp-$target-sub" stdout || exit 1
160       fi
161       test ! -e "sub/stamp-$target-sub" || exit 1
162       ;;
163     esac
164     case $target in
165     distclean | maintainer-clean ) ;;
166     *)
167       if $have_dotmake; then
168         grep "should-not-be-executed" stdout || exit 1
169       fi
170       test ! -e "sub2/sub2-$target-should-not-be-executed" || exit 1
171       ;;
172     esac
173   done
174 }
175
176 $AUTOMAKE -a -Wno-override
177 ./configure
178 check_targets || exit 1
179
180 # Now, introduce BUILT_SOURCES into the toplevel Makefile
181 # TODO: add BUILT_SOURCES to sub2, fix fallout.
182 sed 's/##//' < Makefile.am > t
183 mv -f t Makefile.am
184 $AUTOMAKE -Wno-override --force Makefile
185 ./configure
186 check_targets || exit 1
187
188 exit 0