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