doc: update Vala documentation
[automake.git] / m4 / depend.m4
blob9ab9b29654031999e79c91d75b55a4806367dbf6
1 ##                                                          -*- Autoconf -*-
2 # Copyright (C) 1999-2024 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
9 # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
10 # written in clear, in which case automake, when reading aclocal.m4,
11 # will think it sees a *use*, and therefore will trigger all it's
12 # C support machinery.  Also note that it means that autoscan, seeing
13 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
16 # _AM_DEPENDENCIES(NAME)
17 # ----------------------
18 # See how the compiler implements dependency checking.
19 # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
20 # We try a few techniques and use that to set a single cache variable.
22 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
23 # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
24 # dependency, and given that the user is not expected to run this macro,
25 # just rely on AC_PROG_CC.
26 AC_DEFUN([_AM_DEPENDENCIES],
27 [AC_REQUIRE([AM_SET_DEPDIR])dnl
28 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
29 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
30 AC_REQUIRE([AM_DEP_TRACK])dnl
32 m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
33       [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
34       [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
35       [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
36       [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
37       [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
38                     [depcc="$$1"   am_compiler_list=])
40 AC_CACHE_CHECK([dependency style of $depcc],
41                [am_cv_$1_dependencies_compiler_type],
42 [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
43   # We make a subdir and do the tests there.  Otherwise we can end up
44   # making bogus files that we don't know about and never remove.  For
45   # instance it was reported that on HP-UX the gcc test will end up
46   # making a dummy file named 'D' -- because '-MD' means "put the output
47   # in D".
48   rm -rf conftest.dir
49   mkdir conftest.dir
50   # Copy depcomp to subdir because otherwise we won't find it if we're
51   # using a relative directory.
52   cp "$am_depcomp" conftest.dir
53   cd conftest.dir
54   # We will build objects and dependencies in a subdirectory because
55   # it helps to detect inapplicable dependency modes.  For instance
56   # both Tru64's cc and ICC support -MD to output dependencies as a
57   # side effect of compilation, but ICC will put the dependencies in
58   # the current directory while Tru64 will put them in the object
59   # directory.
60   mkdir sub
62   am_cv_$1_dependencies_compiler_type=none
63   if test "$am_compiler_list" = ""; then
64      am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
65   fi
66   am__universal=false
67   m4_case([$1], [CC],
68     [case " $depcc " in #(
69      *\ -arch\ *\ -arch\ *) am__universal=true ;;
70      esac],
71     [CXX],
72     [case " $depcc " in #(
73      *\ -arch\ *\ -arch\ *) am__universal=true ;;
74      esac])
76   for depmode in $am_compiler_list; do
77     # Setup a source with many dependencies, because some compilers
78     # like to wrap large dependency lists on column 80 (with \), and
79     # we should not choose a depcomp mode which is confused by this.
80     #
81     # We need to recreate these files for each test, as the compiler may
82     # overwrite some of them when testing with obscure command lines.
83     # This happens at least with the AIX C compiler.
84     : > sub/conftest.c
85     for i in 1 2 3 4 5 6; do
86       echo '#include "conftst'$i'.h"' >> sub/conftest.c
87       # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
88       # Solaris 10 /bin/sh.
89       echo '/* dummy */' > sub/conftst$i.h
90     done
91     echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
93     # We check with '-c' and '-o' for the sake of the "dashmstdout"
94     # mode.  It turns out that the SunPro C++ compiler does not properly
95     # handle '-M -o', and we need to detect this.  Also, some Intel
96     # versions had trouble with output in subdirs.
97     am__obj=sub/conftest.${OBJEXT-o}
98     am__minus_obj="-o $am__obj"
99     case $depmode in
100     gcc)
101       # This depmode causes a compiler race in universal mode.
102       test "$am__universal" = false || continue
103       ;;
104     nosideeffect)
105       # After this tag, mechanisms are not by side-effect, so they'll
106       # only be used when explicitly requested.
107       if test "x$enable_dependency_tracking" = xyes; then
108         continue
109       else
110         break
111       fi
112       ;;
113     msvc7 | msvc7msys | msvisualcpp | msvcmsys)
114       # This compiler won't grok '-c -o', but also, the minuso test has
115       # not run yet.  These depmodes are late enough in the game, and
116       # so weak that their functioning should not be impacted.
117       am__obj=conftest.${OBJEXT-o}
118       am__minus_obj=
119       ;;
120     none) break ;;
121     esac
122     if depmode=$depmode \
123        source=sub/conftest.c object=$am__obj \
124        depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
125        $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
126          >/dev/null 2>conftest.err &&
127        grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
128        grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
129        grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
130        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
131       # icc doesn't choke on unknown options, it will just issue warnings
132       # or remarks (even with -Werror).  So we grep stderr for any message
133       # that says an option was ignored or not supported.
134       # When given -MP, icc 7.0 and 7.1 complain thusly:
135       #   icc: Command line warning: ignoring option '-M'; no argument required
136       # The diagnosis changed in icc 8.0:
137       #   icc: Command line remark: option '-MP' not supported
138       if (grep 'ignoring option' conftest.err ||
139           grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
140         am_cv_$1_dependencies_compiler_type=$depmode
141         break
142       fi
143     fi
144   done
146   cd ..
147   rm -rf conftest.dir
148 else
149   am_cv_$1_dependencies_compiler_type=none
152 AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
153 AM_CONDITIONAL([am__fastdep$1], [
154   test "x$enable_dependency_tracking" != xno \
155   && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
159 # AM_SET_DEPDIR
160 # -------------
161 # Choose a directory name for dependency files.
162 # This macro is AC_REQUIREd in _AM_DEPENDENCIES.
163 AC_DEFUN([AM_SET_DEPDIR],
164 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
165 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
169 # AM_DEP_TRACK
170 # ------------
171 AC_DEFUN([AM_DEP_TRACK],
172 [AC_ARG_ENABLE([dependency-tracking], [dnl
173 AS_HELP_STRING(
174   [--enable-dependency-tracking],
175   [do not reject slow dependency extractors])
176 AS_HELP_STRING(
177   [--disable-dependency-tracking],
178   [speeds up one-time build])])
179 if test "x$enable_dependency_tracking" != xno; then
180   am_depcomp="$ac_aux_dir/depcomp"
181   AMDEPBACKSLASH='\'
182   am__nodep='_no'
184 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
185 AC_SUBST([AMDEPBACKSLASH])dnl
186 _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
187 AC_SUBST([am__nodep])dnl
188 _AM_SUBST_NOTMAKE([am__nodep])dnl