xref: /freebsd/Makefile.sys.inc (revision e22224a5)
1a7fa261eSBryan Drewery# $FreeBSD$
2a7fa261eSBryan Drewery#
3a7fa261eSBryan Drewery# This is included very early from share/mk/src.sys.env.mk, after
4a7fa261eSBryan Drewery# /etc/src-env.conf but before /etc/make.conf, /etc/src.conf, or OBJDIR
5a7fa261eSBryan Drewery# handling.
6a7fa261eSBryan Drewery# - It is not safe to use .OBJDIR/OBJTOP/OBJROOT here.
7a7fa261eSBryan Drewery# - __ENV_ONLY_OPTIONS have been parsed by now except for opporutunistic
8a7fa261eSBryan Drewery#   MK_AUTO_OBJ.
9a7fa261eSBryan Drewery#
10a7fa261eSBryan Drewery
11a7fa261eSBryan Drewery.if ${MK_DIRDEPS_BUILD} == "no"
12a7fa261eSBryan Drewery# For AUTO_OBJ many targets do not need object directories created at top-level
13a7fa261eSBryan Drewery# for each visited directory.  Only when things are being built are they
14a7fa261eSBryan Drewery# needed.  Having AUTO_OBJ disabled in a build target is fine as it should
15a7fa261eSBryan Drewery# fallback to running 'make obj' as needed.  If a target is not in this list
16a7fa261eSBryan Drewery# then it is ran with MK_AUTO_OBJ=no in environment.
17a7fa261eSBryan Drewery# 'showconfig' is in the list to avoid forcing MK_AUTO_OBJ=no for it.
18a7fa261eSBryan DreweryAUTO_OBJ_TGT_WHITELIST+= \
19a7fa261eSBryan Drewery	_* all all-man build* depend everything *toolchain* includes \
20a7fa261eSBryan Drewery	libraries obj objlink showconfig tags xdev xdev-build native-xtools \
21a7fa261eSBryan Drewery	stage* create-packages* real-packages sign-packages package-pkg \
22a7fa261eSBryan Drewery	tinderbox universe* kernel kernels world worlds bmake
23a7fa261eSBryan Drewery
24a7fa261eSBryan Drewery# Only allow AUTO_OBJ for the whitelisted targets.  See AUTO_OBJ_TGT_WHITELIST
25a7fa261eSBryan Drewery# above.  MK_AUTO_OBJ not checked here for "yes" as it may not yet be enabled
26a7fa261eSBryan Drewery# since it is opportunistic.
27a7fa261eSBryan Drewery.if empty(.MAKEOVERRIDES:MMK_AUTO_OBJ)
28a7fa261eSBryan Drewery.for _tgt in ${AUTO_OBJ_TGT_WHITELIST}
29a7fa261eSBryan Drewery.if make(${_tgt})
30a7fa261eSBryan Drewery_CAN_USE_AUTO_OBJ?= yes
31a7fa261eSBryan Drewery.endif
32a7fa261eSBryan Drewery.endfor
33a7fa261eSBryan Drewery.if !defined(_CAN_USE_AUTO_OBJ)
34a7fa261eSBryan Drewery_MAKEARGS+=		MK_AUTO_OBJ=no
35a7fa261eSBryan DreweryMK_AUTO_OBJ=		no
367e0aabd9SBryan Drewery# This will prevent src.sys.obj.mk from opportunistically enabling AUTO_OBJ
377e0aabd9SBryan Drewery# in this make execution and for sub-makes.  For all of these targets we
387e0aabd9SBryan Drewery# just want to read any existing OBJDIR but we don't care if we can create
397e0aabd9SBryan Drewery# or write to them.
407e0aabd9SBryan Drewery.MAKEOVERRIDES+=	MK_AUTO_OBJ
41e22224a5SBryan Drewery.else
42e22224a5SBryan Drewery# For top-level we always assume the MAKEOBJDIRPREFIX is writable rather than
43e22224a5SBryan Drewery# falling back to .CURDIR.
44e22224a5SBryan Drewery__objdir_writable= yes
45a7fa261eSBryan Drewery.endif
46a7fa261eSBryan Drewery.endif	# empty(.MAKEOVERRIDES:MMK_AUTO_OBJ)
47a7fa261eSBryan Drewery
48a7fa261eSBryan Drewery.endif	# ${MK_DIRDEPS_BUILD} == "no"
49