xref: /freebsd/share/mk/src.sys.env.mk (revision f6a3b357e9be4c6423c85eff9a847163a0d307c8)
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.
65.if make(*install*) && ${.MAKE.LEVEL} == 0
66META_MODE=	normal
67MK_META_MODE=	no
68.export MK_META_MODE
69.endif
70
71# If we were found via .../share/mk we need to replace that
72# with ${.PARSEDIR:tA} so that we can be found by
73# sub-makes launched from objdir.
74.if ${.MAKEFLAGS:M.../share/mk} != ""
75.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
76.endif
77.if ${MAKESYSPATH:Uno:M*.../*} != ""
78MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
79.export MAKESYSPATH
80.elif empty(MAKESYSPATH)
81MAKESYSPATH:=	${.PARSEDIR:tA}
82.export MAKESYSPATH
83.endif
84
85.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0
86.sinclude "${.CURDIR}/Makefile.sys.inc"
87.endif
88.include <src.sys.obj.mk>
89