aboutsummaryrefslogtreecommitdiff
path: root/share/mk/src.sys.env.mk
blob: 6f11489bfd2fc13e817bce99518a181ba0bc6932 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# $FreeBSD$

# early setup only see also src.sys.mk

# bmake-20170301 started taking '-C' "as is" for some cases, notably absolute
# paths.  Some later comparisons will assume .CURDIR is resolved and matches
# what we would get with 'cd'.  So just force resolve it now if it is an
# absolute path.
.if ${MAKE_VERSION} >= 20170301 && !empty(.CURDIR:M/*)
.CURDIR:= ${.CURDIR:tA}
.endif

# make sure this is defined in a consistent manner
SRCTOP:= ${.PARSEDIR:tA:H:H}

.if ${.CURDIR} == ${SRCTOP}
RELDIR= .
RELTOP= .
.elif ${.CURDIR:M${SRCTOP}/*}
RELDIR:= ${.CURDIR:S,${SRCTOP}/,,}
.endif
RELTOP?= 	${RELDIR:C,[^/]+,..,g}
RELOBJTOP?=	${RELTOP}
RELSRCTOP?=	${RELTOP}

# site customizations that do not depend on anything!

# Save MAKEOBJDIRPREFIX and don't let src-env.conf modify it.
# MAKEOBJDIRPREFIX is only needed in MAKELEVEL=0.  In sub-makes it will
# either be read from environment or OBJDIR/MAKEOBJDIR according to
# src.sys.obj.mk.
.if !(${.MAKE.LEVEL} == 0 || empty(OBJROOT))
.if defined(MAKEOBJDIRPREFIX)
_saveMAKEOBJDIRPREFIX:=	${MAKEOBJDIRPREFIX}
.else
_undefMAKEOBJDIRPREFIX=	t
.endif
.endif

SRC_ENV_CONF?= /etc/src-env.conf
.if !empty(SRC_ENV_CONF) && !target(_src_env_conf_included_)
.-include "${SRC_ENV_CONF}"
_src_env_conf_included_:	.NOTMAIN
.endif

.if defined(_saveMAKEOBJDIRPREFIX) || defined(_undefMAKEOBJDIRPREFIX)
.if defined(MAKEOBJDIRPREFIX) && ((defined(_saveMAKEOBJDIRPREFIX) && \
    ${_saveMAKEOBJDIRPREFIX} != ${MAKEOBJDIRPREFIX}) || \
    defined(_undefMAKEOBJDIRPREFIX))
.warning ${SRC_ENV_CONF}: Ignoring MAKEOBJDIRPREFIX entry in sub-make.  Use '?=' to avoid this warning.
.endif
.if defined(_saveMAKEOBJDIRPREFIX)
MAKEOBJDIRPREFIX:=	${_saveMAKEOBJDIRPREFIX}
.undef _saveMAKEOBJDIRPREFIX
.elif defined(_undefMAKEOBJDIRPREFIX)
.undef MAKEOBJDIRPREFIX
.undef _undefMAKEOBJDIRPREFIX
.endif
.endif

.include <bsd.mkopt.mk>

# Top-level installs should not use meta mode as it may prevent installing
# based on cookies. It's fine with filemon though.
.if !empty(META_MODE:Mnofilemon) && \
  make(*install*) && ${.MAKE.LEVEL} == 0
META_MODE=	normal
MK_META_MODE=	no
.export MK_META_MODE
.endif

# If we were found via .../share/mk we need to replace that
# with ${.PARSEDIR:tA} so that we can be found by
# sub-makes launched from objdir.
.if ${.MAKEFLAGS:M.../share/mk} != ""
.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
.endif
.if ${MAKESYSPATH:Uno:M*.../*} != ""
MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
.export MAKESYSPATH
.elif empty(MAKESYSPATH)
MAKESYSPATH:=	${.PARSEDIR:tA}
.export MAKESYSPATH
.endif

.if ${RELDIR:U} == "." && ${.MAKE.LEVEL} == 0
.sinclude "${.CURDIR}/Makefile.sys.inc"
.endif
.include <src.sys.obj.mk>