xref: /freebsd/share/mk/src.sys.env.mk (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1
2# early setup only see also src.sys.mk
3
4# bmake-20170301 started taking '-C' "as is" for some cases, notably absolute
5# paths.  Some later comparisons will assume .CURDIR is resolved and matches
6# what we would get with 'cd'.  So just force resolve it now if it is an
7# absolute path.
8.if ${MAKE_VERSION} >= 20170301 && !empty(.CURDIR:M/*)
9.CURDIR:= ${.CURDIR:tA}
10.endif
11
12# make sure this is defined in a consistent manner
13SRCTOP:= ${.PARSEDIR:tA:H:H}
14
15.if ${.CURDIR} == ${SRCTOP}
16RELDIR= .
17RELTOP= .
18.elif ${.CURDIR:M${SRCTOP}/*}
19RELDIR:= ${.CURDIR:S,${SRCTOP}/,,}
20.endif
21RELTOP?= 	${RELDIR:C,[^/]+,..,g}
22RELOBJTOP?=	${RELTOP}
23RELSRCTOP?=	${RELTOP}
24
25.if !defined(OS_REVISION)
26OS_REVISION!=eval `sh ${SRCTOP}/sys/conf/newvers.sh -V REVISION` && echo $$REVISION || echo
27.export OS_REVISION
28.endif
29
30# site customizations that do not depend on anything!
31
32# Save MAKEOBJDIRPREFIX and don't let src-env.conf modify it.
33# MAKEOBJDIRPREFIX is only needed in MAKELEVEL=0.  In sub-makes it will
34# either be read from environment or OBJDIR/MAKEOBJDIR according to
35# src.sys.obj.mk.
36.if !(${.MAKE.LEVEL} == 0 || empty(OBJROOT))
37.if defined(MAKEOBJDIRPREFIX)
38_saveMAKEOBJDIRPREFIX:=	${MAKEOBJDIRPREFIX}
39.else
40_undefMAKEOBJDIRPREFIX=	t
41.endif
42.endif
43
44.-include <site.src.sys.env.mk>
45
46SRC_ENV_CONF?= /etc/src-env.conf
47.if !empty(SRC_ENV_CONF) && !target(_src_env_conf_included_)
48.-include "${SRC_ENV_CONF}"
49_src_env_conf_included_:	.NOTMAIN
50.endif
51
52.if defined(_saveMAKEOBJDIRPREFIX) || defined(_undefMAKEOBJDIRPREFIX)
53.if defined(MAKEOBJDIRPREFIX) && ((defined(_saveMAKEOBJDIRPREFIX) && \
54    ${_saveMAKEOBJDIRPREFIX} != ${MAKEOBJDIRPREFIX}) || \
55    defined(_undefMAKEOBJDIRPREFIX))
56.warning ${SRC_ENV_CONF}: Ignoring MAKEOBJDIRPREFIX entry in sub-make.  Use '?=' to avoid this warning.
57.endif
58.if defined(_saveMAKEOBJDIRPREFIX)
59MAKEOBJDIRPREFIX:=	${_saveMAKEOBJDIRPREFIX}
60.undef _saveMAKEOBJDIRPREFIX
61.elif defined(_undefMAKEOBJDIRPREFIX)
62.undef MAKEOBJDIRPREFIX
63.undef _undefMAKEOBJDIRPREFIX
64.endif
65.endif
66
67.include <bsd.mkopt.mk>
68
69# Top-level installs should not use meta mode as it may prevent installing
70# based on cookies. It's fine with filemon though.
71.if !empty(META_MODE:Mnofilemon) && \
72  make(*install*) && ${.MAKE.LEVEL} == 0
73META_MODE=	normal
74MK_META_MODE=	no
75.export MK_META_MODE
76.endif
77
78# If we were found via .../share/mk we need to replace that
79# with ${.PARSEDIR:tA} so that we can be found by
80# sub-makes launched from objdir.
81.if ${.MAKEFLAGS:M.../share/mk} != ""
82.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
83.endif
84.if ${MAKESYSPATH:Uno:M*.../*} != ""
85MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
86.export MAKESYSPATH
87.elif empty(MAKESYSPATH)
88MAKESYSPATH:=	${.PARSEDIR:tA}
89.export MAKESYSPATH
90.endif
91
92.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0
93.-include "${.CURDIR}/Makefile.sys.inc"
94.endif
95.include <src.sys.obj.mk>
96