0002-configure.ac-detect-readline-via-pkg-config-when-pos.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From bdacf0101fea1dad2c89996b27cb4b9caee9109c Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Sun, 22 Apr 2018 22:28:09 +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. ---
  15. configure.ac | 14 ++++++++++++--
  16. wrudf/Makefile.am | 2 +-
  17. 2 files changed, 13 insertions(+), 3 deletions(-)
  18. diff --git a/configure.ac b/configure.ac
  19. index 95fbba3..62b1caa 100644
  20. --- a/configure.ac
  21. +++ b/configure.ac
  22. @@ -9,8 +9,18 @@ AC_PROG_CC
  23. AC_DISABLE_SHARED
  24. AM_PROG_LIBTOOL
  25. -dnl Checks for libraries.
  26. -AC_CHECK_LIB(readline, readline, [ ], AC_MSG_ERROR([cannot find -lreadline.]))
  27. +PKG_PROG_PKG_CONFIG
  28. +
  29. +dnl Checks for libraries, by using pkg-config when available
  30. +if test -n "${PKG_CONFIG}" ; then
  31. + PKG_CHECK_MODULES([READLINE], [readline], [readline_found=yes], [readline_found=no])
  32. +fi
  33. +
  34. +if test "${readline_found}" != "yes" ; then
  35. + AC_CHECK_LIB(readline, readline,
  36. + [AC_SUBST([READLINE_LIBS], [-lreadline])],
  37. + AC_MSG_ERROR([cannot find -lreadline.]))
  38. +fi
  39. dnl Checks for header files.
  40. AC_HEADER_STDC
  41. diff --git a/wrudf/Makefile.am b/wrudf/Makefile.am
  42. index fe1c269..e3ab85b 100644
  43. --- a/wrudf/Makefile.am
  44. +++ b/wrudf/Makefile.am
  45. @@ -1,5 +1,5 @@
  46. bin_PROGRAMS = wrudf
  47. -wrudf_LDADD = $(top_builddir)/libudffs/libudffs.la -lreadline
  48. +wrudf_LDADD = $(top_builddir)/libudffs/libudffs.la $(READLINE_LIBS)
  49. wrudf_SOURCES = wrudf.c wrudf-cmnd.c wrudf-desc.c wrudf-cdrw.c wrudf-cdr.c ide-pc.c wrudf.h ide-pc.h ../include/ecma_167.h ../include/osta_udf.h ../include/bswap.h
  50. AM_CPPFLAGS = -I$(top_srcdir)/include -D_GNU_SOURCE -DDEBUG
  51. --
  52. 2.14.3