ar-lib: new 'AM_PROG_AR' macro, triggering the 'ar-lib' script
[automake.git] / tests / depcomp7.test
blob9b0ed220d8718479ff62f071b4a7dbddbc635ae4
1 #! /bin/sh
2 # Copyright (C) 2006, 2007, 2010, 2011 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Check dependency generation (libtool case).
19 required='libtoolize'
20 . ./defs || Exit 1
22 set -e
24 cat >> configure.in << 'END'
25 AC_PROG_CC
26 AM_PROG_CC_C_O
27 AM_PROG_AR
28 AM_PROG_LIBTOOL
29 AC_CONFIG_FILES([sub2/Makefile])
30 AC_OUTPUT
31 END
33 mkdir sub sub2 sub2/sub3
35 cat >Makefile.am <<'END'
36 SUBDIRS = sub2
37 bin_PROGRAMS = foo
38 foo_SOURCES = foo.c sub/bar.c foo.h sub/bar.h
39 foo_LDADD = sub2/libbaz.la
40 END
42 cat >sub2/Makefile.am <<'END'
43 AUTOMAKE_OPTIONS = subdir-objects
44 noinst_LTLIBRARIES = libbaz.la
45 libbaz_la_SOURCES = baz.c sub3/ba3.c baz.h sub3/ba3.h
46 END
48 cat >foo.c <<'END'
49 #include "foo.h"
50 #include "sub2/baz.h"
51 #include <stdlib.h>
52 int main (void) { printf ("foo"); return bar () + baz (); }
53 END
55 cat >foo.h <<'END'
56 #include <stdio.h>
57 #include "sub/bar.h"
58 END
60 cat >sub/bar.c <<'END'
61 #include "sub/bar.h"
62 int bar (void) { return 0; }
63 END
65 echo 'extern int x;' > sub2/sub3/ba3.h
67 cat >sub/bar.h <<'END'
68 #include <stdio.h>
69 extern int bar (void);
70 END
72 cat >sub2/baz.c <<'END'
73 #include "baz.h"
74 int baz (void) { return 0; }
75 END
77 cat >sub2/baz.h <<'END'
78 extern int baz (void);
79 END
81 cat >sub2/sub3/ba3.in <<'END'
82 #include "ba3.h"
83 int ba3 (void) { return 0; }
84 END
86 libtoolize
87 $ACLOCAL
88 $AUTOCONF
89 $AUTOMAKE -a
91 st=0
92 for staticshared in --disable-shared "" --disable-static; do
94 cp sub2/sub3/ba3.in sub2/sub3/ba3.c
95 ./configure --enable-dependency-tracking $staticshared
96 $MAKE
98 # If we cannot enable dependency tracking, perform only the most basic
99 # checks, and don't consider this test to be PASSed but SKIPped, because
100 # the main purpose of this test is exposing the depmode features.
101 if grep 'depmode=none' Makefile; then
102 st=77
103 else
104 cd sub2
105 $sleep
106 echo 'choke me' > sub3/ba3.h
107 # Do not use `$MAKE && Exit 1' here, since even relatively-recent
108 # versions of the BSD shell wrongly exit when the `errexit' shell
109 # flag is active if a command within "&&" fails inside a compound
110 # statement.
111 if $MAKE; then Exit 1; else :; fi
113 # Ensure the deleted header bug is fixed.
114 rm -f sub3/ba3.h
115 sed 1d sub3/ba3.in >sub3/ba3.c
116 $MAKE
117 cd ..
120 $MAKE distclean
121 test ! -f sub2/sub3/ba3.u
122 test ! -f sub2/sub3/ba3.d
124 echo 'extern int x;' > sub2/sub3/ba3.h
126 done
128 Exit $st