]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.init.mk
Merge branch 'releng/11.3' into releng-CDN/11.3
[FreeBSD/FreeBSD.git] / share / mk / bsd.init.mk
1 # $FreeBSD$
2
3 # The include file <bsd.init.mk> includes <bsd.opts.mk>,
4 # ../Makefile.inc and <bsd.own.mk>; this is used at the
5 # top of all <bsd.*.mk> files that actually "build something".
6 # bsd.opts.mk is included early so Makefile.inc can use the
7 # MK_FOO variables.
8
9 .if !target(__<bsd.init.mk>__)
10 __<bsd.init.mk>__:
11 .include <bsd.opts.mk>
12 .-include "local.init.mk"
13 .if exists(${.CURDIR}/../Makefile.inc)
14 .include "${.CURDIR}/../Makefile.inc"
15 .endif
16 .include <bsd.own.mk>
17 .MAIN: all
18
19 # Handle INSTALL_AS_USER here to maximize the chance that
20 # it has final authority over fooOWN and fooGRP.
21 .if ${MK_INSTALL_AS_USER} != "no"
22 .if !defined(_uid)
23 _uid!=  id -u
24 .export _uid
25 .endif
26 .if ${_uid} != 0
27 .if !defined(_gid)
28 _gid!=  id -g
29 .export _gid
30 .endif
31 .for x in BIN CONF DOC DTB INFO KMOD LIB MAN NLS SHARE
32 $xOWN=  ${_uid}
33 $xGRP=  ${_gid}
34 .endfor
35 .endif
36 .endif
37
38 # Some targets need to know when something may build.  This is used to
39 # optimize targets that are only needed when building something, such as
40 # (not) reading in depend files.  For DIRDEPS_BUILD, it will only calculate
41 # the dependency graph at .MAKE.LEVEL==0, so nothing should be built there.
42 # Skip "build" logic if:
43 # - DIRDEPS_BUILD at MAKELEVEL 0
44 # - make -V is used without an override
45 # - make install is used without other targets.  This is to avoid breaking
46 #   things like 'make all install' or 'make foo install'.
47 # - non-build targets are called
48 .if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL:U1} == 0 && \
49     ${BUILD_AT_LEVEL0:Uyes:tl} == "no" && !make(clean*)
50 _SKIP_BUILD=    not building at level 0
51 .elif !empty(.MAKEFLAGS:M-V${_V_DO_BUILD}) || \
52     ${.TARGETS:M*install*} == ${.TARGETS} || \
53     ${.TARGETS:Mclean*} == ${.TARGETS} || \
54     ${.TARGETS:Mdestroy*} == ${.TARGETS} || \
55     make(obj) || make(analyze) || make(print-dir)
56 # Skip building, but don't show a warning.
57 _SKIP_BUILD=
58 .endif
59 .if ${MK_DIRDEPS_BUILD} == "yes" && ${.MAKE.LEVEL} > 0 && !empty(_SKIP_BUILD)
60 .warning ${_SKIP_BUILD}
61 .endif
62
63 beforebuild: .PHONY .NOTMAIN
64 .if !defined(_SKIP_BUILD)
65 all: beforebuild .WAIT
66 .endif
67
68 .if ${MK_META_MODE} == "yes"
69 .if !exists(/dev/filemon) && \
70     ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !defined(NO_FILEMON) && \
71     !make(showconfig) && !make(print-dir) && ${.MAKEFLAGS:M-V} == ""
72 .warning The filemon module (/dev/filemon) is not loaded.
73 .warning META_MODE is less useful for incremental builds without filemon.
74 .warning 'kldload filemon' or pass -DNO_FILEMON to suppress this warning.
75 .endif
76 .endif  # ${MK_META_MODE} == "yes"
77
78 .endif  # !target(__<bsd.init.mk>__)