Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.3KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_ext_have_lib.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_EXT_HAVE_LIB(<directories>, <library>, <function>, <extra libraries>)
  8. #
  9. # DESCRIPTION
  10. #
  11. # AX_EXT_HAVE_LIB is identical to AC_SEARCH_LIBS with the exception that
  12. # will add -L<directory> when looking, and use a different variable for
  13. # each directory.
  14. #
  15. # Any required -L<directory> flags are added to LDFLAGS and located
  16. # libraies are added to LIBS
  17. #
  18. # Some libraries are unlinkable without other extra libraries, which can
  19. # be specified in the 4th argument. The mysql client library needs -lz,
  20. # for example.
  21. #
  22. # Example:
  23. #
  24. # AX_EXT_HAVE_LIB(/lib /usr/lib /usr/local/lib /usr/lib/mysql /usr/local/mysql/lib, mysqlclient, mysql_init, [-lz])
  25. #
  26. # which finds the mysql client library if succeeds system when it tries
  27. # with -L/usr/lib/mysql then it adds -lmysqlclient to LIBS and
  28. # -L/usr/lib/mysql to LDFLAGS.
  29. #
  30. # The test itself is based on the autoconf 2.53 version of AC_SEARCH_LIBS.
  31. #
  32. # LICENSE
  33. #
  34. # Copyright (c) 2008 Duncan Simpson <dps@simpson.demon.co.uk>
  35. #
  36. # Copying and distribution of this file, with or without modification, are
  37. # permitted in any medium without royalty provided the copyright notice
  38. # and this notice are preserved. This file is offered as-is, without any
  39. # warranty.
  40. #serial 12
  41. AC_DEFUN([AX_EXT_HAVE_LIB],
  42. [
  43. new_ldflags=${LDFLAGS}
  44. new_libs=$LIBS
  45. AC_CHECK_LIB([$2], $3, new_libs="-l$2"; ext_lib_found="yes", ext_lib_found="no")
  46. for dir in $1
  47. do
  48. if test $ext_lib_found = no
  49. then
  50. ext_haslib_cvdir=`echo $dir | $as_tr_sh`
  51. AC_CACHE_CHECK([for $2 library with -L$dir], [ext_cv${ext_haslib_cvdir}_haslib_$2],
  52. [ext_func_search_save_LIBS=$LIBS
  53. ext_func_save_ldflags=${LDFLAGS}
  54. LIBS="-l$2 $4 ${ext_func_search_save_LIBS}"
  55. LDFLAGS="-L$dir ${ext_func_save_ldflags}"
  56. AC_TRY_LINK_FUNC([$3], [eval "ext_cv${ext_haslib_cvdir}_haslib_$2"="yes"],
  57. [eval "ext_cv${ext_haslib_cvdir}_haslib_$2"="no"])
  58. LIBS=$ext_func_search_save_LIBS
  59. LDFLAGS=$ext_func_save_ldflags
  60. ])
  61. if eval `echo 'test x${'ext_cv${ext_haslib_cvdir}_haslib_$2'}' = "xyes"`; then
  62. new_libs="-l$2"
  63. new_ldflags="-L${dir} ${new_ldflags}"
  64. ext_lib_found="yes"
  65. fi
  66. fi
  67. done
  68. LIBS="$new_libs ${LIBS}"
  69. LDFLAGS=$new_ldflags
  70. ])