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