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