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# 16b987685fSBryan DreweryMACHINE_CPUARCH=${MACHINE_ARCH:C/mips(n32|64)?(el)?/mips/:C/arm(v6)?(eb|hf)?/arm/:C/powerpc64/powerpc/:C/riscv64/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 947f17cd1cSBryan Drewery 950b6ba3f2SBryan Drewery 96ccfb9654SSimon J. Gerraty.if ${MK_AUTO_OBJ} == "yes" 97ccfb9654SSimon J. Gerraty# This needs to be done early - before .PATH is computed 98bb8cd0c6SBryan Drewery# Don't do this for 'make showconfig' as it enables all options where meta mode 99bb8cd0c6SBryan Drewery# is not expected. 1009e2f435fSBryan Drewery.if !make(showconfig) && !make(print-dir) 101b9d0791fSWarner Losh.sinclude <auto.obj.mk> 102b9d0791fSWarner Losh.endif 1038d4b8102SBryan Drewery.endif 104232af795SBryan Drewery.else # bmake 105232af795SBryan Drewery.include <bsd.mkopt.mk> 106ccfb9654SSimon J. Gerraty.endif 107ccfb9654SSimon J. Gerraty 1082be2be74SSteve Price# If the special target .POSIX appears (without prerequisites or 1092be2be74SSteve Price# commands) before the first noncomment line in the makefile, make shall 1102be2be74SSteve Price# process the makefile as specified by the Posix 1003.2 specification. 1112be2be74SSteve Price# make(1) sets the special macro %POSIX in this case (to the actual 1122be2be74SSteve Price# value "1003.2", for what it's worth). 1132be2be74SSteve Price# 1142be2be74SSteve Price# The rules below use this macro to distinguish between Posix-compliant 1152be2be74SSteve Price# and default behaviour. 11667292978SColin Percival# 11767292978SColin Percival# This functionality is currently broken, since make(1) processes sys.mk 11867292978SColin Percival# before reading any other files, and consequently has no opportunity to 11967292978SColin Percival# set the %POSIX macro before we read this point. 1202be2be74SSteve Price 1212be2be74SSteve Price.if defined(%POSIX) 1222be2be74SSteve Price.SUFFIXES: .o .c .y .l .a .sh .f 1232be2be74SSteve Price.else 124d58e932fSRuslan Ermilov.SUFFIXES: .out .a .ln .o .c .cc .cpp .cxx .C .m .F .f .e .r .y .l .S .asm .s .cl .p .h .sh 1252be2be74SSteve Price.endif 126afe61c15SRodney W. Grimes 127415bccaaSBruce EvansAR ?= ar 1282be2be74SSteve Price.if defined(%POSIX) 1292be2be74SSteve PriceARFLAGS ?= -rv 1302be2be74SSteve Price.else 131f1c8f60bSDag-Erling SmørgravARFLAGS ?= -crD 1322be2be74SSteve Price.endif 133415bccaaSBruce EvansRANLIB ?= ranlib 134f1c8f60bSDag-Erling Smørgrav.if !defined(%POSIX) 135f1c8f60bSDag-Erling SmørgravRANLIBFLAGS ?= -D 136f1c8f60bSDag-Erling Smørgrav.endif 137afe61c15SRodney W. Grimes 138415bccaaSBruce EvansAS ?= as 139415bccaaSBruce EvansAFLAGS ?= 1405ada7d99SKonstantin BelousovACFLAGS ?= 141afe61c15SRodney W. Grimes 1422be2be74SSteve Price.if defined(%POSIX) 1432be2be74SSteve PriceCC ?= c89 144d17387acSBruce EvansCFLAGS ?= -O 1452be2be74SSteve Price.else 146415bccaaSBruce EvansCC ?= cc 1476fc3ead1SWarner Losh.if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips" 14820c46652SDavid E. O'BrienCFLAGS ?= -O -pipe 149cdc162feSOlivier Houchard.else 15020c46652SDavid E. O'BrienCFLAGS ?= -O2 -pipe 151cfb5b325SJohn Birrell.endif 152cfb5b325SJohn Birrell.if defined(NO_STRICT_ALIASING) 153cfb5b325SJohn BirrellCFLAGS += -fno-strict-aliasing 154d17387acSBruce Evans.endif 155cdc162feSOlivier Houchard.endif 156*c867306eSJonathan AndersonIR_CFLAGS ?= ${STATIC_CFLAGS:N-O*} ${CFLAGS:N-O*} 157424b4e66SStephane E. PotvinPO_CFLAGS ?= ${CFLAGS} 158afe61c15SRodney W. Grimes 1590c76c8aaSMark Johnston# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle 1600c76c8aaSMark Johnston# read-only files as non-root by passing -f. 1610c76c8aaSMark JohnstonCP ?= cp -f 1620c76c8aaSMark Johnston 1630c76c8aaSMark JohnstonCPP ?= cpp 1640c76c8aaSMark Johnston 165770ac3b2SJohn Birrell# C Type Format data is required for DTrace 166770ac3b2SJohn BirrellCTFFLAGS ?= -L VERSION 167770ac3b2SJohn Birrell 168770ac3b2SJohn BirrellCTFCONVERT ?= ctfconvert 169770ac3b2SJohn BirrellCTFMERGE ?= ctfmerge 1707a37b5fcSWill Andrews 171770ac3b2SJohn Birrell.if defined(CFLAGS) && (${CFLAGS:M-g} != "") 172770ac3b2SJohn BirrellCTFFLAGS += -g 173770ac3b2SJohn Birrell.endif 174770ac3b2SJohn Birrell 175443dced5SPaul RichardsCXX ?= c++ 17696f2d85eSMarcel MoolenaarCXXFLAGS ?= ${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition} 177*c867306eSJonathan AndersonIR_CXXFLAGS ?= ${STATIC_CXXFLAGS:N-O*} ${CXXFLAGS:N-O*} 178424b4e66SStephane E. PotvinPO_CXXFLAGS ?= ${CXXFLAGS} 179afe61c15SRodney W. Grimes 1800c76c8aaSMark JohnstonDTRACE ?= dtrace 1810c76c8aaSMark JohnstonDTRACEFLAGS ?= -C -x nolibs 182afe61c15SRodney W. Grimes 18365d2bdc6SRuslan Ermilov.if empty(.MAKEFLAGS:M-s) 184415bccaaSBruce EvansECHO ?= echo 185415bccaaSBruce EvansECHODIR ?= echo 186415bccaaSBruce Evans.else 187415bccaaSBruce EvansECHO ?= true 188415bccaaSBruce Evans.if ${.MAKEFLAGS:M-s} == "-s" 189415bccaaSBruce EvansECHODIR ?= echo 190415bccaaSBruce Evans.else 191415bccaaSBruce EvansECHODIR ?= true 192415bccaaSBruce Evans.endif 193415bccaaSBruce Evans.endif 194afe61c15SRodney W. Grimes 19556585ab5SBryan Drewery.if ${.MAKEFLAGS:M-N} 19656585ab5SBryan Drewery# bmake -N is supposed to skip executing anything but it does not skip 19756585ab5SBryan Drewery# exeucting '+' commands. The '+' feature is used where .MAKE 19856585ab5SBryan Drewery# is not safe for the entire target. -N is intended to skip building sub-makes 19956585ab5SBryan Drewery# so it executing '+' commands is not right. Work around the bug by not 20056585ab5SBryan Drewery# setting '+' when -N is used. 201acabf29aSHartmut Brandt_+_ ?= 202acabf29aSHartmut Brandt.else 203acabf29aSHartmut Brandt_+_ ?= + 204acabf29aSHartmut Brandt.endif 205acabf29aSHartmut Brandt 2062be2be74SSteve Price.if defined(%POSIX) 2072be2be74SSteve PriceFC ?= fort77 2082be2be74SSteve PriceFFLAGS ?= -O 1 2092be2be74SSteve Price.else 210415bccaaSBruce EvansFC ?= f77 211415bccaaSBruce EvansFFLAGS ?= -O 2122be2be74SSteve Price.endif 213415bccaaSBruce EvansEFLAGS ?= 214afe61c15SRodney W. Grimes 215c7499507SAndrey A. ChernovINSTALL ?= install 216c7499507SAndrey A. Chernov 217415bccaaSBruce EvansLEX ?= lex 218415bccaaSBruce EvansLFLAGS ?= 219afe61c15SRodney W. Grimes 220415bccaaSBruce EvansLD ?= ld 2215b6dc2efSSimon J. GerratyLDFLAGS ?= # LDFLAGS is for CC, 2225b6dc2efSSimon J. Gerraty_LDFLAGS = ${LDFLAGS:S/-Wl,//g} # strip -Wl, for LD 223afe61c15SRodney W. Grimes 224415bccaaSBruce EvansLINT ?= lint 225bd42830fSRuslan ErmilovLINTFLAGS ?= -cghapbx 226766f7d6eSMark MurrayLINTKERNFLAGS ?= ${LINTFLAGS} 227766f7d6eSMark MurrayLINTOBJFLAGS ?= -cghapbxu -i 22834d81580SMark MurrayLINTOBJKERNFLAGS?= ${LINTOBJFLAGS} 229766f7d6eSMark MurrayLINTLIBFLAGS ?= -cghapbxu -C ${LIB} 230afe61c15SRodney W. Grimes 231415bccaaSBruce EvansMAKE ?= make 232afe61c15SRodney W. Grimes 2336f1d6967SWarner Losh.if !defined(%POSIX) 234e7c08366SMarcel MoolenaarLORDER ?= lorder 235e7c08366SMarcel Moolenaar 2366f1d6967SWarner LoshNM ?= nm 23725ec8c92SRui PauloNMFLAGS ?= 2386f1d6967SWarner Losh 23970a6e331SBruce EvansOBJC ?= cc 24070a6e331SBruce EvansOBJCFLAGS ?= ${OBJCINCLUDES} ${CFLAGS} -Wno-import 24170a6e331SBruce Evans 242e97696b5SEd MasteOBJCOPY ?= objcopy 243e97696b5SEd Maste 244415bccaaSBruce EvansPC ?= pc 245415bccaaSBruce EvansPFLAGS ?= 246afe61c15SRodney W. Grimes 247415bccaaSBruce EvansRC ?= f77 248415bccaaSBruce EvansRFLAGS ?= 249e7c08366SMarcel Moolenaar 250e7c08366SMarcel MoolenaarTSORT ?= tsort 251e7c08366SMarcel MoolenaarTSORTFLAGS ?= -q 25244383aa3SEd Maste.endif 253415bccaaSBruce Evans 254415bccaaSBruce EvansSHELL ?= sh 255415bccaaSBruce Evans 25678abccfcSBaptiste Daroussin.if !defined(%POSIX) 25778abccfcSBaptiste DaroussinSIZE ?= size 25878abccfcSBaptiste Daroussin.endif 25978abccfcSBaptiste Daroussin 260415bccaaSBruce EvansYACC ?= yacc 2612be2be74SSteve Price.if defined(%POSIX) 2622be2be74SSteve PriceYFLAGS ?= 2632be2be74SSteve Price.else 264415bccaaSBruce EvansYFLAGS ?= -d 2652be2be74SSteve Price.endif 2662be2be74SSteve Price 2672be2be74SSteve Price.if defined(%POSIX) 2688d962594SBruce Evans 269808b18e4SJonathan Anderson.include "bsd.suffixes-posix.mk" 2702be2be74SSteve Price 2712be2be74SSteve Price.else 2722be2be74SSteve Price 2732be2be74SSteve Price# non-Posix rule set 274808b18e4SJonathan Anderson.include "bsd.suffixes.mk" 2753585b293SGarrett Wollman 276daf514d0SSimon J. Gerraty# Pull in global settings. 277daf514d0SSimon J. Gerraty__MAKE_CONF?=/etc/make.conf 278daf514d0SSimon J. Gerraty.if exists(${__MAKE_CONF}) 279daf514d0SSimon J. Gerraty.include "${__MAKE_CONF}" 280daf514d0SSimon J. Gerraty.endif 281daf514d0SSimon J. Gerraty 282daf514d0SSimon J. Gerraty# late include for customization 283b9d0791fSWarner Losh.sinclude <local.sys.mk> 28434bbee43SWarner Losh 2853ea2c169SBryan Drewery.if defined(META_MODE) 2863ea2c169SBryan DreweryMETA_MODE:= ${META_MODE:O:u} 2873ea2c169SBryan Drewery.endif 2883ea2c169SBryan Drewery 289a39cea66SYaroslav Tykhiy.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) 290a39cea66SYaroslav TykhiySHELL= ${__MAKE_SHELL} 291a39cea66SYaroslav Tykhiy.SHELL: path=${__MAKE_SHELL} 292a39cea66SYaroslav Tykhiy.endif 293a39cea66SYaroslav Tykhiy 294a0f1aa83SSimon J. Gerraty# Tell bmake to expand -V VAR by default 295a0f1aa83SSimon J. Gerraty.MAKE.EXPAND_VARIABLES= yes 296a0f1aa83SSimon J. Gerraty 297a0f1aa83SSimon J. Gerraty# Tell bmake the makefile preference 298a0f1aa83SSimon J. Gerraty.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile 299a0f1aa83SSimon J. Gerraty 300c41b6218SBryan Drewery# Tell bmake to always pass job tokens, regardless of target depending on 301c41b6218SBryan Drewery# .MAKE or looking like ${MAKE}/${.MAKE}/$(MAKE)/$(.MAKE)/make. 302c41b6218SBryan Drewery.MAKE.ALWAYS_PASS_JOB_QUEUE= yes 303c41b6218SBryan Drewery 304a0f1aa83SSimon J. Gerraty# By default bmake does *not* use set -e 305a0f1aa83SSimon J. Gerraty# when running target scripts, this is a problem for many makefiles here. 306a0f1aa83SSimon J. Gerraty# So define a shell that will do what FreeBSD expects. 307a0f1aa83SSimon J. Gerraty.ifndef WITHOUT_SHELL_ERRCTL 308b9d0791fSWarner Losh__MAKE_SHELL?=/bin/sh 309a0f1aa83SSimon J. Gerraty.SHELL: name=sh \ 310a0f1aa83SSimon J. Gerraty quiet="set -" echo="set -v" filter="set -" \ 311a0f1aa83SSimon J. Gerraty hasErrCtl=yes check="set -e" ignore="set +e" \ 312a0f1aa83SSimon J. Gerraty echoFlag=v errFlag=e \ 313b9d0791fSWarner Losh path=${__MAKE_SHELL} 314a0f1aa83SSimon J. Gerraty.endif 315a0f1aa83SSimon J. Gerraty 3169ca54343SWarner Losh# Hack for ports compatibility. Historically, ports makefiles have 317682d8404SMarcelo Araujo# assumed they can examine MACHINE_CPU without including anything 3189ca54343SWarner Losh# because this was automatically included in sys.mk. For /usr/src, 3199ca54343SWarner Losh# this file has moved to being included from bsd.opts.mk. Until all 320682d8404SMarcelo Araujo# the ports files are modernized, and a reasonable transition 3219ca54343SWarner Losh# period has passed, include it while we're in a ports tree here 3229ca54343SWarner Losh# to preserve historic behavior. 3239ca54343SWarner Losh.if exists(${.CURDIR}/../../Mk/bsd.port.mk) 3248d962594SBruce Evans.include <bsd.cpu.mk> 3259ca54343SWarner Losh.endif 326be4646cfSWarner Losh 327be4646cfSWarner Losh.endif # ! Posix 328