]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/sys.mk
MFV r323795: 8604 Avoid unnecessary work search in VFS when unmounting snapshots
[FreeBSD/FreeBSD.git] / share / mk / sys.mk
1 #       from: @(#)sys.mk        8.2 (Berkeley) 3/21/94
2 # $FreeBSD$
3
4 unix            ?=      We run FreeBSD, not UNIX.
5 .FreeBSD        ?=      true
6
7 .if !defined(%POSIX)
8 #
9 # MACHINE_CPUARCH defines a collection of MACHINE_ARCH.  Machines with
10 # the same MACHINE_ARCH can run each other's binaries, so it necessarily
11 # has word size and endian swizzled in.  However, the source files for
12 # these machines often are shared amongst all combinations of size
13 # and/or endian.  This is called MACHINE_CPU in NetBSD, but that's used
14 # for something different in FreeBSD.
15 #
16 __TO_CPUARCH=C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v6)?(eb)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64(sf)?/riscv/
17 MACHINE_CPUARCH=${MACHINE_ARCH:${__TO_CPUARCH}}
18 .endif
19
20
21 # Some options we need now
22 __DEFAULT_NO_OPTIONS= \
23         DIRDEPS_BUILD \
24         DIRDEPS_CACHE
25
26 __DEFAULT_DEPENDENT_OPTIONS= \
27         AUTO_OBJ/DIRDEPS_BUILD \
28         META_MODE/DIRDEPS_BUILD \
29         STAGING/DIRDEPS_BUILD \
30         SYSROOT/DIRDEPS_BUILD
31
32 __ENV_ONLY_OPTIONS:= \
33         ${__DEFAULT_NO_OPTIONS} \
34         ${__DEFAULT_YES_OPTIONS} \
35         ${__DEFAULT_DEPENDENT_OPTIONS:H}
36
37 # early include for customization
38 # see local.sys.mk below
39 # Not included when building in fmake compatibility mode (still needed
40 # for older system support)
41 .if defined(.PARSEDIR)
42 .sinclude <local.sys.env.mk>
43
44 .include <bsd.mkopt.mk>
45
46 # Disable MK_META_MODE with make -B
47 .if ${MK_META_MODE} == "yes" && defined(.MAKEFLAGS) && ${.MAKEFLAGS:M-B}
48 MK_META_MODE=   no
49 .endif
50
51 .if ${MK_DIRDEPS_BUILD} == "yes"
52 .sinclude <meta.sys.mk>
53 .elif ${MK_META_MODE} == "yes"
54 # verbose will show .MAKE.META.PREFIX for each target.
55 META_MODE+=     meta verbose
56 .if !defined(NO_META_MISSING)
57 META_MODE+=     missing-meta=yes
58 .endif
59 # silent will hide command output if a .meta file is created.
60 .if !defined(NO_SILENT)
61 META_MODE+=     silent=yes
62 .endif
63 .if !exists(/dev/filemon) || defined(NO_FILEMON)
64 META_MODE+= nofilemon
65 .endif
66 # Require filemon data with bmake
67 .if empty(META_MODE:Mnofilemon)
68 META_MODE+= missing-filemon=yes
69 .endif
70 .endif
71 META_MODE?= normal
72 .export META_MODE
73 .MAKE.MODE?= ${META_MODE}
74 .if !empty(.MAKE.MODE:Mmeta)
75 .if !defined(NO_META_IGNORE_HOST)
76 # Ignore host file changes that will otherwise cause
77 # buildworld -> installworld -> buildworld to rebuild everything.
78 # Since the build is self-reliant and bootstraps everything it needs,
79 # this should not be a real problem for incremental builds.
80 # XXX: This relies on the existing host tools retaining ABI compatibility
81 # through upgrades since they won't be rebuilt on header/library changes.
82 # This is mitigated by Makefile.inc1 for known-ABI-breaking revisions.
83 # Note that these are prefix matching, so /lib matches /libexec.
84 .MAKE.META.IGNORE_PATHS+= \
85         ${__MAKE_SHELL} \
86         /bin \
87         /lib \
88         /rescue \
89         /sbin \
90         /usr/bin \
91         /usr/lib \
92         /usr/sbin \
93         /usr/share \
94
95 .else
96 NO_META_IGNORE_HOST_HEADERS=    1
97 .endif
98 .if !defined(NO_META_IGNORE_HOST_HEADERS)
99 .MAKE.META.IGNORE_PATHS+= /usr/include
100 .endif
101 # We do not want everything out-of-date just because
102 # some unrelated shared lib updated this.
103 .MAKE.META.IGNORE_PATHS+= /usr/local/etc/libmap.d
104 .endif  # !empty(.MAKE.MODE:Mmeta)
105
106 .if ${MK_AUTO_OBJ} == "yes"
107 # This needs to be done early - before .PATH is computed
108 # Don't do this for 'make showconfig' as it enables all options where meta mode
109 # is not expected.
110 .if !make(showconfig) && !make(print-dir)
111 .sinclude <auto.obj.mk>
112 .endif
113 .endif
114 .else # bmake
115 .include <bsd.mkopt.mk>
116 .endif
117
118 # If the special target .POSIX appears (without prerequisites or
119 # commands) before the first noncomment line in the makefile, make shall
120 # process the makefile as specified by the Posix 1003.2 specification.
121 # make(1) sets the special macro %POSIX in this case (to the actual
122 # value "1003.2", for what it's worth).
123 #
124 # The rules below use this macro to distinguish between Posix-compliant
125 # and default behaviour.
126 #
127 # This functionality is currently broken, since make(1) processes sys.mk
128 # before reading any other files, and consequently has no opportunity to
129 # set the %POSIX macro before we read this point.
130
131 .if defined(%POSIX)
132 .SUFFIXES:      .o .c .y .l .a .sh .f
133 .else
134 .SUFFIXES:      .out .a .ln .o .bco .llo .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
135 .endif
136
137 AR              ?=      ar
138 .if defined(%POSIX)
139 ARFLAGS         ?=      -rv
140 .else
141 ARFLAGS         ?=      -crD
142 .endif
143 RANLIB          ?=      ranlib
144 .if !defined(%POSIX)
145 RANLIBFLAGS     ?=      -D
146 .endif
147
148 AS              ?=      as
149 AFLAGS          ?=
150 ACFLAGS         ?=
151
152 .if defined(%POSIX)
153 CC              ?=      c89
154 CFLAGS          ?=      -O
155 .else
156 CC              ?=      cc
157 .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
158 CFLAGS          ?=      -O -pipe
159 .else
160 CFLAGS          ?=      -O2 -pipe
161 .endif
162 .if defined(NO_STRICT_ALIASING)
163 CFLAGS          +=      -fno-strict-aliasing
164 .endif
165 .endif
166 IR_CFLAGS       ?=      ${STATIC_CFLAGS:N-O*} ${CFLAGS:N-O*}
167 PO_CFLAGS       ?=      ${CFLAGS}
168
169 # cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
170 # read-only files as non-root by passing -f.
171 CP              ?=      cp -f
172
173 CPP             ?=      cpp
174
175 # C Type Format data is required for DTrace
176 CTFFLAGS        ?=      -L VERSION
177
178 CTFCONVERT      ?=      ctfconvert
179 CTFMERGE        ?=      ctfmerge
180
181 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
182 CTFFLAGS        +=      -g
183 .endif
184
185 CXX             ?=      c++
186 CXXFLAGS        ?=      ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
187 IR_CXXFLAGS     ?=      ${STATIC_CXXFLAGS:N-O*} ${CXXFLAGS:N-O*}
188 PO_CXXFLAGS     ?=      ${CXXFLAGS}
189
190 DTRACE          ?=      dtrace
191 DTRACEFLAGS     ?=      -C -x nolibs
192
193 .if empty(.MAKEFLAGS:M-s)
194 ECHO            ?=      echo
195 ECHODIR         ?=      echo
196 .else
197 ECHO            ?=      true
198 .if ${.MAKEFLAGS:M-s} == "-s"
199 ECHODIR         ?=      echo
200 .else
201 ECHODIR         ?=      true
202 .endif
203 .endif
204
205 .if ${.MAKEFLAGS:M-N}
206 # bmake -N is supposed to skip executing anything but it does not skip
207 # exeucting '+' commands.  The '+' feature is used where .MAKE
208 # is not safe for the entire target.  -N is intended to skip building sub-makes
209 # so it executing '+' commands is not right.  Work around the bug by not
210 # setting '+' when -N is used.
211 _+_             ?=
212 .else
213 _+_             ?=      +
214 .endif
215
216 .if defined(%POSIX)
217 FC              ?=      fort77
218 FFLAGS          ?=      -O 1
219 .else
220 FC              ?=      f77
221 FFLAGS          ?=      -O
222 .endif
223 EFLAGS          ?=
224
225 INSTALL         ?=      install
226
227 LEX             ?=      lex
228 LFLAGS          ?=
229
230 # LDFLAGS is for CC, _LDFLAGS is for LD.  Generate _LDFLAGS from
231 # LDFLAGS by stripping -Wl, from pass-through arguments and dropping
232 # compiler driver flags (e.g. -mabi=*) that conflict with flags to LD.
233 LD              ?=      ld
234 LDFLAGS         ?=
235 _LDFLAGS        =       ${LDFLAGS:S/-Wl,//g:N-mabi=*}
236
237 LINT            ?=      lint
238 LINTFLAGS       ?=      -cghapbx
239 LINTKERNFLAGS   ?=      ${LINTFLAGS}
240 LINTOBJFLAGS    ?=      -cghapbxu -i
241 LINTOBJKERNFLAGS?=      ${LINTOBJFLAGS}
242 LINTLIBFLAGS    ?=      -cghapbxu -C ${LIB}
243
244 MAKE            ?=      make
245
246 .if !defined(%POSIX)
247 LLVM_LINK       ?=      llvm-link
248
249 LORDER          ?=      lorder
250
251 NM              ?=      nm
252 NMFLAGS         ?=
253
254 OBJC            ?=      cc
255 OBJCFLAGS       ?=      ${OBJCINCLUDES} ${CFLAGS} -Wno-import
256
257 OBJCOPY         ?=      objcopy
258
259 PC              ?=      pc
260 PFLAGS          ?=
261
262 RC              ?=      f77
263 RFLAGS          ?=
264
265 TSORT           ?=      tsort
266 TSORTFLAGS      ?=      -q
267 .endif
268
269 SHELL           ?=      sh
270
271 .if !defined(%POSIX)
272 SIZE            ?=      size
273 .endif
274
275 YACC            ?=      yacc
276 .if defined(%POSIX)
277 YFLAGS          ?=
278 .else
279 YFLAGS          ?=      -d
280 .endif
281
282 .if defined(%POSIX)
283
284 .include "bsd.suffixes-posix.mk"
285
286 .else
287
288 # non-Posix rule set
289 .include "bsd.suffixes.mk"
290
291 # Pull in global settings.
292 __MAKE_CONF?=/etc/make.conf
293 .if exists(${__MAKE_CONF})
294 .include "${__MAKE_CONF}"
295 .endif
296
297 # late include for customization
298 .sinclude <local.sys.mk>
299
300 .if defined(META_MODE)
301 META_MODE:=     ${META_MODE:O:u}
302 .endif
303
304 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
305 SHELL=  ${__MAKE_SHELL}
306 .SHELL: path=${__MAKE_SHELL}
307 .endif
308
309 # Tell bmake to expand -V VAR by default
310 .MAKE.EXPAND_VARIABLES= yes
311
312 # Tell bmake the makefile preference
313 .MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
314
315 # Tell bmake to always pass job tokens, regardless of target depending on
316 # .MAKE or looking like ${MAKE}/${.MAKE}/$(MAKE)/$(.MAKE)/make.
317 .MAKE.ALWAYS_PASS_JOB_QUEUE= yes
318
319 # By default bmake does *not* use set -e
320 # when running target scripts, this is a problem for many makefiles here.
321 # So define a shell that will do what FreeBSD expects.
322 .ifndef WITHOUT_SHELL_ERRCTL
323 __MAKE_SHELL?=/bin/sh
324 .SHELL: name=sh \
325         quiet="set -" echo="set -v" filter="set -" \
326         hasErrCtl=yes check="set -e" ignore="set +e" \
327         echoFlag=v errFlag=e \
328         path=${__MAKE_SHELL}
329 .endif
330
331 # Hack for ports compatibility. Historically, ports makefiles have
332 # assumed they can examine MACHINE_CPU without including anything
333 # because this was automatically included in sys.mk. For /usr/src,
334 # this file has moved to being included from bsd.opts.mk. Until all
335 # the ports files are modernized, and a reasonable transition
336 # period has passed, include it while we're in a ports tree here
337 # to preserve historic behavior.
338 .if exists(${.CURDIR}/../../Mk/bsd.port.mk)
339 .include <bsd.cpu.mk>
340 .endif
341
342 .endif # ! Posix