Add files from parent branch HEAD:
[pkgsrcv2.git] / security / openssl / buildlink.mk
1 # $NetBSD: buildlink.mk,v 1.18 2002/08/15 01:14:32 fredb Exp $
2 #
3 # This Makefile fragment is included by packages that use OpenSSL.
4 #
5 # To use this Makefile fragment, simply:
6 #
7 # (1) Optionally define USE_OPENSSL_VERSION to the mininum OpenSSL version
8 #     number in <openssl/opensslv.h>, i.e. 0x0090600fL, etc.
9 # (2) Include this Makefile fragment in the package Makefile,
10 # (3) Add ${BUILDLINK_DIR}/include to the front of the C preprocessor's header
11 #     search path, and
12 # (4) Add ${BUILDLINK_DIR}/lib to the front of the linker's library search
13 #     path.
14
15 .if !defined(OPENSSL_BUILDLINK_MK)
16 OPENSSL_BUILDLINK_MK=   # defined
17
18 .include "../../mk/bsd.buildlink.mk"
19
20 # OpenSSL version numbers from <openssl/opensslv.h>
21 OPENSSL_VERSION_095A=           0x0090581fL
22 OPENSSL_VERSION_096=            0x0090600fL
23 OPENSSL_VERSION_096A=           0x0090601fL
24 OPENSSL_VERSION_096B=           0x0090602fL
25 OPENSSL_VERSION_096D=           0x0090604fL
26 OPENSSL_VERSION_096E=           0x0090605fL
27 OPENSSL_VERSION_096F=           0x0090606fL
28 OPENSSL_VERSION_096G=           0x0090607fL
29 # Check for a usable installed version of OpenSSL. Version must be greater
30 # than 0.9.6f, or else contain a fix for the 2002-07-30 security advisory.
31 # If a usable version isn't present, then use the pkgsrc OpenSSL package.
32 #
33 .include "../../mk/bsd.prefs.mk"
34 .if ${OPSYS} == "Darwin"
35 _OPENSSLV_H=            /usr/local/include/openssl/opensslv.h
36 _SSL_H=                 /usr/local/include/openssl/ssl.h
37 .else
38 _OPENSSLV_H=            /usr/include/openssl/opensslv.h
39 _SSL_H=                 /usr/include/openssl/ssl.h
40 .endif
41
42 _NEED_OPENSSL=          YES
43 .if exists(${_OPENSSLV_H}) && exists(${_SSL_H})
44 _IN_TREE_OPENSSL_HAS_FIX!=                                      \
45                 ${AWK} 'BEGIN { ans = "NO" }                    \
46                 /SSL_R_SSL2_CONNECTION_ID_TOO_LONG/ { ans = "YES" }     \
47                 END { print ans; exit 0 }' ${_SSL_H}
48
49 . if ${_IN_TREE_OPENSSL_HAS_FIX} == "YES"
50 USE_OPENSSL_VERSION?=           ${OPENSSL_VERSION_096F}
51 . else
52 USE_OPENSSL_VERSION?=           ${OPENSSL_VERSION_096G}
53 . endif
54
55 _OPENSSL_VERSION!=      ${AWK} '/.*OPENSSL_VERSION_NUMBER.*/ { print $$3 }' \
56                                 ${_OPENSSLV_H}
57
58 _VALID_SSL_VERSIONS=    ${OPENSSL_VERSION_096F}         # OpenSSL 0.9.6f
59 # There never was a package for this; only the in-tree openssl had it.
60 #BUILDLINK_DEPENDS.openssl=     openssl>=0.9.6f
61
62 . if ${USE_OPENSSL_VERSION} == ${OPENSSL_VERSION_096G}  # OpenSSL 0.9.6g
63 _VALID_SSL_VERSIONS=    ${OPENSSL_VERSION_096G}
64 BUILDLINK_DEPENDS.openssl=      openssl>=0.9.6g
65 . else
66 _VALID_SSL_VERSIONS+=   ${OPENSSL_VERSION_096G}
67 . endif
68
69 . for PATTERN in ${_VALID_SSL_VERSIONS}
70 .  if ${_OPENSSL_VERSION:M${PATTERN}} != ""
71 _NEED_OPENSSL=          NO
72 .  endif
73 . endfor
74
75 .else
76
77 # Last case to consider.... there is no in-tree openssl!
78 BUILDLINK_DEPENDS.openssl=      openssl>=0.9.6g
79
80 .endif  # exists(${_OPENSSLV_H}) && exists(${_SSL_H})
81
82 .if ${_NEED_OPENSSL} == "YES"
83 BUILDLINK_DEPENDS.openssl?=     openssl>=0.9.6g
84 DEPENDS+=       ${BUILDLINK_DEPENDS.openssl}:../../security/openssl
85 EVAL_PREFIX+=   BUILDLINK_PREFIX.openssl=openssl
86 BUILDLINK_PREFIX.openssl_DEFAULT=       ${LOCALBASE}
87 SSLBASE=                        ${BUILDLINK_PREFIX.openssl}
88 .else
89 . if ${OPSYS} == "Darwin"
90 BUILDLINK_PREFIX.openssl=       /usr/local
91 SSLBASE=                        /usr/local
92 . else
93 BUILDLINK_PREFIX.openssl=       /usr
94 SSLBASE=                        /usr
95 . endif
96 .endif
97
98 .if defined(PKG_SYSCONFDIR.openssl)
99 SSLCERTS=                       ${PKG_SYSCONFDIR.openssl}/certs
100 .elif ${OPSYS} == "NetBSD"
101 SSLCERTS=                       /etc/openssl/certs
102 .else
103 SSLCERTS=                       ${PKG_SYSCONFBASE}/openssl/certs
104 .endif
105 BUILD_DEFS+=                    SSLBASE SSLCERTS
106
107 BUILDLINK_FILES.openssl=        bin/openssl
108 BUILDLINK_FILES.openssl+=       include/openssl/*
109 BUILDLINK_FILES.openssl+=       lib/libRSAglue.*
110 BUILDLINK_FILES.openssl+=       lib/libcrypto.*
111 BUILDLINK_FILES.openssl+=       lib/libssl.*
112
113 .if defined(USE_RSAREF2) && ${USE_RSAREF2} == YES
114 .include "../../security/rsaref/buildlink.mk"
115 .endif
116
117 BUILDLINK_TARGETS.openssl=      openssl-buildlink
118 BUILDLINK_TARGETS+=             ${BUILDLINK_TARGETS.openssl}
119
120 pre-configure: ${BUILDLINK_TARGETS.openssl}
121 openssl-buildlink: _BUILDLINK_USE
122
123 .endif  # OPENSSL_BUILDLINK_MK