acinclude.m4 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. dnl dolt, a replacement for libtool
  2. dnl Copyright © 2007-2008 Josh Triplett <[email protected]>
  3. dnl Copying and distribution of this file, with or without modification,
  4. dnl are permitted in any medium without royalty provided the copyright
  5. dnl notice and this notice are preserved.
  6. dnl
  7. dnl To use dolt, invoke the DOLT macro immediately after the libtool macros.
  8. dnl Optionally, copy this file into acinclude.m4, to avoid the need to have it
  9. dnl installed when running autoconf on your project.
  10. AC_DEFUN([DOLT], [
  11. AC_REQUIRE([AC_CANONICAL_HOST])
  12. # dolt, a replacement for libtool
  13. # Josh Triplett <[email protected]>
  14. AC_PATH_PROG(DOLT_BASH, bash)
  15. AC_MSG_CHECKING([if dolt supports this host])
  16. dolt_supported=yes
  17. if test x$DOLT_BASH = x; then
  18. dolt_supported=no
  19. fi
  20. if test x$GCC != xyes; then
  21. dolt_supported=no
  22. fi
  23. case $host in
  24. i?86-*-linux*|x86_64-*-linux*|powerpc-*-linux*) ;;
  25. amd64-*-freebsd*|i?86-*-freebsd*|ia64-*-freebsd*) ;;
  26. *) dolt_supported=no ;;
  27. esac
  28. if test x$dolt_supported = xno ; then
  29. AC_MSG_RESULT([no, falling back to libtool])
  30. LTCOMPILE='$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
  31. LTCXXCOMPILE='$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
  32. else
  33. AC_MSG_RESULT([yes, replacing libtool])
  34. dnl Start writing out doltcompile.
  35. cat <<__DOLTCOMPILE__EOF__ >doltcompile
  36. #!$DOLT_BASH
  37. __DOLTCOMPILE__EOF__
  38. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  39. args=("$[]@")
  40. for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
  41. if test x"${args@<:@$arg@:>@}" = x-o ; then
  42. objarg=$((arg+1))
  43. break
  44. fi
  45. done
  46. if test x$objarg = x ; then
  47. echo 'Error: no -o on compiler command line' 1>&2
  48. exit 1
  49. fi
  50. lo="${args@<:@$objarg@:>@}"
  51. obj="${lo%.lo}"
  52. if test x"$lo" = x"$obj" ; then
  53. echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
  54. exit 1
  55. fi
  56. objbase="${obj##*/}"
  57. __DOLTCOMPILE__EOF__
  58. dnl Write out shared compilation code.
  59. if test x$enable_shared = xyes; then
  60. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  61. libobjdir="${obj%$objbase}.libs"
  62. if test ! -d "$libobjdir" ; then
  63. mkdir_out="$(mkdir "$libobjdir" 2>&1)"
  64. mkdir_ret=$?
  65. if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
  66. echo "$mkdir_out" 1>&2
  67. exit $mkdir_ret
  68. fi
  69. fi
  70. pic_object="$libobjdir/$objbase.o"
  71. args@<:@$objarg@:>@="$pic_object"
  72. "${args@<:@@@:>@}" -fPIC -DPIC || exit $?
  73. __DOLTCOMPILE__EOF__
  74. fi
  75. dnl Write out static compilation code.
  76. dnl Avoid duplicate compiler output if also building shared objects.
  77. if test x$enable_static = xyes; then
  78. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  79. non_pic_object="$obj.o"
  80. args@<:@$objarg@:>@="$non_pic_object"
  81. __DOLTCOMPILE__EOF__
  82. if test x$enable_shared = xyes; then
  83. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  84. "${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
  85. __DOLTCOMPILE__EOF__
  86. else
  87. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  88. "${args@<:@@@:>@}" || exit $?
  89. __DOLTCOMPILE__EOF__
  90. fi
  91. fi
  92. dnl Write out the code to write the .lo file.
  93. dnl The second line of the .lo file must match "^# Generated by .*libtool"
  94. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  95. {
  96. echo "# $lo - a libtool object file"
  97. echo "# Generated by doltcompile, not libtool"
  98. __DOLTCOMPILE__EOF__
  99. if test x$enable_shared = xyes; then
  100. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  101. echo "pic_object='$pic_object'"
  102. __DOLTCOMPILE__EOF__
  103. else
  104. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  105. echo pic_object=none
  106. __DOLTCOMPILE__EOF__
  107. fi
  108. if test x$enable_static = xyes; then
  109. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  110. echo "non_pic_object='$non_pic_object'"
  111. __DOLTCOMPILE__EOF__
  112. else
  113. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  114. echo non_pic_object=none
  115. __DOLTCOMPILE__EOF__
  116. fi
  117. cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
  118. } > "$lo"
  119. __DOLTCOMPILE__EOF__
  120. dnl Done writing out doltcompile; substitute it for libtool compilation.
  121. chmod +x doltcompile
  122. LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
  123. LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
  124. fi
  125. AC_SUBST(LTCOMPILE)
  126. AC_SUBST(LTCXXCOMPILE)
  127. # end dolt
  128. ])