depstand.m4 revision 1.1.1.1 1 1.1 mrg ## -*- Autoconf -*-
2 1.1 mrg
3 1.1 mrg # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
4 1.1 mrg # Free Software Foundation, Inc.
5 1.1 mrg #
6 1.1 mrg # This file is free software; the Free Software Foundation
7 1.1 mrg # gives unlimited permission to copy and/or distribute it,
8 1.1 mrg # with or without modifications, as long as this notice is preserved.
9 1.1 mrg
10 1.1 mrg # serial 8
11 1.1 mrg
12 1.1 mrg # Based on depend.m4 from automake 1.9, modified for standalone use in
13 1.1 mrg # an environment where GNU make is required.
14 1.1 mrg
15 1.1 mrg # ZW_PROG_COMPILER_DEPENDENCIES
16 1.1 mrg # -----------------------------
17 1.1 mrg # Variant of _AM_DEPENDENCIES which just does the dependency probe and
18 1.1 mrg # sets fooDEPMODE accordingly. Cache-variable compatible with
19 1.1 mrg # original; not side-effect compatible. As the users of this macro
20 1.1 mrg # may require accurate dependencies for correct builds, it does *not*
21 1.1 mrg # honor --disable-dependency-checking, and failure to detect a usable
22 1.1 mrg # method is an error. depcomp is assumed to be located in
23 1.1 mrg # $ac_aux_dir.
24 1.1 mrg #
25 1.1 mrg # FIXME: Should use the Autoconf 2.5x language-selection mechanism.
26 1.1 mrg
27 1.1 mrg AC_DEFUN([ZW_PROG_COMPILER_DEPENDENCIES],
28 1.1 mrg [ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
29 1.1 mrg [$1], CXX, [depcc="$CXX" am_compiler_list=],
30 1.1 mrg [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
31 1.1 mrg [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
32 1.1 mrg [depcc="$$1" am_compiler_list=])
33 1.1 mrg
34 1.1 mrg am_depcomp=$ac_aux_dir/depcomp
35 1.1 mrg AC_CACHE_CHECK([dependency style of $depcc],
36 1.1 mrg [am_cv_$1_dependencies_compiler_type],
37 1.1 mrg [if test -f "$am_depcomp"; then
38 1.1 mrg # We make a subdir and do the tests there. Otherwise we can end up
39 1.1 mrg # making bogus files that we don't know about and never remove. For
40 1.1 mrg # instance it was reported that on HP-UX the gcc test will end up
41 1.1 mrg # making a dummy file named `D' -- because `-MD' means `put the output
42 1.1 mrg # in D'.
43 1.1 mrg mkdir conftest.dir
44 1.1 mrg # Copy depcomp to subdir because otherwise we won't find it if we're
45 1.1 mrg # using a relative directory.
46 1.1 mrg cp "$am_depcomp" conftest.dir
47 1.1 mrg cd conftest.dir
48 1.1 mrg # We will build objects and dependencies in a subdirectory because
49 1.1 mrg # it helps to detect inapplicable dependency modes. For instance
50 1.1 mrg # both Tru64's cc and ICC support -MD to output dependencies as a
51 1.1 mrg # side effect of compilation, but ICC will put the dependencies in
52 1.1 mrg # the current directory while Tru64 will put them in the object
53 1.1 mrg # directory.
54 1.1 mrg mkdir sub
55 1.1 mrg
56 1.1 mrg am_cv_$1_dependencies_compiler_type=none
57 1.1 mrg if test "$am_compiler_list" = ""; then
58 1.1 mrg am_compiler_list=`sed -n ['s/^\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
59 1.1 mrg fi
60 1.1 mrg for depmode in $am_compiler_list; do
61 1.1 mrg if test $depmode = none; then break; fi
62 1.1 mrg
63 1.1 mrg _AS_ECHO([$as_me:$LINENO: trying $depmode], AS_MESSAGE_LOG_FD)
64 1.1 mrg # Setup a source with many dependencies, because some compilers
65 1.1 mrg # like to wrap large dependency lists on column 80 (with \), and
66 1.1 mrg # we should not choose a depcomp mode which is confused by this.
67 1.1 mrg #
68 1.1 mrg # We need to recreate these files for each test, as the compiler may
69 1.1 mrg # overwrite some of them when testing with obscure command lines.
70 1.1 mrg # This happens at least with the AIX C compiler.
71 1.1 mrg : > sub/conftest.c
72 1.1 mrg for i in 1 2 3 4 5 6; do
73 1.1 mrg echo '#include "conftst'$i'.h"' >> sub/conftest.c
74 1.1 mrg # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
75 1.1 mrg # Solaris 8's {/usr,}/bin/sh.
76 1.1 mrg touch sub/conftst$i.h
77 1.1 mrg done
78 1.1 mrg echo "include sub/conftest.Po" > confmf
79 1.1 mrg
80 1.1 mrg # We check with `-c' and `-o' for the sake of the "dashmstdout"
81 1.1 mrg # mode. It turns out that the SunPro C++ compiler does not properly
82 1.1 mrg # handle `-M -o', and we need to detect this.
83 1.1 mrg depcmd="depmode=$depmode \
84 1.1 mrg source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
85 1.1 mrg depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
86 1.1 mrg $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c"
87 1.1 mrg echo "| $depcmd" | sed -e 's/ */ /g' >&AS_MESSAGE_LOG_FD
88 1.1 mrg if env $depcmd > conftest.err 2>&1 &&
89 1.1 mrg grep sub/conftst6.h sub/conftest.Po >>conftest.err 2>&1 &&
90 1.1 mrg grep sub/conftest.${OBJEXT-o} sub/conftest.Po >>conftest.err 2>&1 &&
91 1.1 mrg ${MAKE-make} -s -f confmf >>conftest.err 2>&1; then
92 1.1 mrg # icc doesn't choke on unknown options, it will just issue warnings
93 1.1 mrg # or remarks (even with -Werror). So we grep stderr for any message
94 1.1 mrg # that says an option was ignored or not supported.
95 1.1 mrg # When given -MP, icc 7.0 and 7.1 complain thusly:
96 1.1 mrg # icc: Command line warning: ignoring option '-M'; no argument required
97 1.1 mrg # The diagnosis changed in icc 8.0:
98 1.1 mrg # icc: Command line remark: option '-MP' not supported
99 1.1 mrg if (grep 'ignoring option' conftest.err ||
100 1.1 mrg grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
101 1.1 mrg am_cv_$1_dependencies_compiler_type=$depmode
102 1.1 mrg _AS_ECHO([$as_me:$LINENO: success], AS_MESSAGE_LOG_FD)
103 1.1 mrg break
104 1.1 mrg fi
105 1.1 mrg fi
106 1.1 mrg _AS_ECHO([$as_me:$LINENO: failure, diagnostics are:], AS_MESSAGE_LOG_FD)
107 1.1 mrg sed -e 's/^/| /' < conftest.err >&AS_MESSAGE_LOG_FD
108 1.1 mrg done
109 1.1 mrg
110 1.1 mrg cd ..
111 1.1 mrg rm -rf conftest.dir
112 1.1 mrg else
113 1.1 mrg am_cv_$1_dependencies_compiler_type=none
114 1.1 mrg fi
115 1.1 mrg ])
116 1.1 mrg if test x${am_cv_$1_dependencies_compiler_type-none} = xnone
117 1.1 mrg then AC_MSG_ERROR([no usable dependency style found])
118 1.1 mrg else AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
119 1.1 mrg fi
120 1.1 mrg ])
121 1.1 mrg
122 1.1 mrg # AM_SET_DEPDIR
123 1.1 mrg # -------------
124 1.1 mrg # Choose a directory name for dependency files.
125 1.1 mrg AC_DEFUN([AM_SET_DEPDIR],
126 1.1 mrg [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
127 1.1 mrg AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
128 1.1 mrg ])
129 1.1 mrg
130 1.1 mrg # ZW_CREATE_DEPDIR
131 1.1 mrg # ----------------
132 1.1 mrg # As AM_SET_DEPDIR, but also create the directory at config.status time.
133 1.1 mrg AC_DEFUN([ZW_CREATE_DEPDIR],
134 1.1 mrg [AC_REQUIRE([AM_SET_DEPDIR])dnl
135 1.1 mrg AC_CONFIG_COMMANDS([depdir], [$SHELL $ac_aux_dir/mkinstalldirs $DEPDIR],
136 1.1 mrg [ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR])
137 1.1 mrg ])
138