acinclude.m4 1.3 KB

12345678910111213141516171819202122232425262728
  1. # AC_COMPUTE_NEEDED_DSO(LIBRARY, TEST_PROGRAM, PREPROC_SYMBOL)
  2. # --------------------------------------------------
  3. # Compute the 'actual' dynamic-library used
  4. # for LIBRARY and set it to PREPROC_SYMBOL
  5. AC_DEFUN([AC_COMPUTE_NEEDED_DSO],
  6. [
  7. AC_CACHE_CHECK([Checking for the 'actual' dynamic-library for '-l$1'], ac_cv_libname_$1,
  8. [
  9. echo '$2' > conftest.c
  10. if test -z "`${CC} ${LDFLAGS} -o conftest conftest.c -l$1 2>&1`"; then
  11. dnl Try objdump and ldd in that order to get the dynamic library
  12. if test ! -z "`which objdump | grep -v 'no objdump'`"; then
  13. ac_cv_libname_$1="`objdump -p conftest | grep NEEDED | grep $1 | sed 's/\W*NEEDED\W*\(.*\)\W*$/\"\1\"/'`"
  14. elif test ! -z "`which ldd | grep -v 'no ldd'`"; then
  15. ac_cv_libname_$1="`ldd conftest | grep $1 | sed 's/^[[[^A-Za-z0-9]]]*\([[[A-Za-z0-9\.]]]*\)[[[^A-Za-z0-9]]]*=>.*$/\"\1\"/'`"
  16. elif test ! -z "`which otool | grep -v 'no otool'`"; then
  17. ac_cv_libname_$1=\"`otool -L conftest | grep $1 | sed -e 's/^[ ]*//' -e 's/ .*//' -e 's/.*\/\(.*\)$/\1/'`\";
  18. else
  19. AC_MSG_ERROR(Can't find either 'objdump' or 'ldd' or 'otool' to compute the dynamic library for '-l$1')
  20. fi
  21. else
  22. ac_cv_libname_$1=libnotfound.so
  23. fi
  24. rm -f conftest*
  25. ]
  26. )
  27. AC_DEFINE_UNQUOTED($3, ${ac_cv_libname_$1}, [The 'actual' dynamic-library for '-l$1'])
  28. ])# AC_COMPUTE_NEEDED_DSO