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