0003-configure.ac-detect-readline-via-pkg-config-when-pos.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. From da044aa346fac63571d3d0cff8f8838263acab40 Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Tue, 27 Aug 2019 18:19:05 +0200
  4. Subject: [PATCH] configure.ac: detect readline via pkg-config when possible
  5. pkg-config automatically handles static linking situations, where for
  6. example readline is linked against ncurses, and therefore -lncurses
  7. needs to be passed in addition to -lreadline.
  8. This proposal uses pkg-config when available. If pkg-config is not
  9. found, or readline is not found via pkg-config, we fallback to the
  10. existing AC_CHECK_LIB(). This AC_CHECK_LIB() test is modified to set
  11. READLINE_LIBS, like PKG_CHECK_MODULES() does. The Makefile.am
  12. consequently uses READLINE_LIBS instead of hardcoding -lreadline.
  13. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  14. [Retrieved (and slightly updated) from:
  15. https://git.buildroot.net/buildroot/tree/package/udftools/0002-configure.ac-detect-readline-via-pkg-config-when-pos.patch]
  16. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  17. [Retrieved from:
  18. https://github.com/pali/udftools/commit/da044aa346fac63571d3d0cff8f8838263acab40]
  19. ---
  20. configure.ac | 18 ++++++++++++------
  21. wrudf/Makefile.am | 2 +-
  22. 2 files changed, 13 insertions(+), 7 deletions(-)
  23. diff --git a/configure.ac b/configure.ac
  24. index 0404e50..9329d69 100644
  25. --- a/configure.ac
  26. +++ b/configure.ac
  27. @@ -14,18 +14,24 @@ AC_PROG_MKDIR_P
  28. AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([Your C compiler does not support ISO C99.])])
  29. -dnl Checks for libraries.
  30. -AC_CHECK_LIB(readline, readline, [ ])
  31. +dnl Checks for libraries, by using pkg-config when available
  32. +PKG_PROG_PKG_CONFIG
  33. +AS_IF([test -n "${PKG_CONFIG}"], [PKG_CHECK_MODULES([READLINE], [readline], [readline_found=yes], [readline_found=no])])
  34. -dnl Checks for header files.
  35. -AC_CHECK_HEADERS(readline/readline.h)
  36. +AS_IF([test "${readline_found}" != "yes"],
  37. + [AC_CHECK_LIB(readline, readline,
  38. + [AC_CHECK_HEADERS(readline/readline.h,
  39. + [AC_SUBST([READLINE_LIBS], [-lreadline])
  40. + readline_found=yes],
  41. + [readline_found=no])],
  42. + [readline_found=no])
  43. + ])
  44. dnl Checks for typedefs, structures, and compiler characteristics.
  45. AC_C_INLINE
  46. AC_C_BIGENDIAN
  47. AC_SYS_LARGEFILE
  48. -PKG_PROG_PKG_CONFIG
  49. PKG_CHECK_MODULES(UDEV, [udev], [ac_cv_udevdir=`$PKG_CONFIG --variable=udevdir udev`], [ac_cv_udevdir=""])
  50. AM_CONDITIONAL(UDEVDIR, [test "$ac_cv_udevdir" != ""])
  51. AC_SUBST(UDEVDIR, $ac_cv_udevdir)
  52. @@ -33,7 +39,7 @@ AC_SUBST(UDEVDIR, $ac_cv_udevdir)
  53. dnl Checks for library functions.
  54. AC_SUBST(LTLIBOBJS)
  55. -AM_CONDITIONAL(USE_READLINE, test "$ac_cv_lib_readline_readline" = "yes" -a "$ac_cv_header_readline_readline_h" = "yes")
  56. +AM_CONDITIONAL(USE_READLINE, test "$readline_found" = "yes")
  57. AC_CONFIG_FILES(Makefile libudffs/Makefile mkudffs/Makefile cdrwtool/Makefile pktsetup/Makefile udffsck/Makefile udfinfo/Makefile udflabel/Makefile wrudf/Makefile doc/Makefile)
  58. diff --git a/wrudf/Makefile.am b/wrudf/Makefile.am
  59. index 4224b13..9f6b33d 100644
  60. --- a/wrudf/Makefile.am
  61. +++ b/wrudf/Makefile.am
  62. @@ -5,6 +5,6 @@ wrudf_SOURCES = wrudf.c wrudf-cmnd.c wrudf-desc.c wrudf-cdrw.c wrudf-cdr.c ide-p
  63. AM_CPPFLAGS = -I$(top_srcdir)/include
  64. if USE_READLINE
  65. -wrudf_LDADD += -lreadline
  66. +wrudf_LDADD += $(READLINE_LIBS)
  67. AM_CPPFLAGS += -DUSE_READLINE
  68. endif