Update net/ortp to version 0.23.0_1
[dports.git] / Mk / bsd.openssl.mk
1 #
2 # $FreeBSD$
3 # bsd.openssl.mk - Support for OpenSSL based ports.
4 #
5 # Use of 'USE_OPENSSL=yes' includes this Makefile after bsd.ports.pre.mk
6 #
7 # the user/port can now set this options in the makefiles.
8 #
9 # WITH_OPENSSL_BASE=yes - Use the version in the base system.
10 # WITH_OPENSSL_PORT=yes - Use the OpenSSL port, even if base is up to date
11 #
12 # USE_OPENSSL_RPATH=yes - Pass RFLAGS options in CFLAGS,
13 #                         needed for ports who don't use LDFLAGS
14 #
15 # Overrideable defaults:
16 #
17 # OPENSSL_SHLIBVER=     8
18 # OPENSSL_PORT=         security/openssl
19 #
20 # The makefile sets this variables:
21 # OPENSSLBASE           - "/usr" or ${LOCALBASE}
22 # OPENSSLDIR            - path to openssl
23 # OPENSSLLIB            - path to the libs
24 # OPENSSLINC            - path to the matching includes
25 # OPENSSLRPATH          - rpath for dynamic linker
26 #
27 # MAKE_ENV              - extended with the variables above
28 # CONFIGURE_ENV         - extended with LDFLAGS
29 # BUILD_DEPENDS         - are added if needed
30 # RUN_DEPENDS           - are added if needed
31
32 OpenSSL_Include_MAINTAINER=     dinoex@FreeBSD.org
33
34 #       if no preference was set, check for an installed base version
35 #       but give an installed port preference over it.
36 .if     !defined(WITH_OPENSSL_BASE) && \
37         !defined(WITH_OPENSSL_PORT) && \
38         !exists(${DESTDIR}/${LOCALBASE}/lib/libcrypto.so) && \
39         exists(${DESTDIR}/usr/include/openssl/opensslv.h)
40 WITH_OPENSSL_BASE=yes
41 .endif
42
43 .if defined(WITH_OPENSSL_BASE)
44 OPENSSLBASE=            /usr
45 OPENSSLDIR?=            /etc/ssl
46
47 .if !exists(${DESTDIR}/usr/lib/libcrypto.so)
48 check-depends::
49         @${ECHO_CMD} "Dependency error: this port requires the OpenSSL library, which is part of"
50         @${ECHO_CMD} "the FreeBSD crypto distribution but not installed on your"
51         @${ECHO_CMD} "machine. Please see the \"OpenSSL\" section in the handbook"
52         @${ECHO_CMD} "(at \"http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/openssl.html\", for instance)"
53         @${ECHO_CMD} "for instructions on how to obtain and install the FreeBSD"
54         @${ECHO_CMD} "OpenSSL distribution."
55         @${FALSE}
56 .endif
57 .if exists(${LOCALBASE}/lib/libcrypto.so)
58 check-depends::
59         @${ECHO_CMD} "Dependency error: this port wants the OpenSSL library from the FreeBSD"
60         @${ECHO_CMD} "base system. You can't build against it, while a newer"
61         @${ECHO_CMD} "version is installed by a port."
62         @${ECHO_CMD} "Please deinstall the port or undefine WITH_OPENSSL_BASE."
63         @${FALSE}
64 .endif
65
66 # OpenSSL in the base system may not include IDEA for patent licensing reasons.
67 .if defined(MAKE_IDEA) && !defined(OPENSSL_IDEA)
68 OPENSSL_IDEA=           ${MAKE_IDEA}
69 .else
70 OPENSSL_IDEA?=          NO
71 .endif
72
73 .if ${OPENSSL_IDEA} == "NO"
74 # XXX This is a hack to work around the fact that /etc/make.conf clobbers
75 #     our CFLAGS. It might not be enough for all future ports.
76 .if defined(HAS_CONFIGURE)
77 CFLAGS+=                -DNO_IDEA
78 .else
79 OPENSSL_CFLAGS+=        -DNO_IDEA
80 .endif
81 MAKE_ARGS+=             OPENSSL_CFLAGS="${OPENSSL_CFLAGS}"
82 .endif
83 OPENSSLRPATH=           /usr/lib:${LOCALBASE}/lib
84
85 .else
86
87 OPENSSLBASE=            ${LOCALBASE}
88 .if     !defined(OPENSSL_PORT) && \
89         exists(${DESTDIR}/${LOCALBASE}/lib/libcrypto.so)
90 # find installed port and use it for dependency
91 PKG_DBDIR?=             ${DESTDIR}/var/db/pkg
92 .if !defined(OPENSSL_INSTALLED)
93 .if defined(DESTDIR)
94 PKGARGS=        -c ${DESTDIR}
95 .else
96 PKGARGS=
97 .endif
98 OPENSSL_INSTALLED!=     ${PKG_BIN} ${PKGARGS} which -qo ${LOCALBASE}/lib/libcrypto.so || :
99 .endif
100 .if defined(OPENSSL_INSTALLED) && ${OPENSSL_INSTALLED} != ""
101 OPENSSL_PORT=           ${OPENSSL_INSTALLED}
102 OPENSSL_SHLIBFILE!=     ${PKG_INFO} -ql ${OPENSSL_INSTALLED} | grep "^`pkg query "%p" ${OPENSSL_INSTALLED}`/lib/libcrypto.so.[0-9]*$$"
103 OPENSSL_SHLIBVER?=      ${OPENSSL_SHLIBFILE:E}
104 .else
105 # PKG_DBDIR was not found
106 .endif
107 .endif
108
109 # try to guess SHLIBVER for libressl
110 .if defined(OPENSSL_PORT) && ${OPENSSL_PORT} == security/libressl
111 OPENSSL_SHLIBVER?=      30
112 .endif
113
114 # default
115 OPENSSL_PORT?=          security/openssl
116 OPENSSL_SHLIBVER?=      8
117
118 OPENSSLDIR?=            ${OPENSSLBASE}/openssl
119 BUILD_DEPENDS+=         ${LOCALBASE}/lib/libcrypto.so.${OPENSSL_SHLIBVER}:${PORTSDIR}/${OPENSSL_PORT}
120 RUN_DEPENDS+=           ${LOCALBASE}/lib/libcrypto.so.${OPENSSL_SHLIBVER}:${PORTSDIR}/${OPENSSL_PORT}
121 OPENSSLRPATH=           ${LOCALBASE}/lib
122
123 .endif
124
125 OPENSSLLIB=             ${OPENSSLBASE}/lib
126 OPENSSLINC=             ${OPENSSLBASE}/include
127
128 .if defined(USE_OPENSSL_RPATH)
129 CFLAGS+=                -Wl,-rpath,${OPENSSLRPATH}
130 .endif
131 OPENSSL_LDFLAGS+=       -Wl,-rpath,${OPENSSLRPATH}
132
133 LDFLAGS+=${OPENSSL_LDFLAGS}
134
135 MAKE_ENV+=              OPENSSLLIB=${OPENSSLLIB} OPENSSLINC=${OPENSSLINC} \
136                         OPENSSLBASE=${OPENSSLBASE} OPENSSLDIR=${OPENSSLDIR}
137
138 ### crypto
139 #RESTRICTED=            "Contains cryptography."
140