* m4/depend.m4 (_AM_DEPENDENCIES): Use `touch' rather than `: >'
[automake.git] / m4 / depend.m4
blobfe5fee449d202d4c3f6cd4bdae7e3a4043665c82
1 # serial 7                                              -*- Autoconf -*-
3 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
4 # Free Software Foundation, Inc.
6 # This program 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.
11 # This program 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.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 # 02111-1307, USA.
22 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
23 # written in clear, in which case automake, when reading aclocal.m4,
24 # will think it sees a *use*, and therefore will trigger all it's
25 # C support machinery.  Also note that it means that autoscan, seeing
26 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
30 # _AM_DEPENDENCIES(NAME)
31 # ----------------------
32 # See how the compiler implements dependency checking.
33 # NAME is "CC", "CXX", "GCJ", or "OBJC".
34 # We try a few techniques and use that to set a single cache variable.
36 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
37 # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
38 # dependency, and given that the user is not expected to run this macro,
39 # just rely on AC_PROG_CC.
40 AC_DEFUN([_AM_DEPENDENCIES],
41 [AC_REQUIRE([AM_SET_DEPDIR])dnl
42 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
43 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
44 AC_REQUIRE([AM_DEP_TRACK])dnl
46 ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
47        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
48        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
49        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
50                    [depcc="$$1"   am_compiler_list=])
52 AC_CACHE_CHECK([dependency style of $depcc],
53                [am_cv_$1_dependencies_compiler_type],
54 [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
55   # We make a subdir and do the tests there.  Otherwise we can end up
56   # making bogus files that we don't know about and never remove.  For
57   # instance it was reported that on HP-UX the gcc test will end up
58   # making a dummy file named `D' -- because `-MD' means `put the output
59   # in D'.
60   mkdir conftest.dir
61   # Copy depcomp to subdir because otherwise we won't find it if we're
62   # using a relative directory.
63   cp "$am_depcomp" conftest.dir
64   cd conftest.dir
65   # We will build objects and dependencies in a subdirectory because
66   # it helps to detect inapplicable dependency modes.  For instance
67   # both Tru64's cc and ICC support -MD to output dependencies as a
68   # side effect of compilation, but ICC will put the dependencies in
69   # the current directory while Tru64 will put them in the object
70   # directory.
71   mkdir sub
73   am_cv_$1_dependencies_compiler_type=none
74   if test "$am_compiler_list" = ""; then
75      am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
76   fi
77   for depmode in $am_compiler_list; do
78     # Setup a source with many dependencies, because some compilers
79     # like to wrap large dependency lists on column 80 (with \), and
80     # we should not choose a depcomp mode which is confused by this.
81     #
82     # We need to recreate these files for each test, as the compiler may
83     # overwrite some of them when testing with obscure command lines.
84     # This happens at least with the AIX C compiler.
85     : > sub/conftest.c
86     for i in 1 2 3 4 5 6; do
87       echo '#include "conftst'$i'.h"' >> sub/conftest.c
88       # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
89       # Solaris 8's {/usr,}/bin/sh.
90       touch sub/conftst$i.h
91     done
92     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
94     case $depmode in
95     nosideeffect)
96       # after this tag, mechanisms are not by side-effect, so they'll
97       # only be used when explicitly requested
98       if test "x$enable_dependency_tracking" = xyes; then
99         continue
100       else
101         break
102       fi
103       ;;
104     none) break ;;
105     esac
106     # We check with `-c' and `-o' for the sake of the "dashmstdout"
107     # mode.  It turns out that the SunPro C++ compiler does not properly
108     # handle `-M -o', and we need to detect this.
109     if depmode=$depmode \
110        source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
111        depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
112        $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
113          >/dev/null 2>conftest.err &&
114        grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
115        grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
116        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
117       # icc doesn't choke on unknown options, it will just issue warnings
118       # (even with -Werror).  So we grep stderr for any message
119       # that says an option was ignored.
120       if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
121         am_cv_$1_dependencies_compiler_type=$depmode
122         break
123       fi
124     fi
125   done
127   cd ..
128   rm -rf conftest.dir
129 else
130   am_cv_$1_dependencies_compiler_type=none
133 AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
134 AM_CONDITIONAL([am__fastdep$1], [
135   test "x$enable_dependency_tracking" != xno \
136   && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
140 # AM_SET_DEPDIR
141 # -------------
142 # Choose a directory name for dependency files.
143 # This macro is AC_REQUIREd in _AM_DEPENDENCIES
144 AC_DEFUN([AM_SET_DEPDIR],
145 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
146 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
150 # AM_DEP_TRACK
151 # ------------
152 AC_DEFUN([AM_DEP_TRACK],
153 [AC_ARG_ENABLE(dependency-tracking,
154 [  --disable-dependency-tracking  speeds up one-time build
155   --enable-dependency-tracking   do not reject slow dependency extractors])
156 if test "x$enable_dependency_tracking" != xno; then
157   am_depcomp="$ac_aux_dir/depcomp"
158   AMDEPBACKSLASH='\'
160 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
161 AC_SUBST([AMDEPBACKSLASH])