From c19aa704c84e660c73fb45e0d3f38d0840f17823 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 5 Jul 2005 23:13:57 +0000 Subject: [PATCH] Fix contrib/pgcrypto to autoconfigure for OpenSSL when --with-openssl is used in the toplevel configure. Per Marko Kreen. --- configure | 4 +- configure.in | 3 +- contrib/pgcrypto/Makefile | 80 +++++++++++++-------------------------- src/Makefile.global.in | 4 +- 4 files changed, 34 insertions(+), 57 deletions(-) diff --git a/configure b/configure index 217c133b40..8c29ae3d51 100755 --- a/configure +++ b/configure @@ -314,7 +314,7 @@ ac_includes_default="\ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC CC_FOR_BUILD TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_bonjour with_openssl EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB LORDER TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS configure_args build build_cpu build_vendor build_os host host_cpu host_vendor host_os PORTNAME docdir enable_nls WANTED_LANGUAGES default_port enable_shared enable_rpath enable_debug CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP GCC CC_FOR_BUILD TAS autodepend INCLUDES enable_thread_safety with_tcl with_perl with_python with_krb5 krb_srvtab with_pam with_bonjour with_openssl with_zlib EGREP ELF_SYS LDFLAGS_SL AWK FLEX FLEXFLAGS LN_S LD with_gnu_ld ld_R_works RANLIB ac_ct_RANLIB LORDER TAR STRIP ac_ct_STRIP STRIP_STATIC_LIB STRIP_SHARED_LIB YACC YFLAGS PERL perl_archlibexp perl_privlibexp perl_useshrplib perl_embed_ldflags PYTHON python_version python_configdir python_includespec python_libdir python_libspec python_additional_libs HAVE_IPV6 LIBOBJS acx_pthread_config PTHREAD_CC PTHREAD_LIBS PTHREAD_CFLAGS HAVE_POSIX_SIGNALS MSGFMT MSGMERGE XGETTEXT localedir TCLSH TCL_CONFIG_SH TCL_INCLUDE_SPEC TCL_LIB_FILE TCL_LIBS TCL_LIB_SPEC TCL_SHARED_BUILD TCL_SHLIB_LD_LIBS NSGMLS JADE have_docbook DOCBOOKSTYLE COLLATEINDEX SGMLSPL vpath_build LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -3906,6 +3906,7 @@ else fi; + # # Elf # @@ -22916,6 +22917,7 @@ s,@krb_srvtab@,$krb_srvtab,;t t s,@with_pam@,$with_pam,;t t s,@with_bonjour@,$with_bonjour,;t t s,@with_openssl@,$with_openssl,;t t +s,@with_zlib@,$with_zlib,;t t s,@EGREP@,$EGREP,;t t s,@ELF_SYS@,$ELF_SYS,;t t s,@LDFLAGS_SL@,$LDFLAGS_SL,;t t diff --git a/configure.in b/configure.in index 2b3d72b895..9679b24b8f 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $PostgreSQL: pgsql/configure.in,v 1.415 2005/07/03 18:54:26 petere Exp $ +dnl $PostgreSQL: pgsql/configure.in,v 1.416 2005/07/05 23:13:57 tgl Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -500,6 +500,7 @@ fi # PGAC_ARG_BOOL(with, zlib, yes, [ --without-zlib do not use Zlib]) +AC_SUBST(with_zlib) # # Elf diff --git a/contrib/pgcrypto/Makefile b/contrib/pgcrypto/Makefile index 5e92f92945..36ca7f5c70 100644 --- a/contrib/pgcrypto/Makefile +++ b/contrib/pgcrypto/Makefile @@ -1,59 +1,26 @@ # -# $PostgreSQL: pgsql/contrib/pgcrypto/Makefile,v 1.14 2005/03/21 05:24:51 neilc Exp $ +# $PostgreSQL: pgsql/contrib/pgcrypto/Makefile,v 1.15 2005/07/05 23:13:57 tgl Exp $ # -# either 'builtin', 'openssl' -cryptolib = builtin +# if you don't have OpenSSL, you can use libc random() or /dev/urandom +INT_CFLAGS = -DRAND_SILLY +#INT_CFLAGS = -DRAND_DEV=\"/dev/urandom\" -# either 'builtin', 'system' -cryptsrc = builtin +INT_SRCS = md5.c sha1.c internal.c blf.c rijndael.c -# Random source, preferred order: -# 'dev' - read from random device -# -# 'openssl' - use openssl PRNG. -# Note that currently pgcrypto does not do any -# entropy feeding to it -# This works ofcouse only with cryptolib = openssl -# -# 'silly' - use libc random() - very weak -random = silly -random_dev = \"/dev/urandom\" +OSSL_CFLAGS = -DRAND_OPENSSL +OSSL_SRCS = openssl.c +OSSL_TESTS = des 3des cast5 -########################## +CF_SRCS = $(if $(subst no,,$(with_openssl)), $(OSSL_SRCS), $(INT_SRCS)) +CF_TESTS = $(if $(subst no,,$(with_openssl)), $(OSSL_TESTS)) +CF_CFLAGS = $(if $(subst no,,$(with_openssl)), $(OSSL_CFLAGS), $(INT_CFLAGS)) -ifeq ($(cryptolib), builtin) -CRYPTO_CFLAGS = -CRYPTO_LDFLAGS = -SRCS = md5.c sha1.c internal.c blf.c rijndael.c -EXTRA_TESTS = -endif +PG_CPPFLAGS := $(CF_CFLAGS) -I$(srcdir) $(PG_CPPFLAGS) -ifeq ($(cryptolib), openssl) -CRYPTO_CFLAGS = -I/usr/include/openssl -CRYPTO_LDFLAGS = -lcrypto -SRCS = openssl.c -EXTRA_TESTS = des 3des cast5 -endif - -ifeq ($(cryptsrc), builtin) -SRCS += crypt-blowfish.c crypt-des.c crypt-md5.c -else -CRYPTO_CFLAGS += -DPX_SYSTEM_CRYPT -endif - -ifeq ($(random), dev) -CRYPTO_CFLAGS += -DRAND_DEV=$(random_dev) -endif -ifeq ($(random), openssl) -CRYPTO_CFLAGS += -DRAND_OPENSSL -endif -ifeq ($(random), silly) -CRYPTO_CFLAGS += -DRAND_SILLY -endif - -SRCS += pgcrypto.c px.c px-hmac.c px-crypt.c misc.c \ - crypt-gensalt.c random.c +SRCS = pgcrypto.c px.c px-hmac.c px-crypt.c misc.c random.c \ + crypt-gensalt.c crypt-blowfish.c crypt-des.c \ + crypt-md5.c $(CF_SRCS) MODULE_big = pgcrypto OBJS = $(SRCS:.c=.o) @@ -61,12 +28,9 @@ DOCS = README.pgcrypto DATA_built = pgcrypto.sql EXTRA_CLEAN = gen-rtab -PG_CPPFLAGS = $(CRYPTO_CFLAGS) -I$(srcdir) -SHLIB_LINK = $(CRYPTO_LDFLAGS) - REGRESS = init md5 sha1 hmac-md5 hmac-sha1 blowfish rijndael \ - $(EXTRA_TESTS) \ - crypt-des crypt-md5 crypt-blowfish crypt-xdes + $(CF_TESTS) \ + crypt-des crypt-md5 crypt-blowfish crypt-xdes ifdef USE_PGXS @@ -79,6 +43,14 @@ include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk endif +# Add libraries that pgcrypto depends (or might depend) on into the +# shared library link. (The order in which you list them here doesn't +# matter.) +SHLIB_LINK += $(filter -lcrypt -ldes -lcrypto -lssl, $(LIBS)) +ifeq ($(PORTNAME), win32) +SHLIB_LINK += $(filter -leay32 -lssleay32, $(LIBS)) +endif + # to make ws2_32.lib the last library (must occur after definition of PORTNAME) ifeq ($(PORTNAME),win32) SHLIB_LINK += -lwsock32 -lws2_32 @@ -87,6 +59,6 @@ endif rijndael.o: rijndael.tbl -rijndael.tbl: +rijndael.tbl: rijndael.c $(CC) $(CPPFLAGS) $(CFLAGS) -DPRINT_TABS rijndael.c -o gen-rtab ./gen-rtab > rijndael.tbl diff --git a/src/Makefile.global.in b/src/Makefile.global.in index f537682569..0735ecdcc4 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -1,5 +1,5 @@ # -*-makefile-*- -# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.215 2005/07/03 18:54:28 petere Exp $ +# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.216 2005/07/05 23:13:57 tgl Exp $ #------------------------------------------------------------------------------ # All PostgreSQL makefiles include this file and use the variables it sets, @@ -128,6 +128,8 @@ pgxsdir = $(pkglibdir)/pgxs with_perl = @with_perl@ with_python = @with_python@ with_tcl = @with_tcl@ +with_openssl = @with_openssl@ +with_zlib = @with_zlib@ enable_shared = @enable_shared@ enable_rpath = @enable_rpath@ enable_nls = @enable_nls@