These distributions use pkg-config, a program that lets package makers tell the build system what libraries are needed to build correctly against the package. For openssl on RedHat 9, for example:
prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: OpenSSL Description: Secure Sockets Layer and cryptography libraries and tools Version: 0.9.7a Requires: Libs: -L${libdir} -lssl -lcrypto -L/usr/kerberos/lib -lgssapi_krb5 -lkrb5 -lcom_err -lk5crypto -lresolv -L/usr/kerberos/lib -ldl -lz Cflags: -I${includedir} -I/usr/kerberos/include
My impression is that there are other distributions and platforms that use pkg-config as well, so my patch should build correctly on those as well.
If pkg-config is not present, configure will use the 'openssl_prefix' variable as it already does.
The fix also moves the logic for setting the positions of the OpenSSL libraries from a number of Makefile.am files into the corresponding configure.in files, and fixes a small problem with Makefile.devel where it did not call aclocal at the top level.
If any of you can try this out on your platforms to make sure I haven't broken you, much obliged.
Thanks, Rob Thorne Torenware Networks
? changes.patch Index: Makefile.devel =================================================================== RCS file: /cvsroot/openca/openca-0.9/Makefile.devel,v retrieving revision 1.3 diff -r1.3 Makefile.devel 73a74 > aclocal Index: configure.in =================================================================== RCS file: /cvsroot/openca/openca-0.9/configure.in,v retrieving revision 1.156 diff -r1.156 configure.in 75a76,82 > dnl > dnl RMT: note this is not really what we want. We want to > dnl know how to build with Openssl; the prefix is just a > dnl (invalid!) hack to get at this information. What we > dnl *really* want are the CFLAGs and LIBS for the package. > dnl > 401a409,462 > > dnl Now we like the version of openssl. Let's construct > dnl the build flags for using it. If we find pkg-config > dnl on the system and openssl uses it, we will take > dnl our settings from there. If not, we'll make > dnl our best guess from what we do know. > > dnl Defaults > openssl_cflags= > openssl_libs=-lcrypto -lssl > > dnl Use the pkg-config macros if the > dnl developer has them on their system. > dnl We also test to make sure the install > dnl target has the needed pkg-config program > dnl as well. > ifdef([PKG_CHECK_MODULES], > [ > AC_CHECK_PROG( HAS_PKGCONF, pkg-config, yes, [] , $PATH) > if [[ x${HAS_PKGCONF} != x ]]; then > PKG_CHECK_MODULES( OPENSSL,openssl, [ > AC_MSG_RESULT( [openssl found via pkgconfig]) > openssl_cflags=$OPENSSL_CFLAGS > openssl_libs=$OPENSSL_LIBS > openssl_setup=yes > > ], > [ > AC_MSG_RESULT( [openssl not installed with pkgconfig]) > ]) > fi > ], > [ > ] > )dnl > > if [[ x${openssl_setup} != xyes ]]; then > if [[ x${openssl_prefix} != x ]]; then > openssl_cflags=-I$(openssl_prefix)/include > openssl_libs=-L$(openssl_prefix)/lib -L$(openssl_prefix) -lcrypto -lssl > openssl_setup=yes > else > AC_MSG_WARN( [Unable to find headers for openssl]) > fi > fi > > dnl Flags compatible with what pkgcheck will > dnl give us on RedHat Linux and similar distributions. > dnl Prefix won't cut it, since newer versions link > dnl kerberos as well. > AC_SUBST(openssl_cflags) > AC_SUBST(openssl_libs) > > Index: src/musclecard-engine/Makefile.am =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/musclecard-engine/Makefile.am,v retrieving revision 1.1 diff -r1.1 Makefile.am 30a31,32 > openssl_libs = @openssl_libs@ > openssl_cflags = @openssl_cflags@ Index: src/musclecard-engine/src/Makefile.am =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/musclecard-engine/src/Makefile.am,v retrieving revision 1.1 diff -r1.1 Makefile.am 7c7,9 < OPENSSL_PREFIX = @openssl_prefix@ --- > #OPENSSL_PREFIX = @openssl_prefix@ > OPENSSL_INCLUDE = @openssl_cflags@ > OPENSSL_LIBS = @openssl_libs@ 15,22c17,25 < < if OPENSSL_PREFIX < OPENSSL_INCLUDE_LIBS = -L$(OPENSSL_PREFIX)/lib -L$(OPENSSL_PREFIX) < OPENSSL_INCLUDE = -I$(OPENSSL_PREFIX)/include < OPENSSL_LIBS = -lcrypto -lssl < else < OPENSSL_INCLUDE_LIBS = < OPENSSL_LIBS = -lcrypto -lssl --- > if 0 > if OPENSSL_PREFIX > OPENSSL_INCLUDE_LIBS = -L$(OPENSSL_PREFIX)/lib -L$(OPENSSL_PREFIX) > OPENSSL_INCLUDE = -I$(OPENSSL_PREFIX)/include > OPENSSL_LIBS = -lcrypto -lssl > else > OPENSSL_INCLUDE_LIBS = > OPENSSL_LIBS = -lcrypto -lssl > endif Index: src/ocspd/Makefile.am =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/ocspd/Makefile.am,v retrieving revision 1.2 diff -r1.2 Makefile.am 30a31,32 > openssl_libs = @openssl_libs@ > openssl_cflags = @openssl_cflags@ Index: src/ocspd/configure.in =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/ocspd/configure.in,v retrieving revision 1.4 diff -r1.4 configure.in 126a127,181 > dnl Now we like the version of openssl. Let's construct > dnl the build flags for using it. If we find pkg-config > dnl on the system and openssl uses it, we will take > dnl our settings from there. If not, we'll make > dnl our best guess from what we do know. > > dnl Defaults > openssl_cflags="" > openssl_libs=-lcrypto -lssl > > dnl Use the pkg-config macros if the > dnl developer has them on their system. > dnl We also test to make sure the install > dnl target has the needed pkg-config program > dnl as well. > ifdef([PKG_CHECK_MODULES], > [ > AC_CHECK_PROG( HAS_PKGCONF, pkg-config, yes, [] , $PATH) > if [[ x${HAS_PKGCONF} != x ]]; then > PKG_CHECK_MODULES(OPENSSL,openssl, [ > AC_MSG_RESULT([openssl found via pkgconfig]) > openssl_cflags=$OPENSSL_CFLAGS > openssl_libs=$OPENSSL_LIBS > openssl_setup=yes > > ], > [ > AC_MSG_RESULT([openssl not installed with pkgconfig]) > ]) > fi > ], > [ > ] > )dnl > > > > if [[ x${openssl_setup} != xyes ]]; then > if [[ x${openssl_prefix} != x ]]; then > openssl_cflags=-I$(openssl_prefix)/include > openssl_libs=-L$(openssl_prefix)/lib -L$(openssl_prefix) -lcrypto -lssl > openssl_setup=yes > else > AC_MSG_WARN([[Unable to find headers for openssl]]) > fi > fi > > dnl Flags compatible with what pkgcheck will > dnl give us on RedHat Linux and similar distributions. > dnl Prefix won't cut it, since newer versions link > dnl kerberos as well. > AC_SUBST(openssl_cflags) > AC_SUBST(openssl_libs) > > Index: src/ocspd/src/Makefile.am =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/ocspd/src/Makefile.am,v retrieving revision 1.5 diff -r1.5 Makefile.am 7a8,9 > OPENSSL_INCLUDE = @openssl_cflags@ > OPENSSL_LIBS = @openssl_libs@ 10,17d11 < if OPENSSL_PREFIX < OPENSSL_INCLUDE_LIBS = -L$(OPENSSL_PREFIX)/lib -L$(OPENSSL_PREFIX) < OPENSSL_INCLUDE = -I$(OPENSSL_PREFIX)/include < OPENSSL_LIBS = -lcrypto -lssl < else < OPENSSL_INCLUDE_LIBS = < OPENSSL_LIBS = -lcrypto -lssl < endif Index: src/openca-sv/Makefile.am =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/openca-sv/Makefile.am,v retrieving revision 1.1 diff -r1.1 Makefile.am 30a31,33 > openssl_libs = @openssl_libs@ > openssl_cflags = @openssl_cflags@ > Index: src/openca-sv/configure.in =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/openca-sv/configure.in,v retrieving revision 1.3 diff -r1.3 configure.in 114a115,168 > dnl Now we like the version of openssl. Let's construct > dnl the build flags for using it. If we find pkg-config > dnl on the system and openssl uses it, we will take > dnl our settings from there. If not, we'll make > dnl our best guess from what we do know. > > dnl Defaults > openssl_cflags="" > openssl_libs=-lcrypto -lssl > > > dnl Use the pkg-config macros if the > dnl developer has them on their system. > dnl We also test to make sure the install > dnl target has the needed pkg-config program > dnl as well. > ifdef([PKG_CHECK_MODULES], > [ > AC_CHECK_PROG( HAS_PKGCONF, pkg-config, yes, [] , $PATH) > if [[ x${HAS_PKGCONF} != x ]]; then > PKG_CHECK_MODULES(OPENSSL,openssl, [ > AC_MSG_RESULT([openssl found via pkgconfig]) > openssl_cflags=$OPENSSL_CFLAGS > openssl_libs=$OPENSSL_LIBS > openssl_setup=yes > > ], > [ > AC_MSG_RESULT([openssl not installed with pkgconfig]) > ]) > fi > ], > [ > ] > )dnl > > if [[ x${openssl_setup} != xyes ]]; then > if [[ x${openssl_prefix} != x ]]; then > openssl_cflags=-I$(openssl_prefix)/include > openssl_libs=-L$(openssl_prefix)/lib -L$(openssl_prefix) -lcrypto -lssl > openssl_setup=yes > else > AC_MSG_WARN( [Unable to find headers for openssl] ) > fi > fi > > dnl Flags compatible with what pkgcheck will > dnl give us on RedHat Linux and similar distributions. > dnl Prefix won't cut it, since newer versions link > dnl kerberos as well. > AC_SUBST(openssl_cflags) > AC_SUBST(openssl_libs) > > Index: src/openca-sv/src/Makefile.am =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/openca-sv/src/Makefile.am,v retrieving revision 1.5 diff -r1.5 Makefile.am 8,11c8,10 < if OPENSSL_PREFIX < OPENSSL_INCLUDE_LIBS = [EMAIL PROTECTED]@/lib [EMAIL PROTECTED]@ < OPENSSL_INCLUDES = [EMAIL PROTECTED]@/include < endif --- > OPENSSL_INCLUDE = @openssl_cflags@ > OPENSSL_LIBS = @openssl_libs@ > 42c41 < OPENSSL_LIBS = -lcrypto --- > #OPENSSL_LIBS = -lcrypto Index: src/scep/Makefile.am =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/scep/Makefile.am,v retrieving revision 1.1 diff -r1.1 Makefile.am 30a31,32 > openssl_libs = @openssl_libs@ > openssl_cflags = @openssl_cflags@ Index: src/scep/src/Makefile.am =================================================================== RCS file: /cvsroot/openca/openca-0.9/src/scep/src/Makefile.am,v retrieving revision 1.11 diff -r1.11 Makefile.am 7a8,9 > OPENSSL_INCLUDE = @openssl_cflags@ > OPENSSL_LIBS = @openssl_libs@ 16,23d17 < if OPENSSL_PREFIX < OPENSSL_INCLUDE_LIBS = -L$(OPENSSL_PREFIX)/lib -L$(OPENSSL_PREFIX) < OPENSSL_INCLUDE = -I$(OPENSSL_PREFIX)/include < OPENSSL_LIBS = -lcrypto -lssl -ldl -ll < else < OPENSSL_INCLUDE_LIBS = < OPENSSL_LIBS = -lcrypto -lssl < endif