* automake.texi (Java Support): Added index, @section.
[automake.git] / m4 / depend.m4
blobb07836d8929e7a566c266793e395661953ad09d4
1 # serial 3
3 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
4 # written in clear, in which case automake, when reading aclocal.m4,
5 # will think it sees a *use*, and therefore will trigger all it's
6 # C support machinery.  Also note that it means that autoscan, seeing
7 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
9 # AM_DEPENDENCIES(NAME)
10 # ---------------------
11 # See how the compiler implements dependency checking.
12 # NAME is "CC", "CXX" or "OBJC".
13 # We try a few techniques and use that to set a single cache variable.
14 AC_DEFUN([AM_DEPENDENCIES],
15 [AC_REQUIRE([AM_SET_DEPDIR])dnl
16 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
17 ifelse([$1], CC,
18        [AC_REQUIRE([AC_PROG_][CC])dnl
19 AC_REQUIRE([AC_PROG_][CPP])
20 depcc="$CC"
21 depcpp="$CPP"],
22        [$1], CXX, [AC_REQUIRE([AC_PROG_][CXX])dnl
23 AC_REQUIRE([AC_PROG_][CXXCPP])
24 depcc="$CXX"
25 depcpp="$CXXCPP"],
26        [$1], OBJC, [am_cv_OBJC_dependencies_compiler_type=gcc],
27        [AC_REQUIRE([AC_PROG_][$1])dnl
28 depcc="$$1"
29 depcpp=""])
31 AC_CACHE_CHECK([dependency style of $depcc],
32                [am_cv_$1_dependencies_compiler_type],
33 [if test -z "$AMDEP"; then
34   echo '#include "conftest.h"' > conftest.c
35   echo 'int i;' > conftest.h
37   am_cv_$1_dependencies_compiler_type=none
38   for depmode in `sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < "$am_depcomp"`; do
39     case "$depmode" in
40     nosideeffect)
41       # after this tag, mechanisms are not by side-effect, so they'll
42       # only be used when explicitly requested
43       if test "x$enable_dependency_tracking" = xyes; then
44         continue
45       else
46         break
47       fi
48       ;;
49     none) break ;;
50     esac
51     # We check with `-c' and `-o' for the sake of the "dashmstdout"
52     # mode.  It turns out that the SunPro C++ compiler does not properly
53     # handle `-M -o', and we need to detect this.
54     if depmode="$depmode" \
55        source=conftest.c object=conftest.o \
56        depfile=conftest.Po tmpdepfile=conftest.TPo \
57        $SHELL $am_depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 &&
58        grep conftest.h conftest.Po > /dev/null 2>&1; then
59       am_cv_$1_dependencies_compiler_type="$depmode"
60       break
61     fi
62   done
64   rm -f conftest.*
65 else
66   am_cv_$1_dependencies_compiler_type=none
69 $1DEPMODE="depmode=$am_cv_$1_dependencies_compiler_type"
70 AC_SUBST([$1DEPMODE])
74 # AM_SET_DEPDIR
75 # -------------
76 # Choose a directory name for dependency files.
77 # This macro is AC_REQUIREd in AM_DEPENDENCIES
78 AC_DEFUN([AM_SET_DEPDIR],
79 [if test -d .deps || mkdir .deps 2> /dev/null || test -d .deps; then
80   DEPDIR=.deps
81   # We redirect because .deps might already exist and be populated.
82   # In this situation we don't want to see an error.
83   rmdir .deps > /dev/null 2>&1
84 else
85   DEPDIR=_deps
87 AC_SUBST(DEPDIR)
91 # AM_DEP_TRACK
92 # ------------
93 AC_DEFUN([AM_DEP_TRACK],
94 [AC_ARG_ENABLE(dependency-tracking,
95 [  --disable-dependency-tracking Speeds up one-time builds
96   --enable-dependency-tracking  Do not reject slow dependency extractors])
97 if test "x$enable_dependency_tracking" = xno; then
98   AMDEP="#"
99 else
100   am_depcomp="$ac_aux_dir/depcomp"
101   if test ! -f "$am_depcomp"; then
102     AMDEP="#"
103   else
104     AMDEP=
105   fi
107 AC_SUBST(AMDEP)
108 if test -z "$AMDEP"; then
109   AMDEPBACKSLASH='\'
110 else
111   AMDEPBACKSLASH=
113 pushdef([subst], defn([AC_SUBST]))
114 subst(AMDEPBACKSLASH)
115 popdef([subst])