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 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 # honor obsolete options for a bit
35 .if defined(USE_OPENSSL_BASE) && !defined(WITH_OPENSSL_BASE)
38 .if defined(USE_OPENSSL_PORT) && !defined(WITH_OPENSSL_PORT)
42 # if no preference was set, check for an installed base version
43 # but give an installed port preference over it.
44 .if !defined(WITH_OPENSSL_BASE) && \
45 !defined(WITH_OPENSSL_PORT) && \
46 !exists(${DESTDIR}/${LOCALBASE}/lib/libcrypto.so) && \
47 exists(${DESTDIR}/usr/include/openssl/opensslv.h)
51 .if defined(WITH_OPENSSL_BASE)
55 .if !exists(${DESTDIR}/usr/lib/libcrypto.so)
57 @${ECHO_CMD} "Dependency error: this port requires the OpenSSL library, which is part of"
58 @${ECHO_CMD} "the FreeBSD crypto distribution but not installed on your"
59 @${ECHO_CMD} "machine. Please see the \"OpenSSL\" section in the handbook"
60 @${ECHO_CMD} "(at \"http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/openssl.html\", for instance)"
61 @${ECHO_CMD} "for instructions on how to obtain and install the FreeBSD"
62 @${ECHO_CMD} "OpenSSL distribution."
65 .if exists(${LOCALBASE}/lib/libcrypto.so)
67 @${ECHO_CMD} "Dependency error: this port wants the OpenSSL library from the FreeBSD"
68 @${ECHO_CMD} "base system. You can't build against it, while a newer"
69 @${ECHO_CMD} "version is installed by a port."
70 @${ECHO_CMD} "Please deinstall the port or undefine WITH_OPENSSL_BASE."
74 # OpenSSL in the base system may not include IDEA for patent licensing reasons.
75 .if defined(MAKE_IDEA) && !defined(OPENSSL_IDEA)
76 OPENSSL_IDEA= ${MAKE_IDEA}
81 .if ${OPENSSL_IDEA} == "NO"
82 # XXX This is a hack to work around the fact that /etc/make.conf clobbers
83 # our CFLAGS. It might not be enough for all future ports.
84 .if defined(HAS_CONFIGURE)
87 OPENSSL_CFLAGS+= -DNO_IDEA
89 MAKE_ARGS+= OPENSSL_CFLAGS="${OPENSSL_CFLAGS}"
91 OPENSSLRPATH= /usr/lib:${LOCALBASE}/lib
95 OPENSSLBASE= ${LOCALBASE}
96 .if !defined(OPENSSL_PORT) && \
97 exists(${DESTDIR}/${LOCALBASE}/lib/libcrypto.so)
98 # find installed port and use it for dependency
99 PKG_DBDIR?= ${DESTDIR}/var/db/pkg
100 .if !defined(OPENSSL_INSTALLED)
101 .if defined(WITH_PKGNG)
103 PKGARGS= -c ${DESTDIR}
107 OPENSSL_INSTALLED!= ${PKG_BIN} ${PKGARGS} which -qo ${LOCALBASE}/lib/libcrypto.so || :
109 OPENSSL_INSTALLED!= find "${PKG_DBDIR}/" -type f -name "+CONTENTS" -print0 | \
110 xargs -0 grep -l "^lib/libssl.so." | \
111 while read contents; do \
112 sslprefix=`grep "^@cwd " "$${contents}" | ${HEAD} -n 1`; \
113 if test "$${sslprefix}" = "@cwd ${LOCALBASE}" ; then \
114 echo "$${contents}"; break; fi; done
117 .if defined(OPENSSL_INSTALLED) && ${OPENSSL_INSTALLED} != ""
118 .if defined(WITH_PKGNG)
119 OPENSSL_PORT= ${OPENSSL_INSTALLED}
120 OPENSSL_SHLIBFILE!= ${PKG_INFO} -ql ${OPENSSL_INSTALLED} | grep "^`pkg query "%p" ${OPENSSL_INSTALLED}`/lib/libssl.so."
122 OPENSSL_PORT!= grep "^@comment ORIGIN:" "${OPENSSL_INSTALLED}" | ${CUT} -d : -f 2
123 OPENSSL_SHLIBFILE!= grep "^lib/libssl.so." "${OPENSSL_INSTALLED}"
125 OPENSSL_SHLIBVER?= ${OPENSSL_SHLIBFILE:E}
127 # PKG_DBDIR was not found, default
128 OPENSSL_PORT?= security/openssl
132 OPENSSL_PORT?= security/openssl
135 OPENSSLDIR= ${OPENSSLBASE}/openssl
136 BUILD_DEPENDS+= ${LOCALBASE}/lib/libcrypto.so.${OPENSSL_SHLIBVER}:${PORTSDIR}/${OPENSSL_PORT}
137 RUN_DEPENDS+= ${LOCALBASE}/lib/libcrypto.so.${OPENSSL_SHLIBVER}:${PORTSDIR}/${OPENSSL_PORT}
138 OPENSSLRPATH= ${LOCALBASE}/lib
142 OPENSSLLIB= ${OPENSSLBASE}/lib
143 OPENSSLINC= ${OPENSSLBASE}/include
145 .if defined(USE_OPENSSL_RPATH)
146 CFLAGS+= -Wl,-rpath,${OPENSSLRPATH}
148 OPENSSL_LDFLAGS+= -Wl,-rpath,${OPENSSLRPATH}
150 LDFLAGS+=${OPENSSL_LDFLAGS}
152 MAKE_ENV+= OPENSSLLIB=${OPENSSLLIB} OPENSSLINC=${OPENSSLINC} \
153 OPENSSLBASE=${OPENSSLBASE} OPENSSLDIR=${OPENSSLDIR}
156 #RESTRICTED= "Contains cryptography."