Rewrite argp check using the same AC_SEARCH_LIBS based method used earlier in the fts check.
Signed-off-by: Dmitry V. Levin <l...@altlinux.org> --- ChangeLog | 2 ++ configure.ac | 31 ++++++++----------------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 563af0d2..def6279a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2020-12-11 Dmitry V. Levin <l...@altlinux.org> + * configure.ac: Rewrite argp check. + * configure.ac (AC_MSG_FAILURE): Fix typo. 2020-11-30 Dmitry V. Levin <l...@altlinux.org> diff --git a/configure.ac b/configure.ac index 6c3e05bf..392f9155 100644 --- a/configure.ac +++ b/configure.ac @@ -520,29 +520,14 @@ if test "$ac_cv_implicit_fallthrough" = "yes"; then [Defined if __attribute__((fallthrough)) is supported]) fi -dnl Check if we have argp available from our 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 our 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 - argp_LDADD="-largp" - fi -else - argp_LDADD="" -fi +saved_LIBS="$LIBS" +AC_SEARCH_LIBS([argp_parse], [argp]) +LIBS="$saved_LIBS" +case "$ac_cv_search_argp_parse" in + no) AC_MSG_FAILURE([failed to find argp_parse]) ;; + -l*) argp_LDADD="$ac_cv_search_argp_parse" ;; + *) argp_LDADD= ;; +esac AC_SUBST([argp_LDADD]) saved_LIBS="$LIBS" -- ldv