xref: /illumos-gate/usr/src/Makefile.master (revision fc910014)
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>
3045ede40bSAndy Fiddaman# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
3103c3ec9aSDan McDonald# Copyright 2021 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# The declaration POUND_SIGN is always '#'. This is needed to get around the
727c478bd9Sstevel@tonic-gate# make feature that '#' is always a comment delimiter, even when escaped or
7348bc00d6Sjmcp# quoted. We use this macro expansion method to get POUND_SIGN rather than
7448bc00d6Sjmcp# always breaking out a shell because the general case can cause a noticable
7548bc00d6Sjmcp# slowdown in build times when so many Makefiles include Makefile.master.
767c478bd9Sstevel@tonic-gate#
7748bc00d6Sjmcp# While the majority of users are expected to override the setting below
7848bc00d6Sjmcp# with an env file (via nightly or bldenv), if you aren't building that way
7948bc00d6Sjmcp# (ie, you're using "ws" or some other bootstrapping method) then you need
8048bc00d6Sjmcp# this definition in order to avoid the subshell invocation mentioned above.
8148bc00d6Sjmcp#
8248bc00d6Sjmcp
8348bc00d6SjmcpPRE_POUND=				pre\#
8448bc00d6SjmcpPOUND_SIGN=				$(PRE_POUND:pre\%=%)
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gateNOT_RELEASE_BUILD=
877c478bd9Sstevel@tonic-gateRELEASE_BUILD=				$(POUND_SIGN)
887c478bd9Sstevel@tonic-gate$(RELEASE_BUILD)NOT_RELEASE_BUILD=	$(POUND_SIGN)
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gate# SPARC_BLD is '#' for an Intel build.
917c478bd9Sstevel@tonic-gate# INTEL_BLD is '#' for a Sparc build.
927c478bd9Sstevel@tonic-gateSPARC_BLD_1=    $(MACH:i386=$(POUND_SIGN))
937c478bd9Sstevel@tonic-gateSPARC_BLD=      $(SPARC_BLD_1:sparc=)
947c478bd9Sstevel@tonic-gateINTEL_BLD_1=    $(MACH:sparc=$(POUND_SIGN))
957c478bd9Sstevel@tonic-gateINTEL_BLD=      $(INTEL_BLD_1:i386=)
967c478bd9Sstevel@tonic-gate
9714c3be39SGordon Ross# Allow build-time "configuration" to enable or disable some things.
9814c3be39SGordon Ross# The default is POUND_SIGN, meaning "not enabled". If the environment
9914c3be39SGordon Ross# passes in an override like ENABLE_SMB_PRINTING= (empty) that will
10014c3be39SGordon Ross# uncomment things in the lower Makefiles to enable the feature.
10114c3be39SGordon RossENABLE_SMB_PRINTING=	$(POUND_SIGN)
10214c3be39SGordon Ross
1037c478bd9Sstevel@tonic-gate# BUILD_TOOLS is the root of all tools including compilers.
1047c478bd9Sstevel@tonic-gate# ONBLD_TOOLS is the root of all the tools that are part of SUNWonbld.
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gateBUILD_TOOLS=		/ws/onnv-tools
1077c478bd9Sstevel@tonic-gateONBLD_TOOLS=		$(BUILD_TOOLS)/onbld
1087c478bd9Sstevel@tonic-gate
109e53cbaa9SRichard PALO# define runtime JAVA_HOME, primarily for cmd/pools/poold
110e53cbaa9SRichard PALOJAVA_HOME=	/usr/java
111e53cbaa9SRichard PALO# define buildtime JAVA_ROOT
1127c478bd9Sstevel@tonic-gateJAVA_ROOT=	/usr/java
11351396a8eSPeter Tribble# Build uses java8 by default.  Pass the variable below set to empty
11467048e0fSYuri Pankov# string in the environment to override.
11551396a8eSPeter TribbleBLD_JAVA_11=	$(POUND_SIGN)
1167c478bd9Sstevel@tonic-gate
11769cb22eaSAndy FiddamanGNUC_ROOT=	/usr/gcc/10
1187ed54634SRobert MustacchiGCCLIBDIR=	$(GNUC_ROOT)/lib
1197ed54634SRobert MustacchiGCCLIBDIR64=	$(GNUC_ROOT)/lib/$(MACH64)
1206a3e8e86SRichard Lowe
12111d7e819SRobert MustacchiDOCBOOK_XSL_ROOT=	/usr/share/sgml/docbook/xsl-stylesheets
12211d7e819SRobert Mustacchi
1232aeafac3SToomas SoomeRPCGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/rpcgen
124ae115bc7SmrjELFEXTRACT=	$(ONBLD_TOOLS)/bin/$(MACH)/elfextract
125ae115bc7SmrjMBH_PATCH=	$(ONBLD_TOOLS)/bin/$(MACH)/mbh_patch
1260cc5983cSToomas SoomeBTXLD=		$(ONBLD_TOOLS)/bin/$(MACH)/btxld
1274b529e40SToomas SoomeVTFONTCVT=	$(ONBLD_TOOLS)/bin/$(MACH)/vtfontcvt
128c0855578SRichard Lowe# echo(1) and true(1) are specified without absolute paths, so that the shell
129c0855578SRichard Lowe# spawned by make(1) may use the built-in versions.  This is minimally
130c0855578SRichard Lowe# problematic, as the shell spawned by make(1) is known and under control, the
131c0855578SRichard Lowe# only risk being if the shell falls back to $PATH.
132c0855578SRichard Lowe#
133c0855578SRichard Lowe# We specifically want an echo(1) that does interpolation of escape sequences,
134c0855578SRichard Lowe# which ksh93, /bin/sh, and bash will all provide.
1357c478bd9Sstevel@tonic-gateECHO=		echo
1367c478bd9Sstevel@tonic-gateTRUE=		true
137c0855578SRichard LoweINS=		$(ONBLD_TOOLS)/bin/$(MACH)/install
13802b17e23SRichard LoweED=		/usr/bin/ed
1397c478bd9Sstevel@tonic-gateSYMLINK=	/usr/bin/ln -s
1407c478bd9Sstevel@tonic-gateLN=		/usr/bin/ln
141c0855578SRichard LoweMKDIR=		/usr/bin/mkdir
1427c478bd9Sstevel@tonic-gateCHMOD=		/usr/bin/chmod
1437c478bd9Sstevel@tonic-gateMV=		/usr/bin/mv -f
1447c478bd9Sstevel@tonic-gateRM=		/usr/bin/rm -f
145f4b3ec61SdhCUT=		/usr/bin/cut
146d867f195SRichard LoweNM=		/usr/bin/nm
147f4b3ec61SdhDIFF=		/usr/bin/diff
1487c478bd9Sstevel@tonic-gateGREP=		/usr/bin/grep
1491912d2c4SwesolowsEGREP=		/usr/bin/egrep
1504c06356bSdhELFWRAP=	/usr/bin/elfwrap
15132bd7e59SmjnelsonKSH93=		/usr/bin/ksh93
1527c478bd9Sstevel@tonic-gateSED=		/usr/bin/sed
1537b07063dSIgor KozhukhovAWK=		/usr/bin/nawk
1547c478bd9Sstevel@tonic-gateCP=		/usr/bin/cp -f
155d867f195SRichard LoweMCS=		/usr/bin/mcs
1567c478bd9Sstevel@tonic-gateCAT=            /usr/bin/cat
157d867f195SRichard LoweELFDUMP=	/usr/bin/elfdump
158fca42680SGary MillsM4=		/usr/bin/m4
159bc36eafdSMike GerdtsGM4=		/usr/bin/gm4
160d867f195SRichard LoweSTRIP=		/usr/bin/strip
161d867f195SRichard LoweLEX=		/usr/bin/lex
162cdf815bbSRichard PALOFLEX=		/usr/bin/flex
163d867f195SRichard LoweYACC=		/usr/bin/yacc
164bc36eafdSMike GerdtsBISON=		/usr/bin/bison
1657c478bd9Sstevel@tonic-gateCPP=		/usr/lib/cpp
16602b17e23SRichard LoweSH=		/usr/bin/sh
1677ed54634SRobert MustacchiANSI_CPP=	$(GNUC_ROOT)/bin/cpp
1687c478bd9Sstevel@tonic-gateJAVAC=		$(JAVA_ROOT)/bin/javac
1697c478bd9Sstevel@tonic-gateJAVADOC=	$(JAVA_ROOT)/bin/javadoc
1707c478bd9Sstevel@tonic-gateJAR=		$(JAVA_ROOT)/bin/jar
1717c478bd9Sstevel@tonic-gateCTFCONVERT=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfconvert
172bc1f688bSRobert MustacchiCTFDIFF=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfdiff
1737c478bd9Sstevel@tonic-gateCTFMERGE=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfmerge
1747c478bd9Sstevel@tonic-gateCTFSTABS=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
175a0ed5030SJason KingCTFSTRIP=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstrip
176d0e51869SamwNDRGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/ndrgen
1777c478bd9Sstevel@tonic-gateGENOFFSETS=	$(ONBLD_TOOLS)/bin/genoffsets
1787c478bd9Sstevel@tonic-gateXREF=		$(ONBLD_TOOLS)/bin/xref
1797c478bd9Sstevel@tonic-gateFIND=		/usr/bin/find
1807c478bd9Sstevel@tonic-gatePERL=		/usr/bin/perl
18133392354SAlexander PyhalovPERL_VERSION=	5.10.0
18233392354SAlexander PyhalovPERL_PKGVERS=	-510
1830ae9a84fSAndrew StormontPERL_MACH=	i86pc
1840ae9a84fSAndrew Stormont$(SPARC_BLD)PERL_MACH=	sun4
1850ae9a84fSAndrew StormontPERL_VARIANT=
1860ae9a84fSAndrew StormontPERL_ARCH=	$(PERL_MACH)-solaris$(PERL_VARIANT)-64int
1870ae9a84fSAndrew StormontPERL_ARCH64=	$(PERL_MACH)-solaris$(PERL_VARIANT)-64
18836afce5dSRichard LowePYTHON3_VERSION=	3.9
18936afce5dSRichard LowePYTHON3_PKGVERS=	-39
19036afce5dSRichard LowePYTHON3_SUFFIX=
19170143b9fSRichard LowePYTHON3=		/usr/bin/python$(PYTHON3_VERSION)
19270143b9fSRichard Lowe# BUILDPY3b should be overridden in the env file in order to build python
19370143b9fSRichard Lowe# modules with a secondary python to aid migration between versions.
19445ede40bSAndy FiddamanBUILDPY3b=		$(POUND_SIGN)
19536afce5dSRichard LowePYTHON3b_VERSION=	3.5
19636afce5dSRichard LowePYTHON3b_PKGVERS=	-35
19736afce5dSRichard LowePYTHON3b_SUFFIX=	m
19845ede40bSAndy Fiddaman#
19945ede40bSAndy Fiddaman$(BUILDPY3b)PYTHON3b=	/usr/bin/python$(PYTHON3b_VERSION)
20070143b9fSRichard LoweTOOLS_PYTHON=		$(PYTHON3)
2017c478bd9Sstevel@tonic-gateSORT=		/usr/bin/sort
20216d86563SAlexander PyhalovTR=		/usr/bin/tr
2037c478bd9Sstevel@tonic-gateTOUCH=		/usr/bin/touch
2047c478bd9Sstevel@tonic-gateWC=		/usr/bin/wc
2057c478bd9Sstevel@tonic-gateXARGS=		/usr/bin/xargs
2062cc2d1f4SdarrenmELFEDIT=	/usr/bin/elfedit
2070a49f0acSAdam H. LeventhalDTRACE=		/usr/sbin/dtrace -xnolibs
208620753d0SjmcpUNIQ=		/usr/bin/uniq
2092ad72058SGarrett D'AmoreTAR=		/usr/bin/tar
210e119f243SRobert MustacchiASTBINDIR=	/usr/ast/bin
211e119f243SRobert MustacchiMSGCC=		$(ASTBINDIR)/msgcc
212b599bd93SRobert MustacchiMSGFMT=		/usr/bin/msgfmt -s
213503609a9SYuri PankovLCDEF=		$(ONBLD_TOOLS)/bin/$(MACH)/localedef
214503609a9SYuri PankovTIC=		$(ONBLD_TOOLS)/bin/$(MACH)/tic
215503609a9SYuri PankovZIC=		$(ONBLD_TOOLS)/bin/$(MACH)/zic
216300fdee2SAndy FiddamanOPENSSL=	/usr/bin/openssl
2177e3dbbacSRobert MustacchiCPCGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/cpcgen
218b8767451SRichard LoweGENICONVTBL=	$(ONBLD_TOOLS)/bin/$(MACH)/geniconvtbl
2197c478bd9Sstevel@tonic-gate
2203c562093SToomas SoomeDEFAULT_CONSOLE_COLOR=					\
2213c562093SToomas Soome	-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_WHITE	\
2223c562093SToomas Soome	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_BLACK
2233c562093SToomas Soome
2247c478bd9Sstevel@tonic-gateFILEMODE=	644
2257c478bd9Sstevel@tonic-gateDIRMODE=	755
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate# Declare that nothing should be built in parallel.
2287c478bd9Sstevel@tonic-gate# Individual Makefiles can use the .PARALLEL target to declare otherwise.
2297c478bd9Sstevel@tonic-gate.NO_PARALLEL:
2307c478bd9Sstevel@tonic-gate
2317c478bd9Sstevel@tonic-gate# For stylistic checks
2327c478bd9Sstevel@tonic-gate#
2337c478bd9Sstevel@tonic-gate# Note that the X and C checks are not used at this time and may need
2347c478bd9Sstevel@tonic-gate# modification when they are actually used.
2357c478bd9Sstevel@tonic-gate#
236cdf0c1d5SmjnelsonCSTYLE=		$(ONBLD_TOOLS)/bin/cstyle
2377c478bd9Sstevel@tonic-gateCSTYLE_TAIL=
238cdf0c1d5SmjnelsonHDRCHK=		$(ONBLD_TOOLS)/bin/hdrchk
2397c478bd9Sstevel@tonic-gateHDRCHK_TAIL=
240cdf0c1d5SmjnelsonJSTYLE=		$(ONBLD_TOOLS)/bin/jstyle
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gateDOT_H_CHECK=	\
2437c478bd9Sstevel@tonic-gate	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
2447c478bd9Sstevel@tonic-gate	$(HDRCHK) $< $(HDRCHK_TAIL)
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gateDOT_X_CHECK=	\
2477c478bd9Sstevel@tonic-gate	@$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
2487c478bd9Sstevel@tonic-gate	$(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)
2497c478bd9Sstevel@tonic-gate
2507c478bd9Sstevel@tonic-gateDOT_C_CHECK=	\
2517c478bd9Sstevel@tonic-gate	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gateMANIFEST_CHECK=	\
2547c478bd9Sstevel@tonic-gate	@$(ECHO) "checking $<"; \
2557c478bd9Sstevel@tonic-gate	SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
2561f6eb021SLiane Praza	SVCCFG_REPOSITORY=$(SRC)/cmd/svc/seed/global.db \
2571f6eb021SLiane Praza	SVCCFG_CONFIGD_PATH=$(SRC)/cmd/svc/configd/svc.configd-native \
2587c478bd9Sstevel@tonic-gate	$(SRC)/cmd/svc/svccfg/svccfg-native validate $<
2597c478bd9Sstevel@tonic-gate
2607c478bd9Sstevel@tonic-gateINS.file=	$(RM) $@; $(INS) -s -m $(FILEMODE) -f $(@D) $<
2617c478bd9Sstevel@tonic-gateINS.dir=	$(INS) -s -d -m $(DIRMODE) $@
2627c478bd9Sstevel@tonic-gate# installs and renames at once
2637c478bd9Sstevel@tonic-gate#
2647c478bd9Sstevel@tonic-gateINS.rename=	$(INS.file); $(MV) $(@D)/$(<F) $@
2657c478bd9Sstevel@tonic-gate
2667c478bd9Sstevel@tonic-gate# install a link
2677c478bd9Sstevel@tonic-gateINSLINKTARGET=	$<
2687c478bd9Sstevel@tonic-gateINS.link=	$(RM) $@; $(LN) $(INSLINKTARGET) $@
269b83ec4edSjmcpINS.symlink=	$(RM) $@; $(SYMLINK) $(INSLINKTARGET) $@
270b83ec4edSjmcp
271d8154717SAndy Fiddaman# The path to python that will be used for the shebang line when installing
272d8154717SAndy Fiddaman# python scripts to the proto area. This is overridden by makefiles to
273d8154717SAndy Fiddaman# select to the correct version.
27470143b9fSRichard LowePYSHEBANG=	$(PYTHON3)
275d8154717SAndy Fiddaman
276cdf0c1d5Smjnelson#
277cdf0c1d5Smjnelson# Python bakes the mtime of the .py file into the compiled .pyc and
278cdf0c1d5Smjnelson# rebuilds if the baked-in mtime != the mtime of the source file
279cdf0c1d5Smjnelson# (rather than only if it's less than), thus when installing python
280cdf0c1d5Smjnelson# files we must make certain to not adjust the mtime of the source
281cdf0c1d5Smjnelson# (.py) file.
282cdf0c1d5Smjnelson#
283ca13eaa5SAndy FiddamanINS.pyfile=	$(RM) $@; $(SED) \
284ca13eaa5SAndy Fiddaman		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
285ca13eaa5SAndy Fiddaman		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
286ca13eaa5SAndy Fiddaman		< $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@
2877c478bd9Sstevel@tonic-gate
2887c478bd9Sstevel@tonic-gate# MACH must be set in the shell environment per uname -p on the build host
2897c478bd9Sstevel@tonic-gate# More specific architecture variables should be set in lower makefiles.
2907c478bd9Sstevel@tonic-gate#
2917c478bd9Sstevel@tonic-gate# MACH64 is derived from MACH, and BUILD64 is set to `#' for
2927c478bd9Sstevel@tonic-gate# architectures on which we do not build 64-bit versions.
2937c478bd9Sstevel@tonic-gate# (There are no such architectures at the moment.)
2947c478bd9Sstevel@tonic-gate#
2957c478bd9Sstevel@tonic-gate# Set BUILD64=# in the environment to disable 64-bit amd64
2967c478bd9Sstevel@tonic-gate# builds on i386 machines.
2977c478bd9Sstevel@tonic-gate
2987c478bd9Sstevel@tonic-gateMACH64_1=	$(MACH:sparc=sparcv9)
2997c478bd9Sstevel@tonic-gateMACH64=		$(MACH64_1:i386=amd64)
3007c478bd9Sstevel@tonic-gate
3017c478bd9Sstevel@tonic-gateMACH32_1=	$(MACH:sparc=sparcv7)
3027c478bd9Sstevel@tonic-gateMACH32=		$(MACH32_1:i386=i86)
3037c478bd9Sstevel@tonic-gate
3047c478bd9Sstevel@tonic-gatesparc_BUILD64=
3057c478bd9Sstevel@tonic-gatei386_BUILD64=
3067c478bd9Sstevel@tonic-gateBUILD64=	$($(MACH)_BUILD64)
3077c478bd9Sstevel@tonic-gate
3087c478bd9Sstevel@tonic-gate#
3097c478bd9Sstevel@tonic-gate# C compiler verbose mode. This is so we can enable it globally,
3107c478bd9Sstevel@tonic-gate# but turn it off in the lower level makefiles of things we cannot
3117c478bd9Sstevel@tonic-gate# (or aren't going to) fix.
3127c478bd9Sstevel@tonic-gate#
3137c478bd9Sstevel@tonic-gateCCVERBOSE=		-v
3147c478bd9Sstevel@tonic-gate
3156a3e8e86SRichard Lowe#
3166a3e8e86SRichard Lowe# generate v9 code which tolerates callers using the v7 ABI, for the sake of
3176a3e8e86SRichard Lowe# system calls.
3181a5ea532SRichard LoweCC32BITCALLERS=		-_gcc=-massume-32bit-callers
3196a3e8e86SRichard Lowe
3206a3e8e86SRichard Lowe# GCC, especially, is increasingly beginning to auto-inline functions and
3216a3e8e86SRichard Lowe# sadly does so separately not under the general -fno-inline-functions
32270413d7bSJoshua M. Clulow# Additionally, we wish to prevent optimisations which cause GCC to clone
32370413d7bSJoshua M. Clulow# functions -- in particular, these may cause unhelpful symbols to be
32470413d7bSJoshua M. Clulow# emitted instead of function names
3256b544f0eSJohn LevonCCNOAUTOINLINE= \
3266b544f0eSJohn Levon	-_gcc=-fno-inline-small-functions \
32770413d7bSJoshua M. Clulow	-_gcc=-fno-inline-functions-called-once \
3286b544f0eSJohn Levon	-_gcc=-fno-ipa-cp \
3293873d743SRichard Lowe	-_gcc=-fno-ipa-icf \
3303873d743SRichard Lowe	-_gcc=-fno-clone-functions
3317c478bd9Sstevel@tonic-gate
332b6c711ccSRichard Lowe# GCC may put functions in different named sub-sections of .text based on
333b6c711ccSRichard Lowe# their presumed calling frequency.  At least in the kernel, where we actually
334b6c711ccSRichard Lowe# deliver relocatable objects, we don't want this to happen.
335b6c711ccSRichard Lowe#
336b6c711ccSRichard Lowe# Since at present we don't benefit from this even in userland, we disable it globally,
337b6c711ccSRichard Lowe# but the application of this may move into usr/src/uts/ in future.
33849a4bc70SAndy FiddamanCCNOREORDER=	-_gcc=-fno-reorder-functions \
33949a4bc70SAndy Fiddaman		-_gcc=-fno-reorder-blocks-and-partition
340b6c711ccSRichard Lowe
34192c1a611SBryan Cantrill#
34292c1a611SBryan Cantrill# gcc has a rather aggressive optimization on by default that infers loop
34392c1a611SBryan Cantrill# bounds based on undefined behavior (!!).  This can lead to some VERY
34492c1a611SBryan Cantrill# surprising optimizations -- ones that may be technically correct in the
34592c1a611SBryan Cantrill# strictest sense but also result in incorrect program behavior.  We turn
34692c1a611SBryan Cantrill# this optimization off, with extreme prejudice.
34792c1a611SBryan Cantrill#
3483873d743SRichard LoweCCNOAGGRESSIVELOOPS= -_gcc=-fno-aggressive-loop-optimizations
34992c1a611SBryan Cantrill
350fd5e5f43SAndy Fiddaman#
351fd5e5f43SAndy Fiddaman# gcc has a limit on the maximum size of a function which will be inlined
352fd5e5f43SAndy Fiddaman# in the presence of the 'inline' keyword; this limit varies between versions
353fd5e5f43SAndy Fiddaman# of gcc. For consistent output and to ensure that some of the slightly larger
354fd5e5f43SAndy Fiddaman# functions are inlined as intended, we specify the limit explicitly.
355fd5e5f43SAndy Fiddaman#
356fd5e5f43SAndy FiddamanCCINLINESIZE= -_gcc=--param=max-inline-insns-single=450
357fd5e5f43SAndy FiddamanCCWARNINLINE= -_gcc=-Winline
358fd5e5f43SAndy Fiddaman
3595a0af816SRobert Mustacchi#
3605a0af816SRobert Mustacchi# Options to control which version of stack-protector we enable. This
3615a0af816SRobert Mustacchi# gives us a bit of flexibility and is unfortunately necessary as some
3625a0af816SRobert Mustacchi# modules do not function correctly with our defaults (qede).
3635a0af816SRobert Mustacchi#
3645a0af816SRobert Mustacchi#  o STACKPROTECT_              Sets the appropriate version for the compiler
3655a0af816SRobert Mustacchi#  o STACKPROTECT_strong        Sets us to use strong on all of the
3665a0af816SRobert Mustacchi#                               compilers it supports. This is the same
3675a0af816SRobert Mustacchi#                               as the default.
3685a0af816SRobert Mustacchi#
3695a0af816SRobert Mustacchi#  o STACKPROTECT_none          Disables the stack protector.
3705a0af816SRobert Mustacchi#
3715a0af816SRobert Mustacchi#  o STACKPROTECT_all           Enables it for everything.
3725a0af816SRobert Mustacchi#
3735a0af816SRobert Mustacchi#  o STACKPROTECT_basic         Enables the basic stack protector.
3745a0af816SRobert Mustacchi#
3755a0af816SRobert Mustacchi# -fstack-protector-strong is not available in gcc4 which is why we
3765a0af816SRobert Mustacchi# have per-compiler versions below. These are not added to the default
3775a0af816SRobert Mustacchi# global CFLAGS at this time as it's being incrementally enabled
3785a0af816SRobert Mustacchi# throughout the build.
3795a0af816SRobert Mustacchi#
3803873d743SRichard LoweSTACKPROTECT_           = -_gcc=-fstack-protector-strong
3815a0af816SRobert Mustacchi
3825a0af816SRobert MustacchiSTACKPROTECT_strong     = $(STACKPROTECT_)
3835a0af816SRobert MustacchiSTACKPROTECT_none       =
3845a0af816SRobert MustacchiSTACKPROTECT_all        = -_gcc=-fstack-protector-all
3855a0af816SRobert MustacchiSTACKPROTECT_basic      = -_gcc=-fstack-protector
3865a0af816SRobert Mustacchi
3875a0af816SRobert MustacchiSTACKPROTECT_LD_	= -lssp_ns
3885a0af816SRobert MustacchiSTACKPROTECT_LD_none	=
389a39905c1SRobert MustacchiSTACKPROTECT_LD_all	= $(STACKPROTECT_LD_)
390a39905c1SRobert MustacchiSTACKPROTECT_LD_basic	= $(STACKPROTECT_LD_)
3915a0af816SRobert Mustacchi
3925a0af816SRobert MustacchiCCSTACKPROTECT= $(STACKPROTECT_$(STACKPROTECT))
3935a0af816SRobert MustacchiLDSTACKPROTECT= $(STACKPROTECT_LD_$(STACKPROTECT))
3945a0af816SRobert Mustacchi
3957c478bd9Sstevel@tonic-gate#
3967c478bd9Sstevel@tonic-gate# compiler '-xarch' flag. This is here to centralize it and make it
3977c478bd9Sstevel@tonic-gate# overridable for testing.
3980bb07399SNick Toddsparc_XARCH=	-m32
3990bb07399SNick Toddsparcv9_XARCH=	-m64
4009c05409fSRichard Lowei386_XARCH=	-m32
4010bb07399SNick Toddamd64_XARCH=	-m64 -Ui386 -U__i386
4027c478bd9Sstevel@tonic-gate
4037c478bd9Sstevel@tonic-gate#
4047c478bd9Sstevel@tonic-gate# These flags define what we need to be 'standalone' i.e. -not- part
4057c478bd9Sstevel@tonic-gate# of the rather more cosy userland environment.  This basically means
4067c478bd9Sstevel@tonic-gate# the kernel.
4077c478bd9Sstevel@tonic-gate#
4087c478bd9Sstevel@tonic-gate# XX64	future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
4097c478bd9Sstevel@tonic-gate#
41002e56f3fSwesolowssparc_STAND_FLAGS=	-_gcc=-ffreestanding
41102e56f3fSwesolowssparcv9_STAND_FLAGS=	-_gcc=-ffreestanding
4128528fe16SRichard Lowe# Disabling MMX also disables 3DNow, disabling SSE also disables all later
4138528fe16SRichard Lowe# additions to SSE (SSE2, AVX ,etc.)
4148528fe16SRichard LoweNO_SIMD=		-_gcc=-mno-mmx -_gcc=-mno-sse
4158528fe16SRichard Lowei386_STAND_FLAGS=	-_gcc=-ffreestanding $(NO_SIMD)
4168528fe16SRichard Loweamd64_STAND_FLAGS=	-xmodel=kernel $(NO_SIMD)
4177c478bd9Sstevel@tonic-gate
4187c478bd9Sstevel@tonic-gateSAVEARGS=		-Wu,-save_args
4197c478bd9Sstevel@tonic-gateamd64_STAND_FLAGS	+= $(SAVEARGS)
4207c478bd9Sstevel@tonic-gate
4217c478bd9Sstevel@tonic-gateSTAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
4227c478bd9Sstevel@tonic-gateSTAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
4237c478bd9Sstevel@tonic-gate
4247c478bd9Sstevel@tonic-gate#
4257c478bd9Sstevel@tonic-gate# turn warnings into errors (C)
4267c478bd9Sstevel@tonic-gateCERRWARN = -errtags=yes -errwarn=%all
4277014882cSRichard Lowe
4287014882cSRichard LoweCERRWARN += -_gcc=-Wno-missing-braces
4297014882cSRichard LoweCERRWARN += -_gcc=-Wno-sign-compare
4307014882cSRichard LoweCERRWARN += -_gcc=-Wno-unknown-pragmas
4317014882cSRichard LoweCERRWARN += -_gcc=-Wno-unused-parameter
4327014882cSRichard LoweCERRWARN += -_gcc=-Wno-missing-field-initializers
4337014882cSRichard Lowe
4347014882cSRichard Lowe# Unfortunately, this option can misfire very easily and unfixably.
4357014882cSRichard LoweCERRWARN +=	-_gcc=-Wno-array-bounds
4367014882cSRichard Lowe
4373873d743SRichard LoweCNOWARN_UNINIT = -_gcc=-Wno-maybe-uninitialized
4386a3e8e86SRichard Lowe
4391f5207b7SJohn LevonCERRWARN += -_smatch=-p=illumos_user
4401f5207b7SJohn Levoninclude $(SRC)/Makefile.smatch
4411f5207b7SJohn Levon
4427c478bd9Sstevel@tonic-gate#
4437c478bd9Sstevel@tonic-gate# turn warnings into errors (C++)
4448e0c8248SAndrew StormontCCERRWARN = -errtags=yes -errwarn=%all
4458e0c8248SAndrew Stormont
4468e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-missing-braces
4478e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-sign-compare
4488e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-unknown-pragmas
4498e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-unused-parameter
4508e0c8248SAndrew StormontCCERRWARN += -_gcc=-Wno-missing-field-initializers
4517c478bd9Sstevel@tonic-gate
4521e8d79d2SYuri Pankov# C standard
453bd0ce624SYuri PankovCSTD_GNU89=	-xc99=%none
454bd0ce624SYuri PankovCSTD_GNU99=	-xc99=%all
455bd0ce624SYuri PankovCSTD=		$(CSTD_GNU89)
4567c478bd9Sstevel@tonic-gate
4577c478bd9Sstevel@tonic-gate# In most places, assignments to these macros should be appended with +=
458b819cea2SGordon Ross# (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
459d17be682SRichard Lowesparc_CFLAGS=	$(sparc_XARCH)
460d17be682SRichard Lowesparcv9_CFLAGS=	$(sparcv9_XARCH) $(CCVERBOSE)
4617c478bd9Sstevel@tonic-gatei386_CFLAGS=	$(i386_XARCH)
4627c478bd9Sstevel@tonic-gateamd64_CFLAGS=	$(amd64_XARCH)
4637c478bd9Sstevel@tonic-gate
4645d9d9091SRichard Lowe$(MACH)_ASFLAGS=	$($(MACH)_CFLAGS)
4655d9d9091SRichard Lowe$(MACH64)_ASFLAGS=	$($(MACH64)_CFLAGS)
4665d9d9091SRichard Lowe
46769cb22eaSAndy FiddamanASFLAGS=		$($(MACH)_ASFLAGS)
4685d9d9091SRichard LoweASFLAGS64=		$($(MACH64)_ASFLAGS)
4697c478bd9Sstevel@tonic-gate
4707c478bd9Sstevel@tonic-gate#
4717c478bd9Sstevel@tonic-gatesparc_COPTFLAG=		-xO3
4727c478bd9Sstevel@tonic-gatesparcv9_COPTFLAG=	-xO3
4737c478bd9Sstevel@tonic-gatei386_COPTFLAG=		-O
474662492f5Ssherrymamd64_COPTFLAG=		-xO3
4757c478bd9Sstevel@tonic-gate
4767c478bd9Sstevel@tonic-gateCOPTFLAG= $($(MACH)_COPTFLAG)
4777c478bd9Sstevel@tonic-gateCOPTFLAG64= $($(MACH64)_COPTFLAG)
4787c478bd9Sstevel@tonic-gate
47902e56f3fSwesolows# Sometimes we want all symbols and types in debugging information even
48002e56f3fSwesolows# if they aren't used.
4813cac7b0dSAndy FiddamanCALLSYMS=	-_gcc=-fno-eliminate-unused-debug-symbols \
4823cac7b0dSAndy Fiddaman		-_gcc=-fno-eliminate-unused-debug-types
48302e56f3fSwesolows
484ac204d0dSpetede#
485299e09deSRichard Lowe# We force the compilers to generate the debugging information best understood
486299e09deSRichard Lowe# by the CTF tools.  With Sun Studio this is stabs due to bugs in the Studio
487299e09deSRichard Lowe# compilers.  With GCC this is DWARF v2.
488ac204d0dSpetede#
489d17be682SRichard LoweDEBUGFORMAT=	-_gcc=-gdwarf-2 -_gcc10=-gstrict-dwarf -_gcc11=-gstrict-dwarf
490ac204d0dSpetede
4917c478bd9Sstevel@tonic-gate#
492299e09deSRichard Lowe# Ask the compiler to include debugging information
4937c478bd9Sstevel@tonic-gate#
494299e09deSRichard LoweCCGDEBUG= -g $(DEBUGFORMAT)
495299e09deSRichard Lowe
496299e09deSRichard Lowe#
497299e09deSRichard Lowe# Flags used to build in debug mode for ctf generation.
498299e09deSRichard Lowe#
499d17be682SRichard LoweCTF_FLAGS_sparc	= $(CCGDEBUG) $(CSTD)
500d17be682SRichard LoweCTF_FLAGS_i386	= $(CCGDEBUG) $(CSTD)
5012d4be7aaSRichard Lowe
5022d4be7aaSRichard LoweCTF_FLAGS_sparcv9	= $(CTF_FLAGS_sparc)
5038c426718SRichard LoweCTF_FLAGS_amd64		= $(CTF_FLAGS_i386) $(SAVEARGS)
5042d4be7aaSRichard Lowe
505299e09deSRichard LoweCTF_FLAGS_32	= $(CTF_FLAGS_$(MACH))
506299e09deSRichard LoweCTF_FLAGS_64	= $(CTF_FLAGS_$(MACH64))
5072d4be7aaSRichard LoweCTF_FLAGS	= $(CTF_FLAGS_32)
5087c478bd9Sstevel@tonic-gate
5097c478bd9Sstevel@tonic-gate#
5107c478bd9Sstevel@tonic-gate# Flags used with genoffsets
5117c478bd9Sstevel@tonic-gate#
512299e09deSRichard LoweGENOFFSETS_FLAGS = $(CALLSYMS)
5137c478bd9Sstevel@tonic-gate
5147c478bd9Sstevel@tonic-gateOFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
515299e09deSRichard Lowe	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
516299e09deSRichard Lowe	$(CFLAGS) $(CPPFLAGS)
5177c478bd9Sstevel@tonic-gate
5187c478bd9Sstevel@tonic-gateOFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
519299e09deSRichard Lowe	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
520299e09deSRichard Lowe	$(CFLAGS64) $(CPPFLAGS)
5217c478bd9Sstevel@tonic-gate
522d69cdb36SRichard Lowe# dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
523d69cdb36SRichard Lowe# avoids stripping it.
524d69cdb36SRichard LoweSOURCEDEBUG	= $(POUND_SIGN)
525d69cdb36SRichard LoweSRCDBGBLD	= $(SOURCEDEBUG:yes=)
526d69cdb36SRichard Lowe
527d69cdb36SRichard Lowe#
528d69cdb36SRichard Lowe# These variables are intended ONLY for use by developers to safely pass extra
529d69cdb36SRichard Lowe# flags to the compilers without unintentionally overriding Makefile-set
530d69cdb36SRichard Lowe# flags.  They should NEVER be set to any value in a Makefile.
531d69cdb36SRichard Lowe#
532d69cdb36SRichard Lowe# They come last in the associated FLAGS variable such that they can
533d69cdb36SRichard Lowe# explicitly override things if necessary, there are gaps in this, but it's
534d69cdb36SRichard Lowe# the best we can manage.
535d69cdb36SRichard Lowe#
536d69cdb36SRichard LoweCUSERFLAGS		=
537d69cdb36SRichard LoweCUSERFLAGS64		= $(CUSERFLAGS)
538d69cdb36SRichard LoweCCUSERFLAGS		=
539d69cdb36SRichard LoweCCUSERFLAGS64		= $(CCUSERFLAGS)
540d69cdb36SRichard Lowe
541d69cdb36SRichard LoweCSOURCEDEBUGFLAGS	=
542d69cdb36SRichard LoweCCSOURCEDEBUGFLAGS	=
543d17be682SRichard Lowe$(SRCDBGBLD)CSOURCEDEBUGFLAGS	= $(CCGDEBUG)
544d17be682SRichard Lowe$(SRCDBGBLD)CCSOURCEDEBUGFLAGS	= $(CCGDEBUG)
545d69cdb36SRichard Lowe
546d17be682SRichard LoweCFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) \
547d17be682SRichard Lowe		$(CERRWARN) $(CSTD) $(CCNOAUTOINLINE) $(CCNOREORDER) \
548fd5e5f43SAndy Fiddaman		$(CCNOAGGRESSIVELOOPS) $(CCINLINESIZE) \
549b6c711ccSRichard Lowe		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
550d17be682SRichard LoweCFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) \
551d17be682SRichard Lowe		$(CERRWARN) $(CSTD) $(CCNOAUTOINLINE) $(CCNOREORDER) \
552fd5e5f43SAndy Fiddaman		$(CCNOAGGRESSIVELOOPS) $(CCINLINESIZE) \
553b6c711ccSRichard Lowe		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
554ac204d0dSpetede#
555ac204d0dSpetede# Flags that are used to build parts of the code that are subsequently
556ac204d0dSpetede# run on the build machine (also known as the NATIVE_BUILD).
557ac204d0dSpetede#
558d17be682SRichard LoweNATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) \
559d17be682SRichard Lowe		$(CERRWARN) $(CSTD) $(CCNOAUTOINLINE) \
560fd5e5f43SAndy Fiddaman		$(CCNOREORDER) $(CCNOAGGRESSIVELOOPS) $(CCINLINESIZE) \
561fd5e5f43SAndy Fiddaman		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
5627c478bd9Sstevel@tonic-gate
563a99cb961SToomas SoomeNATIVE_CCFLAGS=	$(CCOPTFLAG) $($(NATIVE_MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
564a99cb961SToomas Soome		$(CCUSERFLAGS)
565a99cb961SToomas Soome
566d17be682SRichard LoweNATIVE_CFLAGS64=	$(COPTFLAG64) $($(NATIVE_MACH64)_CFLAGS) \
567d17be682SRichard Lowe		$(CERRWARN) $(CSTD) $(CCNOAUTOINLINE) \
568fd5e5f43SAndy Fiddaman		$(CCNOREORDER) $(CCNOAGGRESSIVELOOPS) $(CCINLINESIZE) \
569fd5e5f43SAndy Fiddaman		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
57003c3ec9aSDan McDonald
57103c3ec9aSDan McDonaldNATIVE_CCFLAGS64=	$(CCOPTFLAG64) $($(NATIVE_MACH64)_CCFLAGS) \
57203c3ec9aSDan McDonald		$(CCSOURCEDEBUGFLAGS) $(CCUSERFLAGS64)
57303c3ec9aSDan McDonald
5747c478bd9Sstevel@tonic-gateDTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
5757c478bd9Sstevel@tonic-gateDTS_ERRNO=-D_TS_ERRNO
576b819cea2SGordon RossCPPFLAGS.first=	# Please keep empty.  Only lower makefiles should set this.
5777c478bd9Sstevel@tonic-gateCPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
578494f7e12SKeith M Wesolowski	$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
579494f7e12SKeith M Wesolowski	$(ADJUNCT_PROTO:%=-I%/usr/include)
580494f7e12SKeith M WesolowskiCPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
581494f7e12SKeith M Wesolowski		$(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
582b819cea2SGordon RossCPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
583b819cea2SGordon RossAS_CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
58451396a8eSPeter TribbleJAVAFLAGS=	-source 7 -target 7 -Xlint:deprecation,-options
58551396a8eSPeter Tribble$(BLD_JAVA_11)JAVAFLAGS=	-source 7 -target 7 -Xlint:-options
5867c478bd9Sstevel@tonic-gate
5877c478bd9Sstevel@tonic-gate#
5887c478bd9Sstevel@tonic-gate# For source message catalogue
5897c478bd9Sstevel@tonic-gate#
5907c478bd9Sstevel@tonic-gate.SUFFIXES: $(SUFFIXES) .i .po
5917c478bd9Sstevel@tonic-gateMSGROOT= $(ROOT)/catalog
5927c478bd9Sstevel@tonic-gateMSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
5937c478bd9Sstevel@tonic-gateMSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
594d69cdb36SRichard LoweDCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
5957c478bd9Sstevel@tonic-gateDCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
5967c478bd9Sstevel@tonic-gate
5977c478bd9Sstevel@tonic-gateCLOBBERFILES += $(POFILE) $(POFILES)
5987c478bd9Sstevel@tonic-gateCOMPILE.cpp= $(CC) -E -C $(CFLAGS) $(CPPFLAGS)
5997c478bd9Sstevel@tonic-gateXGETTEXT= /usr/bin/xgettext
6007c478bd9Sstevel@tonic-gateXGETFLAGS= -c TRANSLATION_NOTE
60114843421SMatthew AhrensGNUXGETTEXT= /usr/gnu/bin/xgettext
60214843421SMatthew AhrensGNUXGETFLAGS= --add-comments=TRANSLATION_NOTE --keyword=_ \
60314843421SMatthew Ahrens	--strict --no-location --omit-header
6047c478bd9Sstevel@tonic-gateBUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
6057c478bd9Sstevel@tonic-gate	$(RM)	$@ ;\
606a778b211Scarlsonj	$(SED) "/^domain/d" < $(<F).po > $@ ;\
6077c478bd9Sstevel@tonic-gate	$(RM) $(<F).po $<.i
608a778b211Scarlsonj
6097c478bd9Sstevel@tonic-gate#
6107c478bd9Sstevel@tonic-gate# This is overwritten by local Makefile when PROG is a list.
6117c478bd9Sstevel@tonic-gate#
6127c478bd9Sstevel@tonic-gatePOFILE= $(PROG).po
6137c478bd9Sstevel@tonic-gate
614d17be682SRichard Lowesparc_CCFLAGS=		$(sparc_XARCH) $(CCERRWARN)
615d17be682SRichard Lowesparcv9_CCFLAGS=	$(sparcv9_XARCH) $(CCERRWARN)
616d17be682SRichard Lowei386_CCFLAGS=		$(i386_XARCH) $(CCERRWARN)
617d17be682SRichard Loweamd64_CCFLAGS=		$(amd64_XARCH) $(CCERRWARN)
6187c478bd9Sstevel@tonic-gate
6197c478bd9Sstevel@tonic-gatesparc_CCOPTFLAG=	-O
6207c478bd9Sstevel@tonic-gatesparcv9_CCOPTFLAG=	-O
6217c478bd9Sstevel@tonic-gatei386_CCOPTFLAG=		-O
6227c478bd9Sstevel@tonic-gateamd64_CCOPTFLAG=	-O
6237c478bd9Sstevel@tonic-gate
6247c478bd9Sstevel@tonic-gateCCOPTFLAG=	$($(MACH)_CCOPTFLAG)
6257c478bd9Sstevel@tonic-gateCCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
626d69cdb36SRichard LoweCCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
627d69cdb36SRichard Lowe		$(CCUSERFLAGS)
628d69cdb36SRichard LoweCCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
629d69cdb36SRichard Lowe		$(CCUSERFLAGS64)
63024da5b34Srie
6314c06356bSdh#
6324c06356bSdh#
6334c06356bSdh#
634d69cdb36SRichard LoweELFWRAP_FLAGS	=
6354c06356bSdhELFWRAP_FLAGS64	=	-64
6364c06356bSdh
63724da5b34Srie#
63824da5b34Srie# Various mapfiles that are used throughout the build, and delivered to
63924da5b34Srie# /usr/lib/ld.
6407c478bd9Sstevel@tonic-gate#
641cd3e9333SAli BahramiMAPFILE.NED_i386 =	$(SRC)/common/mapfiles/common/map.noexdata
64224da5b34SrieMAPFILE.NED_sparc =
64324da5b34SrieMAPFILE.NED =		$(MAPFILE.NED_$(MACH))
644cd3e9333SAli BahramiMAPFILE.PGA =		$(SRC)/common/mapfiles/common/map.pagealign
64524da5b34SrieMAPFILE.NES =		$(SRC)/common/mapfiles/common/map.noexstk
64624da5b34SrieMAPFILE.FLT =		$(SRC)/common/mapfiles/common/map.filter
647df4628cbSrieMAPFILE.LEX =		$(SRC)/common/mapfiles/common/map.lex.yy
64824da5b34Srie
6497c478bd9Sstevel@tonic-gate#
65024da5b34Srie# Generated mapfiles that are compiler specific, and used throughout the
65124da5b34Srie# build.  These mapfiles are not delivered in /usr/lib/ld.
6527c478bd9Sstevel@tonic-gate#
6538c426718SRichard LoweMAPFILE.NGB_sparc =	$(SRC)/common/mapfiles/gen/sparc_gcc_map.noexeglobs
6548c426718SRichard LoweMAPFILE.NGB_sparcv9 =	$(SRC)/common/mapfiles/gen/sparcv9_gcc_map.noexeglobs
6558c426718SRichard LoweMAPFILE.NGB_i386 =	$(SRC)/common/mapfiles/gen/i386_gcc_map.noexeglobs
6568c426718SRichard LoweMAPFILE.NGB_amd64 =	$(SRC)/common/mapfiles/gen/amd64_gcc_map.noexeglobs
65724da5b34SrieMAPFILE.NGB =		$(MAPFILE.NGB_$(MACH))
65824da5b34Srie
65924da5b34Srie#
66024da5b34Srie# A generic interface mapfile name, used by various dynamic objects to define
66124da5b34Srie# the interfaces and interposers the object must export.
66224da5b34Srie#
66324da5b34SrieMAPFILE.INT =		mapfile-intf
66424da5b34Srie
665d69cdb36SRichard Lowe#
666538aa54dSGarrett D'Amore# LDLIBS32 and LDLIBS64 can be set in the environment to override the following
667538aa54dSGarrett D'Amore# assignments.
668538aa54dSGarrett D'Amore#
6697c478bd9Sstevel@tonic-gateLDLIBS32 =	$(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
670494f7e12SKeith M WesolowskiLDLIBS32 +=	$(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
671aa9ef484SJohn LevonLDLIBS.cmd =	$(LDLIBS32)
6727c478bd9Sstevel@tonic-gateLDLIBS.lib =	$(LDLIBS32)
673538aa54dSGarrett D'Amore
674538aa54dSGarrett D'AmoreLDLIBS64 =	$(ENVLDLIBS1:%=%/$(MACH64)) \
675538aa54dSGarrett D'Amore		$(ENVLDLIBS2:%=%/$(MACH64)) \
676538aa54dSGarrett D'Amore		$(ENVLDLIBS3:%=%/$(MACH64))
677538aa54dSGarrett D'AmoreLDLIBS64 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib/$(MACH64) -L%/lib/$(MACH64))
678538aa54dSGarrett D'Amore
6797c478bd9Sstevel@tonic-gate#
6807c478bd9Sstevel@tonic-gate# Define compilation macros.
6817c478bd9Sstevel@tonic-gate#
6827c478bd9Sstevel@tonic-gateCOMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
6837c478bd9Sstevel@tonic-gateCOMPILE64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) -c
6847c478bd9Sstevel@tonic-gateCOMPILE.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) -c
6857c478bd9Sstevel@tonic-gateCOMPILE64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
6865d9d9091SRichard LoweCOMPILE.s=	$(AS) $(ASFLAGS) $(AS_CPPFLAGS) -c
6875d9d9091SRichard LoweCOMPILE64.s=	$(AS) $(ASFLAGS64) $(AS_CPPFLAGS) -c
6887c478bd9Sstevel@tonic-gateCOMPILE.d=	$(DTRACE) -G -32
6897c478bd9Sstevel@tonic-gateCOMPILE64.d=	$(DTRACE) -G -64
6904c06356bSdhCOMPILE.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
6914c06356bSdhCOMPILE64.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
6927c478bd9Sstevel@tonic-gate
6937c478bd9Sstevel@tonic-gateCLASSPATH=	.
6947c478bd9Sstevel@tonic-gateCOMPILE.java=	$(JAVAC) $(JAVAFLAGS) -classpath $(CLASSPATH)
6957c478bd9Sstevel@tonic-gate
6967c478bd9Sstevel@tonic-gate#
6977c478bd9Sstevel@tonic-gate# Link time macros
6987c478bd9Sstevel@tonic-gate#
6998c426718SRichard LoweCCNEEDED	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
7008c426718SRichard LoweCCEXTNEEDED	= $(CCNEEDED)
7018c426718SRichard LoweNATIVECCNEEDED	= -R$(GCCLIBDIR) -L$(GCCLIBDIR) -lstdc++ -lgcc_s
7027c478bd9Sstevel@tonic-gate
7038c426718SRichard LoweCCNEEDED64	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
7048c426718SRichard LoweNATIVECCNEEDED64 = -R$(GCCLIBDIR) -L$(GCCLIBDIR) -lstdc++ -lgcc_s
7058c426718SRichard LoweCCEXTNEEDED	= $(CCNEEDED64)
7060ae9a84fSAndrew Stormont
7075801b0f0SToomas Soome# Libraries we expect to use natively on the build machine
7085801b0f0SToomas SoomeNATIVE_LIBS=
7095801b0f0SToomas Soome
7105801b0f0SToomas SoomeLDCHECKS		= $(ZASSERTDEFLIB) $(ZGUIDANCE) $(ZFATALWARNINGS)
7115801b0f0SToomas SoomeLDCHECKS		+= $(NATIVE_LIBS:%=$(ZASSERTDEFLIB)=%)
7125801b0f0SToomas Soome
7135801b0f0SToomas SoomeLINK.c=			$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
7145801b0f0SToomas SoomeLINK64.c=		$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
715d17be682SRichard LoweNORUNPATH=		-nolib
7165801b0f0SToomas SoomeLINK.cc=		$(CCC) $(CCFLAGS) $(CPPFLAGS) $(NORUNPATH) \
7175801b0f0SToomas Soome			$(LDFLAGS) $(CCNEEDED) $(LDCHECKS)
7185801b0f0SToomas SoomeLINK64.cc=		$(CCC) $(CCFLAGS64) $(CPPFLAGS) $(NORUNPATH) \
7195801b0f0SToomas Soome			$(LDFLAGS) $(CCNEEDED64) $(LDCHECKS)
7207c478bd9Sstevel@tonic-gate
7217c478bd9Sstevel@tonic-gate# For some future builds, NATIVE_MACH and MACH might be different.
7227c478bd9Sstevel@tonic-gate# Therefore, NATIVE_MACH needs to be redefined in the
7237c478bd9Sstevel@tonic-gate# environment as `uname -p` to override this macro.
7247c478bd9Sstevel@tonic-gate#
7257c478bd9Sstevel@tonic-gate# For now at least, we cross-compile amd64 on i386 machines.
7267c478bd9Sstevel@tonic-gateNATIVE_MACH=	$(MACH:amd64=i386)
7270ae9a84fSAndrew StormontNATIVE_MACH64=	$(MACH64)
7287c478bd9Sstevel@tonic-gate
7298c426718SRichard Lowe# Base directory where compilers can be found.  Usually overridden in the
7308c426718SRichard Lowe# environment.
731cdf815bbSRichard PALOGNU_ROOT=		/usr
7327c478bd9Sstevel@tonic-gate
7338c426718SRichard LowePRIMARY_CC=	gcc10,$(GNUC_ROOT)/bin/gcc,gnu
7348c426718SRichard LowePRIMARY_CCC=	gcc10,$(GNUC_ROOT)/bin/g++,gnu
735aa9ef484SJohn Levon
736aa9ef484SJohn LevonCW_CC_COMPILERS=	$(PRIMARY_CC:%=--primary %) $(SHADOW_CCS:%=--shadow %)
737aa9ef484SJohn LevonCW_CCC_COMPILERS=	$(PRIMARY_CCC:%=--primary %) $(SHADOW_CCCS:%=--shadow %)
738aa9ef484SJohn Levon
73969b1fd3fSRichard LoweCW_LINKER=		--linker $(LD)
740aa9ef484SJohn Levon
7417c478bd9Sstevel@tonic-gate# Specify platform compiler versions for languages
7427c478bd9Sstevel@tonic-gate# that we use (currently only c and c++).
7437c478bd9Sstevel@tonic-gate#
744aa9ef484SJohn LevonCW=			$(ONBLD_TOOLS)/bin/$(MACH)/cw
745aa9ef484SJohn Levon
74669b1fd3fSRichard LoweBUILD_CC=		$(CW) $(CW_LINKER) $(CW_CC_COMPILERS) --
74769b1fd3fSRichard LoweBUILD_CCC=		$(CW) -C $(CW_LINKER) $(CW_CCC_COMPILERS) --
748d867f195SRichard LoweBUILD_CPP=		/usr/lib/cpp
7497a15b0ecSRichard LoweBUILD_LD=		$(ONBLD_TOOLS)/bin/$(MACH64)/ld
750aa9ef484SJohn Levon
751aa9ef484SJohn Levon$(MACH)_CC=		$(BUILD_CC)
752aa9ef484SJohn Levon$(MACH)_CCC=		$(BUILD_CCC)
753aa9ef484SJohn Levon$(MACH)_CPP=		$(BUILD_CPP)
754aa9ef484SJohn Levon$(MACH)_LD=		$(BUILD_LD)
7555d9d9091SRichard Lowe$(MACH)_AS=		$(BUILD_CC)
756aa9ef484SJohn Levon$(MACH64)_CC=		$(BUILD_CC)
757aa9ef484SJohn Levon$(MACH64)_CCC=		$(BUILD_CCC)
758aa9ef484SJohn Levon$(MACH64)_CPP=		$(BUILD_CPP)
759aa9ef484SJohn Levon$(MACH64)_LD=		$(BUILD_LD)
7605d9d9091SRichard Lowe$(MACH64)_AS=		$(BUILD_CC)
7617c478bd9Sstevel@tonic-gate
7627c478bd9Sstevel@tonic-gateNATIVECC=		$($(NATIVE_MACH)_CC)
7637c478bd9Sstevel@tonic-gateNATIVECCC=		$($(NATIVE_MACH)_CCC)
7647c478bd9Sstevel@tonic-gateNATIVECPP=		$($(NATIVE_MACH)_CPP)
7657c478bd9Sstevel@tonic-gateNATIVEAS=		$($(NATIVE_MACH)_AS)
7667c478bd9Sstevel@tonic-gateNATIVELD=		$($(NATIVE_MACH)_LD)
7677c478bd9Sstevel@tonic-gate
7680ae9a84fSAndrew StormontNATIVECC64=		$($(NATIVE_MACH64)_CC)
7690ae9a84fSAndrew StormontNATIVECCC64=		$($(NATIVE_MACH64)_CCC)
7700ae9a84fSAndrew StormontNATIVECPP64=		$($(NATIVE_MACH64)_CPP)
7710ae9a84fSAndrew StormontNATIVEAS64=		$($(NATIVE_MACH64)_AS)
7720ae9a84fSAndrew StormontNATIVELD64=		$($(NATIVE_MACH64)_LD)
7730ae9a84fSAndrew Stormont
7747c478bd9Sstevel@tonic-gate#
7757c478bd9Sstevel@tonic-gate# Makefile.master.64 overrides these settings
7767c478bd9Sstevel@tonic-gate#
7777c478bd9Sstevel@tonic-gateCC=			$(NATIVECC)
7787c478bd9Sstevel@tonic-gateCCC=			$(NATIVECCC)
7797c478bd9Sstevel@tonic-gateCPP=			$(NATIVECPP)
7807c478bd9Sstevel@tonic-gateAS=			$(NATIVEAS)
7817c478bd9Sstevel@tonic-gateLD=			$(NATIVELD)
7827c478bd9Sstevel@tonic-gate
7830ae9a84fSAndrew StormontCC64=			$(NATIVECC64)
7840ae9a84fSAndrew StormontCCC64=			$(NATIVECCC64)
7850ae9a84fSAndrew StormontCPP64=			$(NATIVECPP64)
7860ae9a84fSAndrew StormontAS64=			$(NATIVEAS64)
7870ae9a84fSAndrew StormontLD64=			$(NATIVELD64)
7880ae9a84fSAndrew Stormont
7897c478bd9Sstevel@tonic-gate# Pass -Y flag to cpp (method of which is release-dependent)
7907c478bd9Sstevel@tonic-gateCCYFLAG=		-Y I,
7917c478bd9Sstevel@tonic-gate
79285f4cb87SRichard LoweBDIRECT=	-Wl,-Bdirect
79385f4cb87SRichard LoweBDYNAMIC=	-Wl,-Bdynamic
79485f4cb87SRichard LoweBLOCAL=		-Wl,-Blocal
79585f4cb87SRichard LoweBNODIRECT=	-Wl,-Bnodirect
79685f4cb87SRichard LoweBREDUCE=	-Wl,-Breduce
79785f4cb87SRichard LoweBSTATIC=	-Wl,-Bstatic
79885f4cb87SRichard LoweBSYMBOLIC=	-Wl,-Bsymbolic
79985f4cb87SRichard Lowe
80085f4cb87SRichard LoweZDEFS=		-Wl,-zdefs
80185f4cb87SRichard LoweZDIRECT=	-Wl,-zdirect
80285f4cb87SRichard LoweZIGNORE=	-Wl,-zignore
80385f4cb87SRichard LoweZINITFIRST=	-Wl,-zinitfirst
80485f4cb87SRichard LoweZINTERPOSE=	-Wl,-zinterpose
80585f4cb87SRichard LoweZLAZYLOAD=	-Wl,-zlazyload
80685f4cb87SRichard LoweZLOADFLTR=	-Wl,-zloadfltr
80785f4cb87SRichard LoweZMULDEFS=	-Wl,-zmuldefs
80885f4cb87SRichard LoweZNODEFAULTLIB=	-Wl,-znodefaultlib
80985f4cb87SRichard LoweZNODEFS=	-Wl,-znodefs
81085f4cb87SRichard LoweZNODELETE=	-Wl,-znodelete
81185f4cb87SRichard LoweZNODLOPEN=	-Wl,-znodlopen
81285f4cb87SRichard LoweZNODUMP=	-Wl,-znodump
81385f4cb87SRichard LoweZNOLAZYLOAD=	-Wl,-znolazyload
81485f4cb87SRichard LoweZNOLDYNSYM=	-Wl,-znoldynsym
81585f4cb87SRichard LoweZNORELOC=	-Wl,-znoreloc
81685f4cb87SRichard LoweZNOVERSION=	-Wl,-znoversion
81785f4cb87SRichard LoweZRECORD=	-Wl,-zrecord
81885f4cb87SRichard LoweZREDLOCSYM=	-Wl,-zredlocsym
81985f4cb87SRichard LoweZTEXT=		-Wl,-ztext
82085f4cb87SRichard LoweZVERBOSE=	-Wl,-zverbose
82185f4cb87SRichard LoweZASSERTDEFLIB=	-Wl,-zassert-deflib
82285f4cb87SRichard LoweZGUIDANCE=	-Wl,-zguidance
82385f4cb87SRichard LoweZFATALWARNINGS=	-Wl,-zfatal-warnings
82490d74ed6SAndy FiddamanZASLR=		-Wl,-zaslr
82585f4cb87SRichard Lowe
82685f4cb87SRichard LoweGSHARED=	-shared
8277c478bd9Sstevel@tonic-gateCCMT=		-mt
8287c478bd9Sstevel@tonic-gate
8297c478bd9Sstevel@tonic-gate# Handle different PIC models on different ISAs
8307c478bd9Sstevel@tonic-gate# (May be overridden by lower-level Makefiles)
8317c478bd9Sstevel@tonic-gate
832e1bf37b1SRichard Lowesparc_C_PICFLAGS =	-fpic
833e1bf37b1SRichard Lowesparcv9_C_PICFLAGS =	-fpic
834e1bf37b1SRichard Lowei386_C_PICFLAGS =	-fpic
835e1bf37b1SRichard Loweamd64_C_PICFLAGS =	-fpic
8367c478bd9Sstevel@tonic-gateC_PICFLAGS =		$($(MACH)_C_PICFLAGS)
8377c478bd9Sstevel@tonic-gateC_PICFLAGS64 =		$($(MACH64)_C_PICFLAGS)
8387c478bd9Sstevel@tonic-gate
839e1bf37b1SRichard Lowesparc_C_BIGPICFLAGS =	-fPIC
840e1bf37b1SRichard Lowesparcv9_C_BIGPICFLAGS =	-fPIC
841e1bf37b1SRichard Lowei386_C_BIGPICFLAGS =	-fPIC
842e1bf37b1SRichard Loweamd64_C_BIGPICFLAGS =	-fPIC
8437c478bd9Sstevel@tonic-gateC_BIGPICFLAGS =		$($(MACH)_C_BIGPICFLAGS)
8447c478bd9Sstevel@tonic-gateC_BIGPICFLAGS64 =	$($(MACH64)_C_BIGPICFLAGS)
8457c478bd9Sstevel@tonic-gate
8467c478bd9Sstevel@tonic-gate# CC requires there to be no space between '-K' and 'pic' or 'PIC'.
847e1bf37b1SRichard Lowe# and does not support -f
848d17be682SRichard Lowesparc_CC_PICFLAGS =	-_gcc=-fpic
849d17be682SRichard Lowesparcv9_CC_PICFLAGS =	-_gcc=-fPIC
850d17be682SRichard Lowei386_CC_PICFLAGS =	-_gcc=-fpic
851d17be682SRichard Loweamd64_CC_PICFLAGS =	-_gcc=-fpic
8527c478bd9Sstevel@tonic-gateCC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
8537c478bd9Sstevel@tonic-gateCC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)
8547c478bd9Sstevel@tonic-gate
8555d9d9091SRichard LoweAS_PICFLAGS=		$(C_PICFLAGS)
8565d9d9091SRichard LoweAS_BIGPICFLAGS=		$(C_BIGPICFLAGS)
8577c478bd9Sstevel@tonic-gate
8587c478bd9Sstevel@tonic-gate#
8597c478bd9Sstevel@tonic-gate# Default label for CTF sections
8607c478bd9Sstevel@tonic-gate#
8613eca6103SJohn LevonCTFCVTFLAGS=		-L VERSION
8627c478bd9Sstevel@tonic-gate
8637c478bd9Sstevel@tonic-gate#
864d69cdb36SRichard Lowe# Override to pass module-specific flags to ctfmerge.  Currently used only by
865d69cdb36SRichard Lowe# krtld to turn on fuzzy matching, and source-level debugging to inhibit
866d69cdb36SRichard Lowe# stripping.
8677c478bd9Sstevel@tonic-gate#
8687c478bd9Sstevel@tonic-gateCTFMRGFLAGS=
8697c478bd9Sstevel@tonic-gate
8707c478bd9Sstevel@tonic-gateCTFCONVERT_O		= $(CTFCONVERT) $(CTFCVTFLAGS) $@
8717c478bd9Sstevel@tonic-gate
8727c478bd9Sstevel@tonic-gate# Rules (normally from make.rules) and macros which are used for post
8737c478bd9Sstevel@tonic-gate# processing files. Normally, these do stripping of the comment section
8747c478bd9Sstevel@tonic-gate# automatically.
8753eca6103SJohn Levon#    RELEASE_CM:	Should be edited to reflect the release.
8763eca6103SJohn Levon#    POST_PROCESS_O:	Post-processing for `.o' files (typically C source)
8773eca6103SJohn Levon#    POST_PROCESS_S_O:	Post-processing for `.o' files built from asssembly
8783eca6103SJohn Levon#    POST_PROCESS_CC_O:	Post-processing for `.o' files built from C++
8793eca6103SJohn Levon#    POST_PROCESS_A:		Post-processing for `.a' files (currently null).
8807c478bd9Sstevel@tonic-gate#    POST_PROCESS_SO:	Post-processing for `.so' files.
8817c478bd9Sstevel@tonic-gate#    POST_PROCESS:	Post-processing for executable files (no suffix).
8823eca6103SJohn Levon#
8837c478bd9Sstevel@tonic-gate# Note that these macros are not completely generalized as they are to be
8847c478bd9Sstevel@tonic-gate# used with the file name to be processed following.
8857c478bd9Sstevel@tonic-gate#
8867c478bd9Sstevel@tonic-gate# It is left as an exercise to Release Engineering to embellish the generation
8877c478bd9Sstevel@tonic-gate# of the release comment string.
8887c478bd9Sstevel@tonic-gate#
8897c478bd9Sstevel@tonic-gate#	If this is a standard development build:
8907c478bd9Sstevel@tonic-gate#		compress the comment section (mcs -c)
8917c478bd9Sstevel@tonic-gate#		add the standard comment (mcs -a $(RELEASE_CM))
8927c478bd9Sstevel@tonic-gate#		add the development specific comment (mcs -a $(DEV_CM))
8937c478bd9Sstevel@tonic-gate#
8947c478bd9Sstevel@tonic-gate#	If this is an installation build:
8957c478bd9Sstevel@tonic-gate#		delete the comment section (mcs -d)
8967c478bd9Sstevel@tonic-gate#		add the standard comment (mcs -a $(RELEASE_CM))
8977c478bd9Sstevel@tonic-gate#		add the development specific comment (mcs -a $(DEV_CM))
8987c478bd9Sstevel@tonic-gate#
8997c478bd9Sstevel@tonic-gate#	If this is an release build:
9007c478bd9Sstevel@tonic-gate#		delete the comment section (mcs -d)
9017c478bd9Sstevel@tonic-gate#		add the standard comment (mcs -a $(RELEASE_CM))
9027c478bd9Sstevel@tonic-gate#
9037c478bd9Sstevel@tonic-gate# The following list of macros are used in the definition of RELEASE_CM
9047c478bd9Sstevel@tonic-gate# which is used to label all binaries in the build:
9057c478bd9Sstevel@tonic-gate#
906aa9ef484SJohn Levon#	RELEASE		Specific release of the build, eg: 5.2
9072032ea7bSmeem#	RELEASE_MAJOR	Major version number part of $(RELEASE)
9082032ea7bSmeem#	RELEASE_MINOR	Minor version number part of $(RELEASE)
9097c478bd9Sstevel@tonic-gate#	VERSION		Version of the build (alpha, beta, Generic)
9107c478bd9Sstevel@tonic-gate#	RELEASE_DATE	Date of the Release Build
9117c478bd9Sstevel@tonic-gate#
9122032ea7bSmeemRELEASE_MAJOR=	5
9132032ea7bSmeemRELEASE_MINOR=	11
9142032ea7bSmeemRELEASE=	$(RELEASE_MAJOR).$(RELEASE_MINOR)
9157c478bd9Sstevel@tonic-gateVERSION=	SunOS Development
91648bc00d6SjmcpRELEASE_DATE=	release date not set
917*fc910014SRichard LoweRELEASE_CM=	"@($(POUND_SIGN))illumos $(VERSION) $(RELEASE_DATE)"
9186112cec5SJoshua M. ClulowDEV_CM_TAIL=	development build: $(LOGNAME)
9196112cec5SJoshua M. ClulowDEV_CM=		"@($(POUND_SIGN))illumos $(DEV_CM_TAIL)"
92006abc743SJohn LevonUTS_LABEL=	$(RELEASE)
9217c478bd9Sstevel@tonic-gate
9226112cec5SJoshua M. Clulow#
9236112cec5SJoshua M. Clulow# The boot banner may be overridden by distributions.  Up to five lines can be
9246112cec5SJoshua M. Clulow# specified by overriding the BOOTBANNER macros, and any line that expands to
9256112cec5SJoshua M. Clulow# an empty string will not be printed.  See comments in
9266112cec5SJoshua M. Clulow# bootbanner_expand_template() for more details about the template string
9276112cec5SJoshua M. Clulow# format.
9286112cec5SJoshua M. Clulow#
9296112cec5SJoshua M. ClulowBOOTBANNER1=	^o Version ^v ^w-bit
9306112cec5SJoshua M. ClulowBOOTBANNER2=
9316112cec5SJoshua M. ClulowBOOTBANNER3=
9326112cec5SJoshua M. ClulowBOOTBANNER4=
9336112cec5SJoshua M. ClulowBOOTBANNER5=
9346112cec5SJoshua M. Clulow
93534ae5cdfSJosef 'Jeff' SipekPROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
9367c478bd9Sstevel@tonic-gate$(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
9377c478bd9Sstevel@tonic-gate
938495021bdSRichard LoweSTRIP_STABS=			   $(STRIP) -x $@
939d69cdb36SRichard Lowe$(SRCDBGBLD)STRIP_STABS=	   :
9407a58f538SRobert MustacchiPROCESS_CTF=			   :
9417c478bd9Sstevel@tonic-gate
942aa9ef484SJohn LevonPOST_PROCESS_O=
9433eca6103SJohn LevonPOST_PROCESS_S_O=
9443eca6103SJohn LevonPOST_PROCESS_CC_O=
9457c478bd9Sstevel@tonic-gatePOST_PROCESS_A=
9467c478bd9Sstevel@tonic-gatePOST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
9477c478bd9Sstevel@tonic-gate			$(ELFSIGN_OBJECT)
9487a58f538SRobert MustacchiPOST_PROCESS=		$(PROCESS_COMMENT) $@ ; $(PROCESS_CTF) ; \
9497a58f538SRobert Mustacchi			$(STRIP_STABS) ; $(ELFSIGN_OBJECT)
9507c478bd9Sstevel@tonic-gate
9517c478bd9Sstevel@tonic-gate#
9527c478bd9Sstevel@tonic-gate# PKGARCHIVE specifies the default location where packages should be
9537c478bd9Sstevel@tonic-gate# placed if built.
9547c478bd9Sstevel@tonic-gate#
9557c478bd9Sstevel@tonic-gate$(RELEASE_BUILD)PKGARCHIVESUFFIX=	-nd
9567c478bd9Sstevel@tonic-gatePKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly$(PKGARCHIVESUFFIX)
9577c478bd9Sstevel@tonic-gate
958ead1f93eSLiane Praza#
959ead1f93eSLiane Praza# The repositories will be created with these publisher settings.  To
960ead1f93eSLiane Praza# update an image to the resulting repositories, this must match the
961ead1f93eSLiane Praza# publisher name provided to "pkg set-publisher."
962ead1f93eSLiane Praza#
963ead1f93eSLiane PrazaPKGPUBLISHER_REDIST=	on-nightly
964ead1f93eSLiane PrazaPKGPUBLISHER_NONREDIST=	on-extra
965ead1f93eSLiane Praza
9665d9d9091SRichard Lowe# Allow suffix rules like the below for .S as well as .s
9675d9d9091SRichard Lowe.SUFFIXES: .S
9685d9d9091SRichard Lowe
9697c478bd9Sstevel@tonic-gate#	Default build rules which perform comment section post-processing.
9707c478bd9Sstevel@tonic-gate#
9717c478bd9Sstevel@tonic-gate.c:
9727c478bd9Sstevel@tonic-gate	$(LINK.c) -o $@ $< $(LDLIBS)
9737c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
9747c478bd9Sstevel@tonic-gate.c.o:
9757c478bd9Sstevel@tonic-gate	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
9767c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
9777c478bd9Sstevel@tonic-gate.c.a:
9787c478bd9Sstevel@tonic-gate	$(COMPILE.c) -o $% $<
9797c478bd9Sstevel@tonic-gate	$(PROCESS_COMMENT) $%
9807c478bd9Sstevel@tonic-gate	$(AR) $(ARFLAGS) $@ $%
9817c478bd9Sstevel@tonic-gate	$(RM) $%
9827c478bd9Sstevel@tonic-gate.s.o:
9837c478bd9Sstevel@tonic-gate	$(COMPILE.s) -o $@ $<
9843eca6103SJohn Levon	$(POST_PROCESS_S_O)
9857c478bd9Sstevel@tonic-gate.s.a:
9867c478bd9Sstevel@tonic-gate	$(COMPILE.s) -o $% $<
9877c478bd9Sstevel@tonic-gate	$(PROCESS_COMMENT) $%
9887c478bd9Sstevel@tonic-gate	$(AR) $(ARFLAGS) $@ $%
9897c478bd9Sstevel@tonic-gate	$(RM) $%
9905d9d9091SRichard Lowe
9915d9d9091SRichard Lowe.S.o:
9925d9d9091SRichard Lowe	$(COMPILE.s) -o $@ $<
9935d9d9091SRichard Lowe	$(POST_PROCESS_S_O)
9945d9d9091SRichard Lowe.S.a:
9955d9d9091SRichard Lowe	$(COMPILE.s) -o $% $<
9965d9d9091SRichard Lowe	$(PROCESS_COMMENT) $%
9975d9d9091SRichard Lowe	$(AR) $(ARFLAGS) $@ $%
9985d9d9091SRichard Lowe	$(RM) $%
9997c478bd9Sstevel@tonic-gate.cc:
10007c478bd9Sstevel@tonic-gate	$(LINK.cc) -o $@ $< $(LDLIBS)
10017c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
10027c478bd9Sstevel@tonic-gate.cc.o:
10037c478bd9Sstevel@tonic-gate	$(COMPILE.cc) $(OUTPUT_OPTION) $<
10043eca6103SJohn Levon	$(POST_PROCESS_CC_O)
10057c478bd9Sstevel@tonic-gate.cc.a:
10067c478bd9Sstevel@tonic-gate	$(COMPILE.cc) -o $% $<
10077c478bd9Sstevel@tonic-gate	$(AR) $(ARFLAGS) $@ $%
10087c478bd9Sstevel@tonic-gate	$(PROCESS_COMMENT) $%
10097c478bd9Sstevel@tonic-gate	$(RM) $%
10107c478bd9Sstevel@tonic-gate.y:
10117c478bd9Sstevel@tonic-gate	$(YACC.y) $<
10127c478bd9Sstevel@tonic-gate	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
10137c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
10147c478bd9Sstevel@tonic-gate	$(RM) y.tab.c
10157c478bd9Sstevel@tonic-gate.y.o:
10167c478bd9Sstevel@tonic-gate	$(YACC.y) $<
10177c478bd9Sstevel@tonic-gate	$(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
10187c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
10197c478bd9Sstevel@tonic-gate	$(RM) y.tab.c
10207c478bd9Sstevel@tonic-gate.l:
10217c478bd9Sstevel@tonic-gate	$(RM) $*.c
10227c478bd9Sstevel@tonic-gate	$(LEX.l) $< > $*.c
10237c478bd9Sstevel@tonic-gate	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
10247c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
10257c478bd9Sstevel@tonic-gate	$(RM) $*.c
10267c478bd9Sstevel@tonic-gate.l.o:
10277c478bd9Sstevel@tonic-gate	$(RM) $*.c
10287c478bd9Sstevel@tonic-gate	$(LEX.l) $< > $*.c
10297c478bd9Sstevel@tonic-gate	$(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
10307c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
10317c478bd9Sstevel@tonic-gate	$(RM) $*.c
10327c478bd9Sstevel@tonic-gate
10334c06356bSdh.bin.o:
10344c06356bSdh	$(COMPILE.b) -o $@ $<
10354c06356bSdh	$(POST_PROCESS_O)
10364c06356bSdh
10377c478bd9Sstevel@tonic-gate.java.class:
10387c478bd9Sstevel@tonic-gate	$(COMPILE.java) $<
10397c478bd9Sstevel@tonic-gate
1040a778b211Scarlsonj# Bourne and Korn shell script message catalog build rules.
1041a778b211Scarlsonj# We extract all gettext strings with sed(1) (being careful to permit
1042a778b211Scarlsonj# multiple gettext strings on the same line), weed out the dups, and
1043a778b211Scarlsonj# build the catalogue with awk(1).
10447c478bd9Sstevel@tonic-gate
1045a778b211Scarlsonj.sh.po .ksh.po:
1046aa9ef484SJohn Levon	$(SED) -n -e ":a"					\
1047aa9ef484SJohn Levon		  -e "h"					\
10487c478bd9Sstevel@tonic-gate		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
10497c478bd9Sstevel@tonic-gate		  -e "x"					\
10507c478bd9Sstevel@tonic-gate		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
10517c478bd9Sstevel@tonic-gate		  -e "t a"					\
10524cb69eccSIgor Kozhukhov	       $< | sort -u | $(AWK) '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
10537c478bd9Sstevel@tonic-gate
1054a778b211Scarlsonj#
1055a778b211Scarlsonj# Python and Perl executable and message catalog build rules.
1056a778b211Scarlsonj#
1057cdf0c1d5Smjnelson.SUFFIXES: .pl .pm .py .pyc
1058a778b211Scarlsonj
1059a778b211Scarlsonj.pl:
1060a778b211Scarlsonj	$(RM) $@;
1061a778b211Scarlsonj	$(SED) -e "s@TEXT_DOMAIN@\"$(TEXT_DOMAIN)\"@" $< > $@;
1062a778b211Scarlsonj	$(CHMOD) +x $@
1063a778b211Scarlsonj
1064a778b211Scarlsonj.py:
1065ca13eaa5SAndy Fiddaman	$(RM) $@; $(SED) \
1066ca13eaa5SAndy Fiddaman		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
1067ca13eaa5SAndy Fiddaman		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
1068ca13eaa5SAndy Fiddaman		< $< > $@; $(CHMOD) +x $@
1069a778b211Scarlsonj
107014843421SMatthew Ahrens.py.po:
107114843421SMatthew Ahrens	$(GNUXGETTEXT) $(GNUXGETFLAGS) -d $(<F:%.py=%) $< ;
107214843421SMatthew Ahrens
1073a778b211Scarlsonj.pl.po .pm.po:
1074a778b211Scarlsonj	$(XGETTEXT) $(XGETFLAGS) -d $(<F) $< ;
1075a778b211Scarlsonj	$(RM)	$@ ;
1076a778b211Scarlsonj	$(SED) "/^domain/d" < $(<F).po > $@ ;
1077a778b211Scarlsonj	$(RM) $(<F).po
10789acbbeafSnn
10797c478bd9Sstevel@tonic-gate#
10807c478bd9Sstevel@tonic-gate# When using xgettext, we want messages to go to the default domain,
10817c478bd9Sstevel@tonic-gate# rather than the specified one.  This special version of the
10827c478bd9Sstevel@tonic-gate# COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
10837c478bd9Sstevel@tonic-gate# causing xgettext to put all messages into the default domain.
10847c478bd9Sstevel@tonic-gate#
10857c478bd9Sstevel@tonic-gateCPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
10867c478bd9Sstevel@tonic-gate
10877c478bd9Sstevel@tonic-gate.c.i:
10887c478bd9Sstevel@tonic-gate	$(CPPFORPO) $< > $@
10897c478bd9Sstevel@tonic-gate
10907c478bd9Sstevel@tonic-gate.h.i:
10917c478bd9Sstevel@tonic-gate	$(CPPFORPO) $< > $@
10927c478bd9Sstevel@tonic-gate
10937c478bd9Sstevel@tonic-gate.y.i:
10947c478bd9Sstevel@tonic-gate	$(YACC) -d $<
10957c478bd9Sstevel@tonic-gate	$(CPPFORPO) y.tab.c  > $@
1096d69cdb36SRichard Lowe	$(RM) y.tab.c
10977c478bd9Sstevel@tonic-gate
10987c478bd9Sstevel@tonic-gate.l.i:
10997c478bd9Sstevel@tonic-gate	$(LEX) $<
11007c478bd9Sstevel@tonic-gate	$(CPPFORPO) lex.yy.c  > $@
11017c478bd9Sstevel@tonic-gate	$(RM) lex.yy.c
11027c478bd9Sstevel@tonic-gate
11037c478bd9Sstevel@tonic-gate.c.po:
11047c478bd9Sstevel@tonic-gate	$(CPPFORPO) $< > $<.i
11057c478bd9Sstevel@tonic-gate	$(BUILD.po)
11067c478bd9Sstevel@tonic-gate
110710d63b7dSRichard Lowe.cc.po:
110810d63b7dSRichard Lowe	$(CPPFORPO) $< > $<.i
110910d63b7dSRichard Lowe	$(BUILD.po)
111010d63b7dSRichard Lowe
11117c478bd9Sstevel@tonic-gate.y.po:
11127c478bd9Sstevel@tonic-gate	$(YACC) -d $<
11137c478bd9Sstevel@tonic-gate	$(CPPFORPO) y.tab.c  > $<.i
11147c478bd9Sstevel@tonic-gate	$(BUILD.po)
1115d69cdb36SRichard Lowe	$(RM) y.tab.c
11167c478bd9Sstevel@tonic-gate
11177c478bd9Sstevel@tonic-gate.l.po:
11187c478bd9Sstevel@tonic-gate	$(LEX) $<
11197c478bd9Sstevel@tonic-gate	$(CPPFORPO) lex.yy.c  > $<.i
11207c478bd9Sstevel@tonic-gate	$(BUILD.po)
11217c478bd9Sstevel@tonic-gate	$(RM) lex.yy.c
11227c478bd9Sstevel@tonic-gate
11237c478bd9Sstevel@tonic-gate#
11247c478bd9Sstevel@tonic-gate# Rules to perform stylistic checks
11257c478bd9Sstevel@tonic-gate#
1126a778b211Scarlsonj.SUFFIXES: .x .xml .check .xmlchk
11277c478bd9Sstevel@tonic-gate
11287c478bd9Sstevel@tonic-gate.h.check:
11297c478bd9Sstevel@tonic-gate	$(DOT_H_CHECK)
11307c478bd9Sstevel@tonic-gate
11317c478bd9Sstevel@tonic-gate.x.check:
11327c478bd9Sstevel@tonic-gate	$(DOT_X_CHECK)
11337c478bd9Sstevel@tonic-gate
11347c478bd9Sstevel@tonic-gate.xml.xmlchk:
11357c478bd9Sstevel@tonic-gate	$(MANIFEST_CHECK)
1136