#
# $FreeBSD$
# bsd.openssl.mk - Support for OpenSSL based ports.
#
# Use of 'USE_OPENSSL=yes' includes this Makefile after bsd.ports.pre.mk
#
# the user/port can now set this options in the makefiles.
#
# WITH_OPENSSL_BASE=yes	- Use the version in the base system.
# WITH_OPENSSL_PORT=yes	- Use the port, even if base is up to date
# WITH_OPENSSL_HACK7=yes - Use not the version in the base system on FreeBSD 7.x
#
# USE_OPENSSL_RPATH=yes	- Pass RFLAGS options in CFLAGS,
#			  needed for ports who don't use LDFLAGS
#
# Overrideable defaults:
#
# OPENSSL_SHLIBVER=	3
# OPENSSL_PORT=		security/openssl
#
# The makefile sets this variables:
# OPENSSLBASE		- "/usr" or ${LOCALBASE}
# OPENSSLDIR		- path to openssl
# OPENSSLLIB		- path to the libs
# OPENSSLINC		- path to the matching includes
# OPENSSLRPATH		- rpath for dynamic linker
#
# MAKE_ENV		- extended with the variables above
# CONFIGURE_ENV		- extended with LDFLAGS
# BUILD_DEPENDS		- are added if needed
# RUN_DEPENDS		- are added if needed

OpenSSL_Include_MAINTAINER=	dinoex@FreeBSD.org

# honor obsolete options for a bit
.if defined(USE_OPENSSL_BASE) && !defined(WITH_OPENSSL_BASE)
WITH_OPENSSL_BASE=yes
.endif
.if defined(USE_OPENSSL_PORT) && !defined(WITH_OPENSSL_PORT)
WITH_OPENSSL_PORT=yes
.endif

.if defined(WITH_OPENSSL_HACK7)
.if ${OSVERSION} < 800000
# the openssl in base of FreeBSD 7.x is too old
WITH_OPENSSL_PORT?=	yes
.endif
.endif

#	if no preference was set, check for an installed base version
#	but give an installed port preference over it.
.if	!defined(WITH_OPENSSL_BASE) && \
	!defined(WITH_OPENSSL_PORT) && \
	!exists(${DESTDIR}/${LOCALBASE}/lib/libcrypto.so) && \
	exists(${DESTDIR}/usr/include/openssl/opensslv.h)
WITH_OPENSSL_BASE=yes
.endif

.if defined(WITH_OPENSSL_BASE)
OPENSSLBASE=		/usr
OPENSSLDIR=		/etc/ssl

.if !exists(${DESTDIR}/usr/lib/libcrypto.so)
check-depends::
	@${ECHO_CMD} "Dependency error: this port requires the OpenSSL library, which is part of"
	@${ECHO_CMD} "the FreeBSD crypto distribution but not installed on your"
	@${ECHO_CMD} "machine. Please see the \"OpenSSL\" section in the handbook"
	@${ECHO_CMD} "(at \"http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/openssl.html\", for instance)"
	@${ECHO_CMD} "for instructions on how to obtain and install the FreeBSD"
	@${ECHO_CMD} "OpenSSL distribution."
	@${FALSE}
.endif
.if exists(${LOCALBASE}/lib/libcrypto.so)
check-depends::
	@${ECHO_CMD} "Dependency error: this port wants the OpenSSL library from the FreeBSD"
	@${ECHO_CMD} "base system. You can't build against it, while a newer"
	@${ECHO_CMD} "version is installed by a port."
	@${ECHO_CMD} "Please deinstall the port or undefine WITH_OPENSSL_BASE."
	@${FALSE}
.endif

# OpenSSL in the base system may not include IDEA for patent licensing reasons.
.if defined(MAKE_IDEA) && !defined(OPENSSL_IDEA)
OPENSSL_IDEA=		${MAKE_IDEA}
.else
OPENSSL_IDEA?=		NO
.endif

.if ${OPENSSL_IDEA} == "NO"
# XXX This is a hack to work around the fact that /etc/make.conf clobbers
#     our CFLAGS. It might not be enough for all future ports.
.if defined(HAS_CONFIGURE)
CFLAGS+=		-DNO_IDEA
.else
OPENSSL_CFLAGS+=	-DNO_IDEA
.endif
MAKE_ARGS+=		OPENSSL_CFLAGS="${OPENSSL_CFLAGS}"
.endif
OPENSSLRPATH=		/usr/lib:${LOCALBASE}/lib

.else

OPENSSLBASE=		${LOCALBASE}
.if	!defined(OPENSSL_PORT) && \
	exists(${DESTDIR}/${LOCALBASE}/lib/libcrypto.so)
# find installed port and use it for dependency
PKG_DBDIR?=		${DESTDIR}/var/db/pkg
.if !defined(OPENSSL_INSTALLED)
.if defined(WITH_PKGNG)
.if defined(DESTDIR)
PKGARGS=	-c ${DESTDIR}
.else
PKGARGS=
.endif
OPENSSL_INSTALLED!=	${PKG_BIN} ${PKGARGS} which -qo ${LOCALBASE}/lib/libcrypto.so || :
.else
OPENSSL_INSTALLED!=	find "${PKG_DBDIR}/" -type f -name "+CONTENTS" -print0 | \
			xargs -0 grep -l "^lib/libssl.so." | \
			while read contents; do \
				sslprefix=`grep "^@cwd " "$${contents}" | ${HEAD} -n 1`; \
				if test "$${sslprefix}" = "@cwd ${LOCALBASE}" ; then \
					echo "$${contents}"; break; fi; done
.endif
.endif
.if defined(OPENSSL_INSTALLED) && ${OPENSSL_INSTALLED} != ""
.if defined(WITH_PKGNG)
OPENSSL_PORT=		${OPENSSL_INSTALLED}
OPENSSL_SHLIBFILE!=	${PKG_INFO} -ql ${OPENSSL_INSTALLED} | grep "^`pkg query "%p" ${OPENSSL_INSTALLED}`/lib/libssl.so."
.else
OPENSSL_PORT!=		grep "^@comment ORIGIN:" "${OPENSSL_INSTALLED}" | ${CUT} -d : -f 2
OPENSSL_SHLIBFILE!=	grep "^lib/libssl.so." "${OPENSSL_INSTALLED}"
.endif
OPENSSL_SHLIBVER?=	${OPENSSL_SHLIBFILE:E}
.else
# PKG_DBDIR was not found, default
OPENSSL_PORT?=		security/openssl
OPENSSL_SHLIBVER?=	8
.endif
.endif
OPENSSL_PORT?=		security/openssl
OPENSSL_SHLIBVER?=	8

OPENSSLDIR=		${OPENSSLBASE}/openssl
BUILD_DEPENDS+=		${LOCALBASE}/lib/libcrypto.so.${OPENSSL_SHLIBVER}:${PORTSDIR}/${OPENSSL_PORT}
RUN_DEPENDS+=		${LOCALBASE}/lib/libcrypto.so.${OPENSSL_SHLIBVER}:${PORTSDIR}/${OPENSSL_PORT}
OPENSSLRPATH=		${LOCALBASE}/lib

.endif

OPENSSLLIB=		${OPENSSLBASE}/lib
OPENSSLINC=		${OPENSSLBASE}/include

.if defined(USE_OPENSSL_RPATH)
CFLAGS+=		-Wl,-rpath,${OPENSSLRPATH}
.endif
OPENSSL_LDFLAGS+=	-Wl,-rpath=${OPENSSLRPATH}

LDFLAGS+=${OPENSSL_LDFLAGS}

MAKE_ENV+=		OPENSSLLIB=${OPENSSLLIB} OPENSSLINC=${OPENSSLINC} \
			OPENSSLBASE=${OPENSSLBASE} OPENSSLDIR=${OPENSSLDIR}

### crypto
#RESTRICTED=		"Contains cryptography."

ef='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/?h=mate-1.18'>summary</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/refs/?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>refs</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/archivers/p5-Archive-Tar/distinfo?h=mate-1.18'>log</a><a class='active' href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/tree/archivers/p5-Archive-Tar/distinfo?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>tree</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/commit/archivers/p5-Archive-Tar/distinfo?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>commit</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/diff/archivers/p5-Archive-Tar/distinfo?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>diff</a><a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/stats/archivers/p5-Archive-Tar/distinfo?h=mate-1.18'>stats</a></td><td class='form'><form class='right' method='get' action='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/log/archivers/p5-Archive-Tar/distinfo'>
<input type='hidden' name='h' value='mate-1.18'/><input type='hidden' name='id' value='e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/tree/?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>root</a>/<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/tree/archivers?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>archivers</a>/<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/tree/archivers/p5-Archive-Tar?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>p5-Archive-Tar</a>/<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/tree/archivers/p5-Archive-Tar/distinfo?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>distinfo</a></div><div class='content'>blob: f463fbdcf4bdd78ad7349711b05e803ca734c87f (<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/plain/archivers/p5-Archive-Tar/distinfo?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>plain</a>) (<a href='/~lantw44/cgit/cgit.cgi/freebsd-ports-gnome/blame/archivers/p5-Archive-Tar/distinfo?h=mate-1.18&amp;id=e23c2f0ae9b6f772d2f1521ababb51f2a0c937fb'>blame</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
</pre></td>
<td class='lines'><pre><code>