11#
2- # $PostgreSQL: pgsql/contrib/pgcrypto/Makefile,v 1.14 2005/03/21 05:24:51 neilc Exp $
2+ # $PostgreSQL: pgsql/contrib/pgcrypto/Makefile,v 1.15 2005/07/05 23:13:57 tgl Exp $
33#
44
5- # either 'builtin', 'openssl'
6- cryptolib = builtin
5+ # if you don't have OpenSSL, you can use libc random() or /dev/urandom
6+ INT_CFLAGS = -DRAND_SILLY
7+ # INT_CFLAGS = -DRAND_DEV=\"/dev/urandom\"
78
8- # either 'builtin', 'system'
9- cryptsrc = builtin
9+ INT_SRCS = md5.c sha1.c internal.c blf.c rijndael.c
1010
11- # Random source, preferred order:
12- # 'dev' - read from random device
13- #
14- # 'openssl' - use openssl PRNG.
15- # Note that currently pgcrypto does not do any
16- # entropy feeding to it
17- # This works ofcouse only with cryptolib = openssl
18- #
19- # 'silly' - use libc random() - very weak
20- random = silly
21- random_dev = \"/dev/urandom\"
11+ OSSL_CFLAGS = -DRAND_OPENSSL
12+ OSSL_SRCS = openssl.c
13+ OSSL_TESTS = des 3des cast5
2214
23- # #########################
24-
25- ifeq ($(cryptolib ) , builtin)
26- CRYPTO_CFLAGS =
27- CRYPTO_LDFLAGS =
28- SRCS = md5.c sha1.c internal.c blf.c rijndael.c
29- EXTRA_TESTS =
30- endif
15+ CF_SRCS =$(if $(subst no,,$(with_openssl ) ) ,$(OSSL_SRCS ) ,$(INT_SRCS ) )
16+ CF_TESTS =$(if $(subst no,,$(with_openssl ) ) ,$(OSSL_TESTS ) )
17+ CF_CFLAGS =$(if $(subst no,,$(with_openssl ) ) ,$(OSSL_CFLAGS ) ,$(INT_CFLAGS ) )
3118
32- ifeq ($(cryptolib ) , openssl)
33- CRYPTO_CFLAGS = -I/usr/include/openssl
34- CRYPTO_LDFLAGS = -lcrypto
35- SRCS = openssl.c
36- EXTRA_TESTS = des 3des cast5
37- endif
19+ PG_CPPFLAGS :=$(CF_CFLAGS ) -I$(srcdir ) $(PG_CPPFLAGS )
3820
39- ifeq ($(cryptsrc ) , builtin)
40- SRCS += crypt-blowfish.c crypt-des.c crypt-md5.c
41- else
42- CRYPTO_CFLAGS += -DPX_SYSTEM_CRYPT
43- endif
44-
45- ifeq ($(random ) , dev)
46- CRYPTO_CFLAGS += -DRAND_DEV=$(random_dev )
47- endif
48- ifeq ($(random ) , openssl)
49- CRYPTO_CFLAGS += -DRAND_OPENSSL
50- endif
51- ifeq ($(random ) , silly)
52- CRYPTO_CFLAGS += -DRAND_SILLY
53- endif
54-
55- SRCS += pgcrypto.c px.c px-hmac.c px-crypt.c misc.c\
56- crypt-gensalt.c random.c
21+ SRCS = pgcrypto.c px.c px-hmac.c px-crypt.c misc.c random.c\
22+ crypt-gensalt.c crypt-blowfish.c crypt-des.c\
23+ crypt-md5.c$(CF_SRCS )
5724
5825MODULE_big = pgcrypto
5926OBJS =$(SRCS:.c=.o )
6027DOCS = README.pgcrypto
6128DATA_built = pgcrypto.sql
6229EXTRA_CLEAN = gen-rtab
6330
64- PG_CPPFLAGS =$(CRYPTO_CFLAGS ) -I$(srcdir )
65- SHLIB_LINK =$(CRYPTO_LDFLAGS )
66-
6731REGRESS = init md5 sha1 hmac-md5 hmac-sha1 blowfish rijndael\
68- $( EXTRA_TESTS )\
69- crypt-des crypt-md5 crypt-blowfish crypt-xdes
32+ $( CF_TESTS )\
33+ crypt-des crypt-md5 crypt-blowfish crypt-xdes
7034
7135
7236ifdef USE_PGXS
@@ -79,6 +43,14 @@ include $(top_builddir)/src/Makefile.global
7943include $(top_srcdir ) /contrib/contrib-global.mk
8044endif
8145
46+ # Add libraries that pgcrypto depends (or might depend) on into the
47+ # shared library link. (The order in which you list them here doesn't
48+ # matter.)
49+ SHLIB_LINK +=$(filter -lcrypt -ldes -lcrypto -lssl,$(LIBS ) )
50+ ifeq ($(PORTNAME ) , win32)
51+ SHLIB_LINK +=$(filter -leay32 -lssleay32,$(LIBS ) )
52+ endif
53+
8254# to make ws2_32.lib the last library (must occur after definition of PORTNAME)
8355ifeq ($(PORTNAME ) ,win32)
8456SHLIB_LINK += -lwsock32 -lws2_32
8759
8860rijndael.o : rijndael.tbl
8961
90- rijndael.tbl :
62+ rijndael.tbl : rijndael.c
9163$(CC ) $(CPPFLAGS ) $(CFLAGS ) -DPRINT_TABS rijndael.c -o gen-rtab
9264./gen-rtab> rijndael.tbl