[Patch] ssl support with pkgconfig

Kevin Sonney <[email protected]> 09 May 2003 09:20:15 -0400
Newsgroups gmane.network.irc.irssi.devel
Organization Red Hat, Inc
Message-ID <[email protected]>
Hello all -

On Red Hat Linux 9, OpenSSL is linked against kerberos. Unfortunately,
the default flags (-lssl -lcrypto) aren't complete enough to pull in all
the other needed libraries for this.

pkgconfig addresses this by supplying the proper include paths and link
libraries for openssl. 

The attached patch will attempt to get this information from pkgconfig,
and failing that, default to -lssl -lcrypto. 

I've incorporated this patch into the RPM package I have at
ftp://people.redhat.com/ksonney/SRPMS

Enjoy!

-- 
------------------------------------------
-- Kevin Sonney - Inside Sales Engineer --
--  Red Hat, Inc - 919.754.3700 x44112  --
--  [email protected] - AIM: ksonney   --
------------------------------------------
1024D/EB74 3C54 0260 6A01 705A  6F3F CD3B BAF1 4EB9 55BC
 It's not stupid...it's ADVANCED -- All Mighty Tallest Red (Invader Zim
 Ep 1)
irssi-sslfix.patch (text/plain, 2.3 KB)
--- irssi-0.8.6.CVS/configure.in	2003-01-24 22:30:02.000000000 -0500
+++ irssi-0.8.6.CVS-fixed/configure.in	2003-02-28 12:19:29.000000000 -0500
@@ -420,7 +420,9 @@
     if test $try = 1 -o $try = 2; then
       AM_PATH_GLIB(1.2.0,,, $glib_modules)
     else
-      AM_PATH_GLIB_2_0(2.0.0,,, $glib_modules)
+      if test $try = 3 -o $try = 4; then
+        AM_PATH_GLIB_2_0(2.0.0,,, $glib_modules)
+      fi
     fi
     if test "$GLIB_LIBS"; then
       if test $glib_modules = gmodule; then
@@ -479,26 +481,34 @@
 	###
 	### Check for OpenSSL
 	###
-	save_CFLAGS=$CFLAGS;
-	CFLAGS="-lcrypto";
-
+	save_CFLAGS="$CFLAGS";
+    save_LIBS="$LIBS"
 	enable_openssl="no"; 
-	OPENSSL_LDFLAGS="";
-	AC_CHECK_LIB(ssl, SSL_read, [
-	  AC_CHECK_LIB(crypto, X509_new, [
-	    AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h, [
-	      enable_openssl="yes";
-	      OPENSSL_LDFLAGS="-lssl -lcrypto"
+    OPENSSL_LDFLAGS="-lssl -lcrypto" 
+    OPENSSL_CFLAGS="$openssl_inc_prefix"	
+    PKG_CHECK_MODULES(OPENSSL, openssl, 
+      [ AC_MSG_RESULT(["found via pkgconfig"])
+        enable_openssl="yes" 
+      ],
+      [	AC_CHECK_LIB(ssl, SSL_read, [
+	      AC_CHECK_LIB(crypto, X509_new, [
+	        AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h, [
+	          enable_openssl="yes";
+	          OPENSSL_LDFLAGS="-lssl -lcrypto"
+              OPENSSL_CFLAGS="$openssl_inc_prefix"
+	        ])
+	      ])
 	    ])
-	  ])
-	])
-	CFLAGS=$save_CFLAGS
-
+      ]
+    )
 	if test "x$enable_openssl" = xyes; then
 		AC_DEFINE(HAVE_OPENSSL)
-
-		LIBS="$LIBS -L$openssl_prefix $OPENSSL_LDFLAGS"
-		CFLAGS="$CFLAGS $openssl_inc_prefix"
+		LIBS="$LIBS  $OPENSSL_LDFLAGS"
+		CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
+    else 
+  	    CFLAGS=$save_CFLAGS
+        LIBS=$save_LIBS
+        enable_ssl="no"
 	fi
 else
 	enable_openssl="no"
@@ -748,7 +758,7 @@
 		if test "x$want_perl" = "xstatic"; then
 			dnl * building with static perl support
 			dnl * all PERL_LDFLAGS linking is done in fe-text
-			PERL_LINK_FLAGS="$PERL_LDFLAGS"
+			PERL_LINK_FLAGS="$PERL_LDFLAGS $LDFLAGS"
 			PERL_LINK_LIBS="../perl/libperl_core_static.la"
 			PERL_FE_LINK_LIBS="../perl/libfe_perl_static.la"
 			PERL_LDFLAGS=
@@ -794,7 +804,7 @@
 
 		AC_SUBST(PERL_LINK_FLAGS)
 		AC_SUBST(PERL_LINK_LIBS)
-                AC_SUBST(PERL_FE_LINK_LIBS)
+        AC_SUBST(PERL_FE_LINK_LIBS)
 
 		AC_SUBST(PERL_LDFLAGS)
 		AC_SUBST(PERL_CFLAGS)
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQA+u6sOzTu68U65VbwRAm9hAJ9zGHOTMj4OG0GTrDe4RS42ZYDcnQCePdgv
BgqWv82oeFcVZrMuxFKIqsI=
=+8KX
-----END PGP SIGNATURE-----