afae102feb61cdff30f9d097ced01c91759fb516
[platform/upstream/automake.git] / tests / check3.test
1 #! /bin/sh
2 # Copyright (C) 2002, 2003  Free Software Foundation, Inc.
3 #
4 # This file is part of GNU Automake.
5 #
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.
10 #
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.
15 #
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., 51 Franklin Street, Fifth Floor,
19 # Boston, MA 02110-1301, USA.
20
21 # Make sure `check:' and `install:' honor $(BUILT_SOURCES).
22 # PR/359.
23
24 . ./defs || exit 1
25
26 set -e
27
28 cat >> configure.in << 'END'
29 AC_CONFIG_FILES([dir/Makefile])
30 AC_OUTPUT
31 END
32
33 mkdir dir
34
35 cat > Makefile.am << 'END'
36 BUILT_SOURCES = command1.inc
37 SUBDIRS = dir
38 TESTS = subrun.sh
39 subrun.sh:
40         (echo '#! /bin/sh'; cat command1.inc) > $@
41         chmod +x $@
42 command1.inc:
43         echo 'dir/echo.sh' > $@
44 CLEANFILES = subrun.sh command1.inc
45 END
46
47 cat > dir/Makefile.am << 'END'
48 BUILT_SOURCES = command2.inc
49 check_SCRIPTS = echo.sh
50 echo.sh:
51 ## The next line ensures that command1.inc has been built before
52 ## recurring into the subdir.
53         test -f ../command1.inc
54         (echo '#! /bin/sh'; cat command2.inc) > $@
55         chmod +x $@
56 command2.inc:
57         echo 'echo Hello' > $@
58 CLEANFILES = echo.sh command2.inc
59 END
60
61 $ACLOCAL
62 $AUTOCONF
63 $AUTOMAKE
64 ./configure --prefix `pwd`/inst
65 $MAKE check >stdout
66 cat stdout
67 grep 'PASS: subrun.sh' stdout
68
69 # check should depend directly on check-am (similar tests are
70 # in check.test and check2.test).
71 $FGREP 'check: $(BUILT_SOURCES)' Makefile.in
72 $FGREP 'check: $(BUILT_SOURCES)' dir/Makefile.in
73
74 $MAKE clean
75 # Sanity checks
76 test ! -f command1.inc
77 test ! -f dir/command2.inc
78 # Now make sure these two files are rebuilt during make install.
79 $MAKE install
80 test -f command1.inc
81 test -f dir/command2.inc