170459Speter# $FreeBSD$
270459Speter
3272282Swill.if !defined(PORTSDIR)
4272282Swill# Autodetect if the command is being run in a ports tree that's not rooted
5272282Swill# in the default /usr/ports.  The ../../.. case is in case ports ever grows
6272282Swill# a third level.
7272383Swill.for RELPATH in . .. ../.. ../../..
8272383Swill.if !defined(_PORTSDIR) && exists(${.CURDIR}/${RELPATH}/Mk/bsd.port.mk)
9272383Swill_PORTSDIR=	${.CURDIR}/${RELPATH}
10272282Swill.endif
11272383Swill.endfor
12272383Swill_PORTSDIR?=	/usr/ports
13287436Sbdrewery.if defined(.PARSEDIR)
14287436SbdreweryPORTSDIR=	${_PORTSDIR:tA}
15287436Sbdrewery.else # fmake doesn't have :tA
16272383SwillPORTSDIR!=	realpath ${_PORTSDIR}
17272282Swill.endif
18287436Sbdrewery.endif
19272282Swill
20131482SeikBSDPORTSUBDIRMK?=	${PORTSDIR}/Mk/bsd.port.subdir.mk
2195029Sru
22131482Seik.include "${BSDPORTSUBDIRMK}"
23