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