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