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