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