build: fix cleaning of test directories in contrib (and in t/perf)
[platform/upstream/automake.git] / t / aclocal7.sh
1 #! /bin/sh
2 # Copyright (C) 2003-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 # Make sure aclocal does not overwrite aclocal.m4 needlessly.
18 # Also make sure automake --no-force does not overwrite Makefile.in needlessly.
19
20 . ./defs || exit 1
21
22 cat >> configure.ac << 'END'
23 SOME_DEFS
24 AC_CONFIG_FILES([sub/Makefile])
25 END
26
27 mkdir sub
28 : > sub/Makefile.am
29
30 cat >> Makefile.am << 'END'
31 SUBDIRS = sub
32 include fragment.inc
33 END
34
35 : > fragment.inc
36
37 mkdir m4
38 echo 'AC_DEFUN([SOME_DEFS], [])' > m4/somedefs.m4
39
40 # Automake will take aclocal.m4 to be newer if it has the same timestamp
41 # as Makefile.in.  Avoid the confusing by sleeping.
42 AUTOMAKE_after_aclocal ()
43 {
44   $sleep
45   $AUTOMAKE --no-force
46 }
47
48 $ACLOCAL -I m4
49 AUTOMAKE_after_aclocal
50
51 touch foo
52 $sleep
53 $ACLOCAL -I m4
54 AUTOMAKE_after_aclocal
55 # aclocal.m4 and Makefile.in should not have been updated, so 'foo'
56 # should be younger
57 is_newest foo aclocal.m4 Makefile.in sub/Makefile.in
58
59 $sleep
60 $ACLOCAL -I m4 --force
61 is_newest aclocal.m4 foo
62 # We still use --no-force for automake, but since aclocal.m4 has
63 # changed all Makefile.ins should be updated.
64 AUTOMAKE_after_aclocal
65 is_newest Makefile.in aclocal.m4 foo
66 is_newest sub/Makefile.in aclocal.m4 foo
67
68 $sleep
69 touch m4/somedefs.m4
70 $sleep
71 $ACLOCAL -I m4
72 AUTOMAKE_after_aclocal
73 # aclocal.m4 should have been updated, although its contents haven't
74 # changed.
75 is_newest aclocal.m4 m4/somedefs.m4
76 is_newest Makefile.in m4/somedefs.m4
77 is_newest sub/Makefile.in m4/somedefs.m4
78
79 $sleep
80 touch fragment.inc
81 $sleep
82 $ACLOCAL -I m4
83 AUTOMAKE_after_aclocal
84 # Only ./Makefile.in should change.
85 is_newest Makefile.in fragment.inc
86 is_newest fragment.inc aclocal.m4
87 is_newest fragment.inc sub/Makefile.in
88
89 grep README Makefile.in && exit 1
90
91 $sleep
92 : > README
93 $sleep
94 $AUTOMAKE --no-force
95 # Even if no dependency change, the content changed.
96 is_newest Makefile.in README
97 is_newest README sub/Makefile.in
98
99 grep README Makefile.in
100
101 : > sub/Makefile.in
102 $sleep
103 touch foo
104 $sleep
105 $ACLOCAL -I m4
106 $AUTOMAKE --no-force
107 # Only sub/Makefile.in should change.
108 is_newest foo aclocal.m4
109 is_newest foo Makefile.in
110 is_newest sub/Makefile.in foo
111
112 :