Browse Source

Bug(s) fixed: 211426
Bug Description: autotools: support dirsec packages, mozldap6, svrcore
Reviewed by: nkinder (Thanks!)
Fix Description: Look for the dirsec-nspr and dirsec-nss if nspr and nss
are not found in pkg-config. Look for mozldap6 then mozldap in
pkg-config. Look for svrcore-devel in pkg-config, then look for it in
the system directories.
Nathan pointed out that we do not support mozldap v5.x anymore, so we should just look for mozldap6 with pkg-config. I also added an explicit check of the vendor version in the header file to make sure we are using 600 or greater.
Platforms tested: RHEL4
Flag Day: no
Doc impact: no

Rich Megginson 19 years ago
parent
commit
a326dc36c3
5 changed files with 410 additions and 8 deletions
  1. 355 4
      configure
  2. 20 3
      m4/mozldap.m4
  3. 4 0
      m4/nspr.m4
  4. 4 0
      m4/nss.m4
  5. 27 1
      m4/svrcore.m4

+ 355 - 4
configure

@@ -23574,6 +23574,11 @@ fi
       nspr_lib=`$PKG_CONFIG --libs-only-L nspr`
       echo "$as_me:$LINENO: result: using system NSPR" >&5
 echo "${ECHO_T}using system NSPR" >&6
+    elif $PKG_CONFIG --exists dirsec-nspr; then
+      nspr_inc=`$PKG_CONFIG --cflags-only-I dirsec-nspr`
+      nspr_lib=`$PKG_CONFIG --libs-only-L dirsec-nspr`
+      echo "$as_me:$LINENO: result: using system dirsec NSPR" >&5
+echo "${ECHO_T}using system dirsec NSPR" >&6
     else
       { { echo "$as_me:$LINENO: error: NSPR not found, specify with --with-nspr." >&5
 echo "$as_me: error: NSPR not found, specify with --with-nspr." >&2;}
@@ -23733,6 +23738,11 @@ fi
       nss_lib=`$PKG_CONFIG --libs-only-L nss`
       echo "$as_me:$LINENO: result: using system NSS" >&5
 echo "${ECHO_T}using system NSS" >&6
+    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`
+      echo "$as_me:$LINENO: result: using system dirsec NSS" >&5
+echo "${ECHO_T}using system dirsec NSS" >&6
     else
       { { echo "$as_me:$LINENO: error: NSS not found, specify with --with-nss." >&5
 echo "$as_me: error: NSS not found, specify with --with-nss." >&2;}
@@ -23887,9 +23897,11 @@ echo "${ECHO_T}no" >&6
 fi
 
   if test -n "$PKG_CONFIG"; then
-    if $PKG_CONFIG --exists mozldap; then
-      nspr_inc=`$PKG_CONFIG --cflags-only-I mozldap`
-      nspr_lib=`$PKG_CONFIG --libs-only-L mozldap`
+    if $PKG_CONFIG --exists mozldap6; then
+      ldapsdk_inc=`$PKG_CONFIG --cflags-only-I mozldap6`
+      ldapsdk_lib=`$PKG_CONFIG --libs-only-L mozldap6`
+      echo "$as_me:$LINENO: result: using system mozldap6" >&5
+echo "${ECHO_T}using system mozldap6" >&6
     else
       { { echo "$as_me:$LINENO: error: LDAPSDK not found, specify with --with-ldapsdk-inc|-lib." >&5
 echo "$as_me: error: LDAPSDK not found, specify with --with-ldapsdk-inc|-lib." >&2;}
@@ -23902,6 +23914,74 @@ if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib"; then
 echo "$as_me: error: LDAPSDK not found, specify with --with-ldapsdk-inc|-lib." >&2;}
    { (exit 1); exit 1; }; }
 fi
+save_cppflags="$CPPFLAGS"
+CPPFLAGS="$ldapsdk_inc $nss_inc $nspr_inc"
+echo "$as_me:$LINENO: checking for ldap.h" >&5
+echo $ECHO_N "checking for ldap.h... $ECHO_C" >&6
+if test "${ac_cv_header_ldap_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <ldap-standard.h>
+#if LDAP_VENDOR_VERSION < 600
+#error The LDAP C SDK version is not supported
+#endif
+
+
+#include <ldap.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_header_ldap_h=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_ldap_h=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_ldap_h" >&5
+echo "${ECHO_T}$ac_cv_header_ldap_h" >&6
+if test $ac_cv_header_ldap_h = yes; then
+  isversion6=1
+else
+  isversion6=
+fi
+
+
+CPPFLAGS="$save_cppflags"
+
+if test -z "$isversion6" ; then
+  { { echo "$as_me:$LINENO: error: The LDAPSDK version in $ldapsdk_inc/ldap-standard.h is not supported" >&5
+echo "$as_me: error: The LDAPSDK version in $ldapsdk_inc/ldap-standard.h is not supported" >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 # BEGIN COPYRIGHT BLOCK
 # Copyright (C) 2006 Red Hat, Inc.
@@ -24204,9 +24284,280 @@ echo "${ECHO_T}no" >&6
 fi;
 
 if test -z "$svrcore_inc" -o -z "$svrcore_lib"; then
-  { { echo "$as_me:$LINENO: error: svrcore not found, specify with --with-svrcore." >&5
+  echo "$as_me:$LINENO: checking for svrcore with pkg-config" >&5
+echo $ECHO_N "checking for svrcore with pkg-config... $ECHO_C" >&6
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+
+if test -n "$PKG_CONFIG"; then
+  echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6
+else
+  echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+  if test -n "$PKG_CONFIG"; then
+    if $PKG_CONFIG --exists svrcore-devel; then
+      svrcore_inc=`$PKG_CONFIG --cflags-only-I svrcore-devel`
+      svrcore_lib=`$PKG_CONFIG --libs-only-L svrcore-devel`
+      echo "$as_me:$LINENO: result: using system svrcore" >&5
+echo "${ECHO_T}using system svrcore" >&6
+    fi
+  fi
+fi
+
+if test -z "$svrcore_inc" -o -z "$svrcore_lib"; then
+  echo "$as_me:$LINENO: checking for SVRCORE_GetRegisteredPinObj in -lsvrcore" >&5
+echo $ECHO_N "checking for SVRCORE_GetRegisteredPinObj in -lsvrcore... $ECHO_C" >&6
+if test "${ac_cv_lib_svrcore_SVRCORE_GetRegisteredPinObj+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvrcore $nss_inc $nspr_inc $nss_lib -lnss3 -lsoftokn3 $nspr_lib -lplds4 -lplc4 -lnspr4 $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char SVRCORE_GetRegisteredPinObj ();
+int
+main ()
+{
+SVRCORE_GetRegisteredPinObj ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest$ac_exeext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_lib_svrcore_SVRCORE_GetRegisteredPinObj=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_svrcore_SVRCORE_GetRegisteredPinObj=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_svrcore_SVRCORE_GetRegisteredPinObj" >&5
+echo "${ECHO_T}$ac_cv_lib_svrcore_SVRCORE_GetRegisteredPinObj" >&6
+if test $ac_cv_lib_svrcore_SVRCORE_GetRegisteredPinObj = yes; then
+  havesvrcore=1
+fi
+
+  if test -n "$havesvrcore" ; then
+    save_cppflags="$CPPFLAGS"
+    CPPFLAGS="$nss_inc $nspr_inc"
+    if test "${ac_cv_header_svrcore_h+set}" = set; then
+  echo "$as_me:$LINENO: checking for svrcore.h" >&5
+echo $ECHO_N "checking for svrcore.h... $ECHO_C" >&6
+if test "${ac_cv_header_svrcore_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_svrcore_h" >&5
+echo "${ECHO_T}$ac_cv_header_svrcore_h" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking svrcore.h usability" >&5
+echo $ECHO_N "checking svrcore.h usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <svrcore.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking svrcore.h presence" >&5
+echo $ECHO_N "checking svrcore.h presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <svrcore.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: svrcore.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: svrcore.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: svrcore.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: svrcore.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: svrcore.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: svrcore.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: svrcore.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: svrcore.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: svrcore.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: svrcore.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: svrcore.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: svrcore.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: svrcore.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: svrcore.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: svrcore.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: svrcore.h: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------------------ ##
+## Report this to http://bugzilla.redhat.com/ ##
+## ------------------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for svrcore.h" >&5
+echo $ECHO_N "checking for svrcore.h... $ECHO_C" >&6
+if test "${ac_cv_header_svrcore_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_svrcore_h=$ac_header_preproc
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_svrcore_h" >&5
+echo "${ECHO_T}$ac_cv_header_svrcore_h" >&6
+
+fi
+if test $ac_cv_header_svrcore_h = yes; then
+  havesvrcore=1
+else
+  havesvrcore=
+fi
+
+
+    CPPFLAGS="$save_cppflags"
+  fi
+  if test -z "$havesvrcore" ; then
+    { { echo "$as_me:$LINENO: error: svrcore not found, specify with --with-svrcore." >&5
 echo "$as_me: error: svrcore not found, specify with --with-svrcore." >&2;}
    { (exit 1); exit 1; }; }
+  fi
 fi
 
 # BEGIN COPYRIGHT BLOCK

+ 20 - 3
m4/mozldap.m4

@@ -74,9 +74,10 @@ if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib"; then
   AC_MSG_CHECKING(for mozldap with pkg-config)
   AC_PATH_PROG(PKG_CONFIG, pkg-config)
   if test -n "$PKG_CONFIG"; then
-    if $PKG_CONFIG --exists mozldap; then
-      nspr_inc=`$PKG_CONFIG --cflags-only-I mozldap`
-      nspr_lib=`$PKG_CONFIG --libs-only-L mozldap`
+    if $PKG_CONFIG --exists mozldap6; then
+      ldapsdk_inc=`$PKG_CONFIG --cflags-only-I mozldap6`
+      ldapsdk_lib=`$PKG_CONFIG --libs-only-L mozldap6`
+      AC_MSG_RESULT([using system mozldap6])
     else
       AC_MSG_ERROR([LDAPSDK not found, specify with --with-ldapsdk[-inc|-lib].])
     fi
@@ -85,3 +86,19 @@ fi
 if test -z "$ldapsdk_inc" -o -z "$ldapsdk_lib"; then
   AC_MSG_ERROR([LDAPSDK not found, specify with --with-ldapsdk[-inc|-lib].])
 fi
+dnl make sure the ldap sdk version is 6 or greater - we do not support
+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_inc"
+AC_CHECK_HEADER([ldap.h], [isversion6=1], [isversion6=],
+[#include <ldap-standard.h>
+#if LDAP_VENDOR_VERSION < 600
+#error The LDAP C SDK version is not supported
+#endif
+])
+CPPFLAGS="$save_cppflags"
+
+if test -z "$isversion6" ; then
+  AC_MSG_ERROR([The LDAPSDK version in $ldapsdk_inc/ldap-standard.h is not supported])
+fi

+ 4 - 0
m4/nspr.m4

@@ -78,6 +78,10 @@ if test -z "$nspr_inc" -o -z "$nspr_lib"; then
       nspr_inc=`$PKG_CONFIG --cflags-only-I nspr`
       nspr_lib=`$PKG_CONFIG --libs-only-L nspr`
       AC_MSG_RESULT([using system NSPR])
+    elif $PKG_CONFIG --exists dirsec-nspr; then
+      nspr_inc=`$PKG_CONFIG --cflags-only-I dirsec-nspr`
+      nspr_lib=`$PKG_CONFIG --libs-only-L dirsec-nspr`
+      AC_MSG_RESULT([using system dirsec NSPR])
     else
       AC_MSG_ERROR([NSPR not found, specify with --with-nspr.])
     fi

+ 4 - 0
m4/nss.m4

@@ -78,6 +78,10 @@ if test -z "$nss_inc" -o -z "$nss_lib"; then
       nss_inc=`$PKG_CONFIG --cflags-only-I nss`
       nss_lib=`$PKG_CONFIG --libs-only-L nss`
       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`
+      AC_MSG_RESULT([using system dirsec NSS])
     else
       AC_MSG_ERROR([NSS not found, specify with --with-nss.])
     fi

+ 27 - 1
m4/svrcore.m4

@@ -63,6 +63,32 @@ AC_ARG_WITH(svrcore-lib,
     ],
     AC_MSG_RESULT(no))
 
+dnl svrcore not given - look for pkg-config
 if test -z "$svrcore_inc" -o -z "$svrcore_lib"; then
-  AC_MSG_ERROR([svrcore not found, specify with --with-svrcore.])
+  AC_MSG_CHECKING(for svrcore with pkg-config)
+  AC_PATH_PROG(PKG_CONFIG, pkg-config)
+  if test -n "$PKG_CONFIG"; then
+    if $PKG_CONFIG --exists svrcore-devel; then
+      svrcore_inc=`$PKG_CONFIG --cflags-only-I svrcore-devel`
+      svrcore_lib=`$PKG_CONFIG --libs-only-L svrcore-devel`
+      AC_MSG_RESULT([using system svrcore])
+    fi
+  fi
+fi
+
+if test -z "$svrcore_inc" -o -z "$svrcore_lib"; then
+dnl just see if svrcore is already a system library
+  AC_CHECK_LIB([svrcore], [SVRCORE_GetRegisteredPinObj], [havesvrcore=1],
+	       [], [$nss_inc $nspr_inc $nss_lib -lnss3 -lsoftokn3 $nspr_lib -lplds4 -lplc4 -lnspr4])
+  if test -n "$havesvrcore" ; then
+dnl just see if svrcore is already a system header file
+    save_cppflags="$CPPFLAGS"
+    CPPFLAGS="$nss_inc $nspr_inc"
+    AC_CHECK_HEADER([svrcore.h], [havesvrcore=1], [havesvrcore=])
+    CPPFLAGS="$save_cppflags"
+  fi
+dnl for svrcore to be present, both the library and the header must exist
+  if test -z "$havesvrcore" ; then
+    AC_MSG_ERROR([svrcore not found, specify with --with-svrcore.])
+  fi
 fi