xref: /freebsd/share/mk/sys.mk (revision 808b18e4d6290cd08c2ac2977fff7aaa70ba7c9c)
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
156424b4e66SStephane E. PotvinPO_CFLAGS	?=	${CFLAGS}
157afe61c15SRodney W. Grimes
1580c76c8aaSMark Johnston# cp(1) is used to copy source files to ${.OBJDIR}, make sure it can handle
1590c76c8aaSMark Johnston# read-only files as non-root by passing -f.
1600c76c8aaSMark JohnstonCP		?=	cp -f
1610c76c8aaSMark Johnston
1620c76c8aaSMark JohnstonCPP		?=	cpp
1630c76c8aaSMark Johnston
164770ac3b2SJohn Birrell# C Type Format data is required for DTrace
165770ac3b2SJohn BirrellCTFFLAGS	?=	-L VERSION
166770ac3b2SJohn Birrell
167770ac3b2SJohn BirrellCTFCONVERT	?=	ctfconvert
168770ac3b2SJohn BirrellCTFMERGE	?=	ctfmerge
1697a37b5fcSWill Andrews
170770ac3b2SJohn Birrell.if defined(CFLAGS) && (${CFLAGS:M-g} != "")
171770ac3b2SJohn BirrellCTFFLAGS	+=	-g
172770ac3b2SJohn Birrell.endif
173770ac3b2SJohn Birrell
174443dced5SPaul RichardsCXX		?=	c++
17596f2d85eSMarcel MoolenaarCXXFLAGS	?=	${CFLAGS:N-std=*:N-Wnested-externs:N-W*-prototypes:N-Wno-pointer-sign:N-Wold-style-definition}
176424b4e66SStephane E. PotvinPO_CXXFLAGS	?=	${CXXFLAGS}
177afe61c15SRodney W. Grimes
1780c76c8aaSMark JohnstonDTRACE		?=	dtrace
1790c76c8aaSMark JohnstonDTRACEFLAGS	?=	-C -x nolibs
180afe61c15SRodney W. Grimes
18165d2bdc6SRuslan Ermilov.if empty(.MAKEFLAGS:M-s)
182415bccaaSBruce EvansECHO		?=	echo
183415bccaaSBruce EvansECHODIR		?=	echo
184415bccaaSBruce Evans.else
185415bccaaSBruce EvansECHO		?=	true
186415bccaaSBruce Evans.if ${.MAKEFLAGS:M-s} == "-s"
187415bccaaSBruce EvansECHODIR		?=	echo
188415bccaaSBruce Evans.else
189415bccaaSBruce EvansECHODIR		?=	true
190415bccaaSBruce Evans.endif
191415bccaaSBruce Evans.endif
192afe61c15SRodney W. Grimes
19356585ab5SBryan Drewery.if ${.MAKEFLAGS:M-N}
19456585ab5SBryan Drewery# bmake -N is supposed to skip executing anything but it does not skip
19556585ab5SBryan Drewery# exeucting '+' commands.  The '+' feature is used where .MAKE
19656585ab5SBryan Drewery# is not safe for the entire target.  -N is intended to skip building sub-makes
19756585ab5SBryan Drewery# so it executing '+' commands is not right.  Work around the bug by not
19856585ab5SBryan Drewery# setting '+' when -N is used.
199acabf29aSHartmut Brandt_+_		?=
200acabf29aSHartmut Brandt.else
201acabf29aSHartmut Brandt_+_		?=	+
202acabf29aSHartmut Brandt.endif
203acabf29aSHartmut Brandt
2042be2be74SSteve Price.if defined(%POSIX)
2052be2be74SSteve PriceFC		?=	fort77
2062be2be74SSteve PriceFFLAGS		?=	-O 1
2072be2be74SSteve Price.else
208415bccaaSBruce EvansFC		?=	f77
209415bccaaSBruce EvansFFLAGS		?=	-O
2102be2be74SSteve Price.endif
211415bccaaSBruce EvansEFLAGS		?=
212afe61c15SRodney W. Grimes
213c7499507SAndrey A. ChernovINSTALL		?=	install
214c7499507SAndrey A. Chernov
215415bccaaSBruce EvansLEX		?=	lex
216415bccaaSBruce EvansLFLAGS		?=
217afe61c15SRodney W. Grimes
218415bccaaSBruce EvansLD		?=	ld
2195b6dc2efSSimon J. GerratyLDFLAGS		?=				# LDFLAGS is for CC,
2205b6dc2efSSimon J. Gerraty_LDFLAGS	=	${LDFLAGS:S/-Wl,//g}	# strip -Wl, for LD
221afe61c15SRodney W. Grimes
222415bccaaSBruce EvansLINT		?=	lint
223bd42830fSRuslan ErmilovLINTFLAGS	?=	-cghapbx
224766f7d6eSMark MurrayLINTKERNFLAGS	?=	${LINTFLAGS}
225766f7d6eSMark MurrayLINTOBJFLAGS	?=	-cghapbxu -i
22634d81580SMark MurrayLINTOBJKERNFLAGS?=	${LINTOBJFLAGS}
227766f7d6eSMark MurrayLINTLIBFLAGS	?=	-cghapbxu -C ${LIB}
228afe61c15SRodney W. Grimes
229415bccaaSBruce EvansMAKE		?=	make
230afe61c15SRodney W. Grimes
2316f1d6967SWarner Losh.if !defined(%POSIX)
2326f1d6967SWarner LoshNM		?=	nm
23325ec8c92SRui PauloNMFLAGS		?=
2346f1d6967SWarner Losh
23570a6e331SBruce EvansOBJC		?=	cc
23670a6e331SBruce EvansOBJCFLAGS	?=	${OBJCINCLUDES} ${CFLAGS} -Wno-import
23770a6e331SBruce Evans
238e97696b5SEd MasteOBJCOPY		?=	objcopy
239e97696b5SEd Maste
240415bccaaSBruce EvansPC		?=	pc
241415bccaaSBruce EvansPFLAGS		?=
242afe61c15SRodney W. Grimes
243415bccaaSBruce EvansRC		?=	f77
244415bccaaSBruce EvansRFLAGS		?=
24544383aa3SEd Maste.endif
246415bccaaSBruce Evans
247415bccaaSBruce EvansSHELL		?=	sh
248415bccaaSBruce Evans
24978abccfcSBaptiste Daroussin.if !defined(%POSIX)
25078abccfcSBaptiste DaroussinSIZE		?=	size
25178abccfcSBaptiste Daroussin.endif
25278abccfcSBaptiste Daroussin
253415bccaaSBruce EvansYACC		?=	yacc
2542be2be74SSteve Price.if defined(%POSIX)
2552be2be74SSteve PriceYFLAGS		?=
2562be2be74SSteve Price.else
257415bccaaSBruce EvansYFLAGS		?=	-d
2582be2be74SSteve Price.endif
2592be2be74SSteve Price
2602be2be74SSteve Price.if defined(%POSIX)
2618d962594SBruce Evans
262*808b18e4SJonathan Anderson.include "bsd.suffixes-posix.mk"
2632be2be74SSteve Price
2642be2be74SSteve Price.else
2652be2be74SSteve Price
2662be2be74SSteve Price# non-Posix rule set
267*808b18e4SJonathan Anderson.include "bsd.suffixes.mk"
2683585b293SGarrett Wollman
269daf514d0SSimon J. Gerraty# Pull in global settings.
270daf514d0SSimon J. Gerraty__MAKE_CONF?=/etc/make.conf
271daf514d0SSimon J. Gerraty.if exists(${__MAKE_CONF})
272daf514d0SSimon J. Gerraty.include "${__MAKE_CONF}"
273daf514d0SSimon J. Gerraty.endif
274daf514d0SSimon J. Gerraty
275daf514d0SSimon J. Gerraty# late include for customization
276b9d0791fSWarner Losh.sinclude <local.sys.mk>
27734bbee43SWarner Losh
2783ea2c169SBryan Drewery.if defined(META_MODE)
2793ea2c169SBryan DreweryMETA_MODE:=	${META_MODE:O:u}
2803ea2c169SBryan Drewery.endif
2813ea2c169SBryan Drewery
282a39cea66SYaroslav Tykhiy.if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
283a39cea66SYaroslav TykhiySHELL=	${__MAKE_SHELL}
284a39cea66SYaroslav Tykhiy.SHELL: path=${__MAKE_SHELL}
285a39cea66SYaroslav Tykhiy.endif
286a39cea66SYaroslav Tykhiy
287a0f1aa83SSimon J. Gerraty# Tell bmake to expand -V VAR by default
288a0f1aa83SSimon J. Gerraty.MAKE.EXPAND_VARIABLES= yes
289a0f1aa83SSimon J. Gerraty
290a0f1aa83SSimon J. Gerraty# Tell bmake the makefile preference
291a0f1aa83SSimon J. Gerraty.MAKE.MAKEFILE_PREFERENCE= BSDmakefile makefile Makefile
292a0f1aa83SSimon J. Gerraty
293c41b6218SBryan Drewery# Tell bmake to always pass job tokens, regardless of target depending on
294c41b6218SBryan Drewery# .MAKE or looking like ${MAKE}/${.MAKE}/$(MAKE)/$(.MAKE)/make.
295c41b6218SBryan Drewery.MAKE.ALWAYS_PASS_JOB_QUEUE= yes
296c41b6218SBryan Drewery
297a0f1aa83SSimon J. Gerraty# By default bmake does *not* use set -e
298a0f1aa83SSimon J. Gerraty# when running target scripts, this is a problem for many makefiles here.
299a0f1aa83SSimon J. Gerraty# So define a shell that will do what FreeBSD expects.
300a0f1aa83SSimon J. Gerraty.ifndef WITHOUT_SHELL_ERRCTL
301b9d0791fSWarner Losh__MAKE_SHELL?=/bin/sh
302a0f1aa83SSimon J. Gerraty.SHELL: name=sh \
303a0f1aa83SSimon J. Gerraty	quiet="set -" echo="set -v" filter="set -" \
304a0f1aa83SSimon J. Gerraty	hasErrCtl=yes check="set -e" ignore="set +e" \
305a0f1aa83SSimon J. Gerraty	echoFlag=v errFlag=e \
306b9d0791fSWarner Losh	path=${__MAKE_SHELL}
307a0f1aa83SSimon J. Gerraty.endif
308a0f1aa83SSimon J. Gerraty
3099ca54343SWarner Losh# Hack for ports compatibility. Historically, ports makefiles have
310682d8404SMarcelo Araujo# assumed they can examine MACHINE_CPU without including anything
3119ca54343SWarner Losh# because this was automatically included in sys.mk. For /usr/src,
3129ca54343SWarner Losh# this file has moved to being included from bsd.opts.mk. Until all
313682d8404SMarcelo Araujo# the ports files are modernized, and a reasonable transition
3149ca54343SWarner Losh# period has passed, include it while we're in a ports tree here
3159ca54343SWarner Losh# to preserve historic behavior.
3169ca54343SWarner Losh.if exists(${.CURDIR}/../../Mk/bsd.port.mk)
3178d962594SBruce Evans.include <bsd.cpu.mk>
3189ca54343SWarner Losh.endif
319be4646cfSWarner Losh
320be4646cfSWarner Losh.endif # ! Posix
321