3 # bsd.openssl.mk - Support for OpenSSL based ports.
5 # Use of 'USE_OPENSSL=yes' includes this Makefile after bsd.ports.pre.mk
7 # the user/port can now set this options in the makefiles.
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
12 # USE_OPENSSL_RPATH=yes - Pass RFLAGS options in CFLAGS,
13 # needed for ports who don't use LDFLAGS
15 # Overrideable defaults:
18 # OPENSSL_PORT= security/openssl
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
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
32 OpenSSL_Include_MAINTAINER= dinoex@FreeBSD.org
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)
43 .if defined(WITH_OPENSSL_BASE)
47 .if !exists(${DESTDIR}/usr/lib/libcrypto.so)
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."
57 .if exists(${LOCALBASE}/lib/libcrypto.so)
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."
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}
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)
79 OPENSSL_CFLAGS+= -DNO_IDEA
81 MAKE_ARGS+= OPENSSL_CFLAGS="${OPENSSL_CFLAGS}"
83 OPENSSLRPATH= /usr/lib:${LOCALBASE}/lib
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)
94 PKGARGS= -c ${DESTDIR}
98 OPENSSL_INSTALLED!= ${PKG_BIN} ${PKGARGS} which -qo ${LOCALBASE}/lib/libcrypto.so || :
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}
105 # PKG_DBDIR was not found
109 # try to guess SHLIBVER for libressl
110 .if defined(OPENSSL_PORT) && ${OPENSSL_PORT} == security/libressl
111 OPENSSL_SHLIBVER?= 32
115 OPENSSL_PORT?= security/openssl
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
125 OPENSSLLIB= ${OPENSSLBASE}/lib
126 OPENSSLINC= ${OPENSSLBASE}/include
128 .if defined(USE_OPENSSL_RPATH)
129 CFLAGS+= -Wl,-rpath,${OPENSSLRPATH}
131 OPENSSL_LDFLAGS+= -Wl,-rpath,${OPENSSLRPATH}
133 LDFLAGS+=${OPENSSL_LDFLAGS}
135 MAKE_ENV+= OPENSSLLIB=${OPENSSLLIB} OPENSSLINC=${OPENSSLINC} \
136 OPENSSLBASE=${OPENSSLBASE} OPENSSLDIR=${OPENSSLDIR}
139 #RESTRICTED= "Contains cryptography."