$NetBSD: patch-aa,v 1.11 2000/09/04 11:20:59 itojun Exp $

--- configure.in.orig	Thu Aug 31 07:20:05 2000
+++ configure.in	Mon Sep  4 20:16:40 2000
@@ -234,6 +234,6 @@
 # Checks for header files.
-AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h lastlog.h limits.h login.h login_cap.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h)
+AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h lastlog.h limits.h login.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h)
 
 dnl    Checks for library functions.
-AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage getttyent inet_aton inet_ntoa innetgr login_getcapbool md5_crypt memmove mkdtemp on_exit openpty rresvport_af setenv seteuid setlogin setproctitle setreuid sigaction sigvec snprintf strerror strlcat strlcpy strsep vsnprintf vhangup _getpty __b64_ntop)
+AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock freeaddrinfo gai_strerror getaddrinfo getnameinfo getrusage getttyent inet_aton inet_ntoa innetgr md5_crypt memmove mkdtemp on_exit openpty rresvport_af setenv seteuid setlogin setproctitle setreuid sigaction sigvec snprintf strerror strlcat strlcpy strsep vsnprintf vhangup _getpty __b64_ntop)
 dnl    Checks for time functions
@@ -337,2 +337,3 @@
 saved_CFLAGS="$CFLAGS"
+crypto_LIBS=""
 if test "x$prefix" != "xNONE" ; then
@@ -353,8 +354,21 @@
 
-		LIBS="$saved_LIBS -lcrypto"
-
-		# Basic test to check for compatible version and correct linking
-		# *does not* test for RSA - that comes later.
-		AC_TRY_RUN(
-			[
+		# Some ELF systems can't resolve all the symbols in libcrypto
+		# if libcrypto was linked against RSAREF, and fail to link the
+		# test program correctly, even though a correct installation
+		# of OpenSSL exists.  So we test the linking three times in
+		# case the RSAREF libraries are needed right away.  We'll test
+		# for them explicitly later on.
+		#
+		for libcrypto in \
+			"-lcrypto" \
+			"-lcrypto -lrsaref" \
+			"-lcrypto -lRSAglue -lrsaref"
+		do
+			LIBS="$saved_LIBS $libcrypto"
+
+			# Basic test to check for compatible version and
+			# correct linking *does not* test for RSA - that comes
+			# later.
+			AC_TRY_RUN(
+				[
 #include <string.h>
@@ -368,8 +382,10 @@
 }
-			],
-			[
-				found_crypto=1
-				break;
-			], []
-		)
+				],
+				[
+					found_crypto=1
+					crypto_LIBS=$libcrypto
+					break;
+				], []
+			)
+		done
 
@@ -403,3 +419,3 @@
 fi
-LIBS="$saved_LIBS -lcrypto"
+LIBS="$saved_LIBS $crypto_LIBS"
 
