1 # from: @(#)sys.mk 8.2 (Berkeley) 3/21/94
4 unix ?= We run FreeBSD, not UNIX.
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.
16 __TO_CPUARCH=C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v[67])?(eb)?/arm/:C/powerpc(64|64le|spe)/powerpc/:C/riscv64(sf)?/riscv/
17 MACHINE_CPUARCH=${MACHINE_ARCH:${__TO_CPUARCH}}
20 __DEFAULT_YES_OPTIONS+= \
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.
26 __DEFAULT_YES_OPTIONS+= AUTO_OBJ
29 # Some options we need now
30 __DEFAULT_NO_OPTIONS= \
34 __DEFAULT_DEPENDENT_OPTIONS= \
35 AUTO_OBJ/DIRDEPS_BUILD \
36 META_MODE/DIRDEPS_BUILD \
37 STAGING/DIRDEPS_BUILD \
40 __ENV_ONLY_OPTIONS:= \
41 ${__DEFAULT_NO_OPTIONS} \
42 ${__DEFAULT_YES_OPTIONS} \
43 ${__DEFAULT_DEPENDENT_OPTIONS:H}
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>
52 .include <bsd.mkopt.mk>
54 # Disable MK_META_MODE with make -B
55 .if ${MK_META_MODE} == "yes" && defined(.MAKEFLAGS) && ${.MAKEFLAGS:M-B}
59 .if ${MK_DIRDEPS_BUILD} == "yes"
60 .sinclude <meta.sys.mk>
61 .elif ${MK_META_MODE} == "yes"
63 .if empty(.MAKEFLAGS:M-s)
64 # verbose will show .MAKE.META.PREFIX for each target.
67 .if !defined(NO_META_MISSING)
68 META_MODE+= missing-meta=yes
70 # silent will hide command output if a .meta file is created.
71 .if !defined(NO_SILENT)
72 META_MODE+= silent=yes
74 .if !exists(/dev/filemon) || defined(NO_FILEMON)
77 # Require filemon data with bmake
78 .if empty(META_MODE:Mnofilemon)
79 META_MODE+= missing-filemon=yes
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+= \
107 NO_META_IGNORE_HOST_HEADERS= 1
109 .if !defined(NO_META_IGNORE_HOST_HEADERS)
110 .MAKE.META.IGNORE_PATHS+= /usr/include
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)
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
121 .if !make(showconfig) && !make(print-dir) && !make(test-system-*) && \
122 empty(.MAKEFLAGS:M-[nN])
123 .sinclude <auto.obj.mk>
125 .endif # ${MK_AUTO_OBJ} == "yes"
127 .include <bsd.mkopt.mk>
130 # If the special target .POSIX appears (without prerequisites or
131 # commands) before the first noncomment line in the makefile, make shall
132 # process the makefile as specified by the Posix 1003.2 specification.
133 # make(1) sets the special macro %POSIX in this case (to the actual
134 # value "1003.2", for what it's worth).
136 # The rules below use this macro to distinguish between Posix-compliant
137 # and default behaviour.
139 # This functionality is currently broken, since make(1) processes sys.mk
140 # before reading any other files, and consequently has no opportunity to
141 # set the %POSIX macro before we read this point.
144 .SUFFIXES: .o .c .y .l .a .sh .f
146 .SUFFIXES: .out .a .o .bco .llo .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh
169 .if ${MACHINE_CPUARCH} == "mips"
174 .if defined(NO_STRICT_ALIASING)
175 CFLAGS += -fno-strict-aliasing
178 IR_CFLAGS ?= ${STATIC_CFLAGS:N-O*} ${CFLAGS:N-O*}
179 PO_CFLAGS ?= ${CFLAGS}
181 # cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
182 # read-only files as non-root by passing -f.
187 # C Type Format data is required for DTrace
188 CTFFLAGS ?= -L VERSION
190 CTFCONVERT ?= ctfconvert
193 .if defined(CFLAGS) && (${CFLAGS:M-g} != "")
198 CXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
199 IR_CXXFLAGS ?= ${STATIC_CXXFLAGS:N-O*} ${CXXFLAGS:N-O*}
200 PO_CXXFLAGS ?= ${CXXFLAGS}
203 DTRACEFLAGS ?= -C -x nolibs
205 .if empty(.MAKEFLAGS:M-s)
210 .if ${.MAKEFLAGS:M-s} == "-s"
217 .if ${.MAKEFLAGS:M-N}
218 # bmake -N is supposed to skip executing anything but it does not skip
219 # exeucting '+' commands. The '+' feature is used where .MAKE
220 # is not safe for the entire target. -N is intended to skip building sub-makes
221 # so it executing '+' commands is not right. Work around the bug by not
222 # setting '+' when -N is used.
237 INSTALL ?= ${INSTALL_CMD:Uinstall}
242 # LDFLAGS is for CC, _LDFLAGS is for LD. Generate _LDFLAGS from
243 # LDFLAGS by stripping -Wl, from pass-through arguments and dropping
244 # compiler driver flags (e.g. -mabi=*) that conflict with flags to LD.
247 _LDFLAGS = ${LDFLAGS:S/-Wl,//g:N-mabi=*:N-fuse-ld=*}
252 LLVM_LINK ?= llvm-link
260 OBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import
290 .include "bsd.suffixes-posix.mk"
295 .include "bsd.suffixes.mk"
297 # Pull in global settings.
298 __MAKE_CONF?=/etc/make.conf
299 .if exists(${__MAKE_CONF})
300 .include "${__MAKE_CONF}"
303 # late include for customization
304 .sinclude <local.sys.mk>
306 .if defined(META_MODE)
307 META_MODE:= ${META_MODE:O:u}
310 .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
311 SHELL= ${__MAKE_SHELL}
312 .SHELL: path=${__MAKE_SHELL}
315 # Tell bmake to expand -V VAR by default
316 .MAKE.EXPAND_VARIABLES= yes
318 # Tell bmake the makefile preference
319 MAKEFILE_PREFERENCE?= BSDmakefile makefile Makefile
320 .MAKE.MAKEFILE_PREFERENCE= ${MAKEFILE_PREFERENCE}
322 # Tell bmake to always pass job tokens, regardless of target depending on
323 # .MAKE or looking like ${MAKE}/${.MAKE}/$(MAKE)/$(.MAKE)/make.
324 .MAKE.ALWAYS_PASS_JOB_QUEUE= yes
326 # By default bmake does *not* use set -e
327 # when running target scripts, this is a problem for many makefiles here.
328 # So define a shell that will do what FreeBSD expects.
329 .ifndef WITHOUT_SHELL_ERRCTL
330 __MAKE_SHELL?=/bin/sh
332 quiet="set -" echo="set -v" filter="set -" \
333 hasErrCtl=yes check="set -e" ignore="set +e" \
334 echoFlag=v errFlag=e \
338 # Hack for ports compatibility. Historically, ports makefiles have
339 # assumed they can examine MACHINE_CPU without including anything
340 # because this was automatically included in sys.mk. For /usr/src,
341 # this file has moved to being included from bsd.opts.mk. Until all
342 # the ports files are modernized, and a reasonable transition
343 # period has passed, include it while we're in a ports tree here
344 # to preserve historic behavior.
345 .if exists(${.CURDIR}/../../Mk/bsd.port.mk)
346 .include <bsd.cpu.mk>