From c408c4ad3db6fd713098d821773f91eaf081f798 Mon Sep 17 00:00:00 2001 From: Iker Pedrosa Date: Thu, 10 Aug 2023 09:15:04 +0200 Subject: [PATCH] configure: add `with-libbsd` option It enables the build with libbsd support. By default it is enabled. Resolves: https://github.com/shadow-maint/shadow/issues/779 Signed-off-by: Iker Pedrosa --- configure.ac | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index d9cf73037..6fc8ba68c 100644 --- a/configure.ac +++ b/configure.ac @@ -267,6 +267,9 @@ AC_ARG_WITH(group-name-max-length, AC_ARG_WITH(su, [AS_HELP_STRING([--with-su], [build and install su program and man page @<:@default=yes@:>@])], [with_su=$withval], [with_su=yes]) +AC_ARG_WITH(libbsd, + [AS_HELP_STRING([--with-libbsd], [use libbsd support @<:@default=yes if found@:>@])], + [with_libbsd=$withval], [with_libbsd=yes]) if test "$with_group_name_max_length" = "no" ; then with_group_name_max_length=0 @@ -412,20 +415,27 @@ AC_SUBST(LIYESCRYPT) AC_CHECK_LIB(crypt, crypt, [LIYESCRYPT=-lcrypt], [AC_MSG_ERROR([crypt() not found])]) -AC_SEARCH_LIBS([readpassphrase], [bsd], [], [ - AC_MSG_ERROR([readpassphrase() is missing, either from libc or libbsd]) -]) -AS_IF([test "$ac_cv_search_readpassphrase" = "-lbsd"], [ - PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay]) -]) -dnl Make sure either the libc or libbsd provide the header. -save_CFLAGS="$CFLAGS" -CFLAGS="$CFLAGS $LIBBSD_CFLAGS" -AC_CHECK_HEADERS([readpassphrase.h]) -AS_IF([test "$ac_cv_header_readpassphrase_h" != "yes"], [ - AC_MSG_ERROR([readpassphrase.h is missing]) -]) -CFLAGS="$save_CFLAGS" +AC_SUBST(LIBBSD) +if test "$with_libbsd" != "no"; then + AC_SEARCH_LIBS([readpassphrase], [bsd], [], [ + AC_MSG_ERROR([readpassphrase() is missing, either from libc or libbsd]) + ]) + AS_IF([test "$ac_cv_search_readpassphrase" = "-lbsd"], [ + PKG_CHECK_MODULES([LIBBSD], [libbsd-overlay]) + ]) + dnl Make sure either the libc or libbsd provide the header. + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $LIBBSD_CFLAGS" + AC_CHECK_HEADERS([readpassphrase.h]) + AS_IF([test "$ac_cv_header_readpassphrase_h" != "yes"], [ + AC_MSG_ERROR([readpassphrase.h is missing]) + ]) + CFLAGS="$save_CFLAGS" + AC_DEFINE(WITH_LIBBSD, 1, [Build shadow with libbsd support]) +else + AC_DEFINE(WITH_LIBBSD, 0, [Build shadow without libbsd support]) +fi +AM_CONDITIONAL(WITH_LIBBSD, test x$with_libbsd = xyes) AC_SUBST(LIBACL) if test "$with_acl" != "no"; then -- 2.47.2