xref: /freebsd/share/mk/bsd.init.mk (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
12bdaf7e8SRuslan Ermilov
28609cb7bSWarner Losh# The include file <bsd.init.mk> includes <bsd.opts.mk>,
38609cb7bSWarner Losh# ../Makefile.inc and <bsd.own.mk>; this is used at the
48609cb7bSWarner Losh# top of all <bsd.*.mk> files that actually "build something".
58609cb7bSWarner Losh# bsd.opts.mk is included early so Makefile.inc can use the
68609cb7bSWarner Losh# MK_FOO variables.
72bdaf7e8SRuslan Ermilov
82bdaf7e8SRuslan Ermilov.if !target(__<bsd.init.mk>__)
92bdaf7e8SRuslan Ermilov__<bsd.init.mk>__:
108609cb7bSWarner Losh.include <bsd.opts.mk>
11ccfb9654SSimon J. Gerraty.-include "local.init.mk"
12aba77dddSBryan Drewery
13aba77dddSBryan Drewery# This is also done in bsd.obj.mk
14fa65e3a5SBryan Drewery.if defined(NO_OBJ) && ${.OBJDIR} != ${.CURDIR}
15aba77dddSBryan Drewery.OBJDIR: ${.CURDIR}
16aba77dddSBryan Drewery.endif
17aba77dddSBryan Drewery
182bdaf7e8SRuslan Ermilov.if exists(${.CURDIR}/../Makefile.inc)
192bdaf7e8SRuslan Ermilov.include "${.CURDIR}/../Makefile.inc"
202bdaf7e8SRuslan Ermilov.endif
212bdaf7e8SRuslan Ermilov.include <bsd.own.mk>
222bdaf7e8SRuslan Ermilov.MAIN: all
237750ad47SMarcel Moolenaar
242506d700SSimon J. Gerraty# This is used in bsd.{dep,lib,prog}.mk as ${OBJS_SRCS_FILTER:ts:}
252506d700SSimon J. Gerraty# Some makefiles may want T as well to avoid nested objdirs.
262506d700SSimon J. GerratyOBJS_SRCS_FILTER+= R
272506d700SSimon J. Gerraty
284f2bab59SEric van Gyzen# Handle INSTALL_AS_USER here to maximize the chance that
294f2bab59SEric van Gyzen# it has final authority over fooOWN and fooGRP.
304f2bab59SEric van Gyzen.if ${MK_INSTALL_AS_USER} != "no"
314f2bab59SEric van Gyzen.if !defined(_uid)
324f2bab59SEric van Gyzen_uid!=	id -u
334f2bab59SEric van Gyzen.export _uid
344f2bab59SEric van Gyzen.endif
354f2bab59SEric van Gyzen.if ${_uid} != 0
364f2bab59SEric van Gyzen.if !defined(_gid)
374f2bab59SEric van Gyzen_gid!=	id -g
384f2bab59SEric van Gyzen.export _gid
394f2bab59SEric van Gyzen.endif
404f2bab59SEric van Gyzen.for x in BIN CONF DOC DTB INFO KMOD LIB MAN NLS SHARE
41c9d34d66SEric van Gyzen$xOWN=	${_uid}
424f2bab59SEric van Gyzen$xGRP=	${_gid}
434f2bab59SEric van Gyzen.endfor
444f2bab59SEric van Gyzen.endif
454f2bab59SEric van Gyzen.endif
464f2bab59SEric van Gyzen
47d7173250SBryan Drewery# Some targets need to know when something may build.  This is used to
48d7173250SBryan Drewery# optimize targets that are only needed when building something, such as
49d7173250SBryan Drewery# (not) reading in depend files.  For DIRDEPS_BUILD, it will only calculate
50d7173250SBryan Drewery# the dependency graph at .MAKE.LEVEL==0, so nothing should be built there.
51d7173250SBryan Drewery# Skip "build" logic if:
52d7173250SBryan Drewery# - DIRDEPS_BUILD at MAKELEVEL 0
53d7173250SBryan Drewery# - make -V is used without an override
54d7173250SBryan Drewery# - make install is used without other targets.  This is to avoid breaking
55d7173250SBryan Drewery#   things like 'make all install' or 'make foo install'.
56d7173250SBryan Drewery# - non-build targets are called
57*960b77beSSimon J. Gerraty.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} == 0
58*960b77beSSimon J. Gerraty# targets that are ok at level 0
59*960b77beSSimon J. GerratyDIRDEPS_BUILD_LEVEL0_TARGETS += clean* destroy*
60*960b77beSSimon J. GerratyM_ListToSkip?= O:u:S,^,N,:ts:
61*960b77beSSimon J. Gerraty.if ${.TARGETS:Uall:${DIRDEPS_BUILD_LEVEL0_TARGETS:${M_ListToSkip}}} != ""
627750ad47SMarcel Moolenaar_SKIP_BUILD=	not building at level 0
63*960b77beSSimon J. Gerraty.endif
641f265bbdSBryan Drewery.elif !empty(.MAKEFLAGS:M-V${_V_DO_BUILD}) || \
65d7173250SBryan Drewery    ${.TARGETS:M*install*} == ${.TARGETS} || \
6605f3e1feSBryan Drewery    ${.TARGETS:Mclean*} == ${.TARGETS} || \
673b53f994SBryan Drewery    ${.TARGETS:M*clean} == ${.TARGETS} || \
6805f3e1feSBryan Drewery    ${.TARGETS:Mdestroy*} == ${.TARGETS} || \
69b284f322SBryan Drewery    ${.TARGETS:Mobj} == ${.TARGETS} || \
70b284f322SBryan Drewery    make(analyze) || make(print-dir)
71d7173250SBryan Drewery# Skip building, but don't show a warning.
72d7173250SBryan Drewery_SKIP_BUILD=
737750ad47SMarcel Moolenaar.endif
74d7173250SBryan Drewery.if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} > 0 && !empty(_SKIP_BUILD)
75ccfb9654SSimon J. Gerraty.warning ${_SKIP_BUILD}
76ccfb9654SSimon J. Gerraty.endif
777750ad47SMarcel Moolenaar
78f4fbac19SBryan Drewerybeforebuild: .PHONY .NOTMAIN
79f4fbac19SBryan Drewery.if !defined(_SKIP_BUILD)
80f4fbac19SBryan Dreweryall: beforebuild .WAIT
81f4fbac19SBryan Drewery.endif
82f4fbac19SBryan Drewery
83b8ef21b8SBryan Drewery.if ${MK_META_MODE} == "yes"
84b8ef21b8SBryan Drewery.if !exists(/dev/filemon) && \
85b8ef21b8SBryan Drewery    ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !defined(NO_FILEMON) && \
866e6be2bbSBryan Drewery    !make(test-system-*) && !make(showconfig) && !make(print-dir) && \
876e6be2bbSBryan Drewery    ${.MAKEFLAGS:M-V} == ""
88b8ef21b8SBryan Drewery.warning The filemon module (/dev/filemon) is not loaded.
89b8ef21b8SBryan Drewery.warning META_MODE is less useful for incremental builds without filemon.
90b8ef21b8SBryan Drewery.warning 'kldload filemon' or pass -DNO_FILEMON to suppress this warning.
91b8ef21b8SBryan Drewery.endif
92b8ef21b8SBryan Drewery.endif	# ${MK_META_MODE} == "yes"
93b8ef21b8SBryan Drewery
9484aac273SHartmut Brandt.endif	# !target(__<bsd.init.mk>__)
95