0004-nut_check_libgd.m4-try-to-find-gd-through-pkg-config.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. From cb507c44d26d8ae04a0cc3d1c24e79e3bf33ba23 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Wed, 29 Jul 2020 22:51:54 +0200
  4. Subject: [PATCH] nut_check_libgd.m4: try to find gd through pkg-config
  5. gdlib-config has been dropped from version 2.3.0 with
  6. https://github.com/libgd/libgd/commit/d62f608c7c4a814c70d4ba777725e3e62d9e2cde
  7. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  8. [Retrieved from:
  9. https://github.com/networkupstools/nut/commit/cb507c44d26d8ae04a0cc3d1c24e79e3bf33ba23]
  10. ---
  11. m4/nut_check_libgd.m4 | 88 ++++++++++++++++++++++++-------------------
  12. 1 file changed, 50 insertions(+), 38 deletions(-)
  13. diff --git a/m4/nut_check_libgd.m4 b/m4/nut_check_libgd.m4
  14. index 73f4da76d..c4e96761c 100644
  15. --- a/m4/nut_check_libgd.m4
  16. +++ b/m4/nut_check_libgd.m4
  17. @@ -12,50 +12,62 @@ if test -z "${nut_have_libgd_seen}"; then
  18. LDFLAGS_ORIG="${LDFLAGS}"
  19. LIBS_ORIG="${LIBS}"
  20. - dnl Initial defaults. These are only used if gdlib-config is
  21. - dnl unusable and the user fails to pass better values in --with
  22. - dnl arguments
  23. - CFLAGS=""
  24. - LDFLAGS="-L/usr/X11R6/lib"
  25. - LIBS="-lgd -lpng -lz -ljpeg -lfreetype -lm -lXpm -lX11"
  26. + AC_MSG_CHECKING(for gd version via pkg-config)
  27. + GD_VERSION="`pkg-config --silence-errors --modversion gdlib 2>/dev/null`"
  28. + if test "$?" = "0" -a -n "${GD_VERSION}"; then
  29. + CFLAGS="`pkg-config --silence-errors --cflags gdlib 2>/dev/null`"
  30. + LIBS="`pkg-config --silence-errors --libs gdlib 2>/dev/null`"
  31. + else
  32. + GD_VERSION="none"
  33. + fi
  34. + AC_MSG_RESULT(${GD_VERSION} found)
  35. - dnl By default seek in PATH
  36. - GDLIB_CONFIG=gdlib-config
  37. - AC_ARG_WITH(gdlib-config,
  38. - AS_HELP_STRING([@<:@--with-gdlib-config=/path/to/gdlib-config@:>@],
  39. - [path to program that reports GDLIB configuration]),
  40. - [
  41. - case "${withval}" in
  42. - "") ;;
  43. - yes|no)
  44. - AC_MSG_ERROR(invalid option --with(out)-gdlib-config - see docs/configure.txt)
  45. + if test "${GD_VERSION}" = "none"; then
  46. + dnl Initial defaults. These are only used if gdlib-config is
  47. + dnl unusable and the user fails to pass better values in --with
  48. + dnl arguments
  49. + CFLAGS=""
  50. + LDFLAGS="-L/usr/X11R6/lib"
  51. + LIBS="-lgd -lpng -lz -ljpeg -lfreetype -lm -lXpm -lX11"
  52. +
  53. + dnl By default seek in PATH
  54. + GDLIB_CONFIG=gdlib-config
  55. + AC_ARG_WITH(gdlib-config,
  56. + AS_HELP_STRING([@<:@--with-gdlib-config=/path/to/gdlib-config@:>@],
  57. + [path to program that reports GDLIB configuration]),
  58. + [
  59. + case "${withval}" in
  60. + "") ;;
  61. + yes|no)
  62. + AC_MSG_ERROR(invalid option --with(out)-gdlib-config - see docs/configure.txt)
  63. + ;;
  64. + *)
  65. + GDLIB_CONFIG="${withval}"
  66. + ;;
  67. + esac
  68. + ])
  69. +
  70. + AC_MSG_CHECKING(for gd version via ${GDLIB_CONFIG})
  71. + GD_VERSION=`${GDLIB_CONFIG} --version 2>/dev/null`
  72. + if test "$?" != "0" -o -z "${GD_VERSION}"; then
  73. + GD_VERSION="none"
  74. + fi
  75. + AC_MSG_RESULT(${GD_VERSION} found)
  76. +
  77. + case "${GD_VERSION}" in
  78. + none)
  79. + ;;
  80. + 2.0.5 | 2.0.6 | 2.0.7)
  81. + AC_MSG_WARN([[gd ${GD_VERSION} detected, unable to use ${GDLIB_CONFIG} script]])
  82. + AC_MSG_WARN([[If gd detection fails, upgrade gd or use --with-gd-includes and --with-gd-libs]])
  83. ;;
  84. *)
  85. - GDLIB_CONFIG="${withval}"
  86. + CFLAGS="`${GDLIB_CONFIG} --includes 2>/dev/null`"
  87. + LDFLAGS="`${GDLIB_CONFIG} --ldflags 2>/dev/null`"
  88. + LIBS="`${GDLIB_CONFIG} --libs 2>/dev/null`"
  89. ;;
  90. esac
  91. - ])
  92. -
  93. - AC_MSG_CHECKING(for gd version via ${GDLIB_CONFIG})
  94. - GD_VERSION=`${GDLIB_CONFIG} --version 2>/dev/null`
  95. - if test "$?" != "0" -o -z "${GD_VERSION}"; then
  96. - GD_VERSION="none"
  97. fi
  98. - AC_MSG_RESULT(${GD_VERSION} found)
  99. -
  100. - case "${GD_VERSION}" in
  101. - none)
  102. - ;;
  103. - 2.0.5 | 2.0.6 | 2.0.7)
  104. - AC_MSG_WARN([[gd ${GD_VERSION} detected, unable to use ${GDLIB_CONFIG} script]])
  105. - AC_MSG_WARN([[If gd detection fails, upgrade gd or use --with-gd-includes and --with-gd-libs]])
  106. - ;;
  107. - *)
  108. - CFLAGS="`${GDLIB_CONFIG} --includes 2>/dev/null`"
  109. - LDFLAGS="`${GDLIB_CONFIG} --ldflags 2>/dev/null`"
  110. - LIBS="`${GDLIB_CONFIG} --libs 2>/dev/null`"
  111. - ;;
  112. - esac
  113. dnl Now allow overriding gd settings if the user knows best
  114. AC_MSG_CHECKING(for gd include flags)