xref: /illumos-gate/usr/src/Makefile.master (revision 85f4cb87)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License (the "License").
6# You may not use this file except in compliance with the License.
7#
8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9# or http://www.opensolaris.org/os/licensing.
10# See the License for the specific language governing permissions
11# and limitations under the License.
12#
13# When distributing Covered Code, include this CDDL HEADER in each
14# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15# If applicable, add the following below this CDDL HEADER, with the
16# fields enclosed by brackets "[]" replaced with your own identifying
17# information: Portions Copyright [yyyy] [name of copyright owner]
18#
19# CDDL HEADER END
20#
21
22#
23# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24# Copyright (c) 2012 by Delphix. All rights reserved.
25# Copyright 2014 Garrett D'Amore <garrett@damore.org>
26# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
27# Copyright 2015 Gary Mills
28# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
29# Copyright 2016 Toomas Soome <tsoome@me.com>
30# Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
31# Copyright 2020 Joyent, Inc.
32# Copyright 2019 RackTop Systems.
33# Copyright 2020 Oxide Computer Company
34# Copyright 2020 Peter Tribble
35#
36
37#
38# Makefile.master, global definitions for system source
39#
40ROOT=		/proto
41
42#
43# Adjunct root, containing an additional proto area to be used for headers
44# and libraries.
45#
46ADJUNCT_PROTO=
47# HAVE_ADJUNCT_PROTO - ADJUNCT_PROTO is set to a non-default value
48# NO_ADJUNCT_PROTO - ADJUNCT_PROTO is unset
49#
50# This works by replacing any value in ADJUNCT_PROTO with POUND_SIGN, which
51# only happens if it has some value, and then setting HAVE_ADJUNCT_PROTO
52# oppositely.
53NO_ADJUNCT_PROTO=$(ADJUNCT_PROTO:%=$(POUND_SIGN))
54$(NO_ADJUNCT_PROTO)HAVE_ADJUNCT_PROTO=$(POUND_SIGN)
55
56#
57# Adjunct for building things that run on the build machine.
58#
59NATIVE_ADJUNCT=	/usr
60
61#
62# Compatibility code for FreeBSD etc.
63#
64COMPAT=	$(SRC)/compat
65CONTRIB= $(SRC)/contrib
66
67#
68# RELEASE_BUILD should be cleared for final release builds.
69# NOT_RELEASE_BUILD is exactly what the name implies.
70#
71# __GNUC toggles the building of ON components using gcc and related tools.
72# Normally set to `#', set it to `' to do gcc build.
73#
74# The declaration POUND_SIGN is always '#'. This is needed to get around the
75# make feature that '#' is always a comment delimiter, even when escaped or
76# quoted. We use this macro expansion method to get POUND_SIGN rather than
77# always breaking out a shell because the general case can cause a noticable
78# slowdown in build times when so many Makefiles include Makefile.master.
79#
80# While the majority of users are expected to override the setting below
81# with an env file (via nightly or bldenv), if you aren't building that way
82# (ie, you're using "ws" or some other bootstrapping method) then you need
83# this definition in order to avoid the subshell invocation mentioned above.
84#
85
86PRE_POUND=				pre\#
87POUND_SIGN=				$(PRE_POUND:pre\%=%)
88
89NOT_RELEASE_BUILD=
90RELEASE_BUILD=				$(POUND_SIGN)
91$(RELEASE_BUILD)NOT_RELEASE_BUILD=	$(POUND_SIGN)
92PATCH_BUILD=				$(POUND_SIGN)
93
94# SPARC_BLD is '#' for an Intel build.
95# INTEL_BLD is '#' for a Sparc build.
96SPARC_BLD_1=    $(MACH:i386=$(POUND_SIGN))
97SPARC_BLD=      $(SPARC_BLD_1:sparc=)
98INTEL_BLD_1=    $(MACH:sparc=$(POUND_SIGN))
99INTEL_BLD=      $(INTEL_BLD_1:i386=)
100
101# The variables below control the compilers used during the build.
102# There are a number of permutations.
103#
104# __GNUC and __SUNC control (and indicate) the primary compiler.  Whichever
105# one is not POUND_SIGN is the primary, with the other as the shadow.  They
106# may also be used to control entirely compiler-specific Makefile assignments.
107# __GNUC and GCC are the default.
108#
109# __GNUC64 indicates that the 64bit build should use the GNU C compiler.
110# There is no Sun C analogue.
111#
112# The following version-specific options are operative regardless of which
113# compiler is primary, and control the versions of the given compilers to be
114# used.  They also allow compiler-version specific Makefile fragments.
115#
116
117__SUNC=			$(POUND_SIGN)
118$(__SUNC)__GNUC=	$(POUND_SIGN)
119__GNUC64=		$(__GNUC)
120
121# Allow build-time "configuration" to enable or disable some things.
122# The default is POUND_SIGN, meaning "not enabled". If the environment
123# passes in an override like ENABLE_SMB_PRINTING= (empty) that will
124# uncomment things in the lower Makefiles to enable the feature.
125ENABLE_SMB_PRINTING=	$(POUND_SIGN)
126
127# CLOSED is the root of the tree that contains source which isn't released
128# as open source
129CLOSED=		$(SRC)/../closed
130
131# BUILD_TOOLS is the root of all tools including compilers.
132# ONBLD_TOOLS is the root of all the tools that are part of SUNWonbld.
133
134BUILD_TOOLS=		/ws/onnv-tools
135ONBLD_TOOLS=		$(BUILD_TOOLS)/onbld
136
137# define runtime JAVA_HOME, primarily for cmd/pools/poold
138JAVA_HOME=	/usr/java
139# define buildtime JAVA_ROOT
140JAVA_ROOT=	/usr/java
141# Build uses java8 by default.  Pass the variable below set to empty
142# string in the environment to override.
143BLD_JAVA_11=	$(POUND_SIGN)
144
145GNUC_ROOT=	/usr/gcc/7
146GCCLIBDIR=	$(GNUC_ROOT)/lib
147GCCLIBDIR64=	$(GNUC_ROOT)/lib/$(MACH64)
148
149DOCBOOK_XSL_ROOT=	/usr/share/sgml/docbook/xsl-stylesheets
150
151RPCGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/rpcgen
152STABS=		$(ONBLD_TOOLS)/bin/$(MACH)/stabs
153ELFEXTRACT=	$(ONBLD_TOOLS)/bin/$(MACH)/elfextract
154MBH_PATCH=	$(ONBLD_TOOLS)/bin/$(MACH)/mbh_patch
155BTXLD=		$(ONBLD_TOOLS)/bin/$(MACH)/btxld
156VTFONTCVT=	$(ONBLD_TOOLS)/bin/$(MACH)/vtfontcvt
157# echo(1) and true(1) are specified without absolute paths, so that the shell
158# spawned by make(1) may use the built-in versions.  This is minimally
159# problematic, as the shell spawned by make(1) is known and under control, the
160# only risk being if the shell falls back to $PATH.
161#
162# We specifically want an echo(1) that does interpolation of escape sequences,
163# which ksh93, /bin/sh, and bash will all provide.
164ECHO=		echo
165TRUE=		true
166INS=		$(ONBLD_TOOLS)/bin/$(MACH)/install
167SYMLINK=	/usr/bin/ln -s
168LN=		/usr/bin/ln
169MKDIR=		/usr/bin/mkdir
170CHMOD=		/usr/bin/chmod
171MV=		/usr/bin/mv -f
172RM=		/usr/bin/rm -f
173CUT=		/usr/bin/cut
174NM=		/usr/ccs/bin/nm
175DIFF=		/usr/bin/diff
176GREP=		/usr/bin/grep
177EGREP=		/usr/bin/egrep
178ELFWRAP=	/usr/bin/elfwrap
179KSH93=		/usr/bin/ksh93
180SED=		/usr/bin/sed
181AWK=		/usr/bin/nawk
182CP=		/usr/bin/cp -f
183MCS=		/usr/ccs/bin/mcs
184CAT=            /usr/bin/cat
185ELFDUMP=	/usr/ccs/bin/elfdump
186M4=		/usr/bin/m4
187GM4=		/usr/bin/gm4
188STRIP=		/usr/ccs/bin/strip
189LEX=		/usr/ccs/bin/lex
190FLEX=		/usr/bin/flex
191YACC=		/usr/ccs/bin/yacc
192BISON=		/usr/bin/bison
193CPP=		/usr/lib/cpp
194ANSI_CPP=	$(GNUC_ROOT)/bin/cpp
195JAVAC=		$(JAVA_ROOT)/bin/javac
196JAVADOC=	$(JAVA_ROOT)/bin/javadoc
197JAR=		$(JAVA_ROOT)/bin/jar
198CTFCONVERT=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfconvert
199CTFDIFF=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfdiff
200CTFMERGE=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfmerge
201CTFSTABS=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
202CTFSTRIP=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstrip
203NDRGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/ndrgen
204GENOFFSETS=	$(ONBLD_TOOLS)/bin/genoffsets
205XREF=		$(ONBLD_TOOLS)/bin/xref
206FIND=		/usr/bin/find
207PERL=		/usr/bin/perl
208PERL_VERSION=	5.10.0
209PERL_PKGVERS=	-510
210PERL_MACH=	i86pc
211$(SPARC_BLD)PERL_MACH=	sun4
212PERL_VARIANT=
213PERL_ARCH=	$(PERL_MACH)-solaris$(PERL_VARIANT)-64int
214PERL_ARCH64=	$(PERL_MACH)-solaris$(PERL_VARIANT)-64
215PYTHON_VERSION=	2.7
216PYTHON_PKGVERS=	-27
217PYTHON_SUFFIX=
218PYTHON=		/usr/bin/python$(PYTHON_VERSION)
219PYTHON3_VERSION=	3.5
220PYTHON3_PKGVERS=	-35
221PYTHON3_SUFFIX=		m
222PYTHON3=		/usr/bin/python$(PYTHON3_VERSION)
223$(BUILDPY3TOOLS)TOOLS_PYTHON=		$(PYTHON3)
224$(BUILDPY2TOOLS)TOOLS_PYTHON=		$(PYTHON)
225SORT=		/usr/bin/sort
226TR=		/usr/bin/tr
227TOUCH=		/usr/bin/touch
228WC=		/usr/bin/wc
229XARGS=		/usr/bin/xargs
230ELFEDIT=	/usr/bin/elfedit
231DTRACE=		/usr/sbin/dtrace -xnolibs
232UNIQ=		/usr/bin/uniq
233TAR=		/usr/bin/tar
234ASTBINDIR=	/usr/ast/bin
235MSGCC=		$(ASTBINDIR)/msgcc
236MSGFMT=		/usr/bin/msgfmt -s
237LCDEF=		$(ONBLD_TOOLS)/bin/$(MACH)/localedef
238TIC=		$(ONBLD_TOOLS)/bin/$(MACH)/tic
239ZIC=		$(ONBLD_TOOLS)/bin/$(MACH)/zic
240OPENSSL=	/usr/bin/openssl
241CPCGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/cpcgen
242
243DEFAULT_CONSOLE_COLOR=					\
244	-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_WHITE	\
245	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_BLACK
246
247FILEMODE=	644
248DIRMODE=	755
249
250# Declare that nothing should be built in parallel.
251# Individual Makefiles can use the .PARALLEL target to declare otherwise.
252.NO_PARALLEL:
253
254# For stylistic checks
255#
256# Note that the X and C checks are not used at this time and may need
257# modification when they are actually used.
258#
259CSTYLE=		$(ONBLD_TOOLS)/bin/cstyle
260CSTYLE_TAIL=
261HDRCHK=		$(ONBLD_TOOLS)/bin/hdrchk
262HDRCHK_TAIL=
263JSTYLE=		$(ONBLD_TOOLS)/bin/jstyle
264
265DOT_H_CHECK=	\
266	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
267	$(HDRCHK) $< $(HDRCHK_TAIL)
268
269DOT_X_CHECK=	\
270	@$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
271	$(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)
272
273DOT_C_CHECK=	\
274	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)
275
276MANIFEST_CHECK=	\
277	@$(ECHO) "checking $<"; \
278	SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
279	SVCCFG_REPOSITORY=$(SRC)/cmd/svc/seed/global.db \
280	SVCCFG_CONFIGD_PATH=$(SRC)/cmd/svc/configd/svc.configd-native \
281	$(SRC)/cmd/svc/svccfg/svccfg-native validate $<
282
283INS.file=	$(RM) $@; $(INS) -s -m $(FILEMODE) -f $(@D) $<
284INS.dir=	$(INS) -s -d -m $(DIRMODE) $@
285# installs and renames at once
286#
287INS.rename=	$(INS.file); $(MV) $(@D)/$(<F) $@
288
289# install a link
290INSLINKTARGET=	$<
291INS.link=	$(RM) $@; $(LN) $(INSLINKTARGET) $@
292INS.symlink=	$(RM) $@; $(SYMLINK) $(INSLINKTARGET) $@
293
294# The path to python that will be used for the shebang line when installing
295# python scripts to the proto area. This is overridden by makefiles to
296# select to the correct version.
297PYSHEBANG=	$(PYTHON)
298$(BUILDPY3)PYSHEBANG=	$(PYTHON3)
299$(BUILDPY2)PYSHEBANG=	$(PYTHON)
300
301#
302# Python bakes the mtime of the .py file into the compiled .pyc and
303# rebuilds if the baked-in mtime != the mtime of the source file
304# (rather than only if it's less than), thus when installing python
305# files we must make certain to not adjust the mtime of the source
306# (.py) file.
307#
308INS.pyfile=	$(RM) $@; $(SED) \
309		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
310		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
311		< $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@
312
313# MACH must be set in the shell environment per uname -p on the build host
314# More specific architecture variables should be set in lower makefiles.
315#
316# MACH64 is derived from MACH, and BUILD64 is set to `#' for
317# architectures on which we do not build 64-bit versions.
318# (There are no such architectures at the moment.)
319#
320# Set BUILD64=# in the environment to disable 64-bit amd64
321# builds on i386 machines.
322
323MACH64_1=	$(MACH:sparc=sparcv9)
324MACH64=		$(MACH64_1:i386=amd64)
325
326MACH32_1=	$(MACH:sparc=sparcv7)
327MACH32=		$(MACH32_1:i386=i86)
328
329sparc_BUILD64=
330i386_BUILD64=
331BUILD64=	$($(MACH)_BUILD64)
332
333#
334# C compiler mode. Future compilers may change the default on us,
335# so force extended ANSI mode globally. Lower level makefiles can
336# override this by setting CCMODE.
337#
338CCMODE=			-Xa
339CCMODE64=		-Xa
340
341#
342# C compiler verbose mode. This is so we can enable it globally,
343# but turn it off in the lower level makefiles of things we cannot
344# (or aren't going to) fix.
345#
346CCVERBOSE=		-v
347
348# set this to the secret flag "-Wc,-Qiselect-v9abiwarn=1" to get warnings
349# from the compiler about places the -xarch=v9 may differ from -xarch=v9c.
350V9ABIWARN=
351
352# set this to the secret flag "-Wc,-Qiselect-regsym=0" to disable register
353# symbols (used to detect conflicts between objects that use global registers)
354# we disable this now for safety, and because genunix doesn't link with
355# this feature (the v9 default) enabled.
356#
357# REGSYM is separate since the C++ driver syntax is different.
358CCREGSYM=		-Wc,-Qiselect-regsym=0
359CCCREGSYM=		-Qoption cg -Qiselect-regsym=0
360
361# Prevent the removal of static symbols by the SPARC code generator (cg).
362# The x86 code generator (ube) does not remove such symbols and as such
363# using this workaround is not applicable for x86.
364#
365CCSTATICSYM=		-Wc,-Qassembler-ounrefsym=0
366#
367# generate 32-bit addresses in the v9 kernel. Saves memory.
368CCABS32=		-Wc,-xcode=abs32
369#
370# generate v9 code which tolerates callers using the v7 ABI, for the sake of
371# system calls.
372CC32BITCALLERS=		-_gcc=-massume-32bit-callers
373
374# GCC, especially, is increasingly beginning to auto-inline functions and
375# sadly does so separately not under the general -fno-inline-functions
376# Additionally, we wish to prevent optimisations which cause GCC to clone
377# functions -- in particular, these may cause unhelpful symbols to be
378# emitted instead of function names
379CCNOAUTOINLINE= \
380	-_gcc=-fno-inline-small-functions \
381	-_gcc=-fno-inline-functions-called-once \
382	-_gcc=-fno-ipa-cp \
383	-_gcc7=-fno-ipa-icf \
384	-_gcc8=-fno-ipa-icf \
385	-_gcc9=-fno-ipa-icf \
386	-_gcc7=-fno-clone-functions \
387	-_gcc8=-fno-clone-functions \
388	-_gcc9=-fno-clone-functions
389
390# GCC may put functions in different named sub-sections of .text based on
391# their presumed calling frequency.  At least in the kernel, where we actually
392# deliver relocatable objects, we don't want this to happen.
393#
394# Since at present we don't benefit from this even in userland, we disable it globally,
395# but the application of this may move into usr/src/uts/ in future.
396CCNOREORDER=	\
397	-_gcc7=-fno-reorder-functions \
398	-_gcc8=-fno-reorder-functions \
399	-_gcc9=-fno-reorder-functions
400
401#
402# gcc has a rather aggressive optimization on by default that infers loop
403# bounds based on undefined behavior (!!).  This can lead to some VERY
404# surprising optimizations -- ones that may be technically correct in the
405# strictest sense but also result in incorrect program behavior.  We turn
406# this optimization off, with extreme prejudice.
407#
408CCNOAGGRESSIVELOOPS= \
409	-_gcc7=-fno-aggressive-loop-optimizations \
410	-_gcc8=-fno-aggressive-loop-optimizations \
411	-_gcc9=-fno-aggressive-loop-optimizations
412
413# One optimization the compiler might perform is to turn this:
414#	#pragma weak foo
415#	extern int foo;
416#	if (&foo)
417#		foo = 5;
418# into
419#	foo = 5;
420# Since we do some of this (foo might be referenced in common kernel code
421# but provided only for some cpu modules or platforms), we disable this
422# optimization.
423#
424sparc_CCUNBOUND	= -Wd,-xsafe=unboundsym
425i386_CCUNBOUND	=
426CCUNBOUND	= $($(MACH)_CCUNBOUND)
427
428#
429# compiler '-xarch' flag. This is here to centralize it and make it
430# overridable for testing.
431sparc_XARCH=	-m32
432sparcv9_XARCH=	-m64
433i386_XARCH=	-m32
434amd64_XARCH=	-m64 -Ui386 -U__i386
435
436# assembler '-xarch' flag.  Different from compiler '-xarch' flag.
437sparc_AS_XARCH=		-xarch=v8plus
438sparcv9_AS_XARCH=	-xarch=v9
439i386_AS_XARCH=
440amd64_AS_XARCH=		-xarch=amd64 -P -Ui386 -U__i386
441
442#
443# These flags define what we need to be 'standalone' i.e. -not- part
444# of the rather more cosy userland environment.  This basically means
445# the kernel.
446#
447# XX64	future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
448#
449sparc_STAND_FLAGS=	-_gcc=-ffreestanding
450sparcv9_STAND_FLAGS=	-_gcc=-ffreestanding
451# Disabling MMX also disables 3DNow, disabling SSE also disables all later
452# additions to SSE (SSE2, AVX ,etc.)
453NO_SIMD=		-_gcc=-mno-mmx -_gcc=-mno-sse
454i386_STAND_FLAGS=	-_gcc=-ffreestanding $(NO_SIMD)
455amd64_STAND_FLAGS=	-xmodel=kernel $(NO_SIMD)
456
457SAVEARGS=		-Wu,-save_args
458amd64_STAND_FLAGS	+= $(SAVEARGS)
459
460STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
461STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
462
463#
464# disable the incremental linker
465ILDOFF=			-xildoff
466#
467XFFLAG=			-xF=%all
468XESS=			-xs
469XSTRCONST=		-xstrconst
470
471#
472# turn warnings into errors (C)
473CERRWARN = -errtags=yes -errwarn=%all
474CERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
475CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
476
477CERRWARN += -_gcc=-Wno-missing-braces
478CERRWARN += -_gcc=-Wno-sign-compare
479CERRWARN += -_gcc=-Wno-unknown-pragmas
480CERRWARN += -_gcc=-Wno-unused-parameter
481CERRWARN += -_gcc=-Wno-missing-field-initializers
482
483# Unfortunately, this option can misfire very easily and unfixably.
484CERRWARN +=	-_gcc=-Wno-array-bounds
485
486# gcc4 lacks -Wno-maybe-uninitialized
487CNOWARN_UNINIT = -_gcc4=-Wno-uninitialized \
488    -_gcc7=-Wno-maybe-uninitialized \
489    -_gcc8=-Wno-maybe-uninitialized \
490    -_gcc9=-Wno-maybe-uninitialized
491
492CERRWARN += -_smatch=-p=illumos_user
493include $(SRC)/Makefile.smatch
494
495#
496# turn warnings into errors (C++)
497CCERRWARN = -errtags=yes -errwarn=%all
498CCERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
499CCERRWARN += -erroff=E_STATEMENT_NOT_REACHED
500
501CCERRWARN += -_gcc=-Wno-missing-braces
502CCERRWARN += -_gcc=-Wno-sign-compare
503CCERRWARN += -_gcc=-Wno-unknown-pragmas
504CCERRWARN += -_gcc=-Wno-unused-parameter
505CCERRWARN += -_gcc=-Wno-missing-field-initializers
506
507# C standard.  Keep Studio flags until we get rid of lint.
508CSTD_GNU89=	-xc99=%none
509CSTD_GNU99=	-xc99=%all
510CSTD=		$(CSTD_GNU89)
511C99LMODE=	$(CSTD:-xc99%=-Xc99%)
512
513# In most places, assignments to these macros should be appended with +=
514# (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
515sparc_CFLAGS=	$(sparc_XARCH) $(CCSTATICSYM)
516sparcv9_CFLAGS=	$(sparcv9_XARCH) -dalign $(CCVERBOSE) $(V9ABIWARN) $(CCREGSYM) \
517		$(CCSTATICSYM)
518i386_CFLAGS=	$(i386_XARCH)
519amd64_CFLAGS=	$(amd64_XARCH)
520
521sparc_ASFLAGS=	$(sparc_AS_XARCH)
522sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
523i386_ASFLAGS=	$(i386_AS_XARCH)
524amd64_ASFLAGS=	$(amd64_AS_XARCH)
525
526#
527sparc_COPTFLAG=		-xO3
528sparcv9_COPTFLAG=	-xO3
529i386_COPTFLAG=		-O
530amd64_COPTFLAG=		-xO3
531
532COPTFLAG= $($(MACH)_COPTFLAG)
533COPTFLAG64= $($(MACH64)_COPTFLAG)
534
535# When -g is used, the compiler globalizes static objects
536# (gives them a unique prefix). Disable that.
537CNOGLOBAL= -W0,-noglobal
538
539# Direct the Sun Studio compiler to use a static globalization prefix based on the
540# name of the module rather than something unique. Otherwise, objects
541# will not build deterministically, as subsequent compilations of identical
542# source will yeild objects that always look different.
543#
544# In the same spirit, this will also remove the date from the N_OPT stab.
545CGLOBALSTATIC= -W0,-xglobalstatic
546
547# Sometimes we want all symbols and types in debugging information even
548# if they aren't used.
549CALLSYMS=	-W0,-xdbggen=no%usedonly
550
551#
552# We force the compilers to generate the debugging information best understood
553# by the CTF tools.  With Sun Studio this is stabs due to bugs in the Studio
554# compilers.  With GCC this is DWARF v2.
555#
556DEBUGFORMAT=	-_cc=-xdebugformat=stabs -_gcc=-gdwarf-2
557
558#
559# Ask the compiler to include debugging information
560#
561CCGDEBUG= -g $(DEBUGFORMAT)
562
563#
564# Flags used to build in debug mode for ctf generation.
565#
566CTF_FLAGS_sparc	= $(CCGDEBUG) -Wc,-Qiselect-T1 $(CSTD) $(CNOGLOBAL)
567CTF_FLAGS_i386	= $(CCGDEBUG) $(CSTD) $(CNOGLOBAL)
568
569CTF_FLAGS_sparcv9	= $(CTF_FLAGS_sparc)
570CTF_FLAGS_amd64		= $(CTF_FLAGS_i386)
571
572# Sun Studio produces broken userland code when saving arguments.
573$(__GNUC)CTF_FLAGS_amd64 += $(SAVEARGS)
574
575CTF_FLAGS_32	= $(CTF_FLAGS_$(MACH))
576CTF_FLAGS_64	= $(CTF_FLAGS_$(MACH64))
577CTF_FLAGS	= $(CTF_FLAGS_32)
578
579#
580# Flags used with genoffsets
581#
582GENOFFSETS_FLAGS = $(CALLSYMS)
583
584OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
585	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
586	$(CFLAGS) $(CPPFLAGS)
587
588OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
589	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
590	$(CFLAGS64) $(CPPFLAGS)
591
592#
593# tradeoff time for space (smaller is better)
594#
595sparc_SPACEFLAG		= -xspace -W0,-Lt
596sparcv9_SPACEFLAG	= -xspace -W0,-Lt
597i386_SPACEFLAG		= -xspace
598amd64_SPACEFLAG		=
599
600SPACEFLAG		= $($(MACH)_SPACEFLAG)
601SPACEFLAG64		= $($(MACH64)_SPACEFLAG)
602
603#
604# The Sun Studio 11 compiler has changed the behaviour of integer
605# wrap arounds and so a flag is needed to use the legacy behaviour
606# (without this flag panics/hangs could be exposed within the source).
607#
608sparc_IROPTFLAG		= -W2,-xwrap_int
609sparcv9_IROPTFLAG	= -W2,-xwrap_int
610i386_IROPTFLAG		=
611amd64_IROPTFLAG		=
612
613IROPTFLAG		= $($(MACH)_IROPTFLAG)
614IROPTFLAG64		= $($(MACH64)_IROPTFLAG)
615
616sparc_XREGSFLAG		= -xregs=no%appl
617sparcv9_XREGSFLAG	= -xregs=no%appl
618i386_XREGSFLAG		=
619amd64_XREGSFLAG		=
620
621XREGSFLAG		= $($(MACH)_XREGSFLAG)
622XREGSFLAG64		= $($(MACH64)_XREGSFLAG)
623
624# dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
625# avoids stripping it.
626SOURCEDEBUG	= $(POUND_SIGN)
627SRCDBGBLD	= $(SOURCEDEBUG:yes=)
628
629#
630# These variables are intended ONLY for use by developers to safely pass extra
631# flags to the compilers without unintentionally overriding Makefile-set
632# flags.  They should NEVER be set to any value in a Makefile.
633#
634# They come last in the associated FLAGS variable such that they can
635# explicitly override things if necessary, there are gaps in this, but it's
636# the best we can manage.
637#
638CUSERFLAGS		=
639CUSERFLAGS64		= $(CUSERFLAGS)
640CCUSERFLAGS		=
641CCUSERFLAGS64		= $(CCUSERFLAGS)
642
643CSOURCEDEBUGFLAGS	=
644CCSOURCEDEBUGFLAGS	=
645$(SRCDBGBLD)CSOURCEDEBUGFLAGS	= $(CCGDEBUG) -xs
646$(SRCDBGBLD)CCSOURCEDEBUGFLAGS	= $(CCGDEBUG) -xs
647
648CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
649		$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG) \
650		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
651		$(CCNOAGGRESSIVELOOPS) \
652		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
653CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
654		$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG64) \
655		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
656		$(CCNOAGGRESSIVELOOPS) \
657		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
658#
659# Flags that are used to build parts of the code that are subsequently
660# run on the build machine (also known as the NATIVE_BUILD).
661#
662NATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
663		$(ILDOFF) $(CERRWARN) $(CSTD) $($(NATIVE_MACH)_CCUNBOUND) \
664		$(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE) \
665		$(CCNOREORDER) $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
666
667NATIVE_CCFLAGS=	$(CCOPTFLAG) $($(NATIVE_MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
668		$(CCUSERFLAGS)
669
670DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
671DTS_ERRNO=-D_TS_ERRNO
672CPPFLAGS.first=	# Please keep empty.  Only lower makefiles should set this.
673CPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
674	$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
675	$(ADJUNCT_PROTO:%=-I%/usr/include)
676CPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
677		$(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
678CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
679AS_CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
680JAVAFLAGS=	-source 7 -target 7 -Xlint:deprecation,-options
681$(BLD_JAVA_11)JAVAFLAGS=	-source 7 -target 7 -Xlint:-options
682
683#
684# For source message catalogue
685#
686.SUFFIXES: $(SUFFIXES) .i .po
687MSGROOT= $(ROOT)/catalog
688MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
689MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
690DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
691DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
692
693CLOBBERFILES += $(POFILE) $(POFILES)
694COMPILE.cpp= $(CC) -E -C $(CFLAGS) $(CPPFLAGS)
695XGETTEXT= /usr/bin/xgettext
696XGETFLAGS= -c TRANSLATION_NOTE
697GNUXGETTEXT= /usr/gnu/bin/xgettext
698GNUXGETFLAGS= --add-comments=TRANSLATION_NOTE --keyword=_ \
699	--strict --no-location --omit-header
700BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
701	$(RM)	$@ ;\
702	$(SED) "/^domain/d" < $(<F).po > $@ ;\
703	$(RM) $(<F).po $<.i
704
705#
706# This is overwritten by local Makefile when PROG is a list.
707#
708POFILE= $(PROG).po
709
710sparc_CCFLAGS=		$(sparc_XARCH) -cg92 -compat=4 \
711			-Qoption ccfe -messages=no%anachronism \
712			$(CCERRWARN)
713sparcv9_CCFLAGS=	$(sparcv9_XARCH) -dalign -compat=5 \
714			-Qoption ccfe -messages=no%anachronism \
715			-Qoption ccfe -features=no%conststrings \
716			$(CCCREGSYM) \
717			$(CCERRWARN)
718i386_CCFLAGS=		$(i386_XARCH) -compat=4 \
719			-Qoption ccfe -messages=no%anachronism \
720			-Qoption ccfe -features=no%conststrings \
721			$(CCERRWARN)
722amd64_CCFLAGS=		$(amd64_XARCH) -compat=5 \
723			-Qoption ccfe -messages=no%anachronism \
724			-Qoption ccfe -features=no%conststrings \
725			$(CCERRWARN)
726
727sparc_CCOPTFLAG=	-O
728sparcv9_CCOPTFLAG=	-O
729i386_CCOPTFLAG=		-O
730amd64_CCOPTFLAG=	-O
731
732CCOPTFLAG=	$($(MACH)_CCOPTFLAG)
733CCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
734CCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
735		$(CCUSERFLAGS)
736CCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
737		$(CCUSERFLAGS64)
738
739#
740#
741#
742ELFWRAP_FLAGS	=
743ELFWRAP_FLAGS64	=	-64
744
745#
746# Various mapfiles that are used throughout the build, and delivered to
747# /usr/lib/ld.
748#
749MAPFILE.NED_i386 =	$(SRC)/common/mapfiles/common/map.noexdata
750MAPFILE.NED_sparc =
751MAPFILE.NED =		$(MAPFILE.NED_$(MACH))
752MAPFILE.PGA =		$(SRC)/common/mapfiles/common/map.pagealign
753MAPFILE.NES =		$(SRC)/common/mapfiles/common/map.noexstk
754MAPFILE.FLT =		$(SRC)/common/mapfiles/common/map.filter
755MAPFILE.LEX =		$(SRC)/common/mapfiles/common/map.lex.yy
756
757#
758# Generated mapfiles that are compiler specific, and used throughout the
759# build.  These mapfiles are not delivered in /usr/lib/ld.
760#
761MAPFILE.NGB_sparc=	$(SRC)/common/mapfiles/gen/sparc_cc_map.noexeglobs
762$(__GNUC64)MAPFILE.NGB_sparc= \
763			$(SRC)/common/mapfiles/gen/sparc_gcc_map.noexeglobs
764MAPFILE.NGB_sparcv9=	$(SRC)/common/mapfiles/gen/sparcv9_cc_map.noexeglobs
765$(__GNUC64)MAPFILE.NGB_sparcv9= \
766			$(SRC)/common/mapfiles/gen/sparcv9_gcc_map.noexeglobs
767MAPFILE.NGB_i386=	$(SRC)/common/mapfiles/gen/i386_cc_map.noexeglobs
768$(__GNUC64)MAPFILE.NGB_i386= \
769			$(SRC)/common/mapfiles/gen/i386_gcc_map.noexeglobs
770MAPFILE.NGB_amd64=	$(SRC)/common/mapfiles/gen/amd64_cc_map.noexeglobs
771$(__GNUC64)MAPFILE.NGB_amd64= \
772			$(SRC)/common/mapfiles/gen/amd64_gcc_map.noexeglobs
773MAPFILE.NGB =		$(MAPFILE.NGB_$(MACH))
774
775#
776# A generic interface mapfile name, used by various dynamic objects to define
777# the interfaces and interposers the object must export.
778#
779MAPFILE.INT =		mapfile-intf
780
781#
782# LDLIBS32 and LDLIBS64 can be set in the environment to override the following
783# assignments.
784#
785# These environment settings make sure that no libraries are searched outside
786# of the local workspace proto area:
787#	LDLIBS32=-YP,$ROOT/lib:$ROOT/usr/lib
788#	LDLIBS64=-YP,$ROOT/lib/$MACH64:$ROOT/usr/lib/$MACH64
789#
790LDLIBS32 =	$(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
791LDLIBS32 +=	$(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
792LDLIBS.cmd =	$(LDLIBS32)
793LDLIBS.lib =	$(LDLIBS32)
794
795LDLIBS64 =	$(ENVLDLIBS1:%=%/$(MACH64)) \
796		$(ENVLDLIBS2:%=%/$(MACH64)) \
797		$(ENVLDLIBS3:%=%/$(MACH64))
798LDLIBS64 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib/$(MACH64) -L%/lib/$(MACH64))
799
800#
801# Define compilation macros.
802#
803COMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
804COMPILE64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) -c
805COMPILE.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) -c
806COMPILE64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
807COMPILE.s=	$(AS) $(ASFLAGS) $(AS_CPPFLAGS)
808COMPILE64.s=	$(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
809COMPILE.d=	$(DTRACE) -G -32
810COMPILE64.d=	$(DTRACE) -G -64
811COMPILE.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
812COMPILE64.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
813
814CLASSPATH=	.
815COMPILE.java=	$(JAVAC) $(JAVAFLAGS) -classpath $(CLASSPATH)
816
817#
818# Link time macros
819#
820CCNEEDED		= -lC
821CCEXTNEEDED		= -lCrun -lCstd
822NATIVECCNEEDED		= -lC
823$(__GNUC)CCNEEDED	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
824$(__GNUC)CCEXTNEEDED	= $(CCNEEDED)
825$(__GNUC)NATIVECCNEEDED	= -R$(GCCLIBDIR) -L$(GCCLIBDIR) -lstdc++ -lgcc_s
826
827CCNEEDED64		= -lCrun
828CCEXTNEEDED64		= -lCrun -lCstd
829NATIVECCNEEDED64	= -lCrun
830$(__GNUC64)CCNEEDED64	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
831$(__GNUC64)NATIVECCNEEDED64 = -R$(GCCLIBDIR) -L$(GCCLIBDIR) -lstdc++ -lgcc_s
832$(__GNUC64)CCEXTNEEDED	= $(CCNEEDED64)
833
834# Libraries we expect to use natively on the build machine
835NATIVE_LIBS=
836
837LDCHECKS		= $(ZASSERTDEFLIB) $(ZGUIDANCE) $(ZFATALWARNINGS)
838LDCHECKS		+= $(NATIVE_LIBS:%=$(ZASSERTDEFLIB)=%)
839
840LINK.c=			$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
841LINK64.c=		$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
842NORUNPATH=		-norunpath -nolib
843LINK.cc=		$(CCC) $(CCFLAGS) $(CPPFLAGS) $(NORUNPATH) \
844			$(LDFLAGS) $(CCNEEDED) $(LDCHECKS)
845LINK64.cc=		$(CCC) $(CCFLAGS64) $(CPPFLAGS) $(NORUNPATH) \
846			$(LDFLAGS) $(CCNEEDED64) $(LDCHECKS)
847
848#
849# lint macros
850#
851# Note that the undefine of __PRAGMA_REDEFINE_EXTNAME can be removed once
852# ON is built with a version of lint that has the fix for 4484186.
853#
854ALWAYS_LINT_DEFS =	-errtags=yes -s
855ALWAYS_LINT_DEFS +=	-erroff=E_PTRDIFF_OVERFLOW
856ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_NARROW_CONV
857ALWAYS_LINT_DEFS +=	-U__PRAGMA_REDEFINE_EXTNAME
858ALWAYS_LINT_DEFS +=	$(C99LMODE)
859ALWAYS_LINT_DEFS +=	-errsecurity=$(SECLEVEL)
860ALWAYS_LINT_DEFS +=	-erroff=E_SEC_CREAT_WITHOUT_EXCL
861ALWAYS_LINT_DEFS +=	-erroff=E_SEC_FORBIDDEN_WARN_CREAT
862# XX64 -- really only needed for amd64 lint
863ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_INT_TO_SMALL_INT
864ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_CONST_TO_SMALL_INT
865ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_TO_SMALL_INT
866ALWAYS_LINT_DEFS +=	-erroff=E_CAST_TO_PTR_FROM_INT
867ALWAYS_LINT_DEFS +=	-erroff=E_COMP_INT_WITH_LARGE_INT
868ALWAYS_LINT_DEFS +=	-erroff=E_INTEGRAL_CONST_EXP_EXPECTED
869ALWAYS_LINT_DEFS +=	-erroff=E_PASS_INT_TO_SMALL_INT
870ALWAYS_LINT_DEFS +=	-erroff=E_PTR_CONV_LOSES_BITS
871
872# This forces lint to pick up note.h and sys/note.h from Devpro rather than
873# from the proto area.  The note.h that ON delivers would disable NOTE().
874ONLY_LINT_DEFS =	-I$(SPRO_VROOT)/prod/include/lint
875
876SECLEVEL=	core
877LINT.c=		$(LINT) $(ONLY_LINT_DEFS) $(LINTFLAGS) $(CPPFLAGS) \
878		$(ALWAYS_LINT_DEFS)
879LINT64.c=	$(LINT) $(ONLY_LINT_DEFS) $(LINTFLAGS64) $(CPPFLAGS) \
880		$(ALWAYS_LINT_DEFS)
881LINT.s=		$(LINT.c)
882
883# For some future builds, NATIVE_MACH and MACH might be different.
884# Therefore, NATIVE_MACH needs to be redefined in the
885# environment as `uname -p` to override this macro.
886#
887# For now at least, we cross-compile amd64 on i386 machines.
888NATIVE_MACH=	$(MACH:amd64=i386)
889NATIVE_MACH64=	$(MACH64)
890
891# Define native compilation macros
892#
893
894# Base directory where compilers are loaded.
895# Defined here so it can be overridden by developer.
896#
897SPRO_ROOT=		$(BUILD_TOOLS)/SUNWspro
898SPRO_VROOT=		$(SPRO_ROOT)/SS12
899GNU_ROOT=		/usr
900
901$(__GNUC)PRIMARY_CC=	gcc7,$(GNUC_ROOT)/bin/gcc,gnu
902$(__SUNC)PRIMARY_CC=	studio12,$(SPRO_VROOT)/bin/cc,sun
903$(__GNUC)PRIMARY_CCC=	gcc7,$(GNUC_ROOT)/bin/g++,gnu
904$(__SUNC)PRIMARY_CCC=	studio12,$(SPRO_VROOT)/bin/CC,sun
905
906CW_CC_COMPILERS=	$(PRIMARY_CC:%=--primary %) $(SHADOW_CCS:%=--shadow %)
907CW_CCC_COMPILERS=	$(PRIMARY_CCC:%=--primary %) $(SHADOW_CCCS:%=--shadow %)
908
909CW_LINKER=		--linker $(LD)
910
911# Till SS12u1 formally becomes the NV CBE, LINT is hard
912# coded to be picked up from the $SPRO_ROOT/sunstudio12.1/
913# location. Impacted variables are sparc_LINT, sparcv9_LINT,
914# i386_LINT, amd64_LINT.
915# Reset them when SS12u1 is rolled out.
916#
917
918# Specify platform compiler versions for languages
919# that we use (currently only c and c++).
920#
921CW=			$(ONBLD_TOOLS)/bin/$(MACH)/cw
922
923BUILD_CC=		$(CW) $(CW_LINKER) $(CW_CC_COMPILERS) --
924BUILD_CCC=		$(CW) -C $(CW_LINKER) $(CW_CCC_COMPILERS) --
925BUILD_CPP=		/usr/ccs/lib/cpp
926BUILD_LD=		$(ONBLD_TOOLS)/bin/$(MACH)/ld
927BUILD_LINT=		$(SPRO_ROOT)/sunstudio12.1/bin/lint
928
929$(MACH)_CC=		$(BUILD_CC)
930$(MACH)_CCC=		$(BUILD_CCC)
931$(MACH)_CPP=		$(BUILD_CPP)
932$(MACH)_LD=		$(BUILD_LD)
933$(MACH)_LINT=		$(BUILD_LINT)
934$(MACH64)_CC=		$(BUILD_CC)
935$(MACH64)_CCC=		$(BUILD_CCC)
936$(MACH64)_CPP=		$(BUILD_CPP)
937$(MACH64)_LD=		$(BUILD_LD)
938$(MACH64)_LINT=		$(BUILD_LINT)
939
940sparc_AS=		/usr/ccs/bin/as -xregsym=no
941sparcv9_AS=		$($(MACH)_AS)
942
943i386_AS=		/usr/ccs/bin/as
944$(__GNUC)i386_AS=	$(ONBLD_TOOLS)/bin/$(MACH)/aw
945amd64_AS=		$(ONBLD_TOOLS)/bin/$(MACH)/aw
946
947NATIVECC=		$($(NATIVE_MACH)_CC)
948NATIVECCC=		$($(NATIVE_MACH)_CCC)
949NATIVECPP=		$($(NATIVE_MACH)_CPP)
950NATIVEAS=		$($(NATIVE_MACH)_AS)
951NATIVELD=		$($(NATIVE_MACH)_LD)
952NATIVELINT=		$($(NATIVE_MACH)_LINT)
953
954NATIVECC64=		$($(NATIVE_MACH64)_CC)
955NATIVECCC64=		$($(NATIVE_MACH64)_CCC)
956NATIVECPP64=		$($(NATIVE_MACH64)_CPP)
957NATIVEAS64=		$($(NATIVE_MACH64)_AS)
958NATIVELD64=		$($(NATIVE_MACH64)_LD)
959NATIVELINT64=		$($(NATIVE_MACH64)_LINT)
960
961#
962# Makefile.master.64 overrides these settings
963#
964CC=			$(NATIVECC)
965CCC=			$(NATIVECCC)
966CPP=			$(NATIVECPP)
967AS=			$(NATIVEAS)
968LD=			$(NATIVELD)
969LINT=			$(NATIVELINT)
970
971CC64=			$(NATIVECC64)
972CCC64=			$(NATIVECCC64)
973CPP64=			$(NATIVECPP64)
974AS64=			$(NATIVEAS64)
975LD64=			$(NATIVELD64)
976LINT64=			$(NATIVELINT64)
977
978# Pass -Y flag to cpp (method of which is release-dependent)
979CCYFLAG=		-Y I,
980
981BDIRECT=	-Wl,-Bdirect
982BDYNAMIC=	-Wl,-Bdynamic
983BLOCAL=		-Wl,-Blocal
984BNODIRECT=	-Wl,-Bnodirect
985BREDUCE=	-Wl,-Breduce
986BSTATIC=	-Wl,-Bstatic
987BSYMBOLIC=	-Wl,-Bsymbolic
988
989ZDEFS=		-Wl,-zdefs
990ZDIRECT=	-Wl,-zdirect
991ZIGNORE=	-Wl,-zignore
992ZINITFIRST=	-Wl,-zinitfirst
993ZINTERPOSE=	-Wl,-zinterpose
994ZLAZYLOAD=	-Wl,-zlazyload
995ZLOADFLTR=	-Wl,-zloadfltr
996ZMULDEFS=	-Wl,-zmuldefs
997ZNODEFAULTLIB=	-Wl,-znodefaultlib
998ZNODEFS=	-Wl,-znodefs
999ZNODELETE=	-Wl,-znodelete
1000ZNODLOPEN=	-Wl,-znodlopen
1001ZNODUMP=	-Wl,-znodump
1002ZNOLAZYLOAD=	-Wl,-znolazyload
1003ZNOLDYNSYM=	-Wl,-znoldynsym
1004ZNORELOC=	-Wl,-znoreloc
1005ZNOVERSION=	-Wl,-znoversion
1006ZRECORD=	-Wl,-zrecord
1007ZREDLOCSYM=	-Wl,-zredlocsym
1008ZTEXT=		-Wl,-ztext
1009ZVERBOSE=	-Wl,-zverbose
1010ZASSERTDEFLIB=	-Wl,-zassert-deflib
1011ZGUIDANCE=	-Wl,-zguidance
1012ZFATALWARNINGS=	-Wl,-zfatal-warnings
1013
1014GSHARED=	-shared
1015CCMT=		-mt
1016
1017# Handle different PIC models on different ISAs
1018# (May be overridden by lower-level Makefiles)
1019
1020sparc_C_PICFLAGS =	-fpic
1021sparcv9_C_PICFLAGS =	-fpic
1022i386_C_PICFLAGS =	-fpic
1023amd64_C_PICFLAGS =	-fpic
1024C_PICFLAGS =		$($(MACH)_C_PICFLAGS)
1025C_PICFLAGS64 =		$($(MACH64)_C_PICFLAGS)
1026
1027sparc_C_BIGPICFLAGS =	-fPIC
1028sparcv9_C_BIGPICFLAGS =	-fPIC
1029i386_C_BIGPICFLAGS =	-fPIC
1030amd64_C_BIGPICFLAGS =	-fPIC
1031C_BIGPICFLAGS =		$($(MACH)_C_BIGPICFLAGS)
1032C_BIGPICFLAGS64 =	$($(MACH64)_C_BIGPICFLAGS)
1033
1034# CC requires there to be no space between '-K' and 'pic' or 'PIC'.
1035# and does not support -f
1036sparc_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
1037sparcv9_CC_PICFLAGS =	-_cc=-KPIC -_gcc=-fPIC
1038i386_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
1039amd64_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
1040CC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
1041CC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)
1042
1043AS_PICFLAGS=		-K pic
1044AS_BIGPICFLAGS=		-K PIC
1045
1046#
1047# Default label for CTF sections
1048#
1049CTFCVTFLAGS=		-L VERSION
1050
1051#
1052# Override to pass module-specific flags to ctfmerge.  Currently used only by
1053# krtld to turn on fuzzy matching, and source-level debugging to inhibit
1054# stripping.
1055#
1056CTFMRGFLAGS=
1057
1058CTFCONVERT_O		= $(CTFCONVERT) $(CTFCVTFLAGS) $@
1059
1060# Rules (normally from make.rules) and macros which are used for post
1061# processing files. Normally, these do stripping of the comment section
1062# automatically.
1063#    RELEASE_CM:	Should be edited to reflect the release.
1064#    POST_PROCESS_O:	Post-processing for `.o' files (typically C source)
1065#    POST_PROCESS_S_O:	Post-processing for `.o' files built from asssembly
1066#    POST_PROCESS_CC_O:	Post-processing for `.o' files built from C++
1067#    POST_PROCESS_A:		Post-processing for `.a' files (currently null).
1068#    POST_PROCESS_SO:	Post-processing for `.so' files.
1069#    POST_PROCESS:	Post-processing for executable files (no suffix).
1070#
1071# Note that these macros are not completely generalized as they are to be
1072# used with the file name to be processed following.
1073#
1074# It is left as an exercise to Release Engineering to embellish the generation
1075# of the release comment string.
1076#
1077#	If this is a standard development build:
1078#		compress the comment section (mcs -c)
1079#		add the standard comment (mcs -a $(RELEASE_CM))
1080#		add the development specific comment (mcs -a $(DEV_CM))
1081#
1082#	If this is an installation build:
1083#		delete the comment section (mcs -d)
1084#		add the standard comment (mcs -a $(RELEASE_CM))
1085#		add the development specific comment (mcs -a $(DEV_CM))
1086#
1087#	If this is an release build:
1088#		delete the comment section (mcs -d)
1089#		add the standard comment (mcs -a $(RELEASE_CM))
1090#
1091# The following list of macros are used in the definition of RELEASE_CM
1092# which is used to label all binaries in the build:
1093#
1094#	RELEASE		Specific release of the build, eg: 5.2
1095#	RELEASE_MAJOR	Major version number part of $(RELEASE)
1096#	RELEASE_MINOR	Minor version number part of $(RELEASE)
1097#	VERSION		Version of the build (alpha, beta, Generic)
1098#	PATCHID		If this is a patch this value should contain
1099#			the patchid value (eg: "Generic 100832-01"), otherwise
1100#			it will be set to $(VERSION)
1101#	RELEASE_DATE	Date of the Release Build
1102#	PATCH_DATE	Date the patch was created, if this is blank it
1103#			will default to the RELEASE_DATE
1104#
1105RELEASE_MAJOR=	5
1106RELEASE_MINOR=	11
1107RELEASE=	$(RELEASE_MAJOR).$(RELEASE_MINOR)
1108VERSION=	SunOS Development
1109PATCHID=	$(VERSION)
1110RELEASE_DATE=	release date not set
1111PATCH_DATE=	$(RELEASE_DATE)
1112RELEASE_CM=	"@($(POUND_SIGN))illumos $(PATCHID) $(PATCH_DATE)"
1113DEV_CM_TAIL=	development build: $(LOGNAME)
1114DEV_CM=		"@($(POUND_SIGN))illumos $(DEV_CM_TAIL)"
1115UTS_LABEL=	$(RELEASE)
1116
1117#
1118# The boot banner may be overridden by distributions.  Up to five lines can be
1119# specified by overriding the BOOTBANNER macros, and any line that expands to
1120# an empty string will not be printed.  See comments in
1121# bootbanner_expand_template() for more details about the template string
1122# format.
1123#
1124BOOTBANNER1=	^o Version ^v ^w-bit
1125BOOTBANNER2=
1126BOOTBANNER3=
1127BOOTBANNER4=
1128BOOTBANNER5=
1129
1130PROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
1131$(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
1132
1133STRIP_STABS=			   $(STRIP) -x $@
1134$(SRCDBGBLD)STRIP_STABS=	   :
1135
1136POST_PROCESS_O=
1137POST_PROCESS_S_O=
1138POST_PROCESS_CC_O=
1139POST_PROCESS_A=
1140POST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
1141			$(ELFSIGN_OBJECT)
1142POST_PROCESS=		$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
1143			$(ELFSIGN_OBJECT)
1144
1145#
1146# chk4ubin is a tool that inspects a module for a symbol table
1147# ELF section size which can trigger an OBP bug on older platforms.
1148# This problem affects only specific sun4u bootable modules.
1149#
1150CHK4UBIN=	$(ONBLD_TOOLS)/bin/$(MACH)/chk4ubin
1151CHK4UBINFLAGS=
1152CHK4UBINARY=	$(CHK4UBIN) $(CHK4UBINFLAGS) $@
1153
1154#
1155# PKGARCHIVE specifies the default location where packages should be
1156# placed if built.
1157#
1158$(RELEASE_BUILD)PKGARCHIVESUFFIX=	-nd
1159PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly$(PKGARCHIVESUFFIX)
1160
1161#
1162# The repositories will be created with these publisher settings.  To
1163# update an image to the resulting repositories, this must match the
1164# publisher name provided to "pkg set-publisher."
1165#
1166PKGPUBLISHER_REDIST=	on-nightly
1167PKGPUBLISHER_NONREDIST=	on-extra
1168
1169#	Default build rules which perform comment section post-processing.
1170#
1171.c:
1172	$(LINK.c) -o $@ $< $(LDLIBS)
1173	$(POST_PROCESS)
1174.c.o:
1175	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
1176	$(POST_PROCESS_O)
1177.c.a:
1178	$(COMPILE.c) -o $% $<
1179	$(PROCESS_COMMENT) $%
1180	$(AR) $(ARFLAGS) $@ $%
1181	$(RM) $%
1182.s.o:
1183	$(COMPILE.s) -o $@ $<
1184	$(POST_PROCESS_S_O)
1185.s.a:
1186	$(COMPILE.s) -o $% $<
1187	$(PROCESS_COMMENT) $%
1188	$(AR) $(ARFLAGS) $@ $%
1189	$(RM) $%
1190.cc:
1191	$(LINK.cc) -o $@ $< $(LDLIBS)
1192	$(POST_PROCESS)
1193.cc.o:
1194	$(COMPILE.cc) $(OUTPUT_OPTION) $<
1195	$(POST_PROCESS_CC_O)
1196.cc.a:
1197	$(COMPILE.cc) -o $% $<
1198	$(AR) $(ARFLAGS) $@ $%
1199	$(PROCESS_COMMENT) $%
1200	$(RM) $%
1201.y:
1202	$(YACC.y) $<
1203	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
1204	$(POST_PROCESS)
1205	$(RM) y.tab.c
1206.y.o:
1207	$(YACC.y) $<
1208	$(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
1209	$(POST_PROCESS_O)
1210	$(RM) y.tab.c
1211.l:
1212	$(RM) $*.c
1213	$(LEX.l) $< > $*.c
1214	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
1215	$(POST_PROCESS)
1216	$(RM) $*.c
1217.l.o:
1218	$(RM) $*.c
1219	$(LEX.l) $< > $*.c
1220	$(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
1221	$(POST_PROCESS_O)
1222	$(RM) $*.c
1223
1224.bin.o:
1225	$(COMPILE.b) -o $@ $<
1226	$(POST_PROCESS_O)
1227
1228.java.class:
1229	$(COMPILE.java) $<
1230
1231# Bourne and Korn shell script message catalog build rules.
1232# We extract all gettext strings with sed(1) (being careful to permit
1233# multiple gettext strings on the same line), weed out the dups, and
1234# build the catalogue with awk(1).
1235
1236.sh.po .ksh.po:
1237	$(SED) -n -e ":a"					\
1238		  -e "h"					\
1239		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
1240		  -e "x"					\
1241		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
1242		  -e "t a"					\
1243	       $< | sort -u | $(AWK) '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
1244
1245#
1246# Python and Perl executable and message catalog build rules.
1247#
1248.SUFFIXES: .pl .pm .py .pyc
1249
1250.pl:
1251	$(RM) $@;
1252	$(SED) -e "s@TEXT_DOMAIN@\"$(TEXT_DOMAIN)\"@" $< > $@;
1253	$(CHMOD) +x $@
1254
1255.py:
1256	$(RM) $@; $(SED) \
1257		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
1258		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
1259		< $< > $@; $(CHMOD) +x $@
1260
1261.py.pyc:
1262	$(RM) $@
1263	$(PYTHON) -mpy_compile $<
1264	@[ $(<)c = $@ ] || $(MV) $(<)c $@
1265
1266.py.po:
1267	$(GNUXGETTEXT) $(GNUXGETFLAGS) -d $(<F:%.py=%) $< ;
1268
1269.pl.po .pm.po:
1270	$(XGETTEXT) $(XGETFLAGS) -d $(<F) $< ;
1271	$(RM)	$@ ;
1272	$(SED) "/^domain/d" < $(<F).po > $@ ;
1273	$(RM) $(<F).po
1274
1275#
1276# When using xgettext, we want messages to go to the default domain,
1277# rather than the specified one.  This special version of the
1278# COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
1279# causing xgettext to put all messages into the default domain.
1280#
1281CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
1282
1283.c.i:
1284	$(CPPFORPO) $< > $@
1285
1286.h.i:
1287	$(CPPFORPO) $< > $@
1288
1289.y.i:
1290	$(YACC) -d $<
1291	$(CPPFORPO) y.tab.c  > $@
1292	$(RM) y.tab.c
1293
1294.l.i:
1295	$(LEX) $<
1296	$(CPPFORPO) lex.yy.c  > $@
1297	$(RM) lex.yy.c
1298
1299.c.po:
1300	$(CPPFORPO) $< > $<.i
1301	$(BUILD.po)
1302
1303.cc.po:
1304	$(CPPFORPO) $< > $<.i
1305	$(BUILD.po)
1306
1307.y.po:
1308	$(YACC) -d $<
1309	$(CPPFORPO) y.tab.c  > $<.i
1310	$(BUILD.po)
1311	$(RM) y.tab.c
1312
1313.l.po:
1314	$(LEX) $<
1315	$(CPPFORPO) lex.yy.c  > $<.i
1316	$(BUILD.po)
1317	$(RM) lex.yy.c
1318
1319#
1320# Rules to perform stylistic checks
1321#
1322.SUFFIXES: .x .xml .check .xmlchk
1323
1324.h.check:
1325	$(DOT_H_CHECK)
1326
1327.x.check:
1328	$(DOT_X_CHECK)
1329
1330.xml.xmlchk:
1331	$(MANIFEST_CHECK)
1332