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