Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | From 711e2f76890e3c5b08f64859d9fd913ddbec7d50 Mon Sep 17 00:00:00 2001 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 2 | From: Christopher Larson <chris_larson@mentor.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 3 | Date: Mon, 22 Oct 2018 15:26:47 +0800 |
| 4 | Subject: [PATCH 2/4] Add argument to control the libargp dependency |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 5 | |
| 6 | This ensures that the builds are always deterministic. If the argument isn't |
| 7 | passed, the default behavior is to use libargp if the libc doesn't have argp. |
| 8 | |
| 9 | Upstream-Status: Pending |
| 10 | Signed-off-by: Christopher Larson <chris_larson@mentor.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 11 | |
| 12 | Rebase to 6.6 |
| 13 | Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 14 | --- |
| 15 | configure.ac | 55 ++++++++++++++++++++++++++++++++++++------------------- |
| 16 | 1 file changed, 36 insertions(+), 19 deletions(-) |
| 17 | |
| 18 | diff --git a/configure.ac b/configure.ac |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 19 | index c4a5dd8..dd1c30f 100644 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 20 | --- a/configure.ac |
| 21 | +++ b/configure.ac |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 22 | @@ -40,6 +40,13 @@ AC_ARG_WITH([nistbeacon], |
| 23 | [with_nistbeacon=check] |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 24 | ) |
| 25 | |
| 26 | +AC_ARG_WITH([libargp], |
| 27 | + AS_HELP_STRING([--without-libargp], |
| 28 | + [Disable libargp support. Systems whose libc lacks argp can use libargp instead. (Default: check if libc lacks argp)]), |
| 29 | + [with_libargp=$withval], |
| 30 | + [with_libargp=check] |
| 31 | +) |
| 32 | + |
| 33 | dnl Make sure anyone changing configure.ac/Makefile.am has a clue |
| 34 | AM_MAINTAINER_MODE |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 35 | AM_PROG_AS |
| 36 | @@ -135,27 +142,37 @@ AS_IF( |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 37 | ] |
| 38 | ) |
| 39 | |
| 40 | -dnl First check if we have argp available from libc |
| 41 | -AC_LINK_IFELSE( |
| 42 | - [AC_LANG_PROGRAM( |
| 43 | - [#include <argp.h>], |
| 44 | - [int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;] |
| 45 | - )], |
| 46 | - [libc_has_argp="true"], |
| 47 | - [libc_has_argp="false"] |
| 48 | +dnl Determine if we need libargp: either user requested, or libc has no argp |
| 49 | +AS_IF( |
| 50 | + [test "x$with_libargp" != "xyes"], |
| 51 | + [ |
| 52 | + AC_LINK_IFELSE( |
| 53 | + [AC_LANG_PROGRAM( |
| 54 | + [#include <argp.h>], |
| 55 | + [int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;] |
| 56 | + )], |
| 57 | + [need_libargp=no], |
| 58 | + [need_libargp=yes |
| 59 | + if test "x$with_libargp" = "xno"; then |
| 60 | + AC_MSG_FAILURE([libargp disabled and libc does not have argp]) |
| 61 | + fi] |
| 62 | + ) |
| 63 | + ], |
| 64 | + [need_libargp=yes], |
| 65 | ) |
| 66 | |
| 67 | -dnl If libc doesn't provide argp, then test for libargp |
| 68 | -if test "$libc_has_argp" = "false" ; then |
| 69 | - AC_MSG_WARN("libc does not have argp") |
| 70 | - AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"]) |
| 71 | - |
| 72 | - if test "$have_argp" = "false"; then |
| 73 | - AC_MSG_ERROR("no libargp found") |
| 74 | - else |
| 75 | - LIBS+=" -largp" |
| 76 | - fi |
| 77 | -fi |
| 78 | +dnl Check for libargp |
| 79 | +AS_IF( |
| 80 | + [test "x$need_libargp" = "xyes"], |
| 81 | + [ |
| 82 | + AC_CHECK_LIB( |
| 83 | + [argp], |
| 84 | + [argp_parse], |
| 85 | + [LIBS="$LIBS -largp"], |
| 86 | + [AC_MSG_FAILURE([libargp not found])] |
| 87 | + ) |
| 88 | + ] |
| 89 | +) |
| 90 | |
| 91 | dnl ----------------- |
| 92 | dnl Configure options |
| 93 | -- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 94 | 2.7.4 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 95 | |