Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame^] | 1 | From afc8712a9e6c72fbd03c36f84ecf8703e5d22a8c Mon Sep 17 00:00:00 2001 |
| 2 | From: Christopher Larson <chris_larson@mentor.com> |
| 3 | Date: Mon, 15 Feb 2016 16:11:32 -0700 |
| 4 | Subject: [PATCH 2/2] Add argument to control the libargp dependency |
| 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> |
| 11 | --- |
| 12 | configure.ac | 55 ++++++++++++++++++++++++++++++++++++------------------- |
| 13 | 1 file changed, 36 insertions(+), 19 deletions(-) |
| 14 | |
| 15 | diff --git a/configure.ac b/configure.ac |
| 16 | index 04fcd25..11a5321 100644 |
| 17 | --- a/configure.ac |
| 18 | +++ b/configure.ac |
| 19 | @@ -32,6 +32,13 @@ AC_ARG_WITH([libgcrypt], |
| 20 | [with_libgcrypt=check] |
| 21 | ) |
| 22 | |
| 23 | +AC_ARG_WITH([libargp], |
| 24 | + AS_HELP_STRING([--without-libargp], |
| 25 | + [Disable libargp support. Systems whose libc lacks argp can use libargp instead. (Default: check if libc lacks argp)]), |
| 26 | + [with_libargp=$withval], |
| 27 | + [with_libargp=check] |
| 28 | +) |
| 29 | + |
| 30 | dnl Make sure anyone changing configure.ac/Makefile.am has a clue |
| 31 | AM_MAINTAINER_MODE |
| 32 | |
| 33 | @@ -82,27 +89,37 @@ AS_IF( |
| 34 | ] |
| 35 | ) |
| 36 | |
| 37 | -dnl First check if we have argp available from libc |
| 38 | -AC_LINK_IFELSE( |
| 39 | - [AC_LANG_PROGRAM( |
| 40 | - [#include <argp.h>], |
| 41 | - [int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;] |
| 42 | - )], |
| 43 | - [libc_has_argp="true"], |
| 44 | - [libc_has_argp="false"] |
| 45 | +dnl Determine if we need libargp: either user requested, or libc has no argp |
| 46 | +AS_IF( |
| 47 | + [test "x$with_libargp" != "xyes"], |
| 48 | + [ |
| 49 | + AC_LINK_IFELSE( |
| 50 | + [AC_LANG_PROGRAM( |
| 51 | + [#include <argp.h>], |
| 52 | + [int argc=1; char *argv[]={"test"}; argp_parse(0,argc,argv,0,0,0); return 0;] |
| 53 | + )], |
| 54 | + [need_libargp=no], |
| 55 | + [need_libargp=yes |
| 56 | + if test "x$with_libargp" = "xno"; then |
| 57 | + AC_MSG_FAILURE([libargp disabled and libc does not have argp]) |
| 58 | + fi] |
| 59 | + ) |
| 60 | + ], |
| 61 | + [need_libargp=yes], |
| 62 | ) |
| 63 | |
| 64 | -dnl If libc doesn't provide argp, then test for libargp |
| 65 | -if test "$libc_has_argp" = "false" ; then |
| 66 | - AC_MSG_WARN("libc does not have argp") |
| 67 | - AC_CHECK_LIB([argp], [argp_parse], [have_argp="true"], [have_argp="false"]) |
| 68 | - |
| 69 | - if test "$have_argp" = "false"; then |
| 70 | - AC_MSG_ERROR("no libargp found") |
| 71 | - else |
| 72 | - LIBS+=" -largp" |
| 73 | - fi |
| 74 | -fi |
| 75 | +dnl Check for libargp |
| 76 | +AS_IF( |
| 77 | + [test "x$need_libargp" = "xyes"], |
| 78 | + [ |
| 79 | + AC_CHECK_LIB( |
| 80 | + [argp], |
| 81 | + [argp_parse], |
| 82 | + [LIBS="$LIBS -largp"], |
| 83 | + [AC_MSG_FAILURE([libargp not found])] |
| 84 | + ) |
| 85 | + ] |
| 86 | +) |
| 87 | |
| 88 | dnl ----------------- |
| 89 | dnl Configure options |
| 90 | -- |
| 91 | 2.2.1 |
| 92 | |