All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 3/3] udftools: fix static linking against readline
Date: Sun, 22 Apr 2018 23:20:05 +0200	[thread overview]
Message-ID: <20180422212005.13062-4-thomas.petazzoni@bootlin.com> (raw)
In-Reply-To: <20180422212005.13062-1-thomas.petazzoni@bootlin.com>

One program of udftools uses the readline library, but fails to build
in static linking configurations. In order to fix this, we teach
udftools configure.ac to use pkg-config to detect the readline
library, and to use the proper flags provided by pkg-config.

This obviously requires an autoreconf of the package, and the addition
of host-pkgconf in the dependencies.

Fixes:

  http://autobuild.buildroot.net/results/113a94049d89b8f065112e5d4482667a7b7fb843/

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 ...c-detect-readline-via-pkg-config-when-pos.patch | 60 ++++++++++++++++++++++
 package/udftools/udftools.mk                       |  3 +-
 2 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 package/udftools/0002-configure.ac-detect-readline-via-pkg-config-when-pos.patch

diff --git a/package/udftools/0002-configure.ac-detect-readline-via-pkg-config-when-pos.patch b/package/udftools/0002-configure.ac-detect-readline-via-pkg-config-when-pos.patch
new file mode 100644
index 0000000000..f73db99ca2
--- /dev/null
+++ b/package/udftools/0002-configure.ac-detect-readline-via-pkg-config-when-pos.patch
@@ -0,0 +1,60 @@
+From bdacf0101fea1dad2c89996b27cb4b9caee9109c Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Date: Sun, 22 Apr 2018 22:28:09 +0200
+Subject: [PATCH] configure.ac: detect readline via pkg-config when possible
+
+pkg-config automatically handles static linking situations, where for
+example readline is linked against ncurses, and therefore -lncurses
+needs to be passed in addition to -lreadline.
+
+This proposal uses pkg-config when available. If pkg-config is not
+found, or readline is not found via pkg-config, we fallback to the
+existing AC_CHECK_LIB(). This AC_CHECK_LIB() test is modified to set
+READLINE_LIBS, like PKG_CHECK_MODULES() does. The Makefile.am
+consequently uses READLINE_LIBS instead of hardcoding -lreadline.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+---
+ configure.ac      | 14 ++++++++++++--
+ wrudf/Makefile.am |  2 +-
+ 2 files changed, 13 insertions(+), 3 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 95fbba3..62b1caa 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -9,8 +9,18 @@ AC_PROG_CC
+ AC_DISABLE_SHARED
+ AM_PROG_LIBTOOL
+ 
+-dnl Checks for libraries.
+-AC_CHECK_LIB(readline, readline, [ ], AC_MSG_ERROR([cannot find -lreadline.]))
++PKG_PROG_PKG_CONFIG
++
++dnl Checks for libraries, by using pkg-config when available
++if test -n "${PKG_CONFIG}" ; then
++  PKG_CHECK_MODULES([READLINE], [readline], [readline_found=yes], [readline_found=no])
++fi
++
++if test "${readline_found}" != "yes" ; then
++  AC_CHECK_LIB(readline, readline,
++               [AC_SUBST([READLINE_LIBS], [-lreadline])],
++               AC_MSG_ERROR([cannot find -lreadline.]))
++fi
+ 
+ dnl Checks for header files.
+ AC_HEADER_STDC
+diff --git a/wrudf/Makefile.am b/wrudf/Makefile.am
+index fe1c269..e3ab85b 100644
+--- a/wrudf/Makefile.am
++++ b/wrudf/Makefile.am
+@@ -1,5 +1,5 @@
+ bin_PROGRAMS = wrudf
+-wrudf_LDADD = $(top_builddir)/libudffs/libudffs.la -lreadline
++wrudf_LDADD = $(top_builddir)/libudffs/libudffs.la $(READLINE_LIBS)
+ 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
+ 
+ AM_CPPFLAGS = -I$(top_srcdir)/include -D_GNU_SOURCE -DDEBUG
+-- 
+2.14.3
+
diff --git a/package/udftools/udftools.mk b/package/udftools/udftools.mk
index 2d3477a51c..e5bf59137e 100644
--- a/package/udftools/udftools.mk
+++ b/package/udftools/udftools.mk
@@ -8,6 +8,7 @@ UDFTOOLS_VERSION = 2.0
 UDFTOOLS_SITE = https://github.com/pali/udftools/releases/download/$(UDFTOOLS_VERSION)
 UDFTOOLS_LICENSE = GPL-2.0+
 UDFTOOLS_LICENSE_FILES = COPYING
-UDFTOOLS_DEPENDENCIES = readline
+UDFTOOLS_AUTORECONF = YES
+UDFTOOLS_DEPENDENCIES = readline host-pkgconf
 
 $(eval $(autotools-package))
-- 
2.14.3

  parent reply	other threads:[~2018-04-22 21:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-22 21:20 [Buildroot] [PATCH 0/3] Fix udftools in static linking scenarios Thomas Petazzoni
2018-04-22 21:20 ` [Buildroot] [PATCH 1/3] udftool: add missing dependency on readline Thomas Petazzoni
2018-05-06 19:52   ` Peter Korsgaard
2018-04-22 21:20 ` [Buildroot] [PATCH 2/3] readline: install a .pc file Thomas Petazzoni
2018-05-03 20:14   ` Thomas Petazzoni
2018-05-06 19:52   ` Peter Korsgaard
2018-04-22 21:20 ` Thomas Petazzoni [this message]
2018-05-06 19:53   ` [Buildroot] [PATCH 3/3] udftools: fix static linking against readline Peter Korsgaard
2018-04-26  5:33 ` [Buildroot] [PATCH 0/3] Fix udftools in static linking scenarios Rahul Bedarkar
2018-05-04  9:01   ` Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180422212005.13062-4-thomas.petazzoni@bootlin.com \
    --to=thomas.petazzoni@bootlin.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.