View | Details | Raw Unified | Return to bug 168
Collapse All | Expand All

(-)configure.ac.orig (-149 / +32 lines)
Lines 702-870 Link Here
702
	)
702
	)
703
fi
703
fi
704
704
705
# The big search for OpenSSL
705
# Search for OpenSSL
706
saved_CPPFLAGS="$CPPFLAGS"
707
saved_LDFLAGS="$LDFLAGS"
706
AC_ARG_WITH(ssl-dir,
708
AC_ARG_WITH(ssl-dir,
707
	[  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
709
	[  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
708
	[
710
	[
709
		if test "x$withval" != "xno" ; then
711
		if test "x$withval" != "xno" ; then
710
			tryssldir=$withval
712
			if test -d "$withval/lib"; then
711
		fi
713
				if test -n "${need_dash_r}"; then
712
	]
714
					LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
713
)
715
				else
714
716
					LDFLAGS="-L${withval}/lib ${LDFLAGS}"
715
saved_LIBS="$LIBS"
716
saved_LDFLAGS="$LDFLAGS"
717
saved_CPPFLAGS="$CPPFLAGS"
718
if test "x$prefix" != "xNONE" ; then
719
	tryssldir="$tryssldir $prefix"
720
fi
721
AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
722
	for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
723
		CPPFLAGS="$saved_CPPFLAGS"
724
		LDFLAGS="$saved_LDFLAGS"
725
		LIBS="$saved_LIBS -lcrypto"
726
		
727
		# Skip directories if they don't exist
728
		if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
729
			continue;
730
		fi
731
		if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
732
			# Try to use $ssldir/lib if it exists, otherwise 
733
			# $ssldir
734
			if test -d "$ssldir/lib" ; then
735
				LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
736
				if test ! -z "$need_dash_r" ; then
737
					LDFLAGS="-R$ssldir/lib $LDFLAGS"
738
				fi
717
				fi
739
			else
718
			else
740
				LDFLAGS="-L$ssldir $saved_LDFLAGS"
719
				if test -n "${need_dash_r}"; then
741
				if test ! -z "$need_dash_r" ; then
720
					LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
742
					LDFLAGS="-R$ssldir $LDFLAGS"
721
				else
722
					LDFLAGS="-L${withval} ${LDFLAGS}"
743
				fi
723
				fi
744
			fi
724
			fi
745
			# Try to use $ssldir/include if it exists, otherwise 
725
			if test -d "$withval/include"; then
746
			# $ssldir
726
				CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
747
			if test -d "$ssldir/include" ; then
748
				CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
749
			else
727
			else
750
				CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
728
				CPPFLAGS="-I${withval} ${CPPFLAGS}"
751
			fi
729
			fi
752
		fi
730
		fi
753
731
	]
754
		# Basic test to check for compatible version and correct linking
732
)
755
		# *does not* test for RSA - that comes later.
733
LIBS="-lcrypto $LIBS"
756
		AC_TRY_RUN(
734
AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
757
			[
758
#include <string.h>
759
#include <openssl/rand.h>
760
int main(void) 
761
{
762
	char a[2048];
763
	memset(a, 0, sizeof(a));
764
	RAND_add(a, sizeof(a), sizeof(a));
765
	return(RAND_status() <= 0);
766
}
767
			],
768
			[
769
				found_crypto=1
770
				break;
771
			], []
772
		)
773
774
		if test ! -z "$found_crypto" ; then
775
			break;
776
		fi
777
	done
778
779
	if test -z "$found_crypto" ; then
780
		AC_MSG_ERROR([Could not find working OpenSSL library, please install or check config.log])	
781
	fi
782
	if test -z "$ssldir" ; then
783
		ssldir="(system)"
784
	fi
785
786
	ac_cv_openssldir=$ssldir
787
])
788
789
if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "x(system)") ; then
790
	AC_DEFINE(HAVE_OPENSSL)
791
	dnl Need to recover ssldir - test above runs in subshell
792
	ssldir=$ac_cv_openssldir
793
	if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
794
		# Try to use $ssldir/lib if it exists, otherwise 
795
		# $ssldir
796
		if test -d "$ssldir/lib" ; then
797
			LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
798
			if test ! -z "$need_dash_r" ; then
799
				LDFLAGS="-R$ssldir/lib $LDFLAGS"
800
			fi
801
		else
802
			LDFLAGS="-L$ssldir $saved_LDFLAGS"
803
			if test ! -z "$need_dash_r" ; then
804
				LDFLAGS="-R$ssldir $LDFLAGS"
805
			fi
806
		fi
807
		# Try to use $ssldir/include if it exists, otherwise 
808
		# $ssldir
809
		if test -d "$ssldir/include" ; then
810
			CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
811
		else
812
			CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
813
		fi
814
	fi
815
fi
816
LIBS="$saved_LIBS -lcrypto"
817
818
# Now test RSA support
819
saved_LIBS="$LIBS"
820
AC_MSG_CHECKING([for RSA support])
821
for WANTS_RSAREF in "" 1 ; do
822
	if test -z "$WANTS_RSAREF" ; then
823
		LIBS="$saved_LIBS"
824
	else
825
		LIBS="$saved_LIBS -lRSAglue -lrsaref"
826
	fi
827
	AC_TRY_RUN([
828
#include <string.h>
829
#include <openssl/rand.h>
830
#include <openssl/rsa.h>
831
#include <openssl/bn.h>
832
#include <openssl/sha.h>
833
int main(void) 
834
{
835
	int num; RSA *key; static unsigned char p_in[] = "blahblah";
836
	unsigned char c[256], p[256];
837
	memset(c, 0, sizeof(c)); RAND_add(c, sizeof(c), sizeof(c));
838
	if ((key=RSA_generate_key(512, 3, NULL, NULL))==NULL) return(1);
839
	num = RSA_public_encrypt(sizeof(p_in) - 1, p_in, c, key, RSA_PKCS1_PADDING);
840
	return(-1 == RSA_private_decrypt(num, c, p, key, RSA_PKCS1_PADDING));
841
}
842
	],
843
	[
735
	[
844
		rsa_works=1
736
		dnl Check default openssl install dir
845
		break;
737
		if test -n "${need_dash_r}"; then
846
	], [])
738
			LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
847
done
848
LIBS="$saved_LIBS"
849
850
if test ! -z "$no_rsa" ; then
851
	AC_MSG_RESULT(disabled)
852
	RSA_MSG="disabled"
853
else
854
	if test -z "$rsa_works" ; then
855
		AC_MSG_WARN([*** No RSA support found *** ])
856
		RSA_MSG="no"
857
	else
858
		if test -z "$WANTS_RSAREF" ; then
859
			AC_MSG_RESULT(yes)
860
			RSA_MSG="yes"
861
		else
739
		else
862
			RSA_MSG="yes (using RSAref)"
740
			LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
863
			AC_MSG_RESULT(using RSAref)
864
			LIBS="$LIBS -lcrypto -lRSAglue -lrsaref"
865
		fi
741
		fi
866
	fi
742
		CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
867
fi
743
		AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
744
			[
745
				AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
746
			]
747
		)
748
	]
749
)
750
868
751
869
# Sanity check OpenSSL headers
752
# Sanity check OpenSSL headers
870
AC_MSG_CHECKING([whether OpenSSL's headers match the library])
753
AC_MSG_CHECKING([whether OpenSSL's headers match the library])

Return to bug 168