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