depstand.m4 5.6 KB

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