xref: /freebsd/share/mk/src.sys.env.mk (revision a7623790fb345e6dc986dfd31df0ace115e6f2e4)
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!
27
28# Save MAKEOBJDIRPREFIX and don't let src-env.conf modify it.
29# MAKEOBJDIRPREFIX is only needed in MAKELEVEL=0.  In sub-makes it will
30# either be read from environment or OBJDIR/MAKEOBJDIR according to
31# src.sys.obj.mk.
32.if !(${.MAKE.LEVEL} == 0 || empty(OBJROOT))
33.if defined(MAKEOBJDIRPREFIX)
34_saveMAKEOBJDIRPREFIX:=	${MAKEOBJDIRPREFIX}
35.else
36_undefMAKEOBJDIRPREFIX=	t
37.endif
38.endif
39
40SRC_ENV_CONF?= /etc/src-env.conf
41.if !empty(SRC_ENV_CONF) && !target(_src_env_conf_included_)
42.-include "${SRC_ENV_CONF}"
43_src_env_conf_included_:	.NOTMAIN
44.endif
45
46.if defined(_saveMAKEOBJDIRPREFIX) || defined(_undefMAKEOBJDIRPREFIX)
47.if defined(MAKEOBJDIRPREFIX) && ((defined(_saveMAKEOBJDIRPREFIX) && \
48    ${_saveMAKEOBJDIRPREFIX} != ${MAKEOBJDIRPREFIX}) || \
49    defined(_undefMAKEOBJDIRPREFIX))
50.warning ${SRC_ENV_CONF}: Ignoring MAKEOBJDIRPREFIX entry in sub-make.  Use '?=' to avoid this warning.
51.endif
52.if defined(_saveMAKEOBJDIRPREFIX)
53MAKEOBJDIRPREFIX:=	${_saveMAKEOBJDIRPREFIX}
54.undef _saveMAKEOBJDIRPREFIX
55.elif defined(_undefMAKEOBJDIRPREFIX)
56.undef MAKEOBJDIRPREFIX
57.undef _undefMAKEOBJDIRPREFIX
58.endif
59.endif
60
61.include <bsd.mkopt.mk>
62
63# Top-level installs should not use meta mode as it may prevent installing
64# based on cookies. It's fine with filemon though.
65.if !empty(META_MODE:Mnofilemon) && \
66  make(*install*) && ${.MAKE.LEVEL} == 0
67META_MODE=	normal
68MK_META_MODE=	no
69.export MK_META_MODE
70.endif
71
72# If we were found via .../share/mk we need to replace that
73# with ${.PARSEDIR:tA} so that we can be found by
74# sub-makes launched from objdir.
75.if ${.MAKEFLAGS:M.../share/mk} != ""
76.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
77.endif
78.if ${MAKESYSPATH:Uno:M*.../*} != ""
79MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
80.export MAKESYSPATH
81.elif empty(MAKESYSPATH)
82MAKESYSPATH:=	${.PARSEDIR:tA}
83.export MAKESYSPATH
84.endif
85
86.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0
87.sinclude "${.CURDIR}/Makefile.sys.inc"
88.endif
89.include <src.sys.obj.mk>
90