xref: /freebsd/share/mk/src.sys.env.mk (revision 7ef62cebc2f965b0f640263e179276928885e33d)
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
45.-include <site.src.sys.env.mk>
46
47SRC_ENV_CONF?= /etc/src-env.conf
48.if !empty(SRC_ENV_CONF) && !target(_src_env_conf_included_)
49.-include "${SRC_ENV_CONF}"
50_src_env_conf_included_:	.NOTMAIN
51.endif
52
53.if defined(_saveMAKEOBJDIRPREFIX) || defined(_undefMAKEOBJDIRPREFIX)
54.if defined(MAKEOBJDIRPREFIX) && ((defined(_saveMAKEOBJDIRPREFIX) && \
55    ${_saveMAKEOBJDIRPREFIX} != ${MAKEOBJDIRPREFIX}) || \
56    defined(_undefMAKEOBJDIRPREFIX))
57.warning ${SRC_ENV_CONF}: Ignoring MAKEOBJDIRPREFIX entry in sub-make.  Use '?=' to avoid this warning.
58.endif
59.if defined(_saveMAKEOBJDIRPREFIX)
60MAKEOBJDIRPREFIX:=	${_saveMAKEOBJDIRPREFIX}
61.undef _saveMAKEOBJDIRPREFIX
62.elif defined(_undefMAKEOBJDIRPREFIX)
63.undef MAKEOBJDIRPREFIX
64.undef _undefMAKEOBJDIRPREFIX
65.endif
66.endif
67
68.include <bsd.mkopt.mk>
69
70# Top-level installs should not use meta mode as it may prevent installing
71# based on cookies. It's fine with filemon though.
72.if !empty(META_MODE:Mnofilemon) && \
73  make(*install*) && ${.MAKE.LEVEL} == 0
74META_MODE=	normal
75MK_META_MODE=	no
76.export MK_META_MODE
77.endif
78
79# If we were found via .../share/mk we need to replace that
80# with ${.PARSEDIR:tA} so that we can be found by
81# sub-makes launched from objdir.
82.if ${.MAKEFLAGS:M.../share/mk} != ""
83.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
84.endif
85.if ${MAKESYSPATH:Uno:M*.../*} != ""
86MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
87.export MAKESYSPATH
88.elif empty(MAKESYSPATH)
89MAKESYSPATH:=	${.PARSEDIR:tA}
90.export MAKESYSPATH
91.endif
92
93.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0
94.-include "${.CURDIR}/Makefile.sys.inc"
95.endif
96.include <src.sys.obj.mk>
97