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