summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/rng-tools/rng-tools/0001-If-the-libc-is-lacking-argp-use-libargp.patch
blob: 06d1d943698205878fc56c2472c12e72cdf3b3f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 06ba71887f667d45dd231a782a2751f36e8fe025 Mon Sep 17 00:00:00 2001
From: Christopher Larson <chris_larson@mentor.com>
Date: Mon, 15 Feb 2016 15:59:58 -0700
Subject: [PATCH 1/4] 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 <gentoo@wildgooses.com>
    Signed-off-by: Anthony G. Basile <blueness@gentoo.org>

Upstream-Status: Pending
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 configure.ac | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/configure.ac b/configure.ac
index 4e799dc..c4a5dd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -135,6 +135,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.7.4