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