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