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