xref: /illumos-gate/usr/src/Makefile.master (revision 5328fc53d11d7151861fa272e4fb0248b8f0e145)
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
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 = -errtags=yes -errwarn=%all
483CCERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
484CCERRWARN += -erroff=E_STATEMENT_NOT_REACHED
485
486CCERRWARN += -_gcc=-Wno-missing-braces
487CCERRWARN += -_gcc=-Wno-sign-compare
488CCERRWARN += -_gcc=-Wno-unknown-pragmas
489CCERRWARN += -_gcc=-Wno-unused-parameter
490CCERRWARN += -_gcc=-Wno-missing-field-initializers
491
492# C standard.  Keep Studio flags until we get rid of lint.
493CSTD_GNU89=	-xc99=%none
494CSTD_GNU99=	-xc99=%all
495CSTD=		$(CSTD_GNU89)
496C99LMODE=	$(CSTD:-xc99%=-Xc99%)
497
498# In most places, assignments to these macros should be appended with +=
499# (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
500sparc_CFLAGS=	$(sparc_XARCH) $(CCSTATICSYM)
501sparcv9_CFLAGS=	$(sparcv9_XARCH) -dalign $(CCVERBOSE) $(V9ABIWARN) $(CCREGSYM) \
502		$(CCSTATICSYM)
503i386_CFLAGS=	$(i386_XARCH)
504amd64_CFLAGS=	$(amd64_XARCH)
505
506sparc_ASFLAGS=	$(sparc_AS_XARCH)
507sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
508i386_ASFLAGS=	$(i386_AS_XARCH)
509amd64_ASFLAGS=	$(amd64_AS_XARCH)
510
511#
512sparc_COPTFLAG=		-xO3
513sparcv9_COPTFLAG=	-xO3
514i386_COPTFLAG=		-O
515amd64_COPTFLAG=		-xO3
516
517COPTFLAG= $($(MACH)_COPTFLAG)
518COPTFLAG64= $($(MACH64)_COPTFLAG)
519
520# When -g is used, the compiler globalizes static objects
521# (gives them a unique prefix). Disable that.
522CNOGLOBAL= -W0,-noglobal
523
524# Direct the Sun Studio compiler to use a static globalization prefix based on the
525# name of the module rather than something unique. Otherwise, objects
526# will not build deterministically, as subsequent compilations of identical
527# source will yeild objects that always look different.
528#
529# In the same spirit, this will also remove the date from the N_OPT stab.
530CGLOBALSTATIC= -W0,-xglobalstatic
531
532# Sometimes we want all symbols and types in debugging information even
533# if they aren't used.
534CALLSYMS=	-W0,-xdbggen=no%usedonly
535
536#
537# We force the compilers to generate the debugging information best understood
538# by the CTF tools.  With Sun Studio this is stabs due to bugs in the Studio
539# compilers.  With GCC this is DWARF v2.
540#
541DEBUGFORMAT=	-_cc=-xdebugformat=stabs -_gcc=-gdwarf-2
542
543#
544# Ask the compiler to include debugging information
545#
546CCGDEBUG= -g $(DEBUGFORMAT)
547
548#
549# Flags used to build in debug mode for ctf generation.
550#
551CTF_FLAGS_sparc	= $(CCGDEBUG) -Wc,-Qiselect-T1 $(CSTD) $(CNOGLOBAL)
552CTF_FLAGS_i386	= $(CCGDEBUG) $(CSTD) $(CNOGLOBAL)
553
554CTF_FLAGS_sparcv9	= $(CTF_FLAGS_sparc)
555CTF_FLAGS_amd64		= $(CTF_FLAGS_i386)
556
557# Sun Studio produces broken userland code when saving arguments.
558$(__GNUC)CTF_FLAGS_amd64 += $(SAVEARGS)
559
560CTF_FLAGS_32	= $(CTF_FLAGS_$(MACH))
561CTF_FLAGS_64	= $(CTF_FLAGS_$(MACH64))
562CTF_FLAGS	= $(CTF_FLAGS_32)
563
564#
565# Flags used with genoffsets
566#
567GENOFFSETS_FLAGS = $(CALLSYMS)
568
569OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
570	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
571	$(CFLAGS) $(CPPFLAGS)
572
573OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
574	$(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
575	$(CFLAGS64) $(CPPFLAGS)
576
577#
578# tradeoff time for space (smaller is better)
579#
580sparc_SPACEFLAG		= -xspace -W0,-Lt
581sparcv9_SPACEFLAG	= -xspace -W0,-Lt
582i386_SPACEFLAG		= -xspace
583amd64_SPACEFLAG		=
584
585SPACEFLAG		= $($(MACH)_SPACEFLAG)
586SPACEFLAG64		= $($(MACH64)_SPACEFLAG)
587
588#
589# The Sun Studio 11 compiler has changed the behaviour of integer
590# wrap arounds and so a flag is needed to use the legacy behaviour
591# (without this flag panics/hangs could be exposed within the source).
592#
593sparc_IROPTFLAG		= -W2,-xwrap_int
594sparcv9_IROPTFLAG	= -W2,-xwrap_int
595i386_IROPTFLAG		=
596amd64_IROPTFLAG		=
597
598IROPTFLAG		= $($(MACH)_IROPTFLAG)
599IROPTFLAG64		= $($(MACH64)_IROPTFLAG)
600
601sparc_XREGSFLAG		= -xregs=no%appl
602sparcv9_XREGSFLAG	= -xregs=no%appl
603i386_XREGSFLAG		=
604amd64_XREGSFLAG		=
605
606XREGSFLAG		= $($(MACH)_XREGSFLAG)
607XREGSFLAG64		= $($(MACH64)_XREGSFLAG)
608
609# dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
610# avoids stripping it.
611SOURCEDEBUG	= $(POUND_SIGN)
612SRCDBGBLD	= $(SOURCEDEBUG:yes=)
613
614#
615# These variables are intended ONLY for use by developers to safely pass extra
616# flags to the compilers without unintentionally overriding Makefile-set
617# flags.  They should NEVER be set to any value in a Makefile.
618#
619# They come last in the associated FLAGS variable such that they can
620# explicitly override things if necessary, there are gaps in this, but it's
621# the best we can manage.
622#
623CUSERFLAGS		=
624CUSERFLAGS64		= $(CUSERFLAGS)
625CCUSERFLAGS		=
626CCUSERFLAGS64		= $(CCUSERFLAGS)
627
628CSOURCEDEBUGFLAGS	=
629CCSOURCEDEBUGFLAGS	=
630$(SRCDBGBLD)CSOURCEDEBUGFLAGS	= $(CCGDEBUG) -xs
631$(SRCDBGBLD)CCSOURCEDEBUGFLAGS	= $(CCGDEBUG) -xs
632
633CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
634		$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG) \
635		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
636		$(CCNOAGGRESSIVELOOPS) \
637		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
638CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
639		$(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG64) \
640		$(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
641		$(CCNOAGGRESSIVELOOPS) \
642		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
643#
644# Flags that are used to build parts of the code that are subsequently
645# run on the build machine (also known as the NATIVE_BUILD).
646#
647NATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
648		$(ILDOFF) $(CERRWARN) $(CSTD) $($(NATIVE_MACH)_CCUNBOUND) \
649		$(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE) \
650		$(CCNOREORDER) $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
651
652NATIVE_CCFLAGS=	$(CCOPTFLAG) $($(NATIVE_MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
653		$(CCUSERFLAGS)
654
655DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
656DTS_ERRNO=-D_TS_ERRNO
657CPPFLAGS.first=	# Please keep empty.  Only lower makefiles should set this.
658CPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
659	$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
660	$(ADJUNCT_PROTO:%=-I%/usr/include)
661CPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
662		$(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
663CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
664AS_CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
665JAVAFLAGS=	-source 1.6 -target 1.6 -Xlint:deprecation,-options
666
667#
668# For source message catalogue
669#
670.SUFFIXES: $(SUFFIXES) .i .po
671MSGROOT= $(ROOT)/catalog
672MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
673MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
674DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
675DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
676
677CLOBBERFILES += $(POFILE) $(POFILES)
678COMPILE.cpp= $(CC) -E -C $(CFLAGS) $(CPPFLAGS)
679XGETTEXT= /usr/bin/xgettext
680XGETFLAGS= -c TRANSLATION_NOTE
681GNUXGETTEXT= /usr/gnu/bin/xgettext
682GNUXGETFLAGS= --add-comments=TRANSLATION_NOTE --keyword=_ \
683	--strict --no-location --omit-header
684BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
685	$(RM)	$@ ;\
686	$(SED) "/^domain/d" < $(<F).po > $@ ;\
687	$(RM) $(<F).po $<.i
688
689#
690# This is overwritten by local Makefile when PROG is a list.
691#
692POFILE= $(PROG).po
693
694sparc_CCFLAGS=		$(sparc_XARCH) -cg92 -compat=4 \
695			-Qoption ccfe -messages=no%anachronism \
696			$(CCERRWARN)
697sparcv9_CCFLAGS=	$(sparcv9_XARCH) -dalign -compat=5 \
698			-Qoption ccfe -messages=no%anachronism \
699			-Qoption ccfe -features=no%conststrings \
700			$(CCCREGSYM) \
701			$(CCERRWARN)
702i386_CCFLAGS=		$(i386_XARCH) -compat=4 \
703			-Qoption ccfe -messages=no%anachronism \
704			-Qoption ccfe -features=no%conststrings \
705			$(CCERRWARN)
706amd64_CCFLAGS=		$(amd64_XARCH) -compat=5 \
707			-Qoption ccfe -messages=no%anachronism \
708			-Qoption ccfe -features=no%conststrings \
709			$(CCERRWARN)
710
711sparc_CCOPTFLAG=	-O
712sparcv9_CCOPTFLAG=	-O
713i386_CCOPTFLAG=		-O
714amd64_CCOPTFLAG=	-O
715
716CCOPTFLAG=	$($(MACH)_CCOPTFLAG)
717CCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
718CCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
719		$(CCUSERFLAGS)
720CCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
721		$(CCUSERFLAGS64)
722
723#
724#
725#
726ELFWRAP_FLAGS	=
727ELFWRAP_FLAGS64	=	-64
728
729#
730# Various mapfiles that are used throughout the build, and delivered to
731# /usr/lib/ld.
732#
733MAPFILE.NED_i386 =	$(SRC)/common/mapfiles/common/map.noexdata
734MAPFILE.NED_sparc =
735MAPFILE.NED =		$(MAPFILE.NED_$(MACH))
736MAPFILE.PGA =		$(SRC)/common/mapfiles/common/map.pagealign
737MAPFILE.NES =		$(SRC)/common/mapfiles/common/map.noexstk
738MAPFILE.FLT =		$(SRC)/common/mapfiles/common/map.filter
739MAPFILE.LEX =		$(SRC)/common/mapfiles/common/map.lex.yy
740
741#
742# Generated mapfiles that are compiler specific, and used throughout the
743# build.  These mapfiles are not delivered in /usr/lib/ld.
744#
745MAPFILE.NGB_sparc=	$(SRC)/common/mapfiles/gen/sparc_cc_map.noexeglobs
746$(__GNUC64)MAPFILE.NGB_sparc= \
747			$(SRC)/common/mapfiles/gen/sparc_gcc_map.noexeglobs
748MAPFILE.NGB_sparcv9=	$(SRC)/common/mapfiles/gen/sparcv9_cc_map.noexeglobs
749$(__GNUC64)MAPFILE.NGB_sparcv9= \
750			$(SRC)/common/mapfiles/gen/sparcv9_gcc_map.noexeglobs
751MAPFILE.NGB_i386=	$(SRC)/common/mapfiles/gen/i386_cc_map.noexeglobs
752$(__GNUC64)MAPFILE.NGB_i386= \
753			$(SRC)/common/mapfiles/gen/i386_gcc_map.noexeglobs
754MAPFILE.NGB_amd64=	$(SRC)/common/mapfiles/gen/amd64_cc_map.noexeglobs
755$(__GNUC64)MAPFILE.NGB_amd64= \
756			$(SRC)/common/mapfiles/gen/amd64_gcc_map.noexeglobs
757MAPFILE.NGB =		$(MAPFILE.NGB_$(MACH))
758
759#
760# A generic interface mapfile name, used by various dynamic objects to define
761# the interfaces and interposers the object must export.
762#
763MAPFILE.INT =		mapfile-intf
764
765#
766# LDLIBS32 and LDLIBS64 can be set in the environment to override the following
767# assignments.
768#
769# These environment settings make sure that no libraries are searched outside
770# of the local workspace proto area:
771#	LDLIBS32=-YP,$ROOT/lib:$ROOT/usr/lib
772#	LDLIBS64=-YP,$ROOT/lib/$MACH64:$ROOT/usr/lib/$MACH64
773#
774LDLIBS32 =	$(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
775LDLIBS32 +=	$(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
776LDLIBS.cmd =	$(LDLIBS32)
777LDLIBS.lib =	$(LDLIBS32)
778
779LDLIBS64 =	$(ENVLDLIBS1:%=%/$(MACH64)) \
780		$(ENVLDLIBS2:%=%/$(MACH64)) \
781		$(ENVLDLIBS3:%=%/$(MACH64))
782LDLIBS64 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib/$(MACH64) -L%/lib/$(MACH64))
783
784#
785# Define compilation macros.
786#
787COMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
788COMPILE64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) -c
789COMPILE.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) -c
790COMPILE64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
791COMPILE.s=	$(AS) $(ASFLAGS) $(AS_CPPFLAGS)
792COMPILE64.s=	$(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
793COMPILE.d=	$(DTRACE) -G -32
794COMPILE64.d=	$(DTRACE) -G -64
795COMPILE.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
796COMPILE64.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
797
798CLASSPATH=	.
799COMPILE.java=	$(JAVAC) $(JAVAFLAGS) -classpath $(CLASSPATH)
800
801#
802# Link time macros
803#
804CCNEEDED		= -lC
805CCEXTNEEDED		= -lCrun -lCstd
806$(__GNUC)CCNEEDED	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
807$(__GNUC)CCEXTNEEDED	= $(CCNEEDED)
808
809CCNEEDED64		= -lCrun
810CCEXTNEEDED64		= -lCrun -lCstd
811$(__GNUC64)CCNEEDED64	= -L$(GCCLIBDIR) -lstdc++ -lgcc_s
812$(__GNUC64)CCEXTNEEDED	= $(CCNEEDED64)
813
814LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
815LINK64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
816NORUNPATH=	-norunpath -nolib
817LINK.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) $(NORUNPATH) \
818		$(LDFLAGS) $(CCNEEDED)
819LINK64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) $(NORUNPATH) \
820		$(LDFLAGS) $(CCNEEDED64)
821
822#
823# lint macros
824#
825# Note that the undefine of __PRAGMA_REDEFINE_EXTNAME can be removed once
826# ON is built with a version of lint that has the fix for 4484186.
827#
828ALWAYS_LINT_DEFS =	-errtags=yes -s
829ALWAYS_LINT_DEFS +=	-erroff=E_PTRDIFF_OVERFLOW
830ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_NARROW_CONV
831ALWAYS_LINT_DEFS +=	-U__PRAGMA_REDEFINE_EXTNAME
832ALWAYS_LINT_DEFS +=	$(C99LMODE)
833ALWAYS_LINT_DEFS +=	-errsecurity=$(SECLEVEL)
834ALWAYS_LINT_DEFS +=	-erroff=E_SEC_CREAT_WITHOUT_EXCL
835ALWAYS_LINT_DEFS +=	-erroff=E_SEC_FORBIDDEN_WARN_CREAT
836# XX64 -- really only needed for amd64 lint
837ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_INT_TO_SMALL_INT
838ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_CONST_TO_SMALL_INT
839ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_TO_SMALL_INT
840ALWAYS_LINT_DEFS +=	-erroff=E_CAST_TO_PTR_FROM_INT
841ALWAYS_LINT_DEFS +=	-erroff=E_COMP_INT_WITH_LARGE_INT
842ALWAYS_LINT_DEFS +=	-erroff=E_INTEGRAL_CONST_EXP_EXPECTED
843ALWAYS_LINT_DEFS +=	-erroff=E_PASS_INT_TO_SMALL_INT
844ALWAYS_LINT_DEFS +=	-erroff=E_PTR_CONV_LOSES_BITS
845
846# This forces lint to pick up note.h and sys/note.h from Devpro rather than
847# from the proto area.  The note.h that ON delivers would disable NOTE().
848ONLY_LINT_DEFS =	-I$(SPRO_VROOT)/prod/include/lint
849
850SECLEVEL=	core
851LINT.c=		$(LINT) $(ONLY_LINT_DEFS) $(LINTFLAGS) $(CPPFLAGS) \
852		$(ALWAYS_LINT_DEFS)
853LINT64.c=	$(LINT) $(ONLY_LINT_DEFS) $(LINTFLAGS64) $(CPPFLAGS) \
854		$(ALWAYS_LINT_DEFS)
855LINT.s=		$(LINT.c)
856
857# For some future builds, NATIVE_MACH and MACH might be different.
858# Therefore, NATIVE_MACH needs to be redefined in the
859# environment as `uname -p` to override this macro.
860#
861# For now at least, we cross-compile amd64 on i386 machines.
862NATIVE_MACH=	$(MACH:amd64=i386)
863NATIVE_MACH64=	$(MACH64)
864
865# Define native compilation macros
866#
867
868# Base directory where compilers are loaded.
869# Defined here so it can be overridden by developer.
870#
871SPRO_ROOT=		$(BUILD_TOOLS)/SUNWspro
872SPRO_VROOT=		$(SPRO_ROOT)/SS12
873GNU_ROOT=		/usr
874
875$(__GNUC)PRIMARY_CC=	gcc7,$(GNUC_ROOT)/bin/gcc,gnu
876$(__SUNC)PRIMARY_CC=	studio12,$(SPRO_VROOT)/bin/cc,sun
877$(__GNUC)PRIMARY_CCC=	gcc7,$(GNUC_ROOT)/bin/g++,gnu
878$(__SUNC)PRIMARY_CCC=	studio12,$(SPRO_VROOT)/bin/CC,sun
879
880CW_CC_COMPILERS=	$(PRIMARY_CC:%=--primary %) $(SHADOW_CCS:%=--shadow %)
881CW_CCC_COMPILERS=	$(PRIMARY_CCC:%=--primary %) $(SHADOW_CCCS:%=--shadow %)
882
883CW_LINKER=		--linker $(LD)
884
885# Till SS12u1 formally becomes the NV CBE, LINT is hard
886# coded to be picked up from the $SPRO_ROOT/sunstudio12.1/
887# location. Impacted variables are sparc_LINT, sparcv9_LINT,
888# i386_LINT, amd64_LINT.
889# Reset them when SS12u1 is rolled out.
890#
891
892# Specify platform compiler versions for languages
893# that we use (currently only c and c++).
894#
895CW=			$(ONBLD_TOOLS)/bin/$(MACH)/cw
896
897BUILD_CC=		$(CW) $(CW_LINKER) $(CW_CC_COMPILERS) --
898BUILD_CCC=		$(CW) -C $(CW_LINKER) $(CW_CCC_COMPILERS) --
899BUILD_CPP=		/usr/ccs/lib/cpp
900BUILD_LD=		$(ONBLD_TOOLS)/bin/$(MACH)/ld
901BUILD_LINT=		$(SPRO_ROOT)/sunstudio12.1/bin/lint
902
903$(MACH)_CC=		$(BUILD_CC)
904$(MACH)_CCC=		$(BUILD_CCC)
905$(MACH)_CPP=		$(BUILD_CPP)
906$(MACH)_LD=		$(BUILD_LD)
907$(MACH)_LINT=		$(BUILD_LINT)
908$(MACH64)_CC=		$(BUILD_CC)
909$(MACH64)_CCC=		$(BUILD_CCC)
910$(MACH64)_CPP=		$(BUILD_CPP)
911$(MACH64)_LD=		$(BUILD_LD)
912$(MACH64)_LINT=		$(BUILD_LINT)
913
914sparc_AS=		/usr/ccs/bin/as -xregsym=no
915sparcv9_AS=		$($(MACH)_AS)
916
917i386_AS=		/usr/ccs/bin/as
918$(__GNUC)i386_AS=	$(ONBLD_TOOLS)/bin/$(MACH)/aw
919amd64_AS=		$(ONBLD_TOOLS)/bin/$(MACH)/aw
920
921NATIVECC=		$($(NATIVE_MACH)_CC)
922NATIVECCC=		$($(NATIVE_MACH)_CCC)
923NATIVECPP=		$($(NATIVE_MACH)_CPP)
924NATIVEAS=		$($(NATIVE_MACH)_AS)
925NATIVELD=		$($(NATIVE_MACH)_LD)
926NATIVELINT=		$($(NATIVE_MACH)_LINT)
927
928NATIVECC64=		$($(NATIVE_MACH64)_CC)
929NATIVECCC64=		$($(NATIVE_MACH64)_CCC)
930NATIVECPP64=		$($(NATIVE_MACH64)_CPP)
931NATIVEAS64=		$($(NATIVE_MACH64)_AS)
932NATIVELD64=		$($(NATIVE_MACH64)_LD)
933NATIVELINT64=		$($(NATIVE_MACH64)_LINT)
934
935#
936# Makefile.master.64 overrides these settings
937#
938CC=			$(NATIVECC)
939CCC=			$(NATIVECCC)
940CPP=			$(NATIVECPP)
941AS=			$(NATIVEAS)
942LD=			$(NATIVELD)
943LINT=			$(NATIVELINT)
944
945CC64=			$(NATIVECC64)
946CCC64=			$(NATIVECCC64)
947CPP64=			$(NATIVECPP64)
948AS64=			$(NATIVEAS64)
949LD64=			$(NATIVELD64)
950LINT64=			$(NATIVELINT64)
951
952# Pass -Y flag to cpp (method of which is release-dependent)
953CCYFLAG=		-Y I,
954
955BDIRECT=	-Bdirect
956BDYNAMIC=	-Bdynamic
957BLOCAL=		-Blocal
958BNODIRECT=	-Bnodirect
959BREDUCE=	-Breduce
960BSTATIC=	-Bstatic
961
962ZDEFS=		-zdefs
963ZDIRECT=	-zdirect
964ZIGNORE=	-zignore
965ZINITFIRST=	-zinitfirst
966ZINTERPOSE=	-zinterpose
967ZLAZYLOAD=	-zlazyload
968ZLOADFLTR=	-zloadfltr
969ZMULDEFS=	-zmuldefs
970ZNODEFAULTLIB=	-znodefaultlib
971ZNODEFS=	-znodefs
972ZNODELETE=	-znodelete
973ZNODLOPEN=	-znodlopen
974ZNODUMP=	-znodump
975ZNOLAZYLOAD=	-znolazyload
976ZNOLDYNSYM=	-znoldynsym
977ZNORELOC=	-znoreloc
978ZNOVERSION=	-znoversion
979ZRECORD=	-zrecord
980ZREDLOCSYM=	-zredlocsym
981ZTEXT=		-ztext
982ZVERBOSE=	-zverbose
983
984GSHARED=	-G
985CCMT=		-mt
986
987# Handle different PIC models on different ISAs
988# (May be overridden by lower-level Makefiles)
989
990sparc_C_PICFLAGS =	-fpic
991sparcv9_C_PICFLAGS =	-fpic
992i386_C_PICFLAGS =	-fpic
993amd64_C_PICFLAGS =	-fpic
994C_PICFLAGS =		$($(MACH)_C_PICFLAGS)
995C_PICFLAGS64 =		$($(MACH64)_C_PICFLAGS)
996
997sparc_C_BIGPICFLAGS =	-fPIC
998sparcv9_C_BIGPICFLAGS =	-fPIC
999i386_C_BIGPICFLAGS =	-fPIC
1000amd64_C_BIGPICFLAGS =	-fPIC
1001C_BIGPICFLAGS =		$($(MACH)_C_BIGPICFLAGS)
1002C_BIGPICFLAGS64 =	$($(MACH64)_C_BIGPICFLAGS)
1003
1004# CC requires there to be no space between '-K' and 'pic' or 'PIC'.
1005# and does not support -f
1006sparc_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
1007sparcv9_CC_PICFLAGS =	-_cc=-KPIC -_gcc=-fPIC
1008i386_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
1009amd64_CC_PICFLAGS =	-_cc=-Kpic -_gcc=-fpic
1010CC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
1011CC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)
1012
1013AS_PICFLAGS=		-K pic
1014AS_BIGPICFLAGS=		-K PIC
1015
1016#
1017# Default label for CTF sections
1018#
1019CTFCVTFLAGS=		-L VERSION
1020
1021#
1022# Override to pass module-specific flags to ctfmerge.  Currently used only by
1023# krtld to turn on fuzzy matching, and source-level debugging to inhibit
1024# stripping.
1025#
1026CTFMRGFLAGS=
1027
1028CTFCONVERT_O		= $(CTFCONVERT) $(CTFCVTFLAGS) $@
1029
1030# Rules (normally from make.rules) and macros which are used for post
1031# processing files. Normally, these do stripping of the comment section
1032# automatically.
1033#    RELEASE_CM:	Should be edited to reflect the release.
1034#    POST_PROCESS_O:	Post-processing for `.o' files (typically C source)
1035#    POST_PROCESS_S_O:	Post-processing for `.o' files built from asssembly
1036#    POST_PROCESS_CC_O:	Post-processing for `.o' files built from C++
1037#    POST_PROCESS_A:		Post-processing for `.a' files (currently null).
1038#    POST_PROCESS_SO:	Post-processing for `.so' files.
1039#    POST_PROCESS:	Post-processing for executable files (no suffix).
1040#
1041# Note that these macros are not completely generalized as they are to be
1042# used with the file name to be processed following.
1043#
1044# It is left as an exercise to Release Engineering to embellish the generation
1045# of the release comment string.
1046#
1047#	If this is a standard development build:
1048#		compress the comment section (mcs -c)
1049#		add the standard comment (mcs -a $(RELEASE_CM))
1050#		add the development specific comment (mcs -a $(DEV_CM))
1051#
1052#	If this is an installation build:
1053#		delete the comment section (mcs -d)
1054#		add the standard comment (mcs -a $(RELEASE_CM))
1055#		add the development specific comment (mcs -a $(DEV_CM))
1056#
1057#	If this is an release build:
1058#		delete the comment section (mcs -d)
1059#		add the standard comment (mcs -a $(RELEASE_CM))
1060#
1061# The following list of macros are used in the definition of RELEASE_CM
1062# which is used to label all binaries in the build:
1063#
1064#	RELEASE		Specific release of the build, eg: 5.2
1065#	RELEASE_MAJOR	Major version number part of $(RELEASE)
1066#	RELEASE_MINOR	Minor version number part of $(RELEASE)
1067#	VERSION		Version of the build (alpha, beta, Generic)
1068#	PATCHID		If this is a patch this value should contain
1069#			the patchid value (eg: "Generic 100832-01"), otherwise
1070#			it will be set to $(VERSION)
1071#	RELEASE_DATE	Date of the Release Build
1072#	PATCH_DATE	Date the patch was created, if this is blank it
1073#			will default to the RELEASE_DATE
1074#
1075RELEASE_MAJOR=	5
1076RELEASE_MINOR=	11
1077RELEASE=	$(RELEASE_MAJOR).$(RELEASE_MINOR)
1078VERSION=	SunOS Development
1079PATCHID=	$(VERSION)
1080RELEASE_DATE=	release date not set
1081PATCH_DATE=	$(RELEASE_DATE)
1082RELEASE_CM=	"@($(POUND_SIGN))SunOS $(RELEASE) $(PATCHID) $(PATCH_DATE)"
1083DEV_CM=		"@($(POUND_SIGN))SunOS Internal Development: non-nightly build"
1084UTS_LABEL=	$(RELEASE)
1085
1086PROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
1087$(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
1088
1089STRIP_STABS=			   $(STRIP) -x $@
1090$(SRCDBGBLD)STRIP_STABS=	   :
1091
1092POST_PROCESS_O=
1093POST_PROCESS_S_O=
1094POST_PROCESS_CC_O=
1095POST_PROCESS_A=
1096POST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
1097			$(ELFSIGN_OBJECT)
1098POST_PROCESS=		$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
1099			$(ELFSIGN_OBJECT)
1100
1101#
1102# chk4ubin is a tool that inspects a module for a symbol table
1103# ELF section size which can trigger an OBP bug on older platforms.
1104# This problem affects only specific sun4u bootable modules.
1105#
1106CHK4UBIN=	$(ONBLD_TOOLS)/bin/$(MACH)/chk4ubin
1107CHK4UBINFLAGS=
1108CHK4UBINARY=	$(CHK4UBIN) $(CHK4UBINFLAGS) $@
1109
1110#
1111# PKGARCHIVE specifies the default location where packages should be
1112# placed if built.
1113#
1114$(RELEASE_BUILD)PKGARCHIVESUFFIX=	-nd
1115PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly$(PKGARCHIVESUFFIX)
1116
1117#
1118# The repositories will be created with these publisher settings.  To
1119# update an image to the resulting repositories, this must match the
1120# publisher name provided to "pkg set-publisher."
1121#
1122PKGPUBLISHER_REDIST=	on-nightly
1123PKGPUBLISHER_NONREDIST=	on-extra
1124
1125#	Default build rules which perform comment section post-processing.
1126#
1127.c:
1128	$(LINK.c) -o $@ $< $(LDLIBS)
1129	$(POST_PROCESS)
1130.c.o:
1131	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
1132	$(POST_PROCESS_O)
1133.c.a:
1134	$(COMPILE.c) -o $% $<
1135	$(PROCESS_COMMENT) $%
1136	$(AR) $(ARFLAGS) $@ $%
1137	$(RM) $%
1138.s.o:
1139	$(COMPILE.s) -o $@ $<
1140	$(POST_PROCESS_S_O)
1141.s.a:
1142	$(COMPILE.s) -o $% $<
1143	$(PROCESS_COMMENT) $%
1144	$(AR) $(ARFLAGS) $@ $%
1145	$(RM) $%
1146.cc:
1147	$(LINK.cc) -o $@ $< $(LDLIBS)
1148	$(POST_PROCESS)
1149.cc.o:
1150	$(COMPILE.cc) $(OUTPUT_OPTION) $<
1151	$(POST_PROCESS_CC_O)
1152.cc.a:
1153	$(COMPILE.cc) -o $% $<
1154	$(AR) $(ARFLAGS) $@ $%
1155	$(PROCESS_COMMENT) $%
1156	$(RM) $%
1157.y:
1158	$(YACC.y) $<
1159	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
1160	$(POST_PROCESS)
1161	$(RM) y.tab.c
1162.y.o:
1163	$(YACC.y) $<
1164	$(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
1165	$(POST_PROCESS_O)
1166	$(RM) y.tab.c
1167.l:
1168	$(RM) $*.c
1169	$(LEX.l) $< > $*.c
1170	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
1171	$(POST_PROCESS)
1172	$(RM) $*.c
1173.l.o:
1174	$(RM) $*.c
1175	$(LEX.l) $< > $*.c
1176	$(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
1177	$(POST_PROCESS_O)
1178	$(RM) $*.c
1179
1180.bin.o:
1181	$(COMPILE.b) -o $@ $<
1182	$(POST_PROCESS_O)
1183
1184.java.class:
1185	$(COMPILE.java) $<
1186
1187# Bourne and Korn shell script message catalog build rules.
1188# We extract all gettext strings with sed(1) (being careful to permit
1189# multiple gettext strings on the same line), weed out the dups, and
1190# build the catalogue with awk(1).
1191
1192.sh.po .ksh.po:
1193	$(SED) -n -e ":a"					\
1194		  -e "h"					\
1195		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
1196		  -e "x"					\
1197		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
1198		  -e "t a"					\
1199	       $< | sort -u | $(AWK) '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
1200
1201#
1202# Python and Perl executable and message catalog build rules.
1203#
1204.SUFFIXES: .pl .pm .py .pyc
1205
1206.pl:
1207	$(RM) $@;
1208	$(SED) -e "s@TEXT_DOMAIN@\"$(TEXT_DOMAIN)\"@" $< > $@;
1209	$(CHMOD) +x $@
1210
1211.py:
1212	$(RM) $@; $(SED) \
1213		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
1214		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
1215		< $< > $@; $(CHMOD) +x $@
1216
1217.py.pyc:
1218	$(RM) $@
1219	$(PYTHON) -mpy_compile $<
1220	@[ $(<)c = $@ ] || $(MV) $(<)c $@
1221
1222.py.po:
1223	$(GNUXGETTEXT) $(GNUXGETFLAGS) -d $(<F:%.py=%) $< ;
1224
1225.pl.po .pm.po:
1226	$(XGETTEXT) $(XGETFLAGS) -d $(<F) $< ;
1227	$(RM)	$@ ;
1228	$(SED) "/^domain/d" < $(<F).po > $@ ;
1229	$(RM) $(<F).po
1230
1231#
1232# When using xgettext, we want messages to go to the default domain,
1233# rather than the specified one.  This special version of the
1234# COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
1235# causing xgettext to put all messages into the default domain.
1236#
1237CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
1238
1239.c.i:
1240	$(CPPFORPO) $< > $@
1241
1242.h.i:
1243	$(CPPFORPO) $< > $@
1244
1245.y.i:
1246	$(YACC) -d $<
1247	$(CPPFORPO) y.tab.c  > $@
1248	$(RM) y.tab.c
1249
1250.l.i:
1251	$(LEX) $<
1252	$(CPPFORPO) lex.yy.c  > $@
1253	$(RM) lex.yy.c
1254
1255.c.po:
1256	$(CPPFORPO) $< > $<.i
1257	$(BUILD.po)
1258
1259.cc.po:
1260	$(CPPFORPO) $< > $<.i
1261	$(BUILD.po)
1262
1263.y.po:
1264	$(YACC) -d $<
1265	$(CPPFORPO) y.tab.c  > $<.i
1266	$(BUILD.po)
1267	$(RM) y.tab.c
1268
1269.l.po:
1270	$(LEX) $<
1271	$(CPPFORPO) lex.yy.c  > $<.i
1272	$(BUILD.po)
1273	$(RM) lex.yy.c
1274
1275#
1276# Rules to perform stylistic checks
1277#
1278.SUFFIXES: .x .xml .check .xmlchk
1279
1280.h.check:
1281	$(DOT_H_CHECK)
1282
1283.x.check:
1284	$(DOT_X_CHECK)
1285
1286.xml.xmlchk:
1287	$(MANIFEST_CHECK)
1288