freebsd-skq/share/mk/bsd.port.subdir.mk
bdrewery 2e1c8d943d Avoid sub-shell for realpath(1) for bmake by using its built-in :tA.
MFC after:	2 weeks
Approved by:	portmgr (implicit)
2015-09-03 17:01:58 +00:00

23 lines
594 B
Makefile

# $FreeBSD$
.if !defined(PORTSDIR)
# Autodetect if the command is being run in a ports tree that's not rooted
# in the default /usr/ports. The ../../.. case is in case ports ever grows
# a third level.
.for RELPATH in . .. ../.. ../../..
.if !defined(_PORTSDIR) && exists(${.CURDIR}/${RELPATH}/Mk/bsd.port.mk)
_PORTSDIR= ${.CURDIR}/${RELPATH}
.endif
.endfor
_PORTSDIR?= /usr/ports
.if defined(.PARSEDIR)
PORTSDIR= ${_PORTSDIR:tA}
.else # fmake doesn't have :tA
PORTSDIR!= realpath ${_PORTSDIR}
.endif
.endif
BSDPORTSUBDIRMK?= ${PORTSDIR}/Mk/bsd.port.subdir.mk
.include "${BSDPORTSUBDIRMK}"