expandlibs.m4 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. dnl This Source Code Form is subject to the terms of the Mozilla Public
  2. dnl License, v. 2.0. If a copy of the MPL was not distributed with this
  3. dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. AC_DEFUN([MOZ_EXPAND_LIBS],
  5. [
  6. dnl ========================================================
  7. dnl =
  8. dnl = Check what kind of list files are supported by the
  9. dnl = linker
  10. dnl =
  11. dnl ========================================================
  12. AC_CACHE_CHECK(what kind of list files are supported by the linker,
  13. EXPAND_LIBS_LIST_STYLE,
  14. [echo "int main() {return 0;}" > conftest.${ac_ext}
  15. if AC_TRY_COMMAND(${CC-cc} -o conftest.${OBJ_SUFFIX} -c $CFLAGS $CPPFLAGS conftest.${ac_ext} 1>&5) && test -s conftest.${OBJ_SUFFIX}; then
  16. echo "INPUT(conftest.${OBJ_SUFFIX})" > conftest.list
  17. if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS conftest.list $LIBS 1>&5) && test -s conftest${ac_exeext}; then
  18. EXPAND_LIBS_LIST_STYLE=linkerscript
  19. else
  20. echo "conftest.${OBJ_SUFFIX}" > conftest.list
  21. dnl -filelist is for the OS X linker. We need to try -filelist
  22. dnl first because clang understands @file, but may pass an
  23. dnl oversized argument list to the linker depending on the
  24. dnl contents of @file.
  25. if AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS [-Wl,-filelist,conftest.list] $LIBS 1>&5) && test -s conftest${ac_exeext}; then
  26. EXPAND_LIBS_LIST_STYLE=filelist
  27. elif AC_TRY_COMMAND(${CC-cc} -o conftest${ac_exeext} $LDFLAGS @conftest.list $LIBS 1>&5) && test -s conftest${ac_exeext}; then
  28. EXPAND_LIBS_LIST_STYLE=list
  29. else
  30. EXPAND_LIBS_LIST_STYLE=none
  31. fi
  32. fi
  33. else
  34. dnl We really don't expect to get here, but just in case
  35. AC_ERROR([couldn't compile a simple C file])
  36. fi
  37. rm -rf conftest*])
  38. LIBS_DESC_SUFFIX=desc
  39. AC_SUBST(LIBS_DESC_SUFFIX)
  40. AC_SUBST(EXPAND_LIBS_LIST_STYLE)
  41. if test "$GCC_USE_GNU_LD"; then
  42. AC_CACHE_CHECK(what kind of ordering can be done with the linker,
  43. EXPAND_LIBS_ORDER_STYLE,
  44. [> conftest.order
  45. _SAVE_LDFLAGS="$LDFLAGS"
  46. LDFLAGS="${LDFLAGS} -Wl,--section-ordering-file,conftest.order"
  47. AC_TRY_LINK([], [],
  48. EXPAND_LIBS_ORDER_STYLE=section-ordering-file,
  49. EXPAND_LIBS_ORDER_STYLE=)
  50. LDFLAGS="$_SAVE_LDFLAGS"
  51. if test -z "$EXPAND_LIBS_ORDER_STYLE"; then
  52. if AC_TRY_COMMAND(${CC-cc} ${DSO_LDOPTS} ${LDFLAGS} -o ${DLL_PREFIX}conftest${DLL_SUFFIX} -Wl,--verbose 2> /dev/null | sed -n '/^===/,/^===/p' | grep '\.text'); then
  53. EXPAND_LIBS_ORDER_STYLE=linkerscript
  54. else
  55. EXPAND_LIBS_ORDER_STYLE=none
  56. fi
  57. rm -f ${DLL_PREFIX}conftest${DLL_SUFFIX}
  58. fi])
  59. fi
  60. AC_SUBST(EXPAND_LIBS_ORDER_STYLE)
  61. ])