xref: /illumos-gate/usr/src/Makefile.master (revision a39905c1)
17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# CDDL HEADER START
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
502e56f3fSwesolows# Common Development and Distribution License (the "License").
602e56f3fSwesolows# You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate#
87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate# and limitations under the License.
127c478bd9Sstevel@tonic-gate#
137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate#
197c478bd9Sstevel@tonic-gate# CDDL HEADER END
207c478bd9Sstevel@tonic-gate#
2102e56f3fSwesolows
227c478bd9Sstevel@tonic-gate#
23b83ec4edSjmcp# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
240a49f0acSAdam H. Leventhal# Copyright (c) 2012 by Delphix. All rights reserved.
25538aa54dSGarrett D'Amore# Copyright 2014 Garrett D'Amore <garrett@damore.org>
261f2ca518SDan McDonald# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
27fca42680SGary Mills# Copyright 2015 Gary Mills
284cb69eccSIgor Kozhukhov# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
290cc5983cSToomas Soome# Copyright 2016 Toomas Soome <tsoome@me.com>
30300fdee2SAndy Fiddaman# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
312944b91eSJohn Levon# Copyright 2020 Joyent, Inc.
328e0c8248SAndrew Stormont# Copyright 2019 RackTop Systems.
336112cec5SJoshua M. Clulow# Copyright 2020 Oxide Computer Company
3451396a8eSPeter Tribble# Copyright 2020 Peter Tribble
357c478bd9Sstevel@tonic-gate#
360a49f0acSAdam H. Leventhal
377c478bd9Sstevel@tonic-gate#
387c478bd9Sstevel@tonic-gate# Makefile.master, global definitions for system source
397c478bd9Sstevel@tonic-gate#
407c478bd9Sstevel@tonic-gateROOT=		/proto
417c478bd9Sstevel@tonic-gate
42494f7e12SKeith M Wesolowski#
43494f7e12SKeith M Wesolowski# Adjunct root, containing an additional proto area to be used for headers
44494f7e12SKeith M Wesolowski# and libraries.
45494f7e12SKeith M Wesolowski#
46494f7e12SKeith M WesolowskiADJUNCT_PROTO=
475801b0f0SToomas Soome# HAVE_ADJUNCT_PROTO - ADJUNCT_PROTO is set to a non-default value
485801b0f0SToomas Soome# NO_ADJUNCT_PROTO - ADJUNCT_PROTO is unset
495801b0f0SToomas Soome#
505801b0f0SToomas Soome# This works by replacing any value in ADJUNCT_PROTO with POUND_SIGN, which
515801b0f0SToomas Soome# only happens if it has some value, and then setting HAVE_ADJUNCT_PROTO
525801b0f0SToomas Soome# oppositely.
535801b0f0SToomas SoomeNO_ADJUNCT_PROTO=$(ADJUNCT_PROTO:%=$(POUND_SIGN))
545801b0f0SToomas Soome$(NO_ADJUNCT_PROTO)HAVE_ADJUNCT_PROTO=$(POUND_SIGN)
55494f7e12SKeith M Wesolowski
56494f7e12SKeith M Wesolowski#
57494f7e12SKeith M Wesolowski# Adjunct for building things that run on the build machine.
58494f7e12SKeith M Wesolowski#
59494f7e12SKeith M WesolowskiNATIVE_ADJUNCT=	/usr
60494f7e12SKeith M Wesolowski
614c87aefeSPatrick Mooney#
624c87aefeSPatrick Mooney# Compatibility code for FreeBSD etc.
634c87aefeSPatrick Mooney#
644c87aefeSPatrick MooneyCOMPAT=	$(SRC)/compat
65d0b3c59bSPatrick MooneyCONTRIB= $(SRC)/contrib
664c87aefeSPatrick Mooney
677c478bd9Sstevel@tonic-gate#
6824fe0b3bSjmcp# RELEASE_BUILD should be cleared for final release builds.
6924fe0b3bSjmcp# NOT_RELEASE_BUILD is exactly what the name implies.
707c478bd9Sstevel@tonic-gate#
717c478bd9Sstevel@tonic-gate# __GNUC toggles the building of ON components using gcc and related tools.
727c478bd9Sstevel@tonic-gate# Normally set to `#', set it to `' to do gcc build.
737c478bd9Sstevel@tonic-gate#
747c478bd9Sstevel@tonic-gate# The declaration POUND_SIGN is always '#'. This is needed to get around the
757c478bd9Sstevel@tonic-gate# make feature that '#' is always a comment delimiter, even when escaped or
7648bc00d6Sjmcp# quoted. We use this macro expansion method to get POUND_SIGN rather than
7748bc00d6Sjmcp# always breaking out a shell because the general case can cause a noticable
7848bc00d6Sjmcp# slowdown in build times when so many Makefiles include Makefile.master.
797c478bd9Sstevel@tonic-gate#
8048bc00d6Sjmcp# While the majority of users are expected to override the setting below
8148bc00d6Sjmcp# with an env file (via nightly or bldenv), if you aren't building that way
8248bc00d6Sjmcp# (ie, you're using "ws" or some other bootstrapping method) then you need
8348bc00d6Sjmcp# this definition in order to avoid the subshell invocation mentioned above.
8448bc00d6Sjmcp#
8548bc00d6Sjmcp
8648bc00d6SjmcpPRE_POUND=				pre\#
8748bc00d6SjmcpPOUND_SIGN=				$(PRE_POUND:pre\%=%)
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gateNOT_RELEASE_BUILD=
907c478bd9Sstevel@tonic-gateRELEASE_BUILD=				$(POUND_SIGN)
917c478bd9Sstevel@tonic-gate$(RELEASE_BUILD)NOT_RELEASE_BUILD=	$(POUND_SIGN)
927c478bd9Sstevel@tonic-gatePATCH_BUILD=				$(POUND_SIGN)
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate# SPARC_BLD is '#' for an Intel build.
957c478bd9Sstevel@tonic-gate# INTEL_BLD is '#' for a Sparc build.
967c478bd9Sstevel@tonic-gateSPARC_BLD_1=    $(MACH:i386=$(POUND_SIGN))
977c478bd9Sstevel@tonic-gateSPARC_BLD=      $(SPARC_BLD_1:sparc=)
987c478bd9Sstevel@tonic-gateINTEL_BLD_1=    $(MACH:sparc=$(POUND_SIGN))
997c478bd9Sstevel@tonic-gateINTEL_BLD=      $(INTEL_BLD_1:i386=)
1007c478bd9Sstevel@tonic-gate
1016a3e8e86SRichard Lowe# The variables below control the compilers used during the build.
1026a3e8e86SRichard Lowe# There are a number of permutations.
1036a3e8e86SRichard Lowe#
1046a3e8e86SRichard Lowe# __GNUC and __SUNC control (and indicate) the primary compiler.  Whichever
1056a3e8e86SRichard Lowe# one is not POUND_SIGN is the primary, with the other as the shadow.  They
1066a3e8e86SRichard Lowe# may also be used to control entirely compiler-specific Makefile assignments.
1074f4d4600SRichard Lowe# __GNUC and GCC are the default.
1086a3e8e86SRichard Lowe#
1096a3e8e86SRichard Lowe# __GNUC64 indicates that the 64bit build should use the GNU C compiler.
1106a3e8e86SRichard Lowe# There is no Sun C analogue.
1116a3e8e86SRichard Lowe#
1126a3e8e86SRichard Lowe# The following version-specific options are operative regardless of which
1136a3e8e86SRichard Lowe# compiler is primary, and control the versions of the given compilers to be
1146a3e8e86SRichard Lowe# used.  They also allow compiler-version specific Makefile fragments.
1156a3e8e86SRichard Lowe#
1166a3e8e86SRichard Lowe
1174f4d4600SRichard Lowe__SUNC=			$(POUND_SIGN)
1184f4d4600SRichard Lowe$(__SUNC)__GNUC=	$(POUND_SIGN)
1196a3e8e86SRichard Lowe__GNUC64=		$(__GNUC)
1207c478bd9Sstevel@tonic-gate
12114c3be39SGordon Ross# Allow build-time "configuration" to enable or disable some things.
12214c3be39SGordon Ross# The default is POUND_SIGN, meaning "not enabled". If the environment
12314c3be39SGordon Ross# passes in an override like ENABLE_SMB_PRINTING= (empty) that will
12414c3be39SGordon Ross# uncomment things in the lower Makefiles to enable the feature.
12514c3be39SGordon RossENABLE_SMB_PRINTING=	$(POUND_SIGN)
12614c3be39SGordon Ross
127fb9f9b97Skupfer# CLOSED is the root of the tree that contains source which isn't released
128fb9f9b97Skupfer# as open source
129fb9f9b97SkupferCLOSED=		$(SRC)/../closed
130fb9f9b97Skupfer
1317c478bd9Sstevel@tonic-gate# BUILD_TOOLS is the root of all tools including compilers.
1327c478bd9Sstevel@tonic-gate# ONBLD_TOOLS is the root of all the tools that are part of SUNWonbld.
1337c478bd9Sstevel@tonic-gate
1347c478bd9Sstevel@tonic-gateBUILD_TOOLS=		/ws/onnv-tools
1357c478bd9Sstevel@tonic-gateONBLD_TOOLS=		$(BUILD_TOOLS)/onbld
1367c478bd9Sstevel@tonic-gate
137e53cbaa9SRichard PALO# define runtime JAVA_HOME, primarily for cmd/pools/poold
138e53cbaa9SRichard PALOJAVA_HOME=	/usr/java
139e53cbaa9SRichard PALO# define buildtime JAVA_ROOT
1407c478bd9Sstevel@tonic-gateJAVA_ROOT=	/usr/java
14151396a8eSPeter Tribble# Build uses java8 by default.  Pass the variable below set to empty
14267048e0fSYuri Pankov# string in the environment to override.
14351396a8eSPeter TribbleBLD_JAVA_11=	$(POUND_SIGN)
1447c478bd9Sstevel@tonic-gate
1458123ce61SJohn LevonGNUC_ROOT=	/usr/gcc/7
1467ed54634SRobert MustacchiGCCLIBDIR=	$(GNUC_ROOT)/lib
1477ed54634SRobert MustacchiGCCLIBDIR64=	$(GNUC_ROOT)/lib/$(MACH64)
1486a3e8e86SRichard Lowe
14911d7e819SRobert MustacchiDOCBOOK_XSL_ROOT=	/usr/share/sgml/docbook/xsl-stylesheets
15011d7e819SRobert Mustacchi
1512aeafac3SToomas SoomeRPCGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/rpcgen
1527c478bd9Sstevel@tonic-gateSTABS=		$(ONBLD_TOOLS)/bin/$(MACH)/stabs
153ae115bc7SmrjELFEXTRACT=	$(ONBLD_TOOLS)/bin/$(MACH)/elfextract
154ae115bc7SmrjMBH_PATCH=	$(ONBLD_TOOLS)/bin/$(MACH)/mbh_patch
1550cc5983cSToomas SoomeBTXLD=		$(ONBLD_TOOLS)/bin/$(MACH)/btxld
1564b529e40SToomas SoomeVTFONTCVT=	$(ONBLD_TOOLS)/bin/$(MACH)/vtfontcvt
157c0855578SRichard Lowe# echo(1) and true(1) are specified without absolute paths, so that the shell
158c0855578SRichard Lowe# spawned by make(1) may use the built-in versions.  This is minimally
159c0855578SRichard Lowe# problematic, as the shell spawned by make(1) is known and under control, the
160c0855578SRichard Lowe# only risk being if the shell falls back to $PATH.
161c0855578SRichard Lowe#
162c0855578SRichard Lowe# We specifically want an echo(1) that does interpolation of escape sequences,
163c0855578SRichard Lowe# which ksh93, /bin/sh, and bash will all provide.
1647c478bd9Sstevel@tonic-gateECHO=		echo
1657c478bd9Sstevel@tonic-gateTRUE=		true
166c0855578SRichard LoweINS=		$(ONBLD_TOOLS)/bin/$(MACH)/install
1677c478bd9Sstevel@tonic-gateSYMLINK=	/usr/bin/ln -s
1687c478bd9Sstevel@tonic-gateLN=		/usr/bin/ln
169c0855578SRichard LoweMKDIR=		/usr/bin/mkdir
1707c478bd9Sstevel@tonic-gateCHMOD=		/usr/bin/chmod
1717c478bd9Sstevel@tonic-gateMV=		/usr/bin/mv -f
1727c478bd9Sstevel@tonic-gateRM=		/usr/bin/rm -f
173f4b3ec61SdhCUT=		/usr/bin/cut
174f4b3ec61SdhNM=		/usr/ccs/bin/nm
175f4b3ec61SdhDIFF=		/usr/bin/diff
1767c478bd9Sstevel@tonic-gateGREP=		/usr/bin/grep
1771912d2c4SwesolowsEGREP=		/usr/bin/egrep
1784c06356bSdhELFWRAP=	/usr/bin/elfwrap
17932bd7e59SmjnelsonKSH93=		/usr/bin/ksh93
1807c478bd9Sstevel@tonic-gateSED=		/usr/bin/sed
1817b07063dSIgor KozhukhovAWK=		/usr/bin/nawk
1827c478bd9Sstevel@tonic-gateCP=		/usr/bin/cp -f
1837c478bd9Sstevel@tonic-gateMCS=		/usr/ccs/bin/mcs
1847c478bd9Sstevel@tonic-gateCAT=            /usr/bin/cat
18524da5b34SrieELFDUMP=	/usr/ccs/bin/elfdump
186fca42680SGary MillsM4=		/usr/bin/m4
187bc36eafdSMike GerdtsGM4=		/usr/bin/gm4
1887c478bd9Sstevel@tonic-gateSTRIP=		/usr/ccs/bin/strip
1897c478bd9Sstevel@tonic-gateLEX=		/usr/ccs/bin/lex
190cdf815bbSRichard PALOFLEX=		/usr/bin/flex
1917c478bd9Sstevel@tonic-gateYACC=		/usr/ccs/bin/yacc
192bc36eafdSMike GerdtsBISON=		/usr/bin/bison
1937c478bd9Sstevel@tonic-gateCPP=		/usr/lib/cpp
1947ed54634SRobert MustacchiANSI_CPP=	$(GNUC_ROOT)/bin/cpp
1957c478bd9Sstevel@tonic-gateJAVAC=		$(JAVA_ROOT)/bin/javac
1967c478bd9Sstevel@tonic-gateJAVADOC=	$(JAVA_ROOT)/bin/javadoc
1977c478bd9Sstevel@tonic-gateJAR=		$(JAVA_ROOT)/bin/jar
1987c478bd9Sstevel@tonic-gateCTFCONVERT=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfconvert
199bc1f688bSRobert MustacchiCTFDIFF=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfdiff
2007c478bd9Sstevel@tonic-gateCTFMERGE=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfmerge
2017c478bd9Sstevel@tonic-gateCTFSTABS=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
202a0ed5030SJason KingCTFSTRIP=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstrip
203d0e51869SamwNDRGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/ndrgen
2047c478bd9Sstevel@tonic-gateGENOFFSETS=	$(ONBLD_TOOLS)/bin/genoffsets
2057c478bd9Sstevel@tonic-gateXREF=		$(ONBLD_TOOLS)/bin/xref
2067c478bd9Sstevel@tonic-gateFIND=		/usr/bin/find
2077c478bd9Sstevel@tonic-gatePERL=		/usr/bin/perl
20833392354SAlexander PyhalovPERL_VERSION=	5.10.0
20933392354SAlexander PyhalovPERL_PKGVERS=	-510
2100ae9a84fSAndrew StormontPERL_MACH=	i86pc
2110ae9a84fSAndrew Stormont$(SPARC_BLD)PERL_MACH=	sun4
2120ae9a84fSAndrew StormontPERL_VARIANT=
2130ae9a84fSAndrew StormontPERL_ARCH=	$(PERL_MACH)-solaris$(PERL_VARIANT)-64int
2140ae9a84fSAndrew StormontPERL_ARCH64=	$(PERL_MACH)-solaris$(PERL_VARIANT)-64
2159f923083SAlexander PyhalovPYTHON_VERSION=	2.7
2169f923083SAlexander PyhalovPYTHON_PKGVERS=	-27
217e8921a52SAndy FiddamanPYTHON_SUFFIX=
2189f923083SAlexander PyhalovPYTHON=		/usr/bin/python$(PYTHON_VERSION)
219e8921a52SAndy FiddamanPYTHON3_VERSION=	3.5
220e8921a52SAndy FiddamanPYTHON3_PKGVERS=	-35
221e8921a52SAndy FiddamanPYTHON3_SUFFIX=		m
222e8921a52SAndy FiddamanPYTHON3=		/usr/bin/python$(PYTHON3_VERSION)
223ca13eaa5SAndy Fiddaman$(BUILDPY3TOOLS)TOOLS_PYTHON=		$(PYTHON3)
224ca13eaa5SAndy Fiddaman$(BUILDPY2TOOLS)TOOLS_PYTHON=		$(PYTHON)
2257c478bd9Sstevel@tonic-gateSORT=		/usr/bin/sort
22616d86563SAlexander PyhalovTR=		/usr/bin/tr
2277c478bd9Sstevel@tonic-gateTOUCH=		/usr/bin/touch
2287c478bd9Sstevel@tonic-gateWC=		/usr/bin/wc
2297c478bd9Sstevel@tonic-gateXARGS=		/usr/bin/xargs
2302cc2d1f4SdarrenmELFEDIT=	/usr/bin/elfedit
2310a49f0acSAdam H. LeventhalDTRACE=		/usr/sbin/dtrace -xnolibs
232620753d0SjmcpUNIQ=		/usr/bin/uniq
2332ad72058SGarrett D'AmoreTAR=		/usr/bin/tar
234e119f243SRobert MustacchiASTBINDIR=	/usr/ast/bin
235e119f243SRobert MustacchiMSGCC=		$(ASTBINDIR)/msgcc
236b599bd93SRobert MustacchiMSGFMT=		/usr/bin/msgfmt -s
237503609a9SYuri PankovLCDEF=		$(ONBLD_TOOLS)/bin/$(MACH)/localedef
238503609a9SYuri PankovTIC=		$(ONBLD_TOOLS)/bin/$(MACH)/tic
239503609a9SYuri PankovZIC=		$(ONBLD_TOOLS)/bin/$(MACH)/zic
240300fdee2SAndy FiddamanOPENSSL=	/usr/bin/openssl
2417e3dbbacSRobert MustacchiCPCGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/cpcgen
2427c478bd9Sstevel@tonic-gate
2433c562093SToomas SoomeDEFAULT_CONSOLE_COLOR=					\
2443c562093SToomas Soome	-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_WHITE	\
2453c562093SToomas Soome	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_BLACK
2463c562093SToomas Soome
2477c478bd9Sstevel@tonic-gateFILEMODE=	644
2487c478bd9Sstevel@tonic-gateDIRMODE=	755
2497c478bd9Sstevel@tonic-gate
2507c478bd9Sstevel@tonic-gate# Declare that nothing should be built in parallel.
2517c478bd9Sstevel@tonic-gate# Individual Makefiles can use the .PARALLEL target to declare otherwise.
2527c478bd9Sstevel@tonic-gate.NO_PARALLEL:
2537c478bd9Sstevel@tonic-gate
2547c478bd9Sstevel@tonic-gate# For stylistic checks
2557c478bd9Sstevel@tonic-gate#
2567c478bd9Sstevel@tonic-gate# Note that the X and C checks are not used at this time and may need
2577c478bd9Sstevel@tonic-gate# modification when they are actually used.
2587c478bd9Sstevel@tonic-gate#
259cdf0c1d5SmjnelsonCSTYLE=		$(ONBLD_TOOLS)/bin/cstyle
2607c478bd9Sstevel@tonic-gateCSTYLE_TAIL=
261cdf0c1d5SmjnelsonHDRCHK=		$(ONBLD_TOOLS)/bin/hdrchk
2627c478bd9Sstevel@tonic-gateHDRCHK_TAIL=
263cdf0c1d5SmjnelsonJSTYLE=		$(ONBLD_TOOLS)/bin/jstyle
2647c478bd9Sstevel@tonic-gate
2657c478bd9Sstevel@tonic-gateDOT_H_CHECK=	\
2667c478bd9Sstevel@tonic-gate	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
2677c478bd9Sstevel@tonic-gate	$(HDRCHK) $< $(HDRCHK_TAIL)
2687c478bd9Sstevel@tonic-gate
2697c478bd9Sstevel@tonic-gateDOT_X_CHECK=	\
2707c478bd9Sstevel@tonic-gate	@$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
2717c478bd9Sstevel@tonic-gate	$(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)
2727c478bd9Sstevel@tonic-gate
2737c478bd9Sstevel@tonic-gateDOT_C_CHECK=	\
2747c478bd9Sstevel@tonic-gate	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)
2757c478bd9Sstevel@tonic-gate
2767c478bd9Sstevel@tonic-gateMANIFEST_CHECK=	\
2777c478bd9Sstevel@tonic-gate	@$(ECHO) "checking $<"; \
2787c478bd9Sstevel@tonic-gate	SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
2791f6eb021SLiane Praza	SVCCFG_REPOSITORY=$(SRC)/cmd/svc/seed/global.db \
2801f6eb021SLiane Praza	SVCCFG_CONFIGD_PATH=$(SRC)/cmd/svc/configd/svc.configd-native \
2817c478bd9Sstevel@tonic-gate	$(SRC)/cmd/svc/svccfg/svccfg-native validate $<
2827c478bd9Sstevel@tonic-gate
2837c478bd9Sstevel@tonic-gateINS.file=	$(RM) $@; $(INS) -s -m $(FILEMODE) -f $(@D) $<
2847c478bd9Sstevel@tonic-gateINS.dir=	$(INS) -s -d -m $(DIRMODE) $@
2857c478bd9Sstevel@tonic-gate# installs and renames at once
2867c478bd9Sstevel@tonic-gate#
2877c478bd9Sstevel@tonic-gateINS.rename=	$(INS.file); $(MV) $(@D)/$(<F) $@
2887c478bd9Sstevel@tonic-gate
2897c478bd9Sstevel@tonic-gate# install a link
2907c478bd9Sstevel@tonic-gateINSLINKTARGET=	$<
2917c478bd9Sstevel@tonic-gateINS.link=	$(RM) $@; $(LN) $(INSLINKTARGET) $@
292b83ec4edSjmcpINS.symlink=	$(RM) $@; $(SYMLINK) $(INSLINKTARGET) $@
293b83ec4edSjmcp
294d8154717SAndy Fiddaman# The path to python that will be used for the shebang line when installing
295d8154717SAndy Fiddaman# python scripts to the proto area. This is overridden by makefiles to
296d8154717SAndy Fiddaman# select to the correct version.
297d8154717SAndy FiddamanPYSHEBANG=	$(PYTHON)
298b0858fdcSAlexander Pyhalov$(BUILDPY3)PYSHEBANG=	$(PYTHON3)
299b0858fdcSAlexander Pyhalov$(BUILDPY2)PYSHEBANG=	$(PYTHON)
300d8154717SAndy Fiddaman
301cdf0c1d5Smjnelson#
302cdf0c1d5Smjnelson# Python bakes the mtime of the .py file into the compiled .pyc and
303cdf0c1d5Smjnelson# rebuilds if the baked-in mtime != the mtime of the source file
304cdf0c1d5Smjnelson# (rather than only if it's less than), thus when installing python
305cdf0c1d5Smjnelson# files we must make certain to not adjust the mtime of the source
306cdf0c1d5Smjnelson# (.py) file.
307cdf0c1d5Smjnelson#
308ca13eaa5SAndy FiddamanINS.pyfile=	$(RM) $@; $(SED) \
309ca13eaa5SAndy Fiddaman		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
310ca13eaa5SAndy Fiddaman		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
311ca13eaa5SAndy Fiddaman		< $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@
3127c478bd9Sstevel@tonic-gate
3137c478bd9Sstevel@tonic-gate# MACH must be set in the shell environment per uname -p on the build host
3147c478bd9Sstevel@tonic-gate# More specific architecture variables should be set in lower makefiles.
3157c478bd9Sstevel@tonic-gate#
3167c478bd9Sstevel@tonic-gate# MACH64 is derived from MACH, and BUILD64 is set to `#' for
3177c478bd9Sstevel@tonic-gate# architectures on which we do not build 64-bit versions.
3187c478bd9Sstevel@tonic-gate# (There are no such architectures at the moment.)
3197c478bd9Sstevel@tonic-gate#
3207c478bd9Sstevel@tonic-gate# Set BUILD64=# in the environment to disable 64-bit amd64
3217c478bd9Sstevel@tonic-gate# builds on i386 machines.
3227c478bd9Sstevel@tonic-gate
3237c478bd9Sstevel@tonic-gateMACH64_1=	$(MACH:sparc=sparcv9)
3247c478bd9Sstevel@tonic-gateMACH64=		$(MACH64_1:i386=amd64)
3257c478bd9Sstevel@tonic-gate
3267c478bd9Sstevel@tonic-gateMACH32_1=	$(MACH:sparc=sparcv7)
3277c478bd9Sstevel@tonic-gateMACH32=		$(MACH32_1:i386=i86)
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gatesparc_BUILD64=
3307c478bd9Sstevel@tonic-gatei386_BUILD64=
3317c478bd9Sstevel@tonic-gateBUILD64=	$($(MACH)_BUILD64)
3327c478bd9Sstevel@tonic-gate
3337c478bd9Sstevel@tonic-gate#
3347c478bd9Sstevel@tonic-gate# C compiler mode. Future compilers may change the default on us,
3357c478bd9Sstevel@tonic-gate# so force extended ANSI mode globally. Lower level makefiles can
3367c478bd9Sstevel@tonic-gate# override this by setting CCMODE.
3377c478bd9Sstevel@tonic-gate#
3387c478bd9Sstevel@tonic-gateCCMODE=			-Xa
3397c478bd9Sstevel@tonic-gateCCMODE64=		-Xa
3407c478bd9Sstevel@tonic-gate
3417c478bd9Sstevel@tonic-gate#
3427c478bd9Sstevel@tonic-gate# C compiler verbose mode. This is so we can enable it globally,
3437c478bd9Sstevel@tonic-gate# but turn it off in the lower level makefiles of things we cannot
3447c478bd9Sstevel@tonic-gate# (or aren't going to) fix.
3457c478bd9Sstevel@tonic-gate#
3467c478bd9Sstevel@tonic-gateCCVERBOSE=		-v
3477c478bd9Sstevel@tonic-gate
3487c478bd9Sstevel@tonic-gate# set this to the secret flag "-Wc,-Qiselect-v9abiwarn=1" to get warnings
3497c478bd9Sstevel@tonic-gate# from the compiler about places the -xarch=v9 may differ from -xarch=v9c.
3507c478bd9Sstevel@tonic-gateV9ABIWARN=
3517c478bd9Sstevel@tonic-gate
3527c478bd9Sstevel@tonic-gate# set this to the secret flag "-Wc,-Qiselect-regsym=0" to disable register
3537c478bd9Sstevel@tonic-gate# symbols (used to detect conflicts between objects that use global registers)
3547c478bd9Sstevel@tonic-gate# we disable this now for safety, and because genunix doesn't link with
3557c478bd9Sstevel@tonic-gate# this feature (the v9 default) enabled.
3567c478bd9Sstevel@tonic-gate#
3577c478bd9Sstevel@tonic-gate# REGSYM is separate since the C++ driver syntax is different.
3587c478bd9Sstevel@tonic-gateCCREGSYM=		-Wc,-Qiselect-regsym=0
3597c478bd9Sstevel@tonic-gateCCCREGSYM=		-Qoption cg -Qiselect-regsym=0
3607c478bd9Sstevel@tonic-gate
361face03d9Spetede# Prevent the removal of static symbols by the SPARC code generator (cg).
362face03d9Spetede# The x86 code generator (ube) does not remove such symbols and as such
363face03d9Spetede# using this workaround is not applicable for x86.
364face03d9Spetede#
365ac204d0dSpetedeCCSTATICSYM=		-Wc,-Qassembler-ounrefsym=0
3667c478bd9Sstevel@tonic-gate#
3677c478bd9Sstevel@tonic-gate# generate 32-bit addresses in the v9 kernel. Saves memory.
3687c478bd9Sstevel@tonic-gateCCABS32=		-Wc,-xcode=abs32
3696a3e8e86SRichard Lowe#
3706a3e8e86SRichard Lowe# generate v9 code which tolerates callers using the v7 ABI, for the sake of
3716a3e8e86SRichard Lowe# system calls.
3721a5ea532SRichard LoweCC32BITCALLERS=		-_gcc=-massume-32bit-callers
3736a3e8e86SRichard Lowe
3746a3e8e86SRichard Lowe# GCC, especially, is increasingly beginning to auto-inline functions and
3756a3e8e86SRichard Lowe# sadly does so separately not under the general -fno-inline-functions
37670413d7bSJoshua M. Clulow# Additionally, we wish to prevent optimisations which cause GCC to clone
37770413d7bSJoshua M. Clulow# functions -- in particular, these may cause unhelpful symbols to be
37870413d7bSJoshua M. Clulow# emitted instead of function names
3796b544f0eSJohn LevonCCNOAUTOINLINE= \
3806b544f0eSJohn Levon	-_gcc=-fno-inline-small-functions \
38170413d7bSJoshua M. Clulow	-_gcc=-fno-inline-functions-called-once \
3826b544f0eSJohn Levon	-_gcc=-fno-ipa-cp \
3836b544f0eSJohn Levon	-_gcc7=-fno-ipa-icf \
3846b544f0eSJohn Levon	-_gcc8=-fno-ipa-icf \
3852f57b5e0SToomas Soome	-_gcc9=-fno-ipa-icf \
3866b544f0eSJohn Levon	-_gcc7=-fno-clone-functions \
3872f57b5e0SToomas Soome	-_gcc8=-fno-clone-functions \
3882f57b5e0SToomas Soome	-_gcc9=-fno-clone-functions
3897c478bd9Sstevel@tonic-gate
390b6c711ccSRichard Lowe# GCC may put functions in different named sub-sections of .text based on
391b6c711ccSRichard Lowe# their presumed calling frequency.  At least in the kernel, where we actually
392b6c711ccSRichard Lowe# deliver relocatable objects, we don't want this to happen.
393b6c711ccSRichard Lowe#
394b6c711ccSRichard Lowe# Since at present we don't benefit from this even in userland, we disable it globally,
395b6c711ccSRichard Lowe# but the application of this may move into usr/src/uts/ in future.
396b6c711ccSRichard LoweCCNOREORDER=	\
397b6c711ccSRichard Lowe	-_gcc7=-fno-reorder-functions \
3982f57b5e0SToomas Soome	-_gcc8=-fno-reorder-functions \
3992f57b5e0SToomas Soome	-_gcc9=-fno-reorder-functions
400b6c711ccSRichard Lowe
40192c1a611SBryan Cantrill#
40292c1a611SBryan Cantrill# gcc has a rather aggressive optimization on by default that infers loop
40392c1a611SBryan Cantrill# bounds based on undefined behavior (!!).  This can lead to some VERY
40492c1a611SBryan Cantrill# surprising optimizations -- ones that may be technically correct in the
40592c1a611SBryan Cantrill# strictest sense but also result in incorrect program behavior.  We turn
40692c1a611SBryan Cantrill# this optimization off, with extreme prejudice.
40792c1a611SBryan Cantrill#
40892c1a611SBryan CantrillCCNOAGGRESSIVELOOPS= \
40992c1a611SBryan Cantrill	-_gcc7=-fno-aggressive-loop-optimizations \
4102f57b5e0SToomas Soome	-_gcc8=-fno-aggressive-loop-optimizations \
4112f57b5e0SToomas Soome	-_gcc9=-fno-aggressive-loop-optimizations
41292c1a611SBryan Cantrill
4135a0af816SRobert Mustacchi#
4145a0af816SRobert Mustacchi# Options to control which version of stack-protector we enable. This
4155a0af816SRobert Mustacchi# gives us a bit of flexibility and is unfortunately necessary as some
4165a0af816SRobert Mustacchi# modules do not function correctly with our defaults (qede).
4175a0af816SRobert Mustacchi#
4185a0af816SRobert Mustacchi#  o STACKPROTECT_              Sets the appropriate version for the compiler
4195a0af816SRobert Mustacchi#  o STACKPROTECT_strong        Sets us to use strong on all of the
4205a0af816SRobert Mustacchi#                               compilers it supports. This is the same
4215a0af816SRobert Mustacchi#                               as the default.
4225a0af816SRobert Mustacchi#
4235a0af816SRobert Mustacchi#  o STACKPROTECT_none          Disables the stack protector.
4245a0af816SRobert Mustacchi#
4255a0af816SRobert Mustacchi#  o STACKPROTECT_all           Enables it for everything.
4265a0af816SRobert Mustacchi#
4275a0af816SRobert Mustacchi#  o STACKPROTECT_basic         Enables the basic stack protector.
4285a0af816SRobert Mustacchi#
4295a0af816SRobert Mustacchi# -fstack-protector-strong is not available in gcc4 which is why we
4305a0af816SRobert Mustacchi# have per-compiler versions below. These are not added to the default
4315a0af816SRobert Mustacchi# global CFLAGS at this time as it's being incrementally enabled
4325a0af816SRobert Mustacchi# throughout the build.
4335a0af816SRobert Mustacchi#
4345a0af816SRobert MustacchiSTACKPROTECT_           = -_gcc4=-fstack-protector
4355a0af816SRobert MustacchiSTACKPROTECT_           += -_gcc7=-fstack-protector-strong
4365a0af816SRobert MustacchiSTACKPROTECT_           += -_gcc8=-fstack-protector-strong
4375a0af816SRobert MustacchiSTACKPROTECT_           += -_gcc9=-fstack-protector-strong
4385a0af816SRobert Mustacchi
4395a0af816SRobert MustacchiSTACKPROTECT_strong     = $(STACKPROTECT_)
4405a0af816SRobert MustacchiSTACKPROTECT_none       =
4415a0af816SRobert MustacchiSTACKPROTECT_all        = -_gcc=-fstack-protector-all
4425a0af816SRobert MustacchiSTACKPROTECT_basic      = -_gcc=-fstack-protector
4435a0af816SRobert Mustacchi
4445a0af816SRobert MustacchiSTACKPROTECT_LD_	= -lssp_ns
4455a0af816SRobert MustacchiSTACKPROTECT_LD_none	=
446*a39905c1SRobert MustacchiSTACKPROTECT_LD_all	= $(STACKPROTECT_LD_)
447*a39905c1SRobert MustacchiSTACKPROTECT_LD_basic	= $(STACKPROTECT_LD_)
4485a0af816SRobert Mustacchi
4495a0af816SRobert MustacchiCCSTACKPROTECT= $(STACKPROTECT_$(STACKPROTECT))
4505a0af816SRobert MustacchiLDSTACKPROTECT= $(STACKPROTECT_LD_$(STACKPROTECT))
4515a0af816SRobert Mustacchi
4527c478bd9Sstevel@tonic-gate# One optimization the compiler might perform is to turn this:
4537c478bd9Sstevel@tonic-gate#	#pragma weak foo
4547c478bd9Sstevel@tonic-gate#	extern int foo;
4557c478bd9Sstevel@tonic-gate#	if (&foo)
4567c478bd9Sstevel@tonic-gate#		foo = 5;
4577c478bd9Sstevel@tonic-gate# into
4587c478bd9Sstevel@tonic-gate#	foo = 5;
4597c478bd9Sstevel@tonic-gate# Since we do some of this (foo might be referenced in common kernel code
4607c478bd9Sstevel@tonic-gate# but provided only for some cpu modules or platforms), we disable this
4617c478bd9Sstevel@tonic-gate# optimization.
462d69cdb36SRichard Lowe#
4637c478bd9Sstevel@tonic-gatesparc_CCUNBOUND	= -Wd,-xsafe=unboundsym
4647c478bd9Sstevel@tonic-gatei386_CCUNBOUND	=
4657c478bd9Sstevel@tonic-gateCCUNBOUND	= $($(MACH)_CCUNBOUND)
4667c478bd9Sstevel@tonic-gate
4677c478bd9Sstevel@tonic-gate#
4687c478bd9Sstevel@tonic-gate# compiler '-xarch' flag. This is here to centralize it and make it
4697c478bd9Sstevel@tonic-gate# overridable for testing.
4700bb07399SNick Toddsparc_XARCH=	-m32
4710bb07399SNick Toddsparcv9_XARCH=	-m64
4729c05409fSRichard Lowei386_XARCH=	-m32
4730bb07399SNick Toddamd64_XARCH=	-m64 -Ui386 -U__i386
4747c478bd9Sstevel@tonic-gate
4757c478bd9Sstevel@tonic-gate# assembler '-xarch' flag.  Different from compiler '-xarch' flag.
47660c80770Scraigmsparc_AS_XARCH=		-xarch=v8plus
4777c478bd9Sstevel@tonic-gatesparcv9_AS_XARCH=	-xarch=v9
4787c478bd9Sstevel@tonic-gatei386_AS_XARCH=
4797c478bd9Sstevel@tonic-gateamd64_AS_XARCH=		-xarch=amd64 -P -Ui386 -U__i386
4807c478bd9Sstevel@tonic-gate
4817c478bd9Sstevel@tonic-gate#
4827c478bd9Sstevel@tonic-gate# These flags define what we need to be 'standalone' i.e. -not- part
4837c478bd9Sstevel@tonic-gate# of the rather more cosy userland environment.  This basically means
4847c478bd9Sstevel@tonic-gate# the kernel.
4857c478bd9Sstevel@tonic-gate#
4867c478bd9Sstevel@tonic-gate# XX64	future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
4877c478bd9Sstevel@tonic-gate#
48802e56f3fSwesolowssparc_STAND_FLAGS=	-_gcc=-ffreestanding
48902e56f3fSwesolowssparcv9_STAND_FLAGS=	-_gcc=-ffreestanding
4908528fe16SRichard Lowe# Disabling MMX also disables 3DNow, disabling SSE also disables all later
4918528fe16SRichard Lowe# additions to SSE (SSE2, AVX ,etc.)
4928528fe16SRichard LoweNO_SIMD=		-_gcc=-mno-mmx -_gcc=-mno-sse
4938528fe16SRichard Lowei386_STAND_FLAGS=	-_gcc=-ffreestanding $(NO_SIMD)
4948528fe16SRichard Loweamd64_STAND_FLAGS=	-xmodel=kernel $(NO_SIMD)
4957c478bd9Sstevel@tonic-gate
4967c478bd9Sstevel@tonic-gateSAVEARGS=		-Wu,-save_args
4977c478bd9Sstevel@tonic-gateamd64_STAND_FLAGS	+= $(SAVEARGS)
4987c478bd9Sstevel@tonic-gate
4997c478bd9Sstevel@tonic-gateSTAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
5007c478bd9Sstevel@tonic-gateSTAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
5017c478bd9Sstevel@tonic-gate
5027c478bd9Sstevel@tonic-gate#
5037c478bd9Sstevel@tonic-gate# disable the incremental linker
5047c478bd9Sstevel@tonic-gateILDOFF=			-xildoff
5057c478bd9Sstevel@tonic-gate#
50622337b4bSrieXFFLAG=			-xF=%all
5077c478bd9Sstevel@tonic-gateXESS=			-xs
508d69cdb36SRichard LoweXSTRCONST=		-xstrconst
5097c478bd9Sstevel@tonic-gate
5107c478bd9Sstevel@tonic-gate#
5117c478bd9Sstevel@tonic-gate# turn warnings into errors (C)
5127c478bd9Sstevel@tonic-gateCERRWARN = -errtags=yes -errwarn=%all
5137c478bd9Sstevel@tonic-gateCERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
5147c478bd9Sstevel@tonic-gateCERRWARN += -erroff=E_STATEMENT_NOT_REACHED
5157014882cSRichard Lowe
5167014882cSRichard LoweCERRWARN += -_gcc=-Wno-missing-braces
5177014882cSRichard LoweCERRWARN += -_gcc=-Wno-sign-compare
5187014882cSRichard LoweCERRWARN += -_gcc=-Wno-unknown-pragmas
5197014882cSRichard LoweCERRWARN += -_gcc=-Wno-unused-parameter
5207014882cSRichard LoweCERRWARN += -_gcc=-Wno-missing-field-initializers
5217014882cSRichard Lowe
5227014882cSRichard Lowe# Unfortunately, this option can misfire very easily and unfixably.
5237014882cSRichard LoweCERRWARN +=	-_gcc=-Wno-array-bounds
5247014882cSRichard Lowe
525d3b5f563SJohn Levon# gcc4 lacks -Wno-maybe-uninitialized
526d3b5f563SJohn LevonCNOWARN_UNINIT = -_gcc4=-Wno-uninitialized \
527d3b5f563SJohn Levon    -_gcc7=-Wno-maybe-uninitialized \
5282f57b5e0SToomas Soome    -_gcc8=-Wno-maybe-uninitialized \
5292f57b5e0SToomas Soome    -_gcc9=-Wno-maybe-uninitialized
5306a3e8e86SRichard Lowe
5311f5207b7SJohn LevonCERRWARN += -_smatch=-p=illumos_user
5321f5207b7SJohn Levoninclude $(SRC)/Makefile.smatch
5331f5207b7SJohn Levon
5347c478bd9Sstevel@tonic-gate#
5357c478bd9Sstevel@tonic-gate# turn warnings into errors (C++)
5368e0c8248SAndrew StormontCCERRWARN = -errtags=yes -errwarn=%all
5378e0c8248SAndrew StormontCCERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
5388e0c8248SAndrew StormontCCERRWARN += -erroff=E_STATEMENT_NOT_REACHED
5398e0c8248SAndrew Stormont
5408e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-missing-braces
5418e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-sign-compare
5428e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-unknown-pragmas
5438e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-unused-parameter
5448e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-missing-field-initializers
5457c478bd9Sstevel@tonic-gate
546bd0ce624SYuri Pankov# C standard.  Keep Studio flags until we get rid of lint.
547bd0ce624SYuri PankovCSTD_GNU89=	-xc99=%none
548bd0ce624SYuri PankovCSTD_GNU99=	-xc99=%all
549bd0ce624SYuri PankovCSTD=		$(CSTD_GNU89)
550bd0ce624SYuri PankovC99LMODE=	$(CSTD:-xc99%=-Xc99%)
5517c478bd9Sstevel@tonic-gate
5527c478bd9Sstevel@tonic-gate# In most places, assignments to these macros should be appended with +=
553b819cea2SGordon Ross# (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
554face03d9Spetedesparc_CFLAGS=	$(sparc_XARCH) $(CCSTATICSYM)
555ac204d0dSpetedesparcv9_CFLAGS=	$(sparcv9_XARCH) -dalign $(CCVERBOSE) $(V9ABIWARN) $(CCREGSYM) \
556ac204d0dSpetede		$(CCSTATICSYM)
5577c478bd9Sstevel@tonic-gatei386_CFLAGS=	$(i386_XARCH)
5587c478bd9Sstevel@tonic-gateamd64_CFLAGS=	$(amd64_XARCH)
5597c478bd9Sstevel@tonic-gate
5607c478bd9Sstevel@tonic-gatesparc_ASFLAGS=	$(sparc_AS_XARCH)
5617c478bd9Sstevel@tonic-gatesparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
5627c478bd9Sstevel@tonic-gatei386_ASFLAGS=	$(i386_AS_XARCH)
5637c478bd9Sstevel@tonic-gateamd64_ASFLAGS=	$(amd64_AS_XARCH)
5647c478bd9Sstevel@tonic-gate
5657c478bd9Sstevel@tonic-gate#
5667c478bd9Sstevel@tonic-gatesparc_COPTFLAG=		-xO3
5677c478bd9Sstevel@tonic-gatesparcv9_COPTFLAG=	-xO3
5687c478bd9Sstevel@tonic-gatei386_COPTFLAG=		-O
569662492f5Ssherrymamd64_COPTFLAG=		-xO3
5707c478bd9Sstevel@tonic-gate
5717c478bd9Sstevel@tonic-gateCOPTFLAG= $($(MACH)_COPTFLAG)
5727c478bd9Sstevel@tonic-gateCOPTFLAG64= $($(MACH64)_COPTFLAG)
5737c478bd9Sstevel@tonic-gate
5747c478bd9Sstevel@tonic-gate# When -g is used, the compiler globalizes static objects
5757c478bd9Sstevel@tonic-gate# (gives them a unique prefix). Disable that.
5767c478bd9Sstevel@tonic-gateCNOGLOBAL= -W0,-noglobal
5777c478bd9Sstevel@tonic-gate
57896ccc8cbSesaxe# Direct the Sun Studio compiler to use a static globalization prefix based on the
57996ccc8cbSesaxe# name of the module rather than something unique. Otherwise, objects
58096ccc8cbSesaxe# will not build deterministically, as subsequent compilations of identical
58196ccc8cbSesaxe# source will yeild objects that always look different.
58296ccc8cbSesaxe#
58396ccc8cbSesaxe# In the same spirit, this will also remove the date from the N_OPT stab.
58496ccc8cbSesaxeCGLOBALSTATIC= -W0,-xglobalstatic
58596ccc8cbSesaxe
58602e56f3fSwesolows# Sometimes we want all symbols and types in debugging information even
58702e56f3fSwesolows# if they aren't used.
58802e56f3fSwesolowsCALLSYMS=	-W0,-xdbggen=no%usedonly
58902e56f3fSwesolows
590ac204d0dSpetede#
591299e09deSRichard Lowe# We force the compilers to generate the debugging information best understood
592299e09deSRichard Lowe# by the CTF tools.  With Sun Studio this is stabs due to bugs in the Studio
593299e09deSRichard Lowe# compilers.  With GCC this is DWARF v2.
594ac204d0dSpetede#
595299e09deSRichard LoweDEBUGFORMAT=	-_cc=-xdebugformat=stabs -_gcc=-gdwarf-2
596ac204d0dSpetede
5977c478bd9Sstevel@tonic-gate#
598299e09deSRichard Lowe# Ask the compiler to include debugging information
5997c478bd9Sstevel@tonic-gate#
600299e09deSRichard LoweCCGDEBUG= -g $(DEBUGFORMAT)
601299e09deSRichard Lowe
602299e09deSRichard Lowe#
603299e09deSRichard Lowe# Flags used to build in debug mode for ctf generation.
604299e09deSRichard Lowe#
605299e09deSRichard LoweCTF_FLAGS_sparc	= $(CCGDEBUG) -Wc,-Qiselect-T1 $(CSTD) $(CNOGLOBAL)
606299e09deSRichard LoweCTF_FLAGS_i386	= $(CCGDEBUG) $(CSTD) $(CNOGLOBAL)
6072d4be7aaSRichard Lowe
6082d4be7aaSRichard LoweCTF_FLAGS_sparcv9	= $(CTF_FLAGS_sparc)
6092d4be7aaSRichard LoweCTF_FLAGS_amd64		= $(CTF_FLAGS_i386)
6102d4be7aaSRichard Lowe
6112d4be7aaSRichard Lowe# Sun Studio produces broken userland code when saving arguments.
6122d4be7aaSRichard Lowe$(__GNUC)CTF_FLAGS_amd64 += $(SAVEARGS)
6132d4be7aaSRichard Lowe
614299e09deSRichard LoweCTF_FLAGS_32	= $(CTF_FLAGS_$(MACH))
615299e09deSRichard LoweCTF_FLAGS_64	= $(CTF_FLAGS_$(MACH64))
6162d4be7aaSRichard LoweCTF_FLAGS	= $(CTF_FLAGS_32)
6177c478bd9Sstevel@tonic-gate
6187c478bd9Sstevel@tonic-gate#
6197c478bd9Sstevel@tonic-gate# Flags used with genoffsets
6207c478bd9Sstevel@tonic-gate#
621299e09deSRichard LoweGENOFFSETS_FLAGS = $(CALLSYMS)
6227c478bd9Sstevel@tonic-gate
6237c478bd9Sstevel@tonic-gateOFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
624299e09deSRichard Lowe	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
625299e09deSRichard Lowe	$(CFLAGS) $(CPPFLAGS)
6267c478bd9Sstevel@tonic-gate
6277c478bd9Sstevel@tonic-gateOFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
628299e09deSRichard Lowe	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
629299e09deSRichard Lowe	$(CFLAGS64) $(CPPFLAGS)
6307c478bd9Sstevel@tonic-gate
6317c478bd9Sstevel@tonic-gate#
6327c478bd9Sstevel@tonic-gate# tradeoff time for space (smaller is better)
6337c478bd9Sstevel@tonic-gate#
634ac204d0dSpetedesparc_SPACEFLAG		= -xspace -W0,-Lt
635ac204d0dSpetedesparcv9_SPACEFLAG	= -xspace -W0,-Lt
6367c478bd9Sstevel@tonic-gatei386_SPACEFLAG		= -xspace
6377c478bd9Sstevel@tonic-gateamd64_SPACEFLAG		=
6387c478bd9Sstevel@tonic-gate
6397c478bd9Sstevel@tonic-gateSPACEFLAG		= $($(MACH)_SPACEFLAG)
6407c478bd9Sstevel@tonic-gateSPACEFLAG64		= $($(MACH64)_SPACEFLAG)
6417c478bd9Sstevel@tonic-gate
642ac204d0dSpetede#
643ac204d0dSpetede# The Sun Studio 11 compiler has changed the behaviour of integer
644ac204d0dSpetede# wrap arounds and so a flag is needed to use the legacy behaviour
645ac204d0dSpetede# (without this flag panics/hangs could be exposed within the source).
646ac204d0dSpetede#
647ac204d0dSpetedesparc_IROPTFLAG		= -W2,-xwrap_int
648ac204d0dSpetedesparcv9_IROPTFLAG	= -W2,-xwrap_int
649ac204d0dSpetedei386_IROPTFLAG		=
650ac204d0dSpetedeamd64_IROPTFLAG		=
651ac204d0dSpetede
652ac204d0dSpetedeIROPTFLAG		= $($(MACH)_IROPTFLAG)
653ac204d0dSpetedeIROPTFLAG64		= $($(MACH64)_IROPTFLAG)
654ac204d0dSpetede
6557c478bd9Sstevel@tonic-gatesparc_XREGSFLAG		= -xregs=no%appl
6567c478bd9Sstevel@tonic-gatesparcv9_XREGSFLAG	= -xregs=no%appl
6577c478bd9Sstevel@tonic-gatei386_XREGSFLAG		=
6587c478bd9Sstevel@tonic-gateamd64_XREGSFLAG		=
6597c478bd9Sstevel@tonic-gate
6607c478bd9Sstevel@tonic-gateXREGSFLAG		= $($(MACH)_XREGSFLAG)
6617c478bd9Sstevel@tonic-gateXREGSFLAG64		= $($(MACH64)_XREGSFLAG)
6627c478bd9Sstevel@tonic-gate
663d69cdb36SRichard Lowe# dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
664d69cdb36SRichard Lowe# avoids stripping it.
665d69cdb36SRichard LoweSOURCEDEBUG	= $(POUND_SIGN)
666d69cdb36SRichard LoweSRCDBGBLD	= $(SOURCEDEBUG:yes=)
667d69cdb36SRichard Lowe
668d69cdb36SRichard Lowe#
669d69cdb36SRichard Lowe# These variables are intended ONLY for use by developers to safely pass extra
670d69cdb36SRichard Lowe# flags to the compilers without unintentionally overriding Makefile-set
671d69cdb36SRichard Lowe# flags.  They should NEVER be set to any value in a Makefile.
672d69cdb36SRichard Lowe#
673d69cdb36SRichard Lowe# They come last in the associated FLAGS variable such that they can
674d69cdb36SRichard Lowe# explicitly override things if necessary, there are gaps in this, but it's
675d69cdb36SRichard Lowe# the best we can manage.
676d69cdb36SRichard Lowe#
677d69cdb36SRichard LoweCUSERFLAGS		=
678d69cdb36SRichard LoweCUSERFLAGS64		= $(CUSERFLAGS)
679d69cdb36SRichard LoweCCUSERFLAGS		=
680d69cdb36SRichard LoweCCUSERFLAGS64		= $(CCUSERFLAGS)
681d69cdb36SRichard Lowe
682d69cdb36SRichard LoweCSOURCEDEBUGFLAGS	=
683d69cdb36SRichard LoweCCSOURCEDEBUGFLAGS	=
684299e09deSRichard Lowe$(SRCDBGBLD)CSOURCEDEBUGFLAGS	= $(CCGDEBUG) -xs
685299e09deSRichard Lowe$(SRCDBGBLD)CCSOURCEDEBUGFLAGS	= $(CCGDEBUG) -xs
686d69cdb36SRichard Lowe
6877c478bd9Sstevel@tonic-gateCFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
688bd0ce624SYuri Pankov		$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG) \
689b6c711ccSRichard Lowe		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
69092c1a611SBryan Cantrill		$(CCNOAGGRESSIVELOOPS) \
691b6c711ccSRichard Lowe		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
6927c478bd9Sstevel@tonic-gateCFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
693bd0ce624SYuri Pankov		$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG64) \
694b6c711ccSRichard Lowe		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
69592c1a611SBryan Cantrill		$(CCNOAGGRESSIVELOOPS) \
696b6c711ccSRichard Lowe		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
697ac204d0dSpetede#
698ac204d0dSpetede# Flags that are used to build parts of the code that are subsequently
699ac204d0dSpetede# run on the build machine (also known as the NATIVE_BUILD).
700ac204d0dSpetede#
7017c478bd9Sstevel@tonic-gateNATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
702bd0ce624SYuri Pankov		$(ILDOFF) $(CERRWARN) $(CSTD) $($(NATIVE_MACH)_CCUNBOUND) \
703d69cdb36SRichard Lowe		$(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE) \
704b6c711ccSRichard Lowe		$(CCNOREORDER) $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
7057c478bd9Sstevel@tonic-gate
706a99cb961SToomas SoomeNATIVE_CCFLAGS=	$(CCOPTFLAG) $($(NATIVE_MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
707a99cb961SToomas Soome		$(CCUSERFLAGS)
708a99cb961SToomas Soome
7097c478bd9Sstevel@tonic-gateDTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
7107c478bd9Sstevel@tonic-gateDTS_ERRNO=-D_TS_ERRNO
711b819cea2SGordon RossCPPFLAGS.first=	# Please keep empty.  Only lower makefiles should set this.
7127c478bd9Sstevel@tonic-gateCPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
713494f7e12SKeith M Wesolowski	$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
714494f7e12SKeith M Wesolowski	$(ADJUNCT_PROTO:%=-I%/usr/include)
715494f7e12SKeith M WesolowskiCPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
716494f7e12SKeith M Wesolowski		$(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
717b819cea2SGordon RossCPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
718b819cea2SGordon RossAS_CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
71951396a8eSPeter TribbleJAVAFLAGS=	-source 7 -target 7 -Xlint:deprecation,-options
72051396a8eSPeter Tribble$(BLD_JAVA_11)JAVAFLAGS=	-source 7 -target 7 -Xlint:-options
7217c478bd9Sstevel@tonic-gate
7227c478bd9Sstevel@tonic-gate#
7237c478bd9Sstevel@tonic-gate# For source message catalogue
7247c478bd9Sstevel@tonic-gate#
7257c478bd9Sstevel@tonic-gate.SUFFIXES: $(SUFFIXES) .i .po
7267c478bd9Sstevel@tonic-gateMSGROOT= $(ROOT)/catalog
7277c478bd9Sstevel@tonic-gateMSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
7287c478bd9Sstevel@tonic-gateMSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
729d69cdb36SRichard LoweDCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
7307c478bd9Sstevel@tonic-gateDCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
7317c478bd9Sstevel@tonic-gate
7327c478bd9Sstevel@tonic-gateCLOBBERFILES += $(POFILE) $(POFILES)
7337c478bd9Sstevel@tonic-gateCOMPILE.cpp= $(CC) -E -C $(CFLAGS) $(CPPFLAGS)
7347c478bd9Sstevel@tonic-gateXGETTEXT= /usr/bin/xgettext
7357c478bd9Sstevel@tonic-gateXGETFLAGS= -c TRANSLATION_NOTE
73614843421SMatthew AhrensGNUXGETTEXT= /usr/gnu/bin/xgettext
73714843421SMatthew AhrensGNUXGETFLAGS= --add-comments=TRANSLATION_NOTE --keyword=_ \
73814843421SMatthew Ahrens	--strict --no-location --omit-header
7397c478bd9Sstevel@tonic-gateBUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
7407c478bd9Sstevel@tonic-gate	$(RM)	$@ ;\
741a778b211Scarlsonj	$(SED) "/^domain/d" < $(<F).po > $@ ;\
7427c478bd9Sstevel@tonic-gate	$(RM) $(<F).po $<.i
743a778b211Scarlsonj
7447c478bd9Sstevel@tonic-gate#
7457c478bd9Sstevel@tonic-gate# This is overwritten by local Makefile when PROG is a list.
7467c478bd9Sstevel@tonic-gate#
7477c478bd9Sstevel@tonic-gatePOFILE= $(PROG).po
7487c478bd9Sstevel@tonic-gate
749a99cb961SToomas Soomesparc_CCFLAGS=		$(sparc_XARCH) -cg92 -compat=4 \
7507c478bd9Sstevel@tonic-gate			-Qoption ccfe -messages=no%anachronism \
7517c478bd9Sstevel@tonic-gate			$(CCERRWARN)
7527c478bd9Sstevel@tonic-gatesparcv9_CCFLAGS=	$(sparcv9_XARCH) -dalign -compat=5 \
7537c478bd9Sstevel@tonic-gate			-Qoption ccfe -messages=no%anachronism \
7547c478bd9Sstevel@tonic-gate			-Qoption ccfe -features=no%conststrings \
7557c478bd9Sstevel@tonic-gate			$(CCCREGSYM) \
7567c478bd9Sstevel@tonic-gate			$(CCERRWARN)
757a99cb961SToomas Soomei386_CCFLAGS=		$(i386_XARCH) -compat=4 \
7587c478bd9Sstevel@tonic-gate			-Qoption ccfe -messages=no%anachronism \
7597c478bd9Sstevel@tonic-gate			-Qoption ccfe -features=no%conststrings \
7607c478bd9Sstevel@tonic-gate			$(CCERRWARN)
7617c478bd9Sstevel@tonic-gateamd64_CCFLAGS=		$(amd64_XARCH) -compat=5 \
7627c478bd9Sstevel@tonic-gate			-Qoption ccfe -messages=no%anachronism \
7637c478bd9Sstevel@tonic-gate			-Qoption ccfe -features=no%conststrings \
7647c478bd9Sstevel@tonic-gate			$(CCERRWARN)
7657c478bd9Sstevel@tonic-gate
7667c478bd9Sstevel@tonic-gatesparc_CCOPTFLAG=	-O
7677c478bd9Sstevel@tonic-gatesparcv9_CCOPTFLAG=	-O
7687c478bd9Sstevel@tonic-gatei386_CCOPTFLAG=		-O
7697c478bd9Sstevel@tonic-gateamd64_CCOPTFLAG=	-O
7707c478bd9Sstevel@tonic-gate
7717c478bd9Sstevel@tonic-gateCCOPTFLAG=	$($(MACH)_CCOPTFLAG)
7727c478bd9Sstevel@tonic-gateCCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
773d69cdb36SRichard LoweCCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
774