xref: /freebsd/share/mk/src.sys.env.mk (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1daf514d0SSimon J. Gerraty
2daf514d0SSimon J. Gerraty# early setup only see also src.sys.mk
3daf514d0SSimon J. Gerraty
4154733e8SBryan Drewery# bmake-20170301 started taking '-C' "as is" for some cases, notably absolute
5154733e8SBryan Drewery# paths.  Some later comparisons will assume .CURDIR is resolved and matches
6154733e8SBryan Drewery# what we would get with 'cd'.  So just force resolve it now if it is an
7154733e8SBryan Drewery# absolute path.
8154733e8SBryan Drewery.if ${MAKE_VERSION} >= 20170301 && !empty(.CURDIR:M/*)
9154733e8SBryan Drewery.CURDIR:= ${.CURDIR:tA}
10154733e8SBryan Drewery.endif
11154733e8SBryan Drewery
12daf514d0SSimon J. Gerraty# make sure this is defined in a consistent manner
13daf514d0SSimon J. GerratySRCTOP:= ${.PARSEDIR:tA:H:H}
14daf514d0SSimon J. Gerraty
15ba7a7c1bSBryan Drewery.if ${.CURDIR} == ${SRCTOP}
16ba7a7c1bSBryan DreweryRELDIR= .
1795137b22SBryan DreweryRELTOP= .
18ba7a7c1bSBryan Drewery.elif ${.CURDIR:M${SRCTOP}/*}
19ba7a7c1bSBryan DreweryRELDIR:= ${.CURDIR:S,${SRCTOP}/,,}
20ba7a7c1bSBryan Drewery.endif
2195137b22SBryan DreweryRELTOP?= 	${RELDIR:C,[^/]+,..,g}
2295137b22SBryan DreweryRELOBJTOP?=	${RELTOP}
2395137b22SBryan DreweryRELSRCTOP?=	${RELTOP}
24ba7a7c1bSBryan Drewery
25f9ee4156SAlfredo Dal'Ava Junior.if !defined(OS_REVISION)
26f9ee4156SAlfredo Dal'Ava JuniorOS_REVISION!=eval `sh ${SRCTOP}/sys/conf/newvers.sh -V REVISION` && echo $$REVISION || echo
27f9ee4156SAlfredo Dal'Ava Junior.export OS_REVISION
28f9ee4156SAlfredo Dal'Ava Junior.endif
29f9ee4156SAlfredo Dal'Ava Junior
30daf514d0SSimon J. Gerraty# site customizations that do not depend on anything!
31743ab018SBryan Drewery
32743ab018SBryan Drewery# Save MAKEOBJDIRPREFIX and don't let src-env.conf modify it.
33743ab018SBryan Drewery# MAKEOBJDIRPREFIX is only needed in MAKELEVEL=0.  In sub-makes it will
34743ab018SBryan Drewery# either be read from environment or OBJDIR/MAKEOBJDIR according to
35743ab018SBryan Drewery# src.sys.obj.mk.
36743ab018SBryan Drewery.if !(${.MAKE.LEVEL} == 0 || empty(OBJROOT))
37743ab018SBryan Drewery.if defined(MAKEOBJDIRPREFIX)
38743ab018SBryan Drewery_saveMAKEOBJDIRPREFIX:=	${MAKEOBJDIRPREFIX}
39743ab018SBryan Drewery.else
40743ab018SBryan Drewery_undefMAKEOBJDIRPREFIX=	t
41743ab018SBryan Drewery.endif
42743ab018SBryan Drewery.endif
43743ab018SBryan Drewery
44*073ccb9dSSimon J. Gerraty.-include <site.src.sys.env.mk>
45*073ccb9dSSimon J. Gerraty
46daf514d0SSimon J. GerratySRC_ENV_CONF?= /etc/src-env.conf
47daf514d0SSimon J. Gerraty.if !empty(SRC_ENV_CONF) && !target(_src_env_conf_included_)
48daf514d0SSimon J. Gerraty.-include "${SRC_ENV_CONF}"
49daf514d0SSimon J. Gerraty_src_env_conf_included_:	.NOTMAIN
50daf514d0SSimon J. Gerraty.endif
51daf514d0SSimon J. Gerraty
52743ab018SBryan Drewery.if defined(_saveMAKEOBJDIRPREFIX) || defined(_undefMAKEOBJDIRPREFIX)
53743ab018SBryan Drewery.if defined(MAKEOBJDIRPREFIX) && ((defined(_saveMAKEOBJDIRPREFIX) && \
54743ab018SBryan Drewery    ${_saveMAKEOBJDIRPREFIX} != ${MAKEOBJDIRPREFIX}) || \
55743ab018SBryan Drewery    defined(_undefMAKEOBJDIRPREFIX))
56743ab018SBryan Drewery.warning ${SRC_ENV_CONF}: Ignoring MAKEOBJDIRPREFIX entry in sub-make.  Use '?=' to avoid this warning.
57743ab018SBryan Drewery.endif
58743ab018SBryan Drewery.if defined(_saveMAKEOBJDIRPREFIX)
59743ab018SBryan DreweryMAKEOBJDIRPREFIX:=	${_saveMAKEOBJDIRPREFIX}
60743ab018SBryan Drewery.undef _saveMAKEOBJDIRPREFIX
61743ab018SBryan Drewery.elif defined(_undefMAKEOBJDIRPREFIX)
62743ab018SBryan Drewery.undef MAKEOBJDIRPREFIX
63743ab018SBryan Drewery.undef _undefMAKEOBJDIRPREFIX
64743ab018SBryan Drewery.endif
65743ab018SBryan Drewery.endif
66743ab018SBryan Drewery
67f70bac64SBryan Drewery.include <bsd.mkopt.mk>
68f70bac64SBryan Drewery
6999dd498cSBryan Drewery# Top-level installs should not use meta mode as it may prevent installing
70844939d7SBryan Drewery# based on cookies. It's fine with filemon though.
71844939d7SBryan Drewery.if !empty(META_MODE:Mnofilemon) && \
72844939d7SBryan Drewery  make(*install*) && ${.MAKE.LEVEL} == 0
7399dd498cSBryan DreweryMETA_MODE=	normal
7499dd498cSBryan DreweryMK_META_MODE=	no
753c39d0a0SBryan Drewery.export MK_META_MODE
7699dd498cSBryan Drewery.endif
7799dd498cSBryan Drewery
78daf514d0SSimon J. Gerraty# If we were found via .../share/mk we need to replace that
79daf514d0SSimon J. Gerraty# with ${.PARSEDIR:tA} so that we can be found by
80daf514d0SSimon J. Gerraty# sub-makes launched from objdir.
81daf514d0SSimon J. Gerraty.if ${.MAKEFLAGS:M.../share/mk} != ""
82daf514d0SSimon J. Gerraty.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
83daf514d0SSimon J. Gerraty.endif
84daf514d0SSimon J. Gerraty.if ${MAKESYSPATH:Uno:M*.../*} != ""
85daf514d0SSimon J. GerratyMAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
86daf514d0SSimon J. Gerraty.export MAKESYSPATH
877c75c54fSBryan Drewery.elif empty(MAKESYSPATH)
887c75c54fSBryan DreweryMAKESYSPATH:=	${.PARSEDIR:tA}
897c75c54fSBryan Drewery.export MAKESYSPATH
90daf514d0SSimon J. Gerraty.endif
91dfa09989SBryan Drewery
92f7789552SBryan Drewery.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0
93*073ccb9dSSimon J. Gerraty.-include "${.CURDIR}/Makefile.sys.inc"
94f7789552SBryan Drewery.endif
95dfa09989SBryan Drewery.include <src.sys.obj.mk>
96