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