1415bccaaSBruce Evans# from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 27f3dea24SPeter Wemm# $FreeBSD$ 3afe61c15SRodney W. Grimes 4415bccaaSBruce Evansunix ?= We run FreeBSD, not UNIX. 53f5a93f6SDavid E. O'Brien.FreeBSD ?= true 6afe61c15SRodney W. Grimes 76fc3ead1SWarner Losh.if !defined(%POSIX) 86fc3ead1SWarner Losh# 96fc3ead1SWarner Losh# MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with 10bd4473b8SDimitry Andric# the same MACHINE_ARCH can run each other's binaries, so it necessarily 117709b2aeSWarner Losh# has word size and endian swizzled in. However, the source files for 12bd4473b8SDimitry Andric# these machines often are shared amongst all combinations of size 13bd4473b8SDimitry Andric# and/or endian. This is called MACHINE_CPU in NetBSD, but that's used 14bd4473b8SDimitry Andric# for something different in FreeBSD. 156fc3ead1SWarner Losh# 161ca12bd9SJohn Baldwin__TO_CPUARCH=C/arm(v[67])?/arm/:C/powerpc(64|64le|spe)/powerpc/:C/riscv64/riscv/ 177709b2aeSWarner LoshMACHINE_CPUARCH=${MACHINE_ARCH:${__TO_CPUARCH}} 186b14aaa4SWarner Losh.endif 190815243cSMarcel Moolenaar 20dfa09989SBryan Drewery__DEFAULT_YES_OPTIONS+= \ 21dfa09989SBryan Drewery UNIFIED_OBJDIR 22ccfb9654SSimon J. Gerraty 23615a1e70SBryan Drewery# src.sys.obj.mk enables AUTO_OBJ by default if possible but it is otherwise 24615a1e70SBryan Drewery# disabled. Ensure src.conf.5 shows it as default on. 25615a1e70SBryan Drewery.if make(showconfig) 26615a1e70SBryan Drewery__DEFAULT_YES_OPTIONS+= AUTO_OBJ 27615a1e70SBryan Drewery.endif 28ccfb9654SSimon J. Gerraty 29ccfb9654SSimon J. Gerraty# Some options we need now 30ccfb9654SSimon J. Gerraty__DEFAULT_NO_OPTIONS= \ 31948f327eSSimon J. Gerraty DIRDEPS_BUILD \ 32dba62d8dSSimon J. Gerraty DIRDEPS_CACHE 33ccfb9654SSimon J. Gerraty 34ccfb9654SSimon J. Gerraty__DEFAULT_DEPENDENT_OPTIONS= \ 35948f327eSSimon J. Gerraty AUTO_OBJ/DIRDEPS_BUILD \ 36*bee3d4bfSSimon J. Gerraty META_ERROR_TARGET/DIRDEPS_BUILD \ 37dba62d8dSSimon J. Gerraty META_MODE/DIRDEPS_BUILD \ 38948f327eSSimon J. Gerraty STAGING/DIRDEPS_BUILD \ 39948f327eSSimon J. Gerraty SYSROOT/DIRDEPS_BUILD 40ccfb9654SSimon J. Gerraty 41da6e996dSBryan Drewery__ENV_ONLY_OPTIONS:= \ 42da6e996dSBryan Drewery ${__DEFAULT_NO_OPTIONS} \ 43da6e996dSBryan Drewery ${__DEFAULT_YES_OPTIONS} \ 44da6e996dSBryan Drewery ${__DEFAULT_DEPENDENT_OPTIONS:H} 45da6e996dSBryan Drewery 46daf514d0SSimon J. Gerraty# early include for customization 47daf514d0SSimon J. Gerraty# see local.sys.mk below 48b9d0791fSWarner Losh# Not included when building in fmake compatibility mode (still needed 49b9d0791fSWarner Losh# for older system support) 50b9d0791fSWarner Losh.if defined(.PARSEDIR) 51b9d0791fSWarner Losh.sinclude <local.sys.env.mk> 52ccfb9654SSimon J. Gerraty 53232af795SBryan Drewery.include <bsd.mkopt.mk> 54232af795SBryan Drewery 5537250e48SBryan Drewery# Disable MK_META_MODE with make -B 5637250e48SBryan Drewery.if ${MK_META_MODE} == "yes" && defined(.MAKEFLAGS) && ${.MAKEFLAGS:M-B} 5737250e48SBryan DreweryMK_META_MODE= no 5837250e48SBryan Drewery.endif 5937250e48SBryan Drewery 60948f327eSSimon J. Gerraty.if ${MK_DIRDEPS_BUILD} == "yes" 61*bee3d4bfSSimon J. Gerraty.-include <sys.dirdeps.mk> 62718edb15SBryan Drewery.endif 63*bee3d4bfSSimon J. Gerraty.if ${MK_META_MODE} == "yes" 649369f357SBryan Drewery.if !exists(/dev/filemon) || defined(NO_FILEMON) 6564923b11SBryan DreweryMETA_MODE+= nofilemon 66952de59dSBryan Drewery.endif 67*bee3d4bfSSimon J. Gerraty.-include <meta.sys.mk> 68ccfb9654SSimon J. Gerraty.endif 6964923b11SBryan DreweryMETA_MODE?= normal 7064923b11SBryan Drewery.export META_MODE 7164923b11SBryan Drewery.MAKE.MODE?= ${META_MODE} 72ffe0978fSBryan Drewery.if !empty(.MAKE.MODE:Mmeta) 73ffe0978fSBryan Drewery.if !defined(NO_META_IGNORE_HOST) 747f17cd1cSBryan Drewery# Ignore host file changes that will otherwise cause 757f17cd1cSBryan Drewery# buildworld -> installworld -> buildworld to rebuild everything. 767f17cd1cSBryan Drewery# Since the build is self-reliant and bootstraps everything it needs, 777f17cd1cSBryan Drewery# this should not be a real problem for incremental builds. 78799483e4SBryan Drewery# XXX: This relies on the existing host tools retaining ABI compatibility 79799483e4SBryan Drewery# through upgrades since they won't be rebuilt on header/library changes. 801a9cc831SBryan Drewery# This is mitigated by Makefile.inc1 for known-ABI-breaking revisions. 817f17cd1cSBryan Drewery# Note that these are prefix matching, so /lib matches /libexec. 827f17cd1cSBryan Drewery.MAKE.META.IGNORE_PATHS+= \ 837f17cd1cSBryan Drewery ${__MAKE_SHELL} \ 847f17cd1cSBryan Drewery /bin \ 857f17cd1cSBryan Drewery /lib \ 867f17cd1cSBryan Drewery /rescue \ 877f17cd1cSBryan Drewery /sbin \ 887f17cd1cSBryan Drewery /usr/bin \ 897f17cd1cSBryan Drewery /usr/lib \ 907f17cd1cSBryan Drewery /usr/sbin \ 917f17cd1cSBryan Drewery /usr/share \ 927f17cd1cSBryan Drewery 93ffe0978fSBryan Drewery.else 94ffe0978fSBryan DreweryNO_META_IGNORE_HOST_HEADERS= 1 957f17cd1cSBryan Drewery.endif 96ffe0978fSBryan Drewery.if !defined(NO_META_IGNORE_HOST_HEADERS) 97ffe0978fSBryan Drewery.MAKE.META.IGNORE_PATHS+= /usr/include 98ffe0978fSBryan Drewery.endif 9953b3b059SBryan Drewery# We do not want everything out-of-date just because 10053b3b059SBryan Drewery# some unrelated shared lib updated this. 10153b3b059SBryan Drewery.MAKE.META.IGNORE_PATHS+= /usr/local/etc/libmap.d 102ffe0978fSBryan Drewery.endif # !empty(.MAKE.MODE:Mmeta) 1030b6ba3f2SBryan Drewery 104ccfb9654SSimon J. Gerraty.if ${MK_AUTO_OBJ} == "yes" 105ccfb9654SSimon J. Gerraty# This needs to be done early - before .PATH is computed 106bb8cd0c6SBryan Drewery# Don't do this for 'make showconfig' as it enables all options where meta mode 107bb8cd0c6SBryan Drewery# is not expected. 1086e6be2bbSBryan Drewery.if !make(showconfig) && !make(print-dir) && !make(test-system-*) && \ 1096e6be2bbSBryan Drewery empty(.MAKEFLAGS:M-[nN]) 110b9d0791fSWarner Losh.sinclude <auto.obj.mk> 1118d4b8102SBryan Drewery.endif 11240a54c51SBryan Drewery.endif # ${MK_AUTO_OBJ} == "yes" 113232af795SBryan Drewery.else # bmake 114232af795SBryan Drewery.include <bsd.mkopt.mk> 115ccfb9654SSimon J. Gerraty.endif 116ccfb9654SSimon J. Gerraty 1172be2be74SSteve Price# If the special target .POSIX appears (without prerequisites or 1182be2be74SSteve Price# commands) before the first noncomment line in the makefile, make shall 1192be2be74SSteve Price# process the makefile as specified by the Posix 1003.2 specification. 1202be2be74SSteve Price# make(1) sets the special macro %POSIX in this case (to the actual 1212be2be74SSteve Price# value "1003.2", for what it's worth). 1222be2be74SSteve Price# 1232be2be74SSteve Price# The rules below use this macro to distinguish between Posix-compliant 1242be2be74SSteve Price# and default behaviour. 12567292978SColin Percival# 12667292978SColin Percival# This functionality is currently broken, since make(1) processes sys.mk 12767292978SColin Percival# before reading any other files, and consequently has no opportunity to 12867292978SColin Percival# set the %POSIX macro before we read this point. 1292be2be74SSteve Price 1302be2be74SSteve Price.if defined(%POSIX) 1312be2be74SSteve Price.SUFFIXES: .o .c .y .l .a .sh .f 1322be2be74SSteve Price.else 1331cbb5888SWarner Losh.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 1342be2be74SSteve Price.endif 135afe61c15SRodney W. Grimes 136415bccaaSBruce EvansAR ?= ar 1372be2be74SSteve Price.if defined(%POSIX) 1382be2be74SSteve PriceARFLAGS ?= -rv 1392be2be74SSteve Price.else 1400e1e341bSAlex RichardsonARFLAGS ?= -crsD 1412be2be74SSteve Price.endif 142415bccaaSBruce EvansRANLIB ?= ranlib 143f1c8f60bSDag-Erling Smørgrav.if !defined(%POSIX) 144f1c8f60bSDag-Erling SmørgravRANLIBFLAGS ?= -D 145f1c8f60bSDag-Erling Smørgrav.endif 146afe61c15SRodney W. Grimes 147415bccaaSBruce EvansAS ?= as 148415bccaaSBruce EvansAFLAGS ?= 1495ada7d99SKonstantin BelousovACFLAGS ?= 150afe61c15SRodney W. Grimes 1512be2be74SSteve Price.if defined(%POSIX) 1522be2be74SSteve PriceCC ?= c89 153d17387acSBruce EvansCFLAGS ?= -O 1542be2be74SSteve Price.else 155415bccaaSBruce EvansCC ?= cc 15620c46652SDavid E. O'BrienCFLAGS ?= -O2 -pipe 157cfb5b325SJohn Birrell.if defined(NO_STRICT_ALIASING) 158cfb5b325SJohn BirrellCFLAGS += -fno-strict-aliasing 159d17387acSBruce Evans.endif 160cdc162feSOlivier Houchard.endif 161c867306eSJonathan AndersonIR_CFLAGS ?= ${STATIC_CFLAGS:N-O*} ${CFLAGS:N-O*} 162424b4e66SStephane E. PotvinPO_CFLAGS ?= ${CFLAGS} 163afe61c15SRodney W. Grimes 1640c76c8aaSMark Johnston# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle 1650c76c8aaSMark Johnston# read-only files as non-root by passing -f. 1660c76c8aaSMark JohnstonCP ?= cp -f 1670c76c8aaSMark Johnston 1680c76c8aaSMark JohnstonCPP ?= cpp 1690c76c8aaSMark Johnston 170770ac3b2SJohn Birrell# C Type Format data is required for DTrace 171770ac3b2SJohn BirrellCTFFLAGS ?= -L VERSION 172770ac3b2SJohn Birrell 173770ac3b2SJohn BirrellCTFCONVERT ?= ctfconvert 174770ac3b2SJohn BirrellCTFMERGE ?= ctfmerge 1757a37b5fcSWill Andrews 176770ac3b2SJohn Birrell.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 177770ac3b2SJohn BirrellCTFFLAGS += -g 178770ac3b2SJohn Birrell.endif 179770ac3b2SJohn Birrell 180443dced5SPaul RichardsCXX ?= c++ 18196f2d85eSMarcel MoolenaarCXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 182c867306eSJonathan AndersonIR_CXXFLAGS ?= ${STATIC_CXXFLAGS:N-O*} ${CXXFLAGS:N-O*} 183424b4e66SStephane E. PotvinPO_CXXFLAGS ?= ${CXXFLAGS} 184afe61c15SRodney W. Grimes 1850c76c8aaSMark JohnstonDTRACE ?= dtrace 1860c76c8aaSMark JohnstonDTRACEFLAGS ?= -C -x nolibs 187afe61c15SRodney W. Grimes 18865d2bdc6SRuslan Ermilov.if empty(.MAKEFLAGS:M-s) 189415bccaaSBruce EvansECHO ?= echo 190415bccaaSBruce EvansECHODIR ?= echo 191415bccaaSBruce Evans.else 192415bccaaSBruce EvansECHO ?= true 193415bccaaSBruce Evans.if ${.MAKEFLAGS:M-s} == "-s" 194415bccaaSBruce EvansECHODIR ?= echo 195415bccaaSBruce Evans.else 196415bccaaSBruce EvansECHODIR ?= true 197415bccaaSBruce Evans.endif 198415bccaaSBruce Evans.endif 199afe61c15SRodney W. Grimes 200c6081deaSMarcin WojtasELFCTL ?= elfctl 201c6081deaSMarcin Wojtas 20256585ab5SBryan Drewery.if ${.MAKEFLAGS:M-N} 20356585ab5SBryan Drewery# bmake -N is supposed to skip executing anything but it does not skip 20456585ab5SBryan Drewery# exeucting '+' commands. The '+' feature is used where .MAKE 20556585ab5SBryan Drewery# is not safe for the entire target. -N is intended to skip building sub-makes 20656585ab5SBryan Drewery# so it executing '+' commands is not right. Work around the bug by not 20756585ab5SBryan Drewery# setting '+' when -N is used. 208acabf29aSHartmut Brandt_+_ ?= 209acabf29aSHartmut Brandt.else 210acabf29aSHartmut Brandt_+_ ?= + 211acabf29aSHartmut Brandt.endif 212acabf29aSHartmut Brandt 2132be2be74SSteve Price.if defined(%POSIX) 2142be2be74SSteve PriceFC ?= fort77 2152be2be74SSteve PriceFFLAGS ?= -O 1 2162be2be74SSteve Price.else 217415bccaaSBruce EvansFC ?= f77 218415bccaaSBruce EvansFFLAGS ?= -O 2192be2be74SSteve Price.endif 220415bccaaSBruce EvansEFLAGS ?= 221afe61c15SRodney W. Grimes 222a8b8edb2SMaxim SobolevINSTALL ?= ${INSTALL_CMD:Uinstall} 223c7499507SAndrey A. Chernov 224415bccaaSBruce EvansLEX ?= lex 225415bccaaSBruce EvansLFLAGS ?= 226afe61c15SRodney W. Grimes 227ea22493aSJohn Baldwin# LDFLAGS is for CC, _LDFLAGS is for LD. Generate _LDFLAGS from 228ea22493aSJohn Baldwin# LDFLAGS by stripping -Wl, from pass-through arguments and dropping 229ea22493aSJohn Baldwin# compiler driver flags (e.g. -mabi=*) that conflict with flags to LD. 230415bccaaSBruce EvansLD ?= ld 231ea22493aSJohn BaldwinLDFLAGS ?= 2327bc797e3SAlex Richardson_LDFLAGS = ${LDFLAGS:S/-Wl,//g:N-mabi=*:N-fuse-ld=*:N--ld-path=*:N-fsanitize=*:N-fno-sanitize=*} 233afe61c15SRodney W. Grimes 234415bccaaSBruce EvansMAKE ?= make 235afe61c15SRodney W. Grimes 2366f1d6967SWarner Losh.if !defined(%POSIX) 237e4195e2eSJonathan AndersonLLVM_LINK ?= llvm-link 238e4195e2eSJonathan Anderson 239e7c08366SMarcel MoolenaarLORDER ?= lorder 240e7c08366SMarcel Moolenaar 2416f1d6967SWarner LoshNM ?= nm 24225ec8c92SRui PauloNMFLAGS ?= 2436f1d6967SWarner Losh 24470a6e331SBruce EvansOBJC ?= cc 24570a6e331SBruce EvansOBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 24670a6e331SBruce Evans 247e97696b5SEd MasteOBJCOPY ?= objcopy 248e97696b5SEd Maste 249415bccaaSBruce EvansPC ?= pc 250415bccaaSBruce EvansPFLAGS ?= 251afe61c15SRodney W. Grimes 252415bccaaSBruce EvansRC ?= f77 253415bccaaSBruce EvansRFLAGS ?= 254e7c08366SMarcel Moolenaar 255e7c08366SMarcel MoolenaarTSORT ?= tsort 256e7c08366SMarcel MoolenaarTSORTFLAGS ?= -q 25744383aa3SEd Maste.endif 258415bccaaSBruce Evans 259415bccaaSBruce EvansSHELL ?= sh 260415bccaaSBruce Evans 26178abccfcSBaptiste Daroussin.if !defined(%POSIX) 26278abccfcSBaptiste DaroussinSIZE ?= size 2631a18ab42SAlex RichardsonSTRIPBIN ?= strip 26478abccfcSBaptiste Daroussin.endif 26578abccfcSBaptiste Daroussin 266415bccaaSBruce EvansYACC ?= yacc 2672be2be74SSteve Price.if defined(%POSIX) 2682be2be74SSteve PriceYFLAGS ?= 2692be2be74SSteve Price.else 270415bccaaSBruce EvansYFLAGS ?= -d 2712be2be74SSteve Price.endif 2722be2be74SSteve Price 2732be2be74SSteve Price.if defined(%POSIX) 2748d962594SBruce Evans 275808b18e4SJonathan Anderson.include "bsd.suffixes-posix.mk" 2762be2be74SSteve Price 2772be2be74SSteve Price.else 2782be2be74SSteve Price 2792be2be74SSteve Price# non-Posix rule set 280808b18e4SJonathan Anderson.include "bsd.suffixes.mk" 2813585b293SGarrett Wollman 282daf514d0SSimon J. Gerraty# Pull in global settings. 283daf514d0SSimon J. Gerraty__MAKE_CONF?=/etc/make.conf 284daf514d0SSimon J. Gerraty.if exists(${__MAKE_CONF}) 285daf514d0SSimon J. Gerraty.include "${__MAKE_CONF}" 286daf514d0SSimon J. Gerraty.endif 287daf514d0SSimon J. Gerraty 288daf514d0SSimon J. Gerraty# late include for customization 289b9d0791fSWarner Losh.sinclude <local.sys.mk> 29034bbee43SWarner Losh 2913ea2c169SBryan Drewery.if defined(META_MODE) 2923ea2c169SBryan DreweryMETA_MODE:= ${META_MODE:O:u} 2933ea2c169SBryan Drewery.endif 2943ea2c169SBryan Drewery 295a39cea66SYaroslav Tykhiy.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 296a39cea66SYaroslav TykhiySHELL= ${__MAKE_SHELL} 297a39cea66SYaroslav Tykhiy.SHELL: path=${__MAKE_SHELL} 298a39cea66SYaroslav Tykhiy.endif 299a39cea66SYaroslav Tykhiy 300a0f1aa83SSimon J. Gerraty# Tell bmake to expand -V VAR by default 301a0f1aa83SSimon J. Gerraty.MAKE.EXPAND_VARIABLES= yes 302a0f1aa83SSimon J. Gerraty 303a0f1aa83SSimon J. Gerraty# Tell bmake the makefile preference 304a12a1b47SBryan DreweryMAKEFILE_PREFERENCE?= BSDmakefile makefile Makefile 305a12a1b47SBryan Drewery.MAKE.MAKEFILE_PREFERENCE= ${MAKEFILE_PREFERENCE} 306a0f1aa83SSimon J. Gerraty 307c41b6218SBryan Drewery# Tell bmake to always pass job tokens, regardless of target depending on 308c41b6218SBryan Drewery# .MAKE or looking like ${MAKE}/${.MAKE}/$(MAKE)/$(.MAKE)/make. 309c41b6218SBryan Drewery.MAKE.ALWAYS_PASS_JOB_QUEUE= yes 310c41b6218SBryan Drewery 311a0f1aa83SSimon J. Gerraty# By default bmake does *not* use set -e 312a0f1aa83SSimon J. Gerraty# when running target scripts, this is a problem for many makefiles here. 313a0f1aa83SSimon J. Gerraty# So define a shell that will do what FreeBSD expects. 314a0f1aa83SSimon J. Gerraty.ifndef WITHOUT_SHELL_ERRCTL 315b9d0791fSWarner Losh__MAKE_SHELL?=/bin/sh 316a0f1aa83SSimon J. Gerraty.SHELL: name=sh \ 317a0f1aa83SSimon J. Gerraty quiet="set -" echo="set -v" filter="set -" \ 318a0f1aa83SSimon J. Gerraty hasErrCtl=yes check="set -e" ignore="set +e" \ 319a0f1aa83SSimon J. Gerraty echoFlag=v errFlag=e \ 320b9d0791fSWarner Losh path=${__MAKE_SHELL} 321a0f1aa83SSimon J. Gerraty.endif 322a0f1aa83SSimon J. Gerraty 3239ca54343SWarner Losh# Hack for ports compatibility. Historically, ports makefiles have 324682d8404SMarcelo Araujo# assumed they can examine MACHINE_CPU without including anything 3259ca54343SWarner Losh# because this was automatically included in sys.mk. For /usr/src, 3269ca54343SWarner Losh# this file has moved to being included from bsd.opts.mk. Until all 327682d8404SMarcelo Araujo# the ports files are modernized, and a reasonable transition 3289ca54343SWarner Losh# period has passed, include it while we're in a ports tree here 3299ca54343SWarner Losh# to preserve historic behavior. 3309ca54343SWarner Losh.if exists(${.CURDIR}/../../Mk/bsd.port.mk) 3318d962594SBruce Evans.include <bsd.cpu.mk> 3329ca54343SWarner Losh.endif 333be4646cfSWarner Losh 334be4646cfSWarner Losh.endif # ! Posix 335