xref: /freebsd/share/mk/src.sys.env.mk (revision eb69d1f144a6fcc765d1b9d44a5ae8082353e70b)
1# $FreeBSD$
2
3# early setup only see also src.sys.mk
4
5# bmake-20170301 started taking '-C' "as is" for some cases, notably absolute
6# paths.  Some later comparisons will assume .CURDIR is resolved and matches
7# what we would get with 'cd'.  So just force resolve it now if it is an
8# absolute path.
9.if ${MAKE_VERSION} >= 20170301 && !empty(.CURDIR:M/*)
10.CURDIR:= ${.CURDIR:tA}
11.endif
12
13# make sure this is defined in a consistent manner
14SRCTOP:= ${.PARSEDIR:tA:H:H}
15
16.if ${.CURDIR} == ${SRCTOP}
17RELDIR= .
18RELTOP= .
19.elif ${.CURDIR:M${SRCTOP}/*}
20RELDIR:= ${.CURDIR:S,${SRCTOP}/,,}
21.endif
22RELTOP?= 	${RELDIR:C,[^/]+,..,g}
23RELOBJTOP?=	${RELTOP}
24RELSRCTOP?=	${RELTOP}
25
26# site customizations that do not depend on anything!
27SRC_ENV_CONF?= /etc/src-env.conf
28.if !empty(SRC_ENV_CONF) && !target(_src_env_conf_included_)
29.-include "${SRC_ENV_CONF}"
30_src_env_conf_included_:	.NOTMAIN
31.endif
32
33.include <bsd.mkopt.mk>
34
35# Top-level installs should not use meta mode as it may prevent installing
36# based on cookies.
37.if make(*install*) && ${.MAKE.LEVEL} == 0
38META_MODE=	normal
39MK_META_MODE=	no
40.export MK_META_MODE
41.endif
42
43# If we were found via .../share/mk we need to replace that
44# with ${.PARSEDIR:tA} so that we can be found by
45# sub-makes launched from objdir.
46.if ${.MAKEFLAGS:M.../share/mk} != ""
47.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
48.endif
49.if ${MAKESYSPATH:Uno:M*.../*} != ""
50MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
51.export MAKESYSPATH
52.elif empty(MAKESYSPATH)
53MAKESYSPATH:=	${.PARSEDIR:tA}
54.export MAKESYSPATH
55.endif
56
57.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0
58.sinclude "${.CURDIR}/Makefile.sys.inc"
59.endif
60.include <src.sys.obj.mk>
61