Sync Mk with ports
[dports.git] / Mk / Uses / ssl.mk
1 # $FreeBSD$
2 #
3 # Handle dependency on *ssl ports.
4 #
5 # Feature:      SSL_DEFAULT
6 # Usage:        USES=ssl
7 # Valid ARGS:   none
8 #
9 # The use can choose which ssl library he wants with:
10 #
11 # DEFAULT_VERSIONS+=    ssl=<openssl variant>
12 #
13 # Variants being base, openssl, openssl-devel, libressl, and libressl-devel.
14 #
15 # The Makefile sets these variables:
16 # OPENSSLBASE           - "/usr" or ${LOCALBASE}
17 # OPENSSLDIR            - path to openssl
18 # OPENSSLLIB            - path to the libs
19 # OPENSSLINC            - path to the matching includes
20 # OPENSSLRPATH          - rpath for dynamic linker
21 #
22 # MAKE_ENV              - extended with the variables above
23 # BUILD_DEPENDS         - are added if needed
24 # RUN_DEPENDS           - are added if needed
25 #
26 # MAINTAINER:   portmgr@FreeBSD.org
27 #
28 .if !defined(_INCLUDE_USES_SSL_MK)
29 _INCLUDE_USES_SSL_MK=   yes
30
31 .if !empty(ssl_ARGS)
32 IGNORE= "USES=ssl does not take any argument."
33 .endif
34
35 .if ${SSL_DEFAULT} == base
36 OPENSSLBASE=            /usr
37 OPENSSLDIR?=            /etc/ssl
38
39 .  if !exists(${DESTDIR}/usr/lib/libcrypto.so)
40 check-depends::
41         @${ECHO_CMD} "Dependency error: This port requires the OpenSSL library, which is part of"
42         @${ECHO_CMD} "the FreeBSD crypto distribution, but not installed on your"
43         @${ECHO_CMD} "machine. Please see the \"OpenSSL\" section in the handbook"
44         @${ECHO_CMD} "(at \"http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/openssl.html\", for instance)"
45         @${ECHO_CMD} "for instructions on how to obtain and install the FreeBSD"
46         @${ECHO_CMD} "OpenSSL distribution."
47         @${FALSE}
48 .  endif
49 .  if exists(${LOCALBASE}/lib/libcrypto.so)
50 check-depends::
51         @${ECHO_CMD} "Dependency error: This port wants the OpenSSL library from the FreeBSD"
52         @${ECHO_CMD} "base system. You can't build against it, while a newer"
53         @${ECHO_CMD} "version is installed by a port."
54         @${ECHO_CMD} "Please deinstall the port, remove DEFAULT_VERSIONS=ssl=base or undefine WITH_OPENSSL_BASE."
55         @${FALSE}
56 .  endif
57
58 # OpenSSL in the base system may not include IDEA for patent licensing reasons.
59 .  if defined(MAKE_IDEA) && !defined(OPENSSL_IDEA)
60 OPENSSL_IDEA=           ${MAKE_IDEA}
61 .  else
62 OPENSSL_IDEA?=          NO
63 .  endif
64
65 .  if ${OPENSSL_IDEA} == "NO"
66 # XXX This is a hack to work around the fact that /etc/make.conf clobbers
67 #     our CFLAGS. It might not be enough for all future ports.
68 .    if defined(HAS_CONFIGURE)
69 CFLAGS+=                -DNO_IDEA
70 .    else
71 OPENSSL_CFLAGS+=        -DNO_IDEA
72 .    endif
73 MAKE_ARGS+=             OPENSSL_CFLAGS="${OPENSSL_CFLAGS}"
74 .  endif
75
76 .else # ${SSL_DEFAULT} != base
77
78 OPENSSLBASE=            ${LOCALBASE}
79
80 OPENSSL_PORT=           security/${SSL_DEFAULT}
81
82 # Get OPENSSL_SHLIBVER from the port
83 .sinclude <${PORTSDIR}/${OPENSSL_PORT}/version.mk>
84
85 .  if !defined(OPENSSL_SHLIBVER)
86 .error You are using an unsupported SSL provider ${SSL_DEFAULT}
87 .  endif
88
89 OPENSSLDIR?=            ${OPENSSLBASE}/openssl
90 BUILD_DEPENDS+=         ${LOCALBASE}/lib/libcrypto.so.${OPENSSL_SHLIBVER}:${OPENSSL_PORT}
91 RUN_DEPENDS+=           ${LOCALBASE}/lib/libcrypto.so.${OPENSSL_SHLIBVER}:${OPENSSL_PORT}
92 OPENSSLRPATH=           ${LOCALBASE}/lib
93
94 .endif
95
96 OPENSSLLIB=             ${OPENSSLBASE}/lib
97 OPENSSLINC=             ${OPENSSLBASE}/include
98
99 MAKE_ENV+=              OPENSSLBASE=${OPENSSLBASE}
100 MAKE_ENV+=              OPENSSLDIR=${OPENSSLDIR}
101 MAKE_ENV+=              OPENSSLINC=${OPENSSLINC}
102 MAKE_ENV+=              OPENSSLLIB=${OPENSSLLIB}
103
104 .if defined(OPENSSLRPATH)
105 .  if defined(USE_OPENSSL_RPATH)
106 CFLAGS+=                -Wl,-rpath,${OPENSSLRPATH}
107 .  endif
108 MAKE_ENV+=              OPENSSLRPATH=${OPENSSLRPATH}
109 OPENSSL_LDFLAGS+=       -Wl,-rpath,${OPENSSLRPATH}
110 .endif
111
112 LDFLAGS+=               ${OPENSSL_LDFLAGS}
113
114 .endif