Skip to contentSkip to conversation

rng-tools: fix the build with musl

PATCH New Christopher Larson 1 participant 1 message Feb 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rng-tools: fix the build with musl

From: Christopher Larson <[email protected]>

musl doesn't provide argp, so we need argp-standalone, as we do for uclibc. Rather than passing in -largp via the recipe, patch the configure script to provide an argument for the libargp usage and check for it when needed, and use PACKAGECONFIG. The initial patch to check for libargp and use it if available came from Gentoo. The patches are kept separate despite the second modifying what the first does, in order to keep the history/origin clear.

---
 ...1-If-the-libc-is-lacking-argp-use-libargp.patch | 60 ++++++++++++++
 ...rgument-to-control-the-libargp-dependency.patch | 92 ++++++++++++++++++++++
 meta/recipes-support/rng-tools/rng-tools_5.bb      |  8 +-
 3 files changed, 159 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch
 create mode 100644 meta/recipes-support/rng-tools/rng-tools/0002-Add-argument-to-control-the-libargp-dependency.patch
meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch new file +60 -0
new file mode 100644
index 0000000..4bd9d31
@@ -0,0 +1,60 @@
+From 99679fda405e535a282f04a4decc2381154a749f Mon Sep 17 00:00:00 2001
+From: Christopher Larson <[email protected]>
+Date: Mon, 15 Feb 2016 15:59:58 -0700
+Subject: [PATCH 1/2] If the libc is lacking argp, use libargp
+
+Patch pulled from Gentoo:
+
+    On glibc systems, argp is provided by libc.  However, on
+    uclibc and other systems which lack argp in their C library,
+    argp might be provided by a stand alone library, libargp.
+    This patch adds tests to the build system to find who provides
+    argp.
+
+    X-Gentoo-Bug: 292191
+    X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=292191
+    Reported-by: Ed Wildgoose <[email protected]>
+    Signed-off-by: Anthony G. Basile <[email protected]>
+
+Upstream-Status: Pending
+Signed-off-by: Christopher Larson <[email protected]>
+---
+ configure.ac | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index 27a2dba..04fcd25 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -82,6 +82,28 @@ AS_IF(
+ 	]
+ )
+ 
++dnl First check if we have argp available from libc
++AC_LINK_IFELSE(
++	[AC_LANG_PROGRAM(
++		[#include <argp.h>],
++		[int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;]
++		)],
++	[libc_has_argp="true"],
++	[libc_has_argp="false"]
++)
++
++dnl If libc doesn't provide argp, then test for libargp
++if test "$libc_has_argp" = "false" ; then
++	AC_MSG_WARN("libc does not have argp")
++	AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"])
++
++	if test "$have_argp" = "false"; then
++		AC_MSG_ERROR("no libargp found")
++	else
++		LIBS+=" -largp"
++	fi
++fi
++
+ dnl -----------------
+ dnl Configure options
+ dnl -----------------
+-- 
+2.2.1
+
meta/recipes-support/rng-tools/rng-tools/0002-Add-argument-to-control-the-libargp-dependency.patch new file +92 -0

92 lines not on this page · raw message

meta/recipes-support/rng-tools/rng-tools_5.bb +7 -1
index 67f53f2..9a19d1c 100644
@@ -1,9 +1,10 @@
 SUMMARY = "Random number generator daemon"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=0b6f033afe6db235e559456585dc8cdc"
-DEPENDS_append_libc-uclibc = " argp-standalone"
 
 SRC_URI = "http://heanet.dl.sourceforge.net/sourceforge/gkernel/${BP}.tar.gz \
+           file://0001-If-the-libc-is-lacking-argp-use-libargp.patch \
+           file://0002-Add-argument-to-control-the-libargp-dependency.patch \
            file://init \
            file://default"
 
@@ -19,6 +20,11 @@ python () {
 
 inherit autotools update-rc.d
 
+PACKAGECONFIG = ""
+PACKAGECONFIG_libc-musl = "libargp"
+PACKAGECONFIG_libc-uclibc = "libargp"
+PACKAGECONFIG[libargp] = "--with-libargp,--without-libargp,argp-standalone,"
+
 RDEPENDS_${PN} = "libgcrypt"
 
 do_install_append() {
Signature · 1 line
2.2.1