* configure.ac, NEWS: Bump version to 1.8b.
[automake.git] / tests / spy.test
blobbb4f0832ee361110ad214ed2c7de1d7f3f9f98b7
1 #! /bin/sh
2 # Copyright (C) 2003 Free Software Foundation, Inc.
4 # This file is part of GNU Automake.
6 # GNU Automake is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # GNU Automake is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Automake; see the file COPYING. If not, write to
18 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
21 # Check whether double colon rules work. The Unix V7 make manual
22 # mentions double-colon rules, but POSIX does not. They seem to be
23 # supported by all Make implementation as we can tell. This test case
24 # is a spy: we want to detect if there exist implementations where
25 # these do not work. We might use these rules to simplify the rebuild
26 # rules (instead of the $? hack).
28 # Tom Tromey write:
29 # | In the distant past we used :: rules extensively.
30 # | Fran?ois convinced me to get rid of them:
31 # |
32 # | Thu Nov 23 18:02:38 1995 Tom Tromey <tromey@cambric>
33 # | [ ... ]
34 # | * subdirs.am: Removed "::" rules
35 # | * header.am, libraries.am, mans.am, texinfos.am, footer.am:
36 # | Removed "::" rules
37 # | * scripts.am, programs.am, libprograms.am: Removed "::" rules
38 # |
39 # |
40 # | I no longer remember the rationale for this. It may have only been a
41 # | belief that they were unportable.
43 # On a related topic, the Autoconf manual has the following text:
44 # | `VPATH' and double-colon rules
45 # | Any assignment to `VPATH' causes Sun `make' to only execute
46 # | the first set of double-colon rules. (This comment has been
47 # | here since 1994 and the context has been lost. It's probably
48 # | about SunOS 4. If you can reproduce this, please send us a
49 # | test case for illustration.)
51 # We already know that overlapping ::-rule like
53 # a :: b
54 # echo rule1 >> $@
55 # a :: c
56 # echo rule2 >> $@
57 # a :: b c
58 # echo rule3 >> $@
60 # do not work equally on all platforms. It seems that in all cases
61 # Make attempts to run all matching rules. However at least GNU Make,
62 # NetBSD Make, and FreeBSD Make will detect that $@ was updated by the
63 # first matching rule and skip remaining matches (with the above
64 # example that means that unless `a' was declared PHONY, only "rule1"
65 # will be appended to `a' if both b and c have changed). Other
66 # implementations like OSF1 Make and HP-UX Make do not perform such a
67 # check and execute all matching rules whatever they do ("rule1",
68 # "rule2", abd "rule3" will all be appended to `a' if b and c have
69 # changed).
71 # So it seems only non-overlapping ::-rule may be portable. This is
72 # what we check now.
74 . ./defs || exit 1
76 set -e
78 cat >Makefile <<\EOF
79 a :: b
80 echo rule1 >> $@
81 a :: c
82 echo rule2 >> $@
83 EOF
85 touch b c
86 $sleep
87 : > a
88 $MAKE
89 test "`cat a`" = ''
90 $sleep
91 touch b
92 $MAKE
93 test "`cat a`" = rule1
94 : > a
95 $sleep
96 touch c
97 $MAKE
98 test "`cat a`" = rule2