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