From a7f1dd0858248ab2b5ffafc34df980e6ee7f4898 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Mar 29 2019 01:39:47 +0000 Subject: Use PKG_CHECK_MODULES to detect the nss library --- diff --git a/Makefile.am b/Makefile.am index e87f35e..57f42f8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -139,7 +139,7 @@ AM_CFLAGS = $(DEBUG_CFLAGS) $(GCCSEC_CFLAGS) $(ASAN_CFLAGS) $(MSAN_CFLAGS) $(TSA AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(GCCSEC_CFLAGS) $(ASAN_CFLAGS) $(MSAN_CFLAGS) $(TSAN_CFLAGS) $(UBSAN_CFLAGS) # Flags for Directory Server # WARNING: This needs a clean up, because slap.h is a horrible mess and is publically exposed! -DSPLUGIN_CPPFLAGS = $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES) $(SYSTEMD_DEFINES) $(NUNCSTANS_INCLUDES) @openldap_inc@ @ldapsdk_inc@ @nss_inc@ $(NSPR_INCLUDES) @systemd_inc@ +DSPLUGIN_CPPFLAGS = $(DS_DEFINES) $(DS_INCLUDES) $(PATH_DEFINES) $(SYSTEMD_DEFINES) $(NUNCSTANS_INCLUDES) @openldap_inc@ @ldapsdk_inc@ $(NSS_CFLAGS) $(NSPR_INCLUDES) @systemd_inc@ # This should give access to internal headers only for tests!!! DSINTERNAL_CPPFLAGS = -I$(srcdir)/include/ldaputil # Flags for Datastructure Library @@ -155,7 +155,7 @@ CMOCKA_LINKS = @cmocka_lib@ PROFILING_LINKS = @profiling_links@ NSPR_LINK = $(NSPR_LIBS) -NSS_LINK = @nss_lib@ -lssl3 -lnss3 +NSS_LINK = $(NSS_LIBS) if OPENLDAP # with recent versions of openldap - if you link with both ldap_r and ldap, the diff --git a/configure.ac b/configure.ac index a7318ce..bd2b7bb 100644 --- a/configure.ac +++ b/configure.ac @@ -824,7 +824,15 @@ else PKG_CHECK_MODULES([NSPR], [dirsec-nspr]) fi -m4_include(m4/nss.m4) +if $PKG_CONFIG --exists nss; then + PKG_CHECK_MODULES([NSS], [nss]) + nss_libdir=`$PKG_CONFIG --libs-only-L nss | sed -e s/-L// | sed -e s/\ .*$//` +else + PKG_CHECK_MODULES([NSS], [dirsec-nss]) + nss_libdir=`$PKG_CONFIG --libs-only-L dirsec-nss | sed -e s/-L// | sed -e s/\ .*$//` +fi +AC_SUBST(nss_libdir) + m4_include(m4/openldap.m4) m4_include(m4/mozldap.m4) m4_include(m4/db.m4) diff --git a/m4/mozldap.m4 b/m4/mozldap.m4 index 40fdb88..255bd27 100644 --- a/m4/mozldap.m4 +++ b/m4/mozldap.m4 @@ -145,7 +145,7 @@ dnl default path for the ldap c sdk tools (see [210947] for more details) dnl the old 5.x or prior versions - the ldap server code expects the new dnl ber types and other code used with version 6 save_cppflags="$CPPFLAGS" - CPPFLAGS="$ldapsdk_inc $nss_inc $NSPR_CFLAGS" + CPPFLAGS="$ldapsdk_inc $NSS_CFLAGS $NSPR_CFLAGS" AC_CHECK_HEADER([ldap.h], [isversion6=1], [isversion6=], [#include #if LDAP_VENDOR_VERSION < 600 diff --git a/m4/nss.m4 b/m4/nss.m4 deleted file mode 100644 index 4465479..0000000 --- a/m4/nss.m4 +++ /dev/null @@ -1,93 +0,0 @@ -# BEGIN COPYRIGHT BLOCK -# Copyright (C) 2007 Red Hat, Inc. -# All rights reserved. -# -# License: GPL (version 3 or any later version). -# See LICENSE for details. -# END COPYRIGHT BLOCK - -AC_CHECKING(for NSS) - -# check for --with-nss -AC_MSG_CHECKING(for --with-nss) -AC_ARG_WITH(nss, AS_HELP_STRING([--with-nss@<:@=PATH@:>@],[Network Security Services (NSS) directory]), -[ - if test "$withval" = "yes" - then - AC_MSG_RESULT(yes) - elif test "$withval" = "no" - then - AC_MSG_RESULT(no) - AC_MSG_ERROR([NSS is required.]) - elif test -e "$withval"/include/nss.h -a -d "$withval"/lib - then - AC_MSG_RESULT([using $withval]) - NSSDIR=$withval - nss_inc="-I$NSSDIR/include" - nss_lib="-L$NSSDIR/lib" - nss_libdir="$NSSDIR/lib" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(yes)) - -# check for --with-nss-inc -AC_MSG_CHECKING(for --with-nss-inc) -AC_ARG_WITH(nss-inc, AS_HELP_STRING([--with-nss-inc=PATH],[Network Security Services (NSS) include directory]), -[ - if test -e "$withval"/nss.h - then - AC_MSG_RESULT([using $withval]) - nss_inc="-I$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) - -# check for --with-nss-lib -AC_MSG_CHECKING(for --with-nss-lib) -AC_ARG_WITH(nss-lib, AS_HELP_STRING([--with-nss-lib=PATH],[Network Security Services (NSS) library directory]), -[ - if test -d "$withval" - then - AC_MSG_RESULT([using $withval]) - nss_lib="-L$withval" - nss_libdir="$withval" - else - echo - AC_MSG_ERROR([$withval not found]) - fi -], -AC_MSG_RESULT(no)) - -# if NSS is not found yet, try pkg-config - -# last resort -if test -z "$nss_inc" -o -z "$nss_lib" -o -z "$nss_libdir"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config) - AC_MSG_CHECKING(for nss with pkg-config) - if test -n "$PKG_CONFIG"; then - if $PKG_CONFIG --exists nss; then - nss_inc=`$PKG_CONFIG --cflags-only-I nss` - nss_lib=`$PKG_CONFIG --libs-only-L nss` - nss_libdir=`$PKG_CONFIG --libs-only-L nss | sed -e s/-L// | sed -e s/\ .*$//` - AC_MSG_RESULT([using system NSS]) - elif $PKG_CONFIG --exists dirsec-nss; then - nss_inc=`$PKG_CONFIG --cflags-only-I dirsec-nss` - nss_lib=`$PKG_CONFIG --libs-only-L dirsec-nss` - nss_libdir=`$PKG_CONFIG --libs-only-L dirsec-nss | sed -e s/-L// | sed -e s/\ .*$//` - AC_MSG_RESULT([using system dirsec NSS]) - else - AC_MSG_ERROR([NSS not found, specify with --with-nss.]) - fi - fi -fi - -AC_SUBST(nss_inc) -AC_SUBST(nss_lib) -AC_SUBST(nss_libdir) - diff --git a/m4/openldap.m4 b/m4/openldap.m4 index 71a05b5..70e01f5 100644 --- a/m4/openldap.m4 +++ b/m4/openldap.m4 @@ -118,7 +118,7 @@ dnl lets see if we can find the headers and libs if test "$with_openldap" = yes ; then save_cppflags="$CPPFLAGS" - CPPFLAGS="$openldap_inc $nss_inc $NSPR_CFLAGS" + CPPFLAGS="$openldap_inc $NSS_CFLAGS $NSPR_CFLAGS" AC_CHECK_HEADER([ldap_features.h], [], [AC_MSG_ERROR([specified with-openldap but ldap_features.h not found])]) dnl figure out which version we're using from the header file