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