tagging release
[dasher.git] / m4 / depend.m4
blob23a48d8e6ff7066cc4cf0dc00750631e277a8fb6
1 # serial 4                                              -*- Autoconf -*-
3 # Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 # 02111-1307, USA.
21 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
22 # written in clear, in which case automake, when reading aclocal.m4,
23 # will think it sees a *use*, and therefore will trigger all it's
24 # C support machinery.  Also note that it means that autoscan, seeing
25 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
29 # _AM_DEPENDENCIES(NAME)
30 # ----------------------
31 # See how the compiler implements dependency checking.
32 # NAME is "CC", "CXX", "GCJ", or "OBJC".
33 # We try a few techniques and use that to set a single cache variable.
35 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
36 # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
37 # dependency, and given that the user is not expected to run this macro,
38 # just rely on AC_PROG_CC.
39 AC_DEFUN([_AM_DEPENDENCIES],
40 [AC_REQUIRE([AM_SET_DEPDIR])dnl
41 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
42 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
43 AC_REQUIRE([AM_DEP_TRACK])dnl
45 ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
46        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
47        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
48        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
49                    [depcc="$$1"   am_compiler_list=])
51 AC_CACHE_CHECK([dependency style of $depcc],
52                [am_cv_$1_dependencies_compiler_type],
53 [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
54   # We make a subdir and do the tests there.  Otherwise we can end up
55   # making bogus files that we don't know about and never remove.  For
56   # instance it was reported that on HP-UX the gcc test will end up
57   # making a dummy file named `D' -- because `-MD' means `put the output
58   # in D'.
59   mkdir conftest.dir
60   # Copy depcomp to subdir because otherwise we won't find it if we're
61   # using a relative directory.
62   cp "$am_depcomp" conftest.dir
63   cd conftest.dir
65   am_cv_$1_dependencies_compiler_type=none
66   if test "$am_compiler_list" = ""; then
67      am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
68   fi
69   for depmode in $am_compiler_list; do
70     # We need to recreate these files for each test, as the compiler may
71     # overwrite some of them when testing with obscure command lines.
72     # This happens at least with the AIX C compiler.
73     echo '#include "conftest.h"' > conftest.c
74     echo 'int i;' > conftest.h
75     echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf
77     case $depmode in
78     nosideeffect)
79       # after this tag, mechanisms are not by side-effect, so they'll
80       # only be used when explicitly requested
81       if test "x$enable_dependency_tracking" = xyes; then
82         continue
83       else
84         break
85       fi
86       ;;
87     none) break ;;
88     esac
89     # We check with `-c' and `-o' for the sake of the "dashmstdout"
90     # mode.  It turns out that the SunPro C++ compiler does not properly
91     # handle `-M -o', and we need to detect this.
92     if depmode=$depmode \
93        source=conftest.c object=conftest.o \
94        depfile=conftest.Po tmpdepfile=conftest.TPo \
95        $SHELL ./depcomp $depcc -c -o conftest.o conftest.c >/dev/null 2>&1 &&
96        grep conftest.h conftest.Po > /dev/null 2>&1 &&
97        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
98       am_cv_$1_dependencies_compiler_type=$depmode
99       break
100     fi
101   done
103   cd ..
104   rm -rf conftest.dir
105 else
106   am_cv_$1_dependencies_compiler_type=none
109 AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
110 AM_CONDITIONAL([am__fastdep$1], [
111   test "x$enable_dependency_tracking" != xno \
112   && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
116 # AM_SET_DEPDIR
117 # -------------
118 # Choose a directory name for dependency files.
119 # This macro is AC_REQUIREd in _AM_DEPENDENCIES
120 AC_DEFUN([AM_SET_DEPDIR],
121 [rm -f .deps 2>/dev/null
122 mkdir .deps 2>/dev/null
123 if test -d .deps; then
124   DEPDIR=.deps
125 else
126   # MS-DOS does not allow filenames that begin with a dot.
127   DEPDIR=_deps
129 rmdir .deps 2>/dev/null
130 AC_SUBST([DEPDIR])
134 # AM_DEP_TRACK
135 # ------------
136 AC_DEFUN([AM_DEP_TRACK],
137 [AC_ARG_ENABLE(dependency-tracking,
138 [  --disable-dependency-tracking Speeds up one-time builds
139   --enable-dependency-tracking  Do not reject slow dependency extractors])
140 if test "x$enable_dependency_tracking" != xno; then
141   am_depcomp="$ac_aux_dir/depcomp"
142   AMDEPBACKSLASH='\'
144 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
145 AC_SUBST([AMDEPBACKSLASH])