Clarify overriding of `*_DEPENDENCIES' in LIBOBJS node.
[automake/ericb.git] / tests / spy.test
blobac714aae30d60f5c9b95e438ac3e2b855c5f1779
1 #! /bin/sh
2 # Copyright (C) 2003 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 3, 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 # Check whether double colon rules work. The Unix V7 make manual
18 # mentions double-colon rules, but POSIX does not. They seem to be
19 # supported by all Make implementation as we can tell. This test case
20 # is a spy: we want to detect if there exist implementations where
21 # these do not work. We might use these rules to simplify the rebuild
22 # rules (instead of the $? hack).
24 # Tom Tromey write:
25 # | In the distant past we used :: rules extensively.
26 # | Fran?ois convinced me to get rid of them:
27 # |
28 # | Thu Nov 23 18:02:38 1995 Tom Tromey <tromey@cambric>
29 # | [ ... ]
30 # | * subdirs.am: Removed "::" rules
31 # | * header.am, libraries.am, mans.am, texinfos.am, footer.am:
32 # | Removed "::" rules
33 # | * scripts.am, programs.am, libprograms.am: Removed "::" rules
34 # |
35 # |
36 # | I no longer remember the rationale for this. It may have only been a
37 # | belief that they were unportable.
39 # On a related topic, the Autoconf manual has the following text:
40 # | `VPATH' and double-colon rules
41 # | Any assignment to `VPATH' causes Sun `make' to only execute
42 # | the first set of double-colon rules. (This comment has been
43 # | here since 1994 and the context has been lost. It's probably
44 # | about SunOS 4. If you can reproduce this, please send us a
45 # | test case for illustration.)
47 # We already know that overlapping ::-rule like
49 # a :: b
50 # echo rule1 >> $@
51 # a :: c
52 # echo rule2 >> $@
53 # a :: b c
54 # echo rule3 >> $@
56 # do not work equally on all platforms. It seems that in all cases
57 # Make attempts to run all matching rules. However at least GNU Make,
58 # NetBSD Make, and FreeBSD Make will detect that $@ was updated by the
59 # first matching rule and skip remaining matches (with the above
60 # example that means that unless `a' was declared PHONY, only "rule1"
61 # will be appended to `a' if both b and c have changed). Other
62 # implementations like OSF1 Make and HP-UX Make do not perform such a
63 # check and execute all matching rules whatever they do ("rule1",
64 # "rule2", abd "rule3" will all be appended to `a' if b and c have
65 # changed).
67 # So it seems only non-overlapping ::-rule may be portable. This is
68 # what we check now.
70 . ./defs || Exit 1
72 set -e
74 cat >Makefile <<\EOF
75 a :: b
76 echo rule1 >> $@
77 a :: c
78 echo rule2 >> $@
79 EOF
81 touch b c
82 $sleep
83 : > a
84 $MAKE
85 test "`cat a`" = ''
86 $sleep
87 touch b
88 $MAKE
89 test "`cat a`" = rule1
90 : > a
91 $sleep
92 touch c
93 $MAKE
94 test "`cat a`" = rule2