maint: run "make update-copyright"
[platform/upstream/automake.git] / tests / check3.test
1 #! /bin/sh
2 # Copyright (C) 2002-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 `check:' and `install:' honor $(BUILT_SOURCES).
18 # PR/359.
19
20 . ./defs || Exit 1
21
22 cat >> configure.in << 'END'
23 AC_CONFIG_FILES([dir/Makefile])
24 AC_OUTPUT
25 END
26
27 mkdir dir
28
29 cat > Makefile.am << 'END'
30 BUILT_SOURCES = command1.inc
31 SUBDIRS = dir
32 TESTS = subrun.sh
33 subrun.sh:
34         (echo '#! /bin/sh'; cat command1.inc) > $@
35         chmod +x $@
36 command1.inc:
37         echo 'dir/echo.sh' > $@
38 CLEANFILES = subrun.sh command1.inc
39 END
40
41 cat > dir/Makefile.am << 'END'
42 BUILT_SOURCES = command2.inc
43 check_SCRIPTS = echo.sh
44 echo.sh:
45 ## The next line ensures that command1.inc has been built before
46 ## recurring into the subdir.
47         test -f ../command1.inc
48         (echo '#! /bin/sh'; cat command2.inc) > $@
49         chmod +x $@
50 command2.inc:
51         echo 'echo Hello' > $@
52 CLEANFILES = echo.sh command2.inc
53 END
54
55 $ACLOCAL
56 $AUTOCONF
57 $AUTOMAKE -a
58 ./configure --prefix "`pwd`/inst"
59
60 $MAKE check >stdout || { cat stdout; Exit 1; }
61 cat stdout
62 grep '^PASS: subrun\.sh *$' stdout
63 grep 'PASS.*echo\.sh' stdout && Exit 1
64
65 # check should depend directly on $(BUILT_SOURCES) (similar tests
66 # are in check.test and check2.test).
67 $EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in
68 $EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in
69
70 $MAKE clean
71 # Sanity checks
72 test ! -f command1.inc
73 test ! -f dir/command2.inc
74 # Now make sure these two files are rebuilt during make install.
75 $MAKE install
76 test -f command1.inc
77 test -f dir/command2.inc
78
79 :