depend.m4 7.1 KB

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