xref: /illumos-gate/usr/src/Makefile.master (revision 2aeafac3)
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# Compatibility code for FreeBSD etc.
62#
63COMPAT=	$(SRC)/compat
64CONTRIB= $(SRC)/../contrib
65
66#
67# RELEASE_BUILD should be cleared for final release builds.
68# NOT_RELEASE_BUILD is exactly what the name implies.
69#
70# __GNUC toggles the building of ON components using gcc and related tools.
71# Normally set to `#', set it to `' to do gcc build.
72#
73# The declaration POUND_SIGN is always '#'. This is needed to get around the
74# make feature that '#' is always a comment delimiter, even when escaped or
75# quoted. We use this macro expansion method to get POUND_SIGN rather than
76# always breaking out a shell because the general case can cause a noticable
77# slowdown in build times when so many Makefiles include Makefile.master.
78#
79# While the majority of users are expected to override the setting below
80# with an env file (via nightly or bldenv), if you aren't building that way
81# (ie, you're using "ws" or some other bootstrapping method) then you need
82# this definition in order to avoid the subshell invocation mentioned above.
83#
84
85PRE_POUND=				pre\#
86POUND_SIGN=				$(PRE_POUND:pre\%=%)
87
88NOT_RELEASE_BUILD=
89RELEASE_BUILD=				$(POUND_SIGN)
90$(RELEASE_BUILD)NOT_RELEASE_BUILD=	$(POUND_SIGN)
91PATCH_BUILD=				$(POUND_SIGN)
92
93# SPARC_BLD is '#' for an Intel build.
94# INTEL_BLD is '#' for a Sparc build.
95SPARC_BLD_1=    $(MACH:i386=$(POUND_SIGN))
96SPARC_BLD=      $(SPARC_BLD_1:sparc=)
97INTEL_BLD_1=    $(MACH:sparc=$(POUND_SIGN))
98INTEL_BLD=      $(INTEL_BLD_1:i386=)
99
100# The variables below control the compilers used during the build.
101# There are a number of permutations.
102#
103# __GNUC and __SUNC control (and indicate) the primary compiler.  Whichever
104# one is not POUND_SIGN is the primary, with the other as the shadow.  They
105# may also be used to control entirely compiler-specific Makefile assignments.
106# __GNUC and GCC are the default.
107#
108# __GNUC64 indicates that the 64bit build should use the GNU C compiler.
109# There is no Sun C analogue.
110#
111# The following version-specific options are operative regardless of which
112# compiler is primary, and control the versions of the given compilers to be
113# used.  They also allow compiler-version specific Makefile fragments.
114#
115
116__SUNC=			$(POUND_SIGN)
117$(__SUNC)__GNUC=	$(POUND_SIGN)
118__GNUC64=		$(__GNUC)
119
120# Allow build-time "configuration" to enable or disable some things.
121# The default is POUND_SIGN, meaning "not enabled". If the environment
122# passes in an override like ENABLE_SMB_PRINTING= (empty) that will
123# uncomment things in the lower Makefiles to enable the feature.
124ENABLE_SMB_PRINTING=	$(POUND_SIGN)
125
126# CLOSED is the root of the tree that contains source which isn't released
127# as open source
128CLOSED=		$(SRC)/../closed
129
130# BUILD_TOOLS is the root of all tools including compilers.
131# ONBLD_TOOLS is the root of all the tools that are part of SUNWonbld.
132
133BUILD_TOOLS=		/ws/onnv-tools
134ONBLD_TOOLS=		$(BUILD_TOOLS)/onbld
135
136# define runtime JAVA_HOME, primarily for cmd/pools/poold
137JAVA_HOME=	/usr/java
138# define buildtime JAVA_ROOT
139JAVA_ROOT=	/usr/java
140# Build uses java7 by default.  Pass one the variables below set to empty
141# string in the environment to override.
142BLD_JAVA_6=	$(POUND_SIGN)
143BLD_JAVA_8=	$(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
196JAVAH=		$(JAVA_ROOT)/bin/javah
197JAVADOC=	$(JAVA_ROOT)/bin/javadoc
198RMIC=		$(JAVA_ROOT)/bin/rmic
199JAR=		$(JAVA_ROOT)/bin/jar
200CTFCONVERT=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfconvert
201CTFDIFF=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfdiff
202CTFMERGE=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfmerge
203CTFSTABS=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
204CTFSTRIP=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstrip
205NDRGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/ndrgen
206GENOFFSETS=	$(ONBLD_TOOLS)/bin/genoffsets
207XREF=		$(ONBLD_TOOLS)/bin/xref
208FIND=		/usr/bin/find
209PERL=		/usr/bin/perl
210PERL_VERSION=	5.10.0
211PERL_PKGVERS=	-510
212PERL_MACH=	i86pc
213$(SPARC_BLD)PERL_MACH=	sun4
214PERL_VARIANT=
215PERL_ARCH=	$(PERL_MACH)-solaris$(PERL_VARIANT)-64int
216PERL_ARCH64=	$(PERL_MACH)-solaris$(PERL_VARIANT)-64
217PYTHON_VERSION=	2.7
218PYTHON_PKGVERS=	-27
219PYTHON_SUFFIX=
220PYTHON=		/usr/bin/python$(PYTHON_VERSION)
221PYTHON3_VERSION=	3.5
222PYTHON3_PKGVERS=	-35
223PYTHON3_SUFFIX=		m
224PYTHON3=		/usr/bin/python$(PYTHON3_VERSION)
225$(BUILDPY3TOOLS)TOOLS_PYTHON=		$(PYTHON3)
226$(BUILDPY2TOOLS)TOOLS_PYTHON=		$(PYTHON)
227SORT=		/usr/bin/sort
228TR=		/usr/bin/tr
229TOUCH=		/usr/bin/touch
230WC=		/usr/bin/wc
231XARGS=		/usr/bin/xargs
232ELFEDIT=	/usr/bin/elfedit
233DTRACE=		/usr/sbin/dtrace -xnolibs
234UNIQ=		/usr/bin/uniq
235TAR=		/usr/bin/tar
236ASTBINDIR=	/usr/ast/bin
237MSGCC=		$(ASTBINDIR)/msgcc
238MSGFMT=		/usr/bin/msgfmt -s
239LCDEF=		$(ONBLD_TOOLS)/bin/$(MACH)/localedef
240TIC=		$(ONBLD_TOOLS)/bin/$(MACH)/tic
241ZIC=		$(ONBLD_TOOLS)/bin/$(MACH)/zic
242OPENSSL=	/usr/bin/openssl
243CPCGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/cpcgen
244
245DEFAULT_CONSOLE_COLOR=					\
246	-DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_WHITE	\
247	-DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_BLACK
248
249FILEMODE=	644
250DIRMODE=	755
251
252# Declare that nothing should be built in parallel.
253# Individual Makefiles can use the .PARALLEL target to declare otherwise.
254.NO_PARALLEL:
255
256# For stylistic checks
257#
258# Note that the X and C checks are not used at this time and may need
259# modification when they are actually used.
260#
261CSTYLE=		$(ONBLD_TOOLS)/bin/cstyle
262CSTYLE_TAIL=
263HDRCHK=		$(ONBLD_TOOLS)/bin/hdrchk
264HDRCHK_TAIL=
265JSTYLE=		$(ONBLD_TOOLS)/bin/jstyle
266
267DOT_H_CHECK=	\
268	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
269	$(HDRCHK) $< $(HDRCHK_TAIL)
270
271DOT_X_CHECK=	\
272	@$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
273	$(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)
274
275DOT_C_CHECK=	\
276	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)
277
278MANIFEST_CHECK=	\
279	@$(ECHO) "checking $<"; \
280	SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
281	SVCCFG_REPOSITORY=$(SRC)/cmd/svc/seed/global.db \
282	SVCCFG_CONFIGD_PATH=$(SRC)/cmd/svc/configd/svc.configd-native \
283	$(SRC)/cmd/svc/svccfg/svccfg-native validate $<
284
285INS.file=	$(RM) $@; $(INS) -s -m $(FILEMODE) -f $(@D) $<
286INS.dir=	$(INS) -s -d -m $(DIRMODE) $@
287# installs and renames at once
288#
289INS.rename=	$(INS.file); $(MV) $(@D)/$(<F) $@
290
291# install a link
292INSLINKTARGET=	$<
293INS.link=	$(RM) $@; $(LN) $(INSLINKTARGET) $@
294INS.symlink=	$(RM) $@; $(SYMLINK) $(INSLINKTARGET) $@
295
296# The path to python that will be used for the shebang line when installing
297# python scripts to the proto area. This is overridden by makefiles to
298# select to the correct version.
299PYSHEBANG=	$(PYTHON)
300$(BUILDPY3)PYSHEBANG=	$(PYTHON3)
301$(BUILDPY2)PYSHEBANG=	$(PYTHON)
302
303#
304# Python bakes the mtime of the .py file into the compiled .pyc and
305# rebuilds if the baked-in mtime != the mtime of the source file
306# (rather than only if it's less than), thus when installing python
307# files we must make certain to not adjust the mtime of the source
308# (.py) file.
309#
310INS.pyfile=	$(RM) $@; $(SED) \
311		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
312		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
313		< $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@
314
315# MACH must be set in the shell environment per uname -p on the build host
316# More specific architecture variables should be set in lower makefiles.
317#
318# MACH64 is derived from MACH, and BUILD64 is set to `#' for
319# architectures on which we do not build 64-bit versions.
320# (There are no such architectures at the moment.)
321#
322# Set BUILD64=# in the environment to disable 64-bit amd64
323# builds on i386 machines.
324
325MACH64_1=	$(MACH:sparc=sparcv9)
326MACH64=		$(MACH64_1:i386=amd64)
327
328MACH32_1=	$(MACH:sparc=sparcv7)
329MACH32=		$(MACH32_1:i386=i86)
330
331sparc_BUILD64=
332i386_BUILD64=
333BUILD64=	$($(MACH)_BUILD64)
334
335#
336# C compiler mode. Future compilers may change the default on us,
337# so force extended ANSI mode globally. Lower level makefiles can
338# override this by setting CCMODE.
339#
340CCMODE=			-Xa
341CCMODE64=		-Xa
342
343#
344# C compiler verbose mode. This is so we can enable it globally,
345# but turn it off in the lower level makefiles of things we cannot
346# (or aren't going to) fix.
347#
348CCVERBOSE=		-v
349
350# set this to the secret flag "-Wc,-Qiselect-v9abiwarn=1" to get warnings
351# from the compiler about places the -xarch=v9 may differ from -xarch=v9c.
352V9ABIWARN=
353
354# set this to the secret flag "-Wc,-Qiselect-regsym=0" to disable register
355# symbols (used to detect conflicts between objects that use global registers)
356# we disable this now for safety, and because genunix doesn't link with
357# this feature (the v9 default) enabled.
358#
359# REGSYM is separate since the C++ driver syntax is different.
360CCREGSYM=		-Wc,-Qiselect-regsym=0
361CCCREGSYM=		-Qoption cg -Qiselect-regsym=0
362
363# Prevent the removal of static symbols by the SPARC code generator (cg).
364# The x86 code generator (ube) does not remove such symbols and as such
365# using this workaround is not applicable for x86.
366#
367CCSTATICSYM=		-Wc,-Qassembler-ounrefsym=0
368#
369# generate 32-bit addresses in the v9 kernel. Saves memory.
370CCABS32=		-Wc,-xcode=abs32
371#
372# generate v9 code which tolerates callers using the v7 ABI, for the sake of
373# system calls.
374CC32BITCALLERS=		-_gcc=-massume-32bit-callers
375
376# GCC, especially, is increasingly beginning to auto-inline functions and
377# sadly does so separately not under the general -fno-inline-functions
378# Additionally, we wish to prevent optimisations which cause GCC to clone
379# functions -- in particular, these may cause unhelpful symbols to be
380# emitted instead of function names
381CCNOAUTOINLINE= \
382	-_gcc=-fno-inline-small-functions \
383	-_gcc=-fno-inline-functions-called-once \
384	-_gcc=-fno-ipa-cp \
385	-_gcc7=-fno-ipa-icf \
386	-_gcc8=-fno-ipa-icf \
387	-_gcc9=-fno-ipa-icf \
388	-_gcc7=-fno-clone-functions \
389	-_gcc8=-fno-clone-functions \
390	-_gcc9=-fno-clone-functions
391
392# GCC may put functions in different named sub-sections of .text based on
393# their presumed calling frequency.  At least in the kernel, where we actually
394# deliver relocatable objects, we don't want this to happen.
395#
396# Since at present we don't benefit from this even in userland, we disable it globally,
397# but the application of this may move into usr/src/uts/ in future.
398CCNOREORDER=	\
399	-_gcc7=-fno-reorder-functions \
400	-_gcc8=-fno-reorder-functions \
401	-_gcc9=-fno-reorder-functions
402
403#
404# gcc has a rather aggressive optimization on by default that infers loop
405# bounds based on undefined behavior (!!).  This can lead to some VERY
406# surprising optimizations -- ones that may be technically correct in the
407# strictest sense but also result in incorrect program behavior.  We turn
408# this optimization off, with extreme prejudice.
409#
410CCNOAGGRESSIVELOOPS= \
411	-_gcc7=-fno-aggressive-loop-optimizations \
412	-_gcc8=-fno-aggressive-loop-optimizations \
413	-_gcc9=-fno-aggressive-loop-optimizations
414
415# One optimization the compiler might perform is to turn this:
416#	#pragma weak foo
417#	extern int foo;
418#	if (&foo)
419#		foo = 5;
420# into
421#	foo = 5;
422# Since we do some of this (foo might be referenced in common kernel code
423# but provided only for some cpu modules or platforms), we disable this
424# optimization.
425#
426sparc_CCUNBOUND	= -Wd,-xsafe=unboundsym
427i386_CCUNBOUND	=
428CCUNBOUND	= $($(MACH)_CCUNBOUND)
429
430#
431# compiler '-xarch' flag. This is here to centralize it and make it
432# overridable for testing.
433sparc_XARCH=	-m32
434sparcv9_XARCH=	-m64
435i386_XARCH=	-m32
436amd64_XARCH=	-m64 -Ui386 -U__i386
437
438# assembler '-xarch' flag.  Different from compiler '-xarch' flag.
439sparc_AS_XARCH=		-xarch=v8plus
440sparcv9_AS_XARCH=	-xarch=v9
441i386_AS_XARCH=
442amd64_AS_XARCH=		-xarch=amd64 -P -Ui386 -U__i386
443
444#
445# These flags define what we need to be 'standalone' i.e. -not- part
446# of the rather more cosy userland environment.  This basically means
447# the kernel.
448#
449# XX64	future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
450#
451sparc_STAND_FLAGS=	-_gcc=-ffreestanding
452sparcv9_STAND_FLAGS=	-_gcc=-ffreestanding
453# Disabling MMX also disables 3DNow, disabling SSE also disables all later
454# additions to SSE (SSE2, AVX ,etc.)
455NO_SIMD=		-_gcc=-mno-mmx -_gcc=-mno-sse
456i386_STAND_FLAGS=	-_gcc=-ffreestanding $(NO_SIMD)
457amd64_STAND_FLAGS=	-xmodel=kernel $(NO_SIMD)
458
459SAVEARGS=		-Wu,-save_args
460amd64_STAND_FLAGS	+= $(SAVEARGS)
461
462STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
463STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
464
465#
466# disable the incremental linker
467ILDOFF=			-xildoff
468#
469XFFLAG=			-xF=%all
470XESS=			-xs
471XSTRCONST=		-xstrconst
472
473#
474# turn warnings into errors (C)
475CERRWARN = -errtags=yes -errwarn=%all
476CERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
477CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
478
479CERRWARN += -_gcc=-Wno-missing-braces
480CERRWARN += -_gcc=-Wno-sign-compare
481CERRWARN += -_gcc=-Wno-unknown-pragmas
482CERRWARN += -_gcc=-Wno-unused-parameter
483CERRWARN += -_gcc=-Wno-missing-field-initializers
484
485# Unfortunately, this option can misfire very easily and unfixably.
486CERRWARN +=	-_gcc=-Wno-array-bounds
487
488# gcc4 lacks -Wno-maybe-uninitialized
489CNOWARN_UNINIT = -_gcc4=-Wno-uninitialized \
490    -_gcc7=-Wno-maybe-uninitialized \
491    -_gcc8=-Wno-maybe-uninitialized \
492    -_gcc9=-Wno-maybe-uninitialized
493
494CERRWARN += -_smatch=-p=illumos_user
495include $(SRC)/Makefile.smatch
496
497#
498# turn warnings into errors (C++)
499CCERRWARN = -errtags=yes -errwarn=%all
500CCERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
501CCERRWARN += -erroff=E_STATEMENT_NOT_REACHED
502
503CCERRWARN += -_gcc=-Wno-missing-braces
504CCERRWARN += -_gcc=-Wno-sign-compare
505CCERRWARN += -_gcc=-Wno-unknown-pragmas
506CCERRWARN += -_gcc=-Wno-unused-parameter
507CCERRWARN += -_gcc=-Wno-missing-field-initializers
508
509# C standard.  Keep Studio flags until we get rid of lint.
510CSTD_GNU89=	-xc99=%none
511CSTD_GNU99=	-xc99=%all
512CSTD=		$(CSTD_GNU89)
513C99LMODE=	$(CSTD:-xc99%=-Xc99%)
514
515# In most places, assignments to these macros should be appended with +=
516# (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
517sparc_CFLAGS=	$(sparc_XARCH) $(CCSTATICSYM)
518sparcv9_CFLAGS=	$(sparcv9_XARCH) -dalign $(CCVERBOSE) $(V9ABIWARN) $(CCREGSYM) \
519		$(CCSTATICSYM)
520i386_CFLAGS=	$(i386_XARCH)
521amd64_CFLAGS=	$(amd64_XARCH)
522
523sparc_ASFLAGS=	$(sparc_AS_XARCH)
524sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
525i386_ASFLAGS=	$(i386_AS_XARCH)
526amd64_ASFLAGS=	$(amd64_AS_XARCH)
527
528#
529sparc_COPTFLAG=		-xO3
530sparcv9_COPTFLAG=	-xO3
531i386_COPTFLAG=		-O
532amd64_COPTFLAG=		-xO3
533
534COPTFLAG= $($(MACH)_COPTFLAG)
535COPTFLAG64= $($(MACH64)_COPTFLAG)
536
537# When -g is used, the compiler globalizes static objects
538# (gives them a unique prefix). Disable that.
539CNOGLOBAL= -W0,-noglobal
540
541# Direct the Sun Studio compiler to use a static globalization prefix based on the
542# name of the module rather than something unique. Otherwise, objects
543# will not build deterministically, as subsequent compilations of identical
544# source will yeild objects that always look different.
545#
546# In the same spirit, this will also remove the date from the N_OPT stab.
547CGLOBALSTATIC= -W0,-xglobalstatic
548
549# Sometimes we want all symbols and types in debugging information even
550# if they aren't used.
551CALLSYMS=	-W0,-xdbggen=no%usedonly
552
553#
554# We force the compilers to generate the debugging information best understood
555# by the CTF tools.  With Sun Studio this is stabs due to bugs in the Studio
556# compilers.  With GCC this is DWARF v2.
557#
558DEBUGFORMAT=	-_cc=-xdebugformat=stabs -_gcc=-gdwarf-2
559
560#
561# Ask the compiler to include debugging information
562#
563CCGDEBUG= -g $(DEBUGFORMAT)
564
565#
566# Flags used to build in debug mode for ctf generation.
567#
568CTF_FLAGS_sparc	= $(CCGDEBUG) -Wc,-Qiselect-T1 $(CSTD) $(CNOGLOBAL)
569CTF_FLAGS_i386	= $(CCGDEBUG) $(CSTD) $(CNOGLOBAL)
570
571CTF_FLAGS_sparcv9	= $(CTF_FLAGS_sparc)
572CTF_FLAGS_amd64		= $(CTF_FLAGS_i386)
573
574# Sun Studio produces broken userland code when saving arguments.
575$(__GNUC)CTF_FLAGS_amd64 += $(SAVEARGS)
576
577CTF_FLAGS_32	= $(CTF_FLAGS_$(MACH))
578CTF_FLAGS_64	= $(CTF_FLAGS_$(MACH64))
579CTF_FLAGS	= $(CTF_FLAGS_32)
580
581#
582# Flags used with genoffsets
583#
584GENOFFSETS_FLAGS = $(CALLSYMS)
585
586OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
587	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
588	$(CFLAGS) $(CPPFLAGS)
589
590OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
591	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
592	$(CFLAGS64) $(CPPFLAGS)
593
594#
595# tradeoff time for space (smaller is better)
596#
597sparc_SPACEFLAG		= -xspace -W0,-Lt
598sparcv9_SPACEFLAG	= -xspace -W0,-Lt
599i386_SPACEFLAG		= -xspace
600amd64_SPACEFLAG		=
601
602SPACEFLAG		= $($(MACH)_SPACEFLAG)
603SPACEFLAG64		= $($(MACH64)_SPACEFLAG)
604
605#
606# The Sun Studio 11 compiler has changed the behaviour of integer
607# wrap arounds and so a flag is needed to use the legacy behaviour
608# (without this flag panics/hangs could be exposed within the source).
609#
610sparc_IROPTFLAG		= -W2,-xwrap_int
611sparcv9_IROPTFLAG	= -W2,-xwrap_int
612i386_IROPTFLAG		=
613amd64_IROPTFLAG		=
614
615IROPTFLAG		= $($(MACH)_IROPTFLAG)
616IROPTFLAG64		= $($(MACH64)_IROPTFLAG)
617
618sparc_XREGSFLAG		= -xregs=no%appl
619sparcv9_XREGSFLAG	= -xregs=no%appl
620i386_XREGSFLAG		=
621amd64_XREGSFLAG		=
622
623XREGSFLAG		= $($(MACH)_XREGSFLAG)
624XREGSFLAG64		= $($(MACH64)_XREGSFLAG)
625
626# dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
627# avoids stripping it.
628SOURCEDEBUG	= $(POUND_SIGN)
629SRCDBGBLD	= $(SOURCEDEBUG:yes=)
630
631#
632# These variables are intended ONLY for use by developers to safely pass extra
633# flags to the compilers without unintentionally overriding Makefile-set
634# flags.  They should NEVER be set to any value in a Makefile.
635#
636# They come last in the associated FLAGS variable such that they can
637# explicitly override things if necessary, there are gaps in this, but it's
638# the best we can manage.
639#
640CUSERFLAGS		=
641CUSERFLAGS64		= $(CUSERFLAGS)
642CCUSERFLAGS		=
643CCUSERFLAGS64		= $(CCUSERFLAGS)
644
645CSOURCEDEBUGFLAGS	=
646CCSOURCEDEBUGFLAGS	=
647$(SRCDBGBLD)CSOURCEDEBUGFLAGS	= $(CCGDEBUG) -xs
648$(SRCDBGBLD)CCSOURCEDEBUGFLAGS	= $(CCGDEBUG) -xs
649
650CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
651		$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG) \
652		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
653		$(CCNOAGGRESSIVELOOPS) \
654		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
655CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
656		$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG64) \
657		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
658		$(CCNOAGGRESSIVELOOPS) \
659		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
660#
661# Flags that are used to build parts of the code that are subsequently
662# run on the build machine (also known as the NATIVE_BUILD).
663#
664NATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
665		$(ILDOFF) $(CERRWARN) $(CSTD) $($(NATIVE_MACH)_CCUNBOUND) \
666		$(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE) \
667		$(CCNOREORDER) $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
668
669NATIVE_CCFLAGS=	$(CCOPTFLAG) $($(NATIVE_MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
670		$(CCUSERFLAGS)
671
672DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
673DTS_ERRNO=-D_TS_ERRNO
674CPPFLAGS.first=	# Please keep empty.  Only lower makefiles should set this.
675CPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
676	$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
677	$(ADJUNCT_PROTO:%=-I%/usr/include)
678CPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
679		$(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
680CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
681AS_CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
682JAVAFLAGS=	-source 1.6 -target 1.6 -Xlint:deprecation,-options
683
684#
685# For source message catalogue
686#
687.SUFFIXES: $(SUFFIXES) .i .po
688MSGROOT= $(ROOT)/catalog
689MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
690MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
691DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
692DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
693
694CLOBBERFILES += $(POFILE) $(POFILES)
695COMPILE.cpp= $(CC) -E -C $(CFLAGS) $(CPPFLAGS)
696XGETTEXT= /usr/bin/xgettext
697XGETFLAGS= -c TRANSLATION_NOTE
698GNUXGETTEXT= /usr/gnu/bin/xgettext
699GNUXGETFLAGS= --add-comments=TRANSLATION_NOTE --keyword=_ \
700	--strict --no-location --omit-header
701BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
702	$(RM)	$@ ;\
703	$(SED) "/^domain/d" < $(<F).po > $@ ;\
704	$(RM) $(<F).po $<.i
705
706#
707# This is overwritten by local Makefile when PROG is a list.
708#
709POFILE= $(PROG).po
710
711sparc_CCFLAGS=		$(sparc_XARCH) -cg92 -compat=4 \
712			-Qoption ccfe -messages=no%anachronism \
713			$(CCERRWARN)
714sparcv9_CCFLAGS=	$(sparcv9_XARCH) -dalign -compat=5 \
715			-Qoption ccfe -messages=no%anachronism \
716			-Qoption ccfe -features=no%conststrings \
717			$(CCCREGSYM) \
718			$(CCERRWARN)
719i386_CCFLAGS=		$(i386_XARCH) -compat=4 \
720			-Qoption ccfe -messages=no%anachronism \
721			-Qoption ccfe -features=no%conststrings \
722			$(CCERRWARN)
723amd64_CCFLAGS=		$(amd64_XARCH) -compat=5 \
724			-Qoption ccfe -messages=no%anachronism \
725			-Qoption ccfe -features=no%conststrings \
726			$(CCERRWARN)
727
728sparc_CCOPTFLAG=	-O
729sparcv9_CCOPTFLAG=	-O
730i386_CCOPTFLAG=		-O
731amd64_CCOPTFLAG=	-O
732
733CCOPTFLAG=	$($(MACH)_CCOPTFLAG)
734CCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
735CCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
736		$(CCUSERFLAGS)
737CCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
738		$(CCUSERFLAGS64)
739
740#
741#
742#
743ELFWRAP_FLAGS	=
744ELFWRAP_FLAGS64	=	-64
745
746#
747# Various mapfiles that are used throughout the build, and delivered to
748# /usr/lib/ld.
749#
750MAPFILE.NED_i386 =	$(SRC)/common/mapfiles/common/map.noexdata
751MAPFILE.NED_sparc =
752MAPFILE.NED =		$(MAPFILE.NED_$(MACH))
753MAPFILE.PGA =		$(SRC)/common/mapfiles/common/map.pagealign
754MAPFILE.NES =		$(SRC)/common/mapfiles/common/map.noexstk
755MAPFILE.FLT =		$(SRC)/common/mapfiles/common/map.filter
756MAPFILE.LEX =		$(SRC)/common/mapfiles/common/map.lex.yy
757
758#
759# Generated mapfiles that are compiler specific, and used throughout the
760# build.  These mapfiles are not delivered in /usr/lib/ld.
761#
762MAPFILE.NGB_sparc=	$(SRC)/common/mapfiles/gen/sparc_cc_map.noexeglobs
763$(__GNUC64)MAPFILE.NGB_sparc= \
764			$(SRC)/common/mapfiles/gen/sparc_gcc_map.noexeglobs
765MAPFILE.NGB_sparcv9=	$(SRC)/common/mapfiles/gen/sparcv9_cc_map.noexeglobs
766$(__GNUC64)MAPFILE.NGB_sparcv9= \
767			$(SRC)/common/mapfiles/gen/sparcv9_gcc_map.noexeglobs
768MAPFILE.NGB_i386=	$(SRC)/common/mapfiles/gen/i386_cc_map.noexeglobs
769$(__GNUC64)MAPFILE.NGB_i386= \
770			$(SRC)/common/mapfiles/gen/i386_gcc_map.noexeglobs
771MAPFILE.NGB_amd64=	$(SRC)/common/mapfiles/gen/amd64_cc_map.noexeglobs
772$(__GNUC64)MAPFILE.NGB_amd64= \
773			$(SRC)/common/mapfiles/gen/amd64_gcc_map.noexeglobs
774MAPFILE.NGB =		$(MAPFILE.NGB_$(MACH))
775
776#
777# A generic interface mapfile name, used by various dynamic objects to define
778# the interfaces and interposers the object must export.
779#
780MAPFILE.INT =		mapfile-intf
781
782#
783# LDLIBS32 and LDLIBS64 can be set in the environment to override the following
784# assignments.
785#
786# These environment settings make sure that no libraries are searched outside
787# of the local workspace proto area:
788#	LDLIBS32=-YP,$ROOT/lib:$ROOT/usr/lib
789#	LDLIBS64=-YP,$ROOT/lib/$MACH64:$ROOT/usr/lib/$MACH64
790#
791LDLIBS32 =	$(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
792LDLIBS32 +=	$(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
793LDLIBS.cmd =	$(LDLIBS32)
794LDLIBS.lib =	$(LDLIBS32)
795
796LDLIBS64 =	$(ENVLDLIBS1:%=%/$(MACH64)) \
797		$(ENVLDLIBS2:%=%/$(MACH64)) \
798		$(ENVLDLIBS3:%=%/$(MACH64))
799LDLIBS64 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib/$(MACH64) -L%/lib/$(MACH64))
800
801#
802# Define compilation macros.
803#
804COMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
805COMPILE64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) -c
806COMPILE.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) -c
807COMPILE64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
808COMPILE.s=	$(AS) $(ASFLAGS) $(AS_CPPFLAGS)
809COMPILE64.s=	$(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
810COMPILE.d=	$(DTRACE) -G -32
811COMPILE64.d=	$(DTRACE) -G -64
812COMPILE.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
813COMPILE64.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
814
815CLASSPATH=	.
816COMPILE.java=	$(JAVAC) $(JAVAFLAGS) -classpath $(CLASSPATH)
817
818#
819# Link time macros
820#
821CCNEEDED		= -lC
822CCEXTNEEDED		= -lCrun -lCstd
823NATIVECCNEEDED		= -lC
824$(__GNUC)CCNEEDED	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
825$(__GNUC)CCEXTNEEDED	= $(CCNEEDED)
826$(__GNUC)NATIVECCNEEDED	= -R$(GCCLIBDIR) -L$(GCCLIBDIR) -lstdc++ -lgcc_s
827
828CCNEEDED64		= -lCrun
829CCEXTNEEDED64		= -lCrun -lCstd
830NATIVECCNEEDED64	= -lCrun
831$(__GNUC64)CCNEEDED64	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
832$(__GNUC64)NATIVECCNEEDED64 = -R$(GCCLIBDIR) -L$(GCCLIBDIR) -lstdc++ -lgcc_s
833$(__GNUC64)CCEXTNEEDED	= $(CCNEEDED64)
834
835# Libraries we expect to use natively on the build machine
836NATIVE_LIBS=
837
838LDCHECKS		= $(ZASSERTDEFLIB) $(ZGUIDANCE) $(ZFATALWARNINGS)
839LDCHECKS		+= $(NATIVE_LIBS:%=$(ZASSERTDEFLIB)=%)
840
841LINK.c=			$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
842LINK64.c=		$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
843NORUNPATH=		-norunpath -nolib
844LINK.cc=		$(CCC) $(CCFLAGS) $(CPPFLAGS) $(NORUNPATH) \
845			$(LDFLAGS) $(CCNEEDED) $(LDCHECKS)
846LINK64.cc=		$(CCC) $(CCFLAGS64) $(CPPFLAGS) $(NORUNPATH) \
847			$(LDFLAGS) $(CCNEEDED64) $(LDCHECKS)
848
849#
850# lint macros
851#
852# Note that the undefine of __PRAGMA_REDEFINE_EXTNAME can be removed once
853# ON is built with a version of lint that has the fix for 4484186.
854#
855ALWAYS_LINT_DEFS =	-errtags=yes -s
856ALWAYS_LINT_DEFS +=	-erroff=E_PTRDIFF_OVERFLOW
857ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_NARROW_CONV
858ALWAYS_LINT_DEFS +=	-U__PRAGMA_REDEFINE_EXTNAME
859ALWAYS_LINT_DEFS +=	$(C99LMODE)
860ALWAYS_LINT_DEFS +=	-errsecurity=$(SECLEVEL)
861ALWAYS_LINT_DEFS +=	-erroff=E_SEC_CREAT_WITHOUT_EXCL
862ALWAYS_LINT_DEFS +=	-erroff=E_SEC_FORBIDDEN_WARN_CREAT
863# XX64 -- really only needed for amd64 lint
864ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_INT_TO_SMALL_INT
865ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_CONST_TO_SMALL_INT
866ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_TO_SMALL_INT
867ALWAYS_LINT_DEFS +=	-erroff=E_CAST_TO_PTR_FROM_INT
868ALWAYS_LINT_DEFS +=	-erroff=E_COMP_INT_WITH_LARGE_INT
869ALWAYS_LINT_DEFS +=	-erroff=E_INTEGRAL_CONST_EXP_EXPECTED
870ALWAYS_LINT_DEFS +=	-erroff=E_PASS_INT_TO_SMALL_INT
871ALWAYS_LINT_DEFS +=	-erroff=E_PTR_CONV_LOSES_BITS
872
873# This forces lint to pick up note.h and sys/note.h from Devpro rather than
874# from the proto area.  The note.h that ON delivers would disable NOTE().
875ONLY_LINT_DEFS =	-I$(SPRO_VROOT)/prod/include/lint
876
877SECLEVEL=	core
878LINT.c=		$(LINT) $(ONLY_LINT_DEFS) $(LINTFLAGS) $(CPPFLAGS) \
879		$(ALWAYS_LINT_DEFS)
880LINT64.c=	$(LINT) $(ONLY_LINT_DEFS) $(LINTFLAGS64) $(CPPFLAGS) \
881		$(ALWAYS_LINT_DEFS)
882LINT.s=		$(LINT.c)
883
884# For some future builds, NATIVE_MACH and MACH might be different.
885# Therefore, NATIVE_MACH needs to be redefined in the
886# environment as `uname -p` to override this macro.
887#
888# For now at least, we cross-compile amd64 on i386 machines.
889NATIVE_MACH=	$(MACH:amd64=i386)
890NATIVE_MACH64=	$(MACH64)
891
892# Define native compilation macros
893#
894
895# Base directory where compilers are loaded.
896# Defined here so it can be overridden by developer.
897#
898SPRO_ROOT=		$(BUILD_TOOLS)/SUNWspro
899SPRO_VROOT=		$(SPRO_ROOT)/SS12
900GNU_ROOT=		/usr
901
902$(__GNUC)PRIMARY_CC=	gcc7,$(GNUC_ROOT)/bin/gcc,gnu
903$(__SUNC)PRIMARY_CC=	studio12,$(SPRO_VROOT)/bin/cc,sun
904$(__GNUC)PRIMARY_CCC=	gcc7,$(GNUC_ROOT)/bin/g++,gnu
905$(__SUNC)PRIMARY_CCC=	studio12,$(SPRO_VROOT)/bin/CC,sun
906
907CW_CC_COMPILERS=	$(PRIMARY_CC:%=--primary %) $(SHADOW_CCS:%=--shadow %)
908CW_CCC_COMPILERS=	$(PRIMARY_CCC:%=--primary %) $(SHADOW_CCCS:%=--shadow %)
909
910CW_LINKER=		--linker $(LD)
911
912# Till SS12u1 formally becomes the NV CBE, LINT is hard
913# coded to be picked up from the $SPRO_ROOT/sunstudio12.1/
914# location. Impacted variables are sparc_LINT, sparcv9_LINT,
915# i386_LINT, amd64_LINT.
916# Reset them when SS12u1 is rolled out.
917#
918
919# Specify platform compiler versions for languages
920# that we use (currently only c and c++).
921#
922CW=			$(ONBLD_TOOLS)/bin/$(MACH)/cw
923
924BUILD_CC=		$(CW) $(CW_LINKER) $(CW_CC_COMPILERS) --
925BUILD_CCC=		$(CW) -C $(CW_LINKER) $(CW_CCC_COMPILERS) --
926BUILD_CPP=		/usr/ccs/lib/cpp
927BUILD_LD=		$(ONBLD_TOOLS)/bin/$(MACH)/ld
928BUILD_LINT=		$(SPRO_ROOT)/sunstudio12.1/bin/lint
929
930$(MACH)_CC=		$(BUILD_CC)
931$(MACH)_CCC=		$(BUILD_CCC)
932$(MACH)_CPP=		$(BUILD_CPP)
933$(MACH)_LD=		$(BUILD_LD)
934$(MACH)_LINT=		$(BUILD_LINT)
935$(MACH64)_CC=		$(BUILD_CC)
936$(MACH64)_CCC=		$(BUILD_CCC)
937$(MACH64)_CPP=		$(BUILD_CPP)
938$(MACH64)_LD=		$(BUILD_LD)
939$(MACH64)_LINT=		$(BUILD_LINT)
940
941sparc_AS=		/usr/ccs/bin/as -xregsym=no
942sparcv9_AS=		$($(MACH)_AS)
943
944i386_AS=		/usr/ccs/bin/as
945$(__GNUC)i386_AS=	$(ONBLD_TOOLS)/bin/$(MACH)/aw
946amd64_AS=		$(ONBLD_TOOLS)/bin/$(MACH)/aw
947
948NATIVECC=		$($(NATIVE_MACH)_CC)
949NATIVECCC=		$($(NATIVE_MACH)_CCC)
950NATIVECPP=		$($(NATIVE_MACH)_CPP)
951NATIVEAS=		$($(NATIVE_MACH)_AS)
952NATIVELD=		$($(NATIVE_MACH)_LD)
953NATIVELINT=		$($(NATIVE_MACH)_LINT)
954
955NATIVECC64=		$($(NATIVE_MACH64)_CC)
956NATIVECCC64=		$($(NATIVE_MACH64)_CCC)
957NATIVECPP64=		$($(NATIVE_MACH64)_CPP)
958NATIVEAS64=		$($(NATIVE_MACH64)_AS)
959NATIVELD64=		$($(NATIVE_MACH64)_LD)
960NATIVELINT64=		$($(NATIVE_MACH64)_LINT)
961
962#
963# Makefile.master.64 overrides these settings
964#
965CC=			$(NATIVECC)
966CCC=			$(NATIVECCC)
967CPP=			$(NATIVECPP)
968AS=			$(NATIVEAS)
969LD=			$(NATIVELD)
970LINT=			$(NATIVELINT)
971
972CC64=			$(NATIVECC64)
973CCC64=			$(NATIVECCC64)
974CPP64=			$(NATIVECPP64)
975AS64=			$(NATIVEAS64)
976LD64=			$(NATIVELD64)
977LINT64=			$(NATIVELINT64)
978
979# Pass -Y flag to cpp (method of which is release-dependent)
980CCYFLAG=		-Y I,
981
982BDIRECT=	-Bdirect
983BDYNAMIC=	-Bdynamic
984BLOCAL=		-Blocal
985BNODIRECT=	-Bnodirect
986BREDUCE=	-Breduce
987BSTATIC=	-Bstatic
988
989ZDEFS=		-zdefs
990ZDIRECT=	-zdirect
991ZIGNORE=	-zignore
992ZINITFIRST=	-zinitfirst
993ZINTERPOSE=	-zinterpose
994ZLAZYLOAD=	-zlazyload
995ZLOADFLTR=	-zloadfltr
996ZMULDEFS=	-zmuldefs
997ZNODEFAULTLIB=	-znodefaultlib
998ZNODEFS=	-znodefs
999ZNODELETE=	-znodelete
1000ZNODLOPEN=	-znodlopen
1001ZNODUMP=	-znodump
1002ZNOLAZYLOAD=	-znolazyload
1003ZNOLDYNSYM=	-znoldynsym
1004ZNORELOC=	-znoreloc
1005ZNOVERSION=	-znoversion
1006ZRECORD=	-zrecord
1007ZREDLOCSYM=	-zredlocsym
1008ZTEXT=		-ztext
1009ZVERBOSE=	-zverbose
1010ZASSERTDEFLIB=	-zassert-deflib
1011ZGUIDANCE=	-zguidance
1012ZFATALWARNINGS=	-zfatal-warnings
1013
1014GSHARED=	-G
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