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