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 11bd4473b8SDimitry Andric# has word size and endian swizzled in. However, support 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# 167804dd52SRuslan BukinMACHINE_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/} 176b14aaa4SWarner Losh.endif 180815243cSMarcel Moolenaar 19ccfb9654SSimon J. Gerraty 20ccfb9654SSimon J. Gerraty# Some options we need now 21ccfb9654SSimon J. Gerraty__DEFAULT_NO_OPTIONS= \ 22948f327eSSimon J. Gerraty DIRDEPS_BUILD \ 23dba62d8dSSimon J. Gerraty DIRDEPS_CACHE 24ccfb9654SSimon J. Gerraty 25ccfb9654SSimon J. Gerraty__DEFAULT_DEPENDENT_OPTIONS= \ 26948f327eSSimon J. Gerraty AUTO_OBJ/DIRDEPS_BUILD \ 27dba62d8dSSimon J. Gerraty META_MODE/DIRDEPS_BUILD \ 28948f327eSSimon J. Gerraty STAGING/DIRDEPS_BUILD \ 29948f327eSSimon J. Gerraty SYSROOT/DIRDEPS_BUILD 30ccfb9654SSimon J. Gerraty 31da6e996dSBryan Drewery__ENV_ONLY_OPTIONS:= \ 32da6e996dSBryan Drewery ${__DEFAULT_NO_OPTIONS} \ 33da6e996dSBryan Drewery ${__DEFAULT_YES_OPTIONS} \ 34da6e996dSBryan Drewery ${__DEFAULT_DEPENDENT_OPTIONS:H} 35da6e996dSBryan Drewery 36daf514d0SSimon J. Gerraty# early include for customization 37daf514d0SSimon J. Gerraty# see local.sys.mk below 38b9d0791fSWarner Losh# Not included when building in fmake compatibility mode (still needed 39b9d0791fSWarner Losh# for older system support) 40b9d0791fSWarner Losh.if defined(.PARSEDIR) 41b9d0791fSWarner Losh.sinclude <local.sys.env.mk> 42ccfb9654SSimon J. Gerraty 43232af795SBryan Drewery.include <bsd.mkopt.mk> 44232af795SBryan Drewery 4537250e48SBryan Drewery# Disable MK_META_MODE with make -B 4637250e48SBryan Drewery.if ${MK_META_MODE} == "yes" && defined(.MAKEFLAGS) && ${.MAKEFLAGS:M-B} 4737250e48SBryan DreweryMK_META_MODE= no 4837250e48SBryan Drewery.endif 4937250e48SBryan Drewery 50948f327eSSimon J. Gerraty.if ${MK_DIRDEPS_BUILD} == "yes" 51b9d0791fSWarner Losh.sinclude <meta.sys.mk> 5237250e48SBryan Drewery.elif ${MK_META_MODE} == "yes" 5364923b11SBryan Drewery# verbose will show .MAKE.META.PREFIX for each target. 54699f93b9SBryan DreweryMETA_MODE+= meta verbose 553681768cSBryan Drewery.if !defined(NO_META_MISSING) 563681768cSBryan DreweryMETA_MODE+= missing-meta=yes 573681768cSBryan Drewery.endif 58b29980a6SBryan Drewery# silent will hide command output if a .meta file is created. 59b29980a6SBryan Drewery.if !defined(NO_SILENT) 60b29980a6SBryan DreweryMETA_MODE+= silent=yes 61b29980a6SBryan Drewery.endif 62952de59dSBryan Drewery.if !exists(/dev/filemon) 6364923b11SBryan DreweryMETA_MODE+= nofilemon 64952de59dSBryan Drewery.endif 653681768cSBryan Drewery# Require filemon data with bmake 663681768cSBryan Drewery.if empty(META_MODE:Mnofilemon) 673681768cSBryan DreweryMETA_MODE+= missing-filemon=yes 683681768cSBryan Drewery.endif 69ccfb9654SSimon J. Gerraty.endif 7064923b11SBryan DreweryMETA_MODE?= normal 7164923b11SBryan Drewery.export META_MODE 7264923b11SBryan Drewery.MAKE.MODE?= ${META_MODE} 737f17cd1cSBryan Drewery.if !empty(.MAKE.MODE:Mmeta) && !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. 807f17cd1cSBryan Drewery# Note that these are prefix matching, so /lib matches /libexec. 817f17cd1cSBryan Drewery.MAKE.META.IGNORE_PATHS+= \ 827f17cd1cSBryan Drewery ${__MAKE_SHELL} \ 837f17cd1cSBryan Drewery /bin \ 847f17cd1cSBryan Drewery /lib \ 857f17cd1cSBryan Drewery /rescue \ 867f17cd1cSBryan Drewery /sbin \ 877f17cd1cSBryan Drewery /usr/bin \ 887f17cd1cSBryan Drewery /usr/include \ 897f17cd1cSBryan Drewery /usr/lib \ 907f17cd1cSBryan Drewery /usr/sbin \ 917f17cd1cSBryan Drewery /usr/share \ 927f17cd1cSBryan Drewery 937f17cd1cSBryan Drewery.endif 94*53b3b059SBryan Drewery.if !empty(.MAKE.MODE:Mmeta) 95*53b3b059SBryan Drewery# We do not want everything out-of-date just because 96*53b3b059SBryan Drewery# some unrelated shared lib updated this. 97*53b3b059SBryan Drewery.MAKE.META.IGNORE_PATHS+= /usr/local/etc/libmap.d 98*53b3b059SBryan Drewery.endif 990b6ba3f2SBryan Drewery 100ccfb9654SSimon J. Gerraty.if ${MK_AUTO_OBJ} == "yes" 101ccfb9654SSimon J. Gerraty# This needs to be done early - before .PATH is computed 102bb8cd0c6SBryan Drewery# Don't do this for 'make showconfig' as it enables all options where meta mode 103bb8cd0c6SBryan Drewery# is not expected. 1049e2f435fSBryan Drewery.if !make(showconfig) && !make(print-dir) 105b9d0791fSWarner Losh.sinclude <auto.obj.mk> 106b9d0791fSWarner Losh.endif 1078d4b8102SBryan Drewery.endif 108232af795SBryan Drewery.else # bmake 109232af795SBryan Drewery.include <bsd.mkopt.mk> 110ccfb9654SSimon J. Gerraty.endif 111ccfb9654SSimon J. Gerraty 1122be2be74SSteve Price# If the special target .POSIX appears (without prerequisites or 1132be2be74SSteve Price# commands) before the first noncomment line in the makefile, make shall 1142be2be74SSteve Price# process the makefile as specified by the Posix 1003.2 specification. 1152be2be74SSteve Price# make(1) sets the special macro %POSIX in this case (to the actual 1162be2be74SSteve Price# value "1003.2", for what it's worth). 1172be2be74SSteve Price# 1182be2be74SSteve Price# The rules below use this macro to distinguish between Posix-compliant 1192be2be74SSteve Price# and default behaviour. 12067292978SColin Percival# 12167292978SColin Percival# This functionality is currently broken, since make(1) processes sys.mk 12267292978SColin Percival# before reading any other files, and consequently has no opportunity to 12367292978SColin Percival# set the %POSIX macro before we read this point. 1242be2be74SSteve Price 1252be2be74SSteve Price.if defined(%POSIX) 1262be2be74SSteve Price.SUFFIXES: .o .c .y .l .a .sh .f 1272be2be74SSteve Price.else 128c4e24cafSDimitry Andric.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 1292be2be74SSteve Price.endif 130afe61c15SRodney W. Grimes 131415bccaaSBruce EvansAR ?= ar 1322be2be74SSteve Price.if defined(%POSIX) 1332be2be74SSteve PriceARFLAGS ?= -rv 1342be2be74SSteve Price.else 135f1c8f60bSDag-Erling SmørgravARFLAGS ?= -crD 1362be2be74SSteve Price.endif 137415bccaaSBruce EvansRANLIB ?= ranlib 138f1c8f60bSDag-Erling Smørgrav.if !defined(%POSIX) 139f1c8f60bSDag-Erling SmørgravRANLIBFLAGS ?= -D 140f1c8f60bSDag-Erling Smørgrav.endif 141afe61c15SRodney W. Grimes 142415bccaaSBruce EvansAS ?= as 143415bccaaSBruce EvansAFLAGS ?= 1445ada7d99SKonstantin BelousovACFLAGS ?= 145afe61c15SRodney W. Grimes 1462be2be74SSteve Price.if defined(%POSIX) 1472be2be74SSteve PriceCC ?= c89 148d17387acSBruce EvansCFLAGS ?= -O 1492be2be74SSteve Price.else 150415bccaaSBruce EvansCC ?= cc 1516fc3ead1SWarner Losh.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" 15220c46652SDavid E. O'BrienCFLAGS ?= -O -pipe 153cdc162feSOlivier Houchard.else 15420c46652SDavid E. O'BrienCFLAGS ?= -O2 -pipe 155cfb5b325SJohn Birrell.endif 156cfb5b325SJohn Birrell.if defined(NO_STRICT_ALIASING) 157cfb5b325SJohn BirrellCFLAGS += -fno-strict-aliasing 158d17387acSBruce Evans.endif 159cdc162feSOlivier Houchard.endif 160c867306eSJonathan AndersonIR_CFLAGS ?= ${STATIC_CFLAGS:N-O*} ${CFLAGS:N-O*} 161424b4e66SStephane E. PotvinPO_CFLAGS ?= ${CFLAGS} 162afe61c15SRodney W. Grimes 1630c76c8aaSMark Johnston# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle 1640c76c8aaSMark Johnston# read-only files as non-root by passing -f. 1650c76c8aaSMark JohnstonCP ?= cp -f 1660c76c8aaSMark Johnston 1670c76c8aaSMark JohnstonCPP ?= cpp 1680c76c8aaSMark Johnston 169770ac3b2SJohn Birrell# C Type Format data is required for DTrace 170770ac3b2SJohn BirrellCTFFLAGS ?= -L VERSION 171770ac3b2SJohn Birrell 172770ac3b2SJohn BirrellCTFCONVERT ?= ctfconvert 173770ac3b2SJohn BirrellCTFMERGE ?= ctfmerge 1747a37b5fcSWill Andrews 175770ac3b2SJohn Birrell.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 176770ac3b2SJohn BirrellCTFFLAGS += -g 177770ac3b2SJohn Birrell.endif 178770ac3b2SJohn Birrell 179443dced5SPaul RichardsCXX ?= c++ 18096f2d85eSMarcel MoolenaarCXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 181c867306eSJonathan AndersonIR_CXXFLAGS ?= ${STATIC_CXXFLAGS:N-O*} ${CXXFLAGS:N-O*} 182424b4e66SStephane E. PotvinPO_CXXFLAGS ?= ${CXXFLAGS} 183afe61c15SRodney W. Grimes 1840c76c8aaSMark JohnstonDTRACE ?= dtrace 1850c76c8aaSMark JohnstonDTRACEFLAGS ?= -C -x nolibs 186afe61c15SRodney W. Grimes 18765d2bdc6SRuslan Ermilov.if empty(.MAKEFLAGS:M-s) 188415bccaaSBruce EvansECHO ?= echo 189415bccaaSBruce EvansECHODIR ?= echo 190415bccaaSBruce Evans.else 191415bccaaSBruce EvansECHO ?= true 192415bccaaSBruce Evans.if ${.MAKEFLAGS:M-s} == "-s" 193415bccaaSBruce EvansECHODIR ?= echo 194415bccaaSBruce Evans.else 195415bccaaSBruce EvansECHODIR ?= true 196415bccaaSBruce Evans.endif 197415bccaaSBruce Evans.endif 198afe61c15SRodney W. Grimes 19956585ab5SBryan Drewery.if ${.MAKEFLAGS:M-N} 20056585ab5SBryan Drewery# bmake -N is supposed to skip executing anything but it does not skip 20156585ab5SBryan Drewery# exeucting '+' commands. The '+' feature is used where .MAKE 20256585ab5SBryan Drewery# is not safe for the entire target. -N is intended to skip building sub-makes 20356585ab5SBryan Drewery# so it executing '+' commands is not right. Work around the bug by not 20456585ab5SBryan Drewery# setting '+' when -N is used. 205acabf29aSHartmut Brandt_+_ ?= 206acabf29aSHartmut Brandt.else 207acabf29aSHartmut Brandt_+_ ?= + 208acabf29aSHartmut Brandt.endif 209acabf29aSHartmut Brandt 2102be2be74SSteve Price.if defined(%POSIX) 2112be2be74SSteve PriceFC ?= fort77 2122be2be74SSteve PriceFFLAGS ?= -O 1 2132be2be74SSteve Price.else 214415bccaaSBruce EvansFC ?= f77 215415bccaaSBruce EvansFFLAGS ?= -O 2162be2be74SSteve Price.endif 217415bccaaSBruce EvansEFLAGS ?= 218afe61c15SRodney W. Grimes 219c7499507SAndrey A. ChernovINSTALL ?= install 220c7499507SAndrey A. Chernov 221415bccaaSBruce EvansLEX ?= lex 222415bccaaSBruce EvansLFLAGS ?= 223afe61c15SRodney W. Grimes 224ea22493aSJohn Baldwin# LDFLAGS is for CC, _LDFLAGS is for LD. Generate _LDFLAGS from 225ea22493aSJohn Baldwin# LDFLAGS by stripping -Wl, from pass-through arguments and dropping 226ea22493aSJohn Baldwin# compiler driver flags (e.g. -mabi=*) that conflict with flags to LD. 227415bccaaSBruce EvansLD ?= ld 228ea22493aSJohn BaldwinLDFLAGS ?= 229ea22493aSJohn Baldwin_LDFLAGS = ${LDFLAGS:S/-Wl,//g:N-mabi=*} 230afe61c15SRodney W. Grimes 231415bccaaSBruce EvansLINT ?= lint 232bd42830fSRuslan ErmilovLINTFLAGS ?= -cghapbx 233766f7d6eSMark MurrayLINTKERNFLAGS ?= ${LINTFLAGS} 234766f7d6eSMark MurrayLINTOBJFLAGS ?= -cghapbxu -i 23534d81580SMark MurrayLINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 236766f7d6eSMark MurrayLINTLIBFLAGS ?= -cghapbxu -C ${LIB} 237afe61c15SRodney W. Grimes 238415bccaaSBruce EvansMAKE ?= make 239afe61c15SRodney W. Grimes 2406f1d6967SWarner Losh.if !defined(%POSIX) 241e4195e2eSJonathan AndersonLLVM_LINK ?= llvm-link 242e4195e2eSJonathan Anderson 243e7c08366SMarcel MoolenaarLORDER ?= lorder 244e7c08366SMarcel Moolenaar 2456f1d6967SWarner LoshNM ?= nm 24625ec8c92SRui PauloNMFLAGS ?= 2476f1d6967SWarner Losh 24870a6e331SBruce EvansOBJC ?= cc 24970a6e331SBruce EvansOBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 25070a6e331SBruce Evans 251e97696b5SEd MasteOBJCOPY ?= objcopy 252e97696b5SEd Maste 253415bccaaSBruce EvansPC ?= pc 254415bccaaSBruce EvansPFLAGS ?= 255afe61c15SRodney W. Grimes 256415bccaaSBruce EvansRC ?= f77 257415bccaaSBruce EvansRFLAGS ?= 258e7c08366SMarcel Moolenaar 259e7c08366SMarcel MoolenaarTSORT ?= tsort 260e7c08366SMarcel MoolenaarTSORTFLAGS ?= -q 26144383aa3SEd Maste.endif 262415bccaaSBruce Evans 263415bccaaSBruce EvansSHELL ?= sh 264415bccaaSBruce Evans 26578abccfcSBaptiste Daroussin.if !defined(%POSIX) 26678abccfcSBaptiste DaroussinSIZE ?= size 26778abccfcSBaptiste Daroussin.endif 26878abccfcSBaptiste Daroussin 269415bccaaSBruce EvansYACC ?= yacc 2702be2be74SSteve Price.if defined(%POSIX) 2712be2be74SSteve PriceYFLAGS ?= 2722be2be74SSteve Price.else 273415bccaaSBruce EvansYFLAGS ?= -d 2742be2be74SSteve Price.endif 2752be2be74SSteve Price 2762be2be74SSteve Price.if defined(%POSIX) 2778d962594SBruce Evans 278808b18e4SJonathan Anderson.include "bsd.suffixes-posix.mk" 2792be2be74SSteve Price 2802be2be74SSteve Price.else 2812be2be74SSteve Price 2822be2be74SSteve Price# non-Posix rule set 283808b18e4SJonathan Anderson.include "bsd.suffixes.mk" 2843585b293SGarrett Wollman 285daf514d0SSimon J. Gerraty# Pull in global settings. 286daf514d0SSimon J. Gerraty__MAKE_CONF?=/etc/make.conf 287daf514d0SSimon J. Gerraty.if exists(${__MAKE_CONF}) 288daf514d0SSimon J. Gerraty.include "${__MAKE_CONF}" 289daf514d0SSimon J. Gerraty.endif 290daf514d0SSimon J. Gerraty 291daf514d0SSimon J. Gerraty# late include for customization 292b9d0791fSWarner Losh.sinclude <local.sys.mk> 29334bbee43SWarner Losh 2943ea2c169SBryan Drewery.if defined(META_MODE) 2953ea2c169SBryan DreweryMETA_MODE:= ${META_MODE:O:u} 2963ea2c169SBryan Drewery.endif 2973ea2c169SBryan Drewery 298a39cea66SYaroslav Tykhiy.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 299a39cea66SYaroslav TykhiySHELL= ${__MAKE_SHELL} 300a39cea66SYaroslav Tykhiy.SHELL: path=${__MAKE_SHELL} 301a39cea66SYaroslav Tykhiy.endif 302a39cea66SYaroslav Tykhiy 303a0f1aa83SSimon J. Gerraty# Tell bmake to expand -V VAR by default 304a0f1aa83SSimon J. Gerraty.MAKE.EXPAND_VARIABLES= yes 305a0f1aa83SSimon J. Gerraty 306a0f1aa83SSimon J. Gerraty# Tell bmake the makefile preference 307a0f1aa83SSimon J. Gerraty.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile 308a0f1aa83SSimon J. Gerraty 309c41b6218SBryan Drewery# Tell bmake to always pass job tokens, regardless of target depending on 310c41b6218SBryan Drewery# .MAKE or looking like ${MAKE}/${.MAKE}/$(MAKE)/$(.MAKE)/make. 311c41b6218SBryan Drewery.MAKE.ALWAYS_PASS_JOB_QUEUE= yes 312c41b6218SBryan Drewery 313a0f1aa83SSimon J. Gerraty# By default bmake does *not* use set -e 314a0f1aa83SSimon J. Gerraty# when running target scripts, this is a problem for many makefiles here. 315a0f1aa83SSimon J. Gerraty# So define a shell that will do what FreeBSD expects. 316a0f1aa83SSimon J. Gerraty.ifndef WITHOUT_SHELL_ERRCTL 317b9d0791fSWarner Losh__MAKE_SHELL?=/bin/sh 318a0f1aa83SSimon J. Gerraty.SHELL: name=sh \ 319a0f1aa83SSimon J. Gerraty quiet="set -" echo="set -v" filter="set -" \ 320a0f1aa83SSimon J. Gerraty hasErrCtl=yes check="set -e" ignore="set +e" \ 321a0f1aa83SSimon J. Gerraty echoFlag=v errFlag=e \ 322b9d0791fSWarner Losh path=${__MAKE_SHELL} 323a0f1aa83SSimon J. Gerraty.endif 324a0f1aa83SSimon J. Gerraty 3259ca54343SWarner Losh# Hack for ports compatibility. Historically, ports makefiles have 326682d8404SMarcelo Araujo# assumed they can examine MACHINE_CPU without including anything 3279ca54343SWarner Losh# because this was automatically included in sys.mk. For /usr/src, 3289ca54343SWarner Losh# this file has moved to being included from bsd.opts.mk. Until all 329682d8404SMarcelo Araujo# the ports files are modernized, and a reasonable transition 3309ca54343SWarner Losh# period has passed, include it while we're in a ports tree here 3319ca54343SWarner Losh# to preserve historic behavior. 3329ca54343SWarner Losh.if exists(${.CURDIR}/../../Mk/bsd.port.mk) 3338d962594SBruce Evans.include <bsd.cpu.mk> 3349ca54343SWarner Losh.endif 335be4646cfSWarner Losh 336be4646cfSWarner Losh.endif # ! Posix 337