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