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