Merge branch 'msvc'
[platform/upstream/automake.git] / tests / depcomp6.test
1 #! /bin/sh
2 # Copyright (C) 2006, 2010 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 # Check dependency generation (non libtool case).
18
19 . ./defs || Exit 1
20
21 set -e
22
23 cat >> configure.in << 'END'
24 AC_PROG_CC
25 AM_PROG_CC_C_O
26 AC_PROG_RANLIB
27 AC_CONFIG_FILES([sub2/Makefile])
28 AC_OUTPUT
29 END
30
31 mkdir sub sub2 sub2/sub3
32
33 cat >Makefile.am <<'END'
34 SUBDIRS = sub2
35 bin_PROGRAMS = foo
36 foo_SOURCES = foo.c sub/bar.c foo.h sub/bar.h
37 foo_LDADD = sub2/libbaz.a
38 END
39
40 cat >sub2/Makefile.am <<'END'
41 AUTOMAKE_OPTIONS = subdir-objects
42 noinst_LIBRARIES = libbaz.a
43 libbaz_a_SOURCES = baz.c sub3/ba3.c baz.h sub3/ba3.h
44 END
45
46 cat >foo.c <<'END'
47 #include "foo.h"
48 #include "sub2/baz.h"
49 #include <stdlib.h>
50 int main() { printf("foo"); return bar() + baz(); }
51 END
52
53 cat >foo.h <<'END'
54 #include <stdio.h>
55 #include "sub/bar.h"
56 END
57
58 cat >sub/bar.c <<'END'
59 #include "sub/bar.h"
60 int bar() { return 0; }
61 END
62
63 touch sub2/sub3/ba3.h
64
65 cat >sub/bar.h <<'END'
66 #include <stdio.h>
67 extern int bar();
68 END
69
70 cat >sub2/baz.c <<'END'
71 #include "baz.h"
72 int baz() { return 0; }
73 END
74
75 cat >sub2/baz.h <<'END'
76 extern int baz();
77 END
78
79 cat >sub2/sub3/ba3.c <<'END'
80 #include "ba3.h"
81 int ba3() { return 0; }
82 END
83
84 $ACLOCAL
85 $AUTOCONF
86 $AUTOMAKE -a
87
88 ./configure --enable-dependency-tracking
89 $MAKE
90
91 # check that dependency tracking works
92 if grep 'depmode=none' Makefile; then :
93 else
94   cd sub2
95   $sleep
96   echo 'choke me' > sub3/ba3.h
97   # Do not use `$MAKE && Exit 1' here, since even relatively-recent
98   # versions of the BSD shell wrongly exit when the `errexit' shell
99   # flag is active if a command within "&&" fails inside a compound
100   # statement.
101   if $MAKE; then Exit 1; else :; fi
102 fi
103
104 :