1dc24dddru# $FreeBSD$
2dc24dddru
34c3c62dimp# The include file <bsd.init.mk> includes <bsd.opts.mk>,
44c3c62dimp# ../Makefile.inc and <bsd.own.mk>; this is used at the
54c3c62dimp# top of all <bsd.*.mk> files that actually "build something".
64c3c62dimp# bsd.opts.mk is included early so Makefile.inc can use the
74c3c62dimp# MK_FOO variables.
8dc24dddru
9dc24dddru.if !target(__<bsd.init.mk>__)
10dc24dddru__<bsd.init.mk>__:
114c3c62dimp.include <bsd.opts.mk>
12008d7c8sjg.-include "local.init.mk"
13bc0048ebdrewery
14bc0048ebdrewery# This is also done in bsd.obj.mk
15e10157cbdrewery.if defined(NO_OBJ) && ${.OBJDIR} != ${.CURDIR}
16bc0048ebdrewery.OBJDIR: ${.CURDIR}
17bc0048ebdrewery.endif
18bc0048ebdrewery
19dc24dddru.if exists(${.CURDIR}/../Makefile.inc)
20dc24dddru.include "${.CURDIR}/../Makefile.inc"
21dc24dddru.endif
22dc24dddru.include <bsd.own.mk>
23dc24dddru.MAIN: all
249dd41e3marcel
258425f75sjg# This is used in bsd.{dep,lib,prog}.mk as ${OBJS_SRCS_FILTER:ts:}
268425f75sjg# Some makefiles may want T as well to avoid nested objdirs.
278425f75sjgOBJS_SRCS_FILTER+= R
288425f75sjg
29cafe808vangyzen# Handle INSTALL_AS_USER here to maximize the chance that
30cafe808vangyzen# it has final authority over fooOWN and fooGRP.
31cafe808vangyzen.if ${MK_INSTALL_AS_USER} != "no"
32cafe808vangyzen.if !defined(_uid)
33cafe808vangyzen_uid!=	id -u
34cafe808vangyzen.export _uid
35cafe808vangyzen.endif
36cafe808vangyzen.if ${_uid} != 0
37cafe808vangyzen.if !defined(_gid)
38cafe808vangyzen_gid!=	id -g
39cafe808vangyzen.export _gid
40cafe808vangyzen.endif
41cafe808vangyzen.for x in BIN CONF DOC DTB INFO KMOD LIB MAN NLS SHARE
429a2a2c2vangyzen$xOWN=	${_uid}
43cafe808vangyzen$xGRP=	${_gid}
44cafe808vangyzen.endfor
45cafe808vangyzen.endif
46cafe808vangyzen.endif
47cafe808vangyzen
481ef0682bdrewery# Some targets need to know when something may build.  This is used to
491ef0682bdrewery# optimize targets that are only needed when building something, such as
501ef0682bdrewery# (not) reading in depend files.  For DIRDEPS_BUILD, it will only calculate
511ef0682bdrewery# the dependency graph at .MAKE.LEVEL==0, so nothing should be built there.
521ef0682bdrewery# Skip "build" logic if:
531ef0682bdrewery# - DIRDEPS_BUILD at MAKELEVEL 0
541ef0682bdrewery# - make -V is used without an override
551ef0682bdrewery# - make install is used without other targets.  This is to avoid breaking
561ef0682bdrewery#   things like 'make all install' or 'make foo install'.
571ef0682bdrewery# - non-build targets are called
581ef0682bdrewery.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL:U1} == 0 && \
593f7167abdrewery    ${BUILD_AT_LEVEL0:Uyes:tl} == "no" && !make(clean*) && !make(*clean)
601ef0682bdrewery_SKIP_BUILD=	not building at level 0
61329898fbdrewery.elif !empty(.MAKEFLAGS:M-V${_V_DO_BUILD}) || \
621ef0682bdrewery    ${.TARGETS:M*install*} == ${.TARGETS} || \
6357488d2bdrewery    ${.TARGETS:Mclean*} == ${.TARGETS} || \
643f7167abdrewery    ${.TARGETS:M*clean} == ${.TARGETS} || \
6557488d2bdrewery    ${.TARGETS:Mdestroy*} == ${.TARGETS} || \
66602b873bdrewery    ${.TARGETS:Mobj} == ${.TARGETS} || \
67602b873bdrewery    make(analyze) || make(print-dir)
681ef0682bdrewery# Skip building, but don't show a warning.
691ef0682bdrewery_SKIP_BUILD=
709dd41e3marcel.endif
711ef0682bdrewery.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} > 0 && !empty(_SKIP_BUILD)
72008d7c8sjg.warning ${_SKIP_BUILD}
73008d7c8sjg.endif
749dd41e3marcel
7544e1938bdrewerybeforebuild: .PHONY .NOTMAIN
7644e1938bdrewery.if !defined(_SKIP_BUILD)
7744e1938bdreweryall: beforebuild .WAIT
7844e1938bdrewery.endif
7944e1938bdrewery
802e92e3abdrewery.if ${MK_META_MODE} == "yes"
812e92e3abdrewery.if !exists(/dev/filemon) && \
822e92e3abdrewery    ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !defined(NO_FILEMON) && \
835c86164bdrewery    !make(test-system-*) && !make(showconfig) && !make(print-dir) && \
845c86164bdrewery    ${.MAKEFLAGS:M-V} == ""
852e92e3abdrewery.warning The filemon module (/dev/filemon) is not loaded.
862e92e3abdrewery.warning META_MODE is less useful for incremental builds without filemon.
872e92e3abdrewery.warning 'kldload filemon' or pass -DNO_FILEMON to suppress this warning.
882e92e3abdrewery.endif
892e92e3abdrewery.endif	# ${MK_META_MODE} == "yes"
902e92e3abdrewery
91f2968c8harti.endif	# !target(__<bsd.init.mk>__)
92