xref: /titanic_52/usr/src/Makefile.master (revision 657b1f3d64bcf8eaa2385dba72a6047f089433b2)
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 2006 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27#
28
29#
30# Makefile.master, global definitions for system source
31#
32ROOT=		/proto
33
34# Historically, ON builds were always done with root permissions, and the
35# owner/group information was duplicated in the Makefiles and the packaging
36# data and kept in sync by manual intervention.  This is no longer true.
37# The only source of this information is packaging.  The proto area ($ROOT)
38# does not have definitive onwer/group information, and no Makefile should
39# attempt to set this.  CH once toggled operations restricted to root.  It
40# is now just set to `#'.
41#
42# At some point in the future, CH, CHOWN, CHGRP, OWNER, and GROUP should all
43# be stripped completely from the source base.  They are kept for now until
44# on10-based projects can merge and transition away from them.
45#
46# RELEASE_BUILD should be cleared for final release builds. This is completely
47# independent of CH. NOT_RELEASE_BUILD is exactly what the name implies.
48#
49# INTERNAL_RELEASE_BUILD is a subset of RELEASE_BUILD. It mostly controls
50# identification strings. Enabling RELEASE_BUILD automatically enables
51# INTERNAL_RELEASE_BUILD.
52#
53# EXPORT_RELEASE_BUILD controls whether binaries are built in a form that
54# can be released for export under a binary license.  It is orthogonal to
55# the other *RELEASE_BUILD settings.  ("#" means do an export release
56# build, "" means do a normal build.)
57#
58# CLOSED_BUILD controls whether we try to build files under
59# usr/closed.  ("" means to build closed code, "#" means don't try to
60# build it.)  Skipping the closed code implies doing an export release
61# build.
62#
63# STRIP_COMMENTS toggles comment section striping. Generally the same setting
64# as INTERNAL_RELEASE_BUILD.
65#
66# __GNUC toggles the building of ON components using gcc and related tools.
67# Normally set to `#', set it to `' to do gcc build.
68#
69# The declaration POUND_SIGN is always '#'. This is needed to get around the
70# make feature that '#' is always a comment delimiter, even when escaped or
71# quoted.  The only way of generating this is the :sh macro mechanism.  Note
72# however that in general :sh macros should be avoided in makefiles that are
73# widely included into other makefiles, as the resulting shell executions can
74# cause a noticable slowdown in build times.
75#
76POUND_SIGN:sh=				echo \\043
77CH=					$(POUND_SIGN)
78
79NOT_RELEASE_BUILD=
80INTERNAL_RELEASE_BUILD=			$(POUND_SIGN)
81RELEASE_BUILD=				$(POUND_SIGN)
82$(RELEASE_BUILD)NOT_RELEASE_BUILD=	$(POUND_SIGN)
83$(RELEASE_BUILD)INTERNAL_RELEASE_BUILD=
84PATCH_BUILD=				$(POUND_SIGN)
85
86# If CLOSED_IS_PRESENT is not set, assume the closed tree is present.
87CLOSED_BUILD_1=	$(CLOSED_IS_PRESENT:yes=)
88CLOSED_BUILD=	$(CLOSED_BUILD_1:no=$(POUND_SIGN))
89
90EXPORT_RELEASE_BUILD=			$(POUND_SIGN)
91$(CLOSED_BUILD)EXPORT_RELEASE_BUILD=
92
93# SPARC_BLD is '#' for an Intel build.
94# INTEL_BLD is '#' for a Sparc build.
95SPARC_BLD_1=    $(MACH:i386=$(POUND_SIGN))
96SPARC_BLD=      $(SPARC_BLD_1:sparc=)
97INTEL_BLD_1=    $(MACH:sparc=$(POUND_SIGN))
98INTEL_BLD=      $(INTEL_BLD_1:i386=)
99
100STRIP_COMMENTS=	$(INTERNAL_RELEASE_BUILD)
101
102# set __GNUC= in the environment to build 32-bit with the gcc compiler.
103# The default is to use the Sun Studio compiler for all processor types.
104__GNUC=		$(POUND_SIGN)
105
106# set __GNUC64= in the environment to build 64-bit with the gcc compiler.
107# Inherit the __GNUC value by default, and if that is set to $(POUND_SIGN)
108# then this means use the Sun Studio compiler.
109__GNUC64=	$(__GNUC)
110
111# set __SSNEXT= in the enviroment to build with the 'next' release of
112# the Sun Studio compiler. This will cause command line options specific
113# to the 'next' version of the Sun Studio compiler to be used.
114__SSNEXT=	$(POUND_SIGN)
115
116# CLOSED is the root of the tree that contains source which isn't released
117# as open source
118CLOSED=		$(SRC)/../closed
119
120# BUILD_TOOLS is the root of all tools including compilers.
121# ONBLD_TOOLS is the root of all the tools that are part of SUNWonbld.
122
123BUILD_TOOLS=		/ws/onnv-tools
124ONBLD_TOOLS=		$(BUILD_TOOLS)/onbld
125
126JAVA_ROOT=	/usr/java
127
128SFW_ROOT=	/usr/sfw
129SFWINCDIR=	$(SFW_ROOT)/include
130SFWLIBDIR=	$(SFW_ROOT)/lib
131SFWLIBDIR64=	$(SFW_ROOT)/lib/$(MACH64)
132
133RPCGEN=		/usr/bin/rpcgen
134STABS=		$(ONBLD_TOOLS)/bin/$(MACH)/stabs
135ECHO=		echo
136INS=		install
137TRUE=		true
138SYMLINK=	/usr/bin/ln -s
139LN=		/usr/bin/ln
140CHMOD=		/usr/bin/chmod
141CHOWN=		$(TRUE)
142CHGRP=		$(TRUE)
143MV=		/usr/bin/mv -f
144RM=		/usr/bin/rm -f
145GREP=		/usr/bin/grep
146EGREP=		/usr/bin/egrep
147SED=		/usr/bin/sed
148NAWK=		/usr/bin/nawk
149CP=		/usr/bin/cp -f
150MCS=		/usr/ccs/bin/mcs
151CAT=            /usr/bin/cat
152M4=		/usr/ccs/bin/m4
153STRIP=		/usr/ccs/bin/strip
154LEX=		/usr/ccs/bin/lex
155YACC=		/usr/ccs/bin/yacc
156CPP=		/usr/lib/cpp
157JAVAC=		$(JAVA_ROOT)/bin/javac
158JAVAH=		$(JAVA_ROOT)/bin/javah
159JAVADOC=	$(JAVA_ROOT)/bin/javadoc
160RMIC=		$(JAVA_ROOT)/bin/rmic
161JAR=		$(JAVA_ROOT)/bin/jar
162CTFCONVERT=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfconvert
163CTFMERGE=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfmerge
164CTFSTABS=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
165GENOFFSETS=	$(ONBLD_TOOLS)/bin/genoffsets
166CTFCVTPTBL=	$(ONBLD_TOOLS)/bin/ctfcvtptbl
167CTFFINDMOD=	$(ONBLD_TOOLS)/bin/ctffindmod
168XREF=		$(ONBLD_TOOLS)/bin/xref
169FIND=		/usr/bin/find
170PERL=		/usr/bin/perl
171SORT=		/usr/bin/sort
172TOUCH=		/usr/bin/touch
173WC=		/usr/bin/wc
174XARGS=		/usr/bin/xargs
175ELFSIGN=	/usr/bin/elfsign
176DTRACE=		/usr/sbin/dtrace
177CHECK_FNAMES=	$(ONBLD_TOOLS)/bin/check_fnames
178
179# Due to 6367203, objects built with gcc will fail the namespace checks.
180# Remove this override once the compiler bug is fixed.
181$(__GNUC)CHECK_FNAMES=	$(TRUE)
182
183FILEMODE=	644
184DIRMODE=	755
185
186# Note: owner and group for proto area objects is no longer set by
187# Makefiles at all.  These have no real effect and are kept here for
188# transition purposes.  They (along with CH, CHOWN, and CHGRP) should be
189# removed early in the s11 development cycle.
190OWNER=		root
191GROUP=		bin
192
193#
194# The version of the patch makeup table optimized for build-time use.  Used
195# during patch builds only.
196$(PATCH_BUILD)PMTMO_FILE=$(SRC)/patch_makeup_table.mo
197
198# Declare that nothing should be built in parallel.
199# Individual Makefiles can use the .PARALLEL target to declare otherwise.
200.NO_PARALLEL:
201
202# For stylistic checks
203#
204# Note that the X and C checks are not used at this time and may need
205# modification when they are actually used.
206#
207CSTYLE=		cstyle
208CSTYLE_TAIL=
209HDRCHK=		hdrchk
210HDRCHK_TAIL=
211JSTYLE=		jstyle
212
213DOT_H_CHECK=	\
214	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
215	$(HDRCHK) $< $(HDRCHK_TAIL)
216
217DOT_X_CHECK=	\
218	@$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
219	$(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)
220
221DOT_C_CHECK=	\
222	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)
223
224MANIFEST_CHECK=	\
225	@$(ECHO) "checking $<"; \
226	SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
227	$(SRC)/cmd/svc/svccfg/svccfg-native validate $<
228
229INS.file=	$(RM) $@; $(INS) -s -m $(FILEMODE) -f $(@D) $<
230INS.dir=	$(INS) -s -d -m $(DIRMODE) $@
231# installs and renames at once
232#
233INS.rename=	$(INS.file); $(MV) $(@D)/$(<F) $@
234
235# install a link
236INSLINKTARGET=	$<
237INS.link=	$(RM) $@; $(LN) $(INSLINKTARGET) $@
238
239# MACH must be set in the shell environment per uname -p on the build host
240# More specific architecture variables should be set in lower makefiles.
241#
242# MACH64 is derived from MACH, and BUILD64 is set to `#' for
243# architectures on which we do not build 64-bit versions.
244# (There are no such architectures at the moment.)
245#
246# Set BUILD64=# in the environment to disable 64-bit amd64
247# builds on i386 machines.
248
249MACH64_1=	$(MACH:sparc=sparcv9)
250MACH64=		$(MACH64_1:i386=amd64)
251
252MACH32_1=	$(MACH:sparc=sparcv7)
253MACH32=		$(MACH32_1:i386=i86)
254
255sparc_BUILD64=
256i386_BUILD64=
257BUILD64=	$($(MACH)_BUILD64)
258
259#
260# C compiler mode. Future compilers may change the default on us,
261# so force extended ANSI mode globally. Lower level makefiles can
262# override this by setting CCMODE.
263#
264CCMODE=			-Xa
265CCMODE64=		-Xa
266
267#
268# C compiler verbose mode. This is so we can enable it globally,
269# but turn it off in the lower level makefiles of things we cannot
270# (or aren't going to) fix.
271#
272CCVERBOSE=		-v
273
274# set this to the secret flag "-Wc,-Qiselect-v9abiwarn=1" to get warnings
275# from the compiler about places the -xarch=v9 may differ from -xarch=v9c.
276V9ABIWARN=
277
278# set this to the secret flag "-Wc,-Qiselect-regsym=0" to disable register
279# symbols (used to detect conflicts between objects that use global registers)
280# we disable this now for safety, and because genunix doesn't link with
281# this feature (the v9 default) enabled.
282#
283# REGSYM is separate since the C++ driver syntax is different.
284CCREGSYM=		-Wc,-Qiselect-regsym=0
285CCCREGSYM=		-Qoption cg -Qiselect-regsym=0
286
287# Prevent the removal of static symbols by the SPARC code generator (cg).
288# The x86 code generator (ube) does not remove such symbols and as such
289# using this workaround is not applicable for x86.
290#
291CCSTATICSYM=		-Wc,-Qassembler-ounrefsym=0
292#
293# generate 32-bit addresses in the v9 kernel. Saves memory.
294CCABS32=		-Wc,-xcode=abs32
295
296# One optimization the compiler might perform is to turn this:
297#	#pragma weak foo
298#	extern int foo;
299#	if (&foo)
300#		foo = 5;
301# into
302#	foo = 5;
303# Since we do some of this (foo might be referenced in common kernel code
304# but provided only for some cpu modules or platforms), we disable this
305# optimization.
306#
307sparc_CCUNBOUND	= -Wd,-xsafe=unboundsym
308i386_CCUNBOUND	=
309CCUNBOUND	= $($(MACH)_CCUNBOUND)
310
311#
312# compiler '-xarch' flag. This is here to centralize it and make it
313# overridable for testing.
314sparc_XARCH=		-xarch=v8
315sparcv9_XARCH=		-xarch=v9
316i386_XARCH=
317amd64_XARCH=		-xarch=amd64 -Ui386 -U__i386
318
319# assembler '-xarch' flag.  Different from compiler '-xarch' flag.
320sparc_AS_XARCH=		-xarch=v8plus
321sparcv9_AS_XARCH=	-xarch=v9
322i386_AS_XARCH=
323amd64_AS_XARCH=		-xarch=amd64 -P -Ui386 -U__i386
324
325#
326# These flags define what we need to be 'standalone' i.e. -not- part
327# of the rather more cosy userland environment.  This basically means
328# the kernel.
329#
330# XX64	future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
331#
332sparc_STAND_FLAGS=	-_gcc=-ffreestanding
333sparcv9_STAND_FLAGS=	-_gcc=-ffreestanding
334i386_STAND_FLAGS=	-_gcc=-ffreestanding
335amd64_STAND_FLAGS=	-Wu,-xmodel=kernel
336$(__SSNEXT)amd64_STAND_FLAGS=	-xmodel=kernel
337
338SAVEARGS=		-Wu,-save_args
339amd64_STAND_FLAGS	+= $(SAVEARGS)
340
341STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
342STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
343
344#
345# disable the incremental linker
346ILDOFF=			-xildoff
347#
348XDEPEND=		-xdepend
349XFFLAG=			-xF
350XESS=			-xs
351XSTRCONST=		-xstrconst
352
353#
354# turn warnings into errors (C)
355CERRWARN = -errtags=yes -errwarn=%all
356CERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
357CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
358
359#
360# turn warnings into errors (C++)
361CCERRWARN=		-xwe
362
363# C99 mode
364C99_ENABLE=	-xc99=%all
365C99_DISABLE=	-xc99=%none
366C99MODE=	$(C99_DISABLE)
367C99LMODE=	$(C99MODE:-xc99%=-Xc99%)
368
369# In most places, assignments to these macros should be appended with +=
370# (CPPFLAGS.master allows values to be prepended to CPPFLAGS).
371sparc_CFLAGS=	$(sparc_XARCH) $(CCSTATICSYM)
372sparcv9_CFLAGS=	$(sparcv9_XARCH) -dalign $(CCVERBOSE) $(V9ABIWARN) $(CCREGSYM) \
373		$(CCSTATICSYM)
374i386_CFLAGS=	$(i386_XARCH)
375amd64_CFLAGS=	$(amd64_XARCH)
376
377sparc_ASFLAGS=	$(sparc_AS_XARCH)
378sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
379i386_ASFLAGS=	$(i386_AS_XARCH)
380amd64_ASFLAGS=	$(amd64_AS_XARCH)
381
382#
383sparc_COPTFLAG=		-xO3
384sparcv9_COPTFLAG=	-xO3
385i386_COPTFLAG=		-O
386amd64_COPTFLAG=		-xO3
387
388COPTFLAG= $($(MACH)_COPTFLAG)
389COPTFLAG64= $($(MACH64)_COPTFLAG)
390
391# When -g is used, the compiler globalizes static objects
392# (gives them a unique prefix). Disable that.
393CNOGLOBAL= -W0,-noglobal
394
395# Direct the Sun Studio compiler to use a static globalization prefix based on the
396# name of the module rather than something unique. Otherwise, objects
397# will not build deterministically, as subsequent compilations of identical
398# source will yeild objects that always look different.
399#
400# In the same spirit, this will also remove the date from the N_OPT stab.
401CGLOBALSTATIC= -W0,-xglobalstatic
402
403# Normally, gcc uses indirect DWARF strings to save space.  However,
404# this causes relocations that ctfconvert cannot handle.  Disable this.
405CDWARFSTR=	-_gcc=-fno-dwarf2-indirect-strings
406
407# Sometimes we want all symbols and types in debugging information even
408# if they aren't used.
409CALLSYMS=	-W0,-xdbggen=no%usedonly
410
411#
412# Default debug format for Sun Studio 11 is dwarf, so force it to
413# generate stabs.
414#
415DEBUGFORMAT=	-xdebugformat=stabs
416
417#
418# Flags used to build in debug mode for ctf generation.  Bugs in the Devpro
419# compilers currently prevent us from building with cc-emitted DWARF.
420#
421CTF_FLAGS_sparc	= -g -Wc,-Qiselect-T1 $(C99MODE) $(CNOGLOBAL) $(CDWARFSTR)
422CTF_FLAGS_i386	= -g $(C99MODE) $(CNOGLOBAL) $(CDWARFSTR)
423CTF_FLAGS	= $(CTF_FLAGS_$(MACH)) $(DEBUGFORMAT)
424
425#
426# Flags used with genoffsets
427#
428GOFLAGS = -_noecho \
429	$(CALLSYMS) \
430	$(CDWARFSTR)
431
432OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
433	$(CC) $(GOFLAGS) $(CFLAGS) $(CPPFLAGS)
434
435OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
436	$(CC) $(GOFLAGS) $(CFLAGS64) $(CPPFLAGS)
437
438#
439# tradeoff time for space (smaller is better)
440#
441sparc_SPACEFLAG		= -xspace -W0,-Lt
442sparcv9_SPACEFLAG	= -xspace -W0,-Lt
443i386_SPACEFLAG		= -xspace
444amd64_SPACEFLAG		=
445
446SPACEFLAG		= $($(MACH)_SPACEFLAG)
447SPACEFLAG64		= $($(MACH64)_SPACEFLAG)
448
449#
450# The Sun Studio 11 compiler has changed the behaviour of integer
451# wrap arounds and so a flag is needed to use the legacy behaviour
452# (without this flag panics/hangs could be exposed within the source).
453#
454sparc_IROPTFLAG		= -W2,-xwrap_int
455sparcv9_IROPTFLAG	= -W2,-xwrap_int
456i386_IROPTFLAG		=
457amd64_IROPTFLAG		=
458
459IROPTFLAG		= $($(MACH)_IROPTFLAG)
460IROPTFLAG64		= $($(MACH64)_IROPTFLAG)
461
462sparc_XREGSFLAG		= -xregs=no%appl
463sparcv9_XREGSFLAG	= -xregs=no%appl
464i386_XREGSFLAG		=
465amd64_XREGSFLAG		=
466
467XREGSFLAG		= $($(MACH)_XREGSFLAG)
468XREGSFLAG64		= $($(MACH64)_XREGSFLAG)
469
470CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
471		$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG) \
472		$(CGLOBALSTATIC)
473CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
474		$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG64) \
475		$(CGLOBALSTATIC)
476#
477# Flags that are used to build parts of the code that are subsequently
478# run on the build machine (also known as the NATIVE_BUILD).
479#
480NATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
481		$(ILDOFF) $(CERRWARN) $(C99MODE) $($(NATIVE_MACH)_CCUNBOUND) \
482		$(IROPTFLAG) $(CGLOBALSTATIC)
483
484DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
485DTS_ERRNO=-D_TS_ERRNO
486CPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
487	$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4)
488CPPFLAGS=	$(CPPFLAGS.master)
489AS_CPPFLAGS=	$(CPPFLAGS.master)
490JAVAFLAGS=	-deprecation
491
492#
493# For source message catalogue
494#
495.SUFFIXES: $(SUFFIXES) .i .po
496MSGROOT= $(ROOT)/catalog
497MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
498MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
499DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
500DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
501
502CLOBBERFILES += $(POFILE) $(POFILES)
503COMPILE.cpp= $(CC) -E -C $(CFLAGS) $(CPPFLAGS)
504XGETTEXT= /usr/bin/xgettext
505XGETFLAGS= -c TRANSLATION_NOTE
506BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
507	$(RM)	$@ ;\
508	sed "/^domain/d" < $(<F).po > $@ ;\
509	$(RM) $(<F).po $<.i
510#
511# This is overwritten by local Makefile when PROG is a list.
512#
513POFILE= $(PROG).po
514
515sparc_CCFLAGS=		-cg92 -compat=4 \
516			-Qoption ccfe -messages=no%anachronism \
517			$(CCERRWARN)
518sparcv9_CCFLAGS=	$(sparcv9_XARCH) -dalign -compat=5 \
519			-Qoption ccfe -messages=no%anachronism \
520			-Qoption ccfe -features=no%conststrings \
521			$(CCCREGSYM) \
522			$(CCERRWARN)
523i386_CCFLAGS=		-compat=4 \
524			-Qoption ccfe -messages=no%anachronism \
525			-Qoption ccfe -features=no%conststrings \
526			$(CCERRWARN)
527amd64_CCFLAGS=		$(amd64_XARCH) -compat=5 \
528			-Qoption ccfe -messages=no%anachronism \
529			-Qoption ccfe -features=no%conststrings \
530			$(CCERRWARN)
531
532sparc_CCOPTFLAG=	-O
533sparcv9_CCOPTFLAG=	-O
534i386_CCOPTFLAG=		-O
535amd64_CCOPTFLAG=	-O
536
537CCOPTFLAG=	$($(MACH)_CCOPTFLAG)
538CCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
539CCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS)
540CCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS)
541#
542# Used by Makefile.cmd, Makefile.lib and Makefile.ucbcmd
543#
544PGA_MAPFILE =	$(SRC)/cmd/sgs/mapfiles/$(MACH)/map.pagealign
545#
546#
547# LDLIBS32 can be set in the environment to override the following assignment.
548# LDLIBS64 can be set to override the assignment made in Makefile.master.64.
549# These environment settings make sure that no libraries are searched outside
550# of the local workspace proto area:
551#	LDLIBS32=-YP,$ROOT/lib:$ROOT/usr/lib
552#	LDLIBS64=-YP,$ROOT/lib/$MACH64:$ROOT/usr/lib/$MACH64
553#
554LDLIBS32 =	$(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
555LDLIBS.cmd = 	$(LDLIBS32)
556LDLIBS.lib =	$(LDLIBS32)
557#
558# Define compilation macros.
559#
560COMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
561COMPILE64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) -c
562COMPILE.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) -c
563COMPILE64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
564COMPILE.s=	$(AS) $(ASFLAGS) $(AS_CPPFLAGS)
565COMPILE64.s=	$(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
566COMPILE.d=	$(DTRACE) -G -32
567COMPILE64.d=	$(DTRACE) -G -64
568
569CLASSPATH=	.
570COMPILE.java=	$(JAVAC) $(JAVAFLAGS) -classpath $(CLASSPATH)
571
572#
573# Link time macros
574#
575CCNEEDED		= -lC
576$(__GNUC)CCNEEDED	= -L$(SFWLIBDIR) -R$(SFWLIBDIR) -lstdc++ -lgcc_s
577
578LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
579LINK64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
580NORUNPATH=	-norunpath -nolib
581LINK.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) $(NORUNPATH) \
582		$(LDFLAGS) $(CCNEEDED)
583LINK64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) $(NORUNPATH) \
584		$(LDFLAGS) $(CCNEEDED)
585
586#
587# lint macros
588#
589# Note that the undefine of __PRAGMA_REDEFINE_EXTNAME can be removed once
590# ON is built with a version of lint that has the fix for 4484186.
591#
592ALWAYS_LINT_DEFS =	-errtags=yes -s
593ALWAYS_LINT_DEFS +=	-erroff=E_PTRDIFF_OVERFLOW
594ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_NARROW_CONV
595ALWAYS_LINT_DEFS +=	-U__PRAGMA_REDEFINE_EXTNAME
596ALWAYS_LINT_DEFS +=	$(C99LMODE)
597ALWAYS_LINT_DEFS +=	-errsecurity=$(SECLEVEL)
598ALWAYS_LINT_DEFS +=	-erroff=E_SEC_CREAT_WITHOUT_EXCL
599ALWAYS_LINT_DEFS +=	-erroff=E_SEC_FORBIDDEN_WARN_CREAT
600# XX64 -- really only needed for amd64 lint
601ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_INT_TO_SMALL_INT
602ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_CONST_TO_SMALL_INT
603ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_TO_SMALL_INT
604ALWAYS_LINT_DEFS +=	-erroff=E_CAST_TO_PTR_FROM_INT
605ALWAYS_LINT_DEFS +=	-erroff=E_COMP_INT_WITH_LARGE_INT
606ALWAYS_LINT_DEFS +=	-erroff=E_INTEGRAL_CONST_EXP_EXPECTED
607ALWAYS_LINT_DEFS +=	-erroff=E_PASS_INT_TO_SMALL_INT
608ALWAYS_LINT_DEFS +=	-erroff=E_PTR_CONV_LOSES_BITS
609
610SECLEVEL=	core
611LINT.c=		$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(ALWAYS_LINT_DEFS)
612LINT64.c=	$(LINT) $(LINTFLAGS64) $(CPPFLAGS) $(ALWAYS_LINT_DEFS)
613LINT.s=		$(LINT.c)
614
615# For some future builds, NATIVE_MACH and MACH might be different.
616# Therefore, NATIVE_MACH needs to be redefined in the
617# environment as `uname -p` to override this macro.
618#
619# For now at least, we cross-compile amd64 on i386 machines.
620NATIVE_MACH=	$(MACH:amd64=i386)
621
622# Define native compilation macros
623#
624
625# Base directory where compilers are loaded.
626# Defined here so it can be overridden by developer.
627#
628SPRO_ROOT=		$(BUILD_TOOLS)/SUNWspro
629SPRO_VROOT=		$(SPRO_ROOT)/SS11
630GNU_ROOT=		$(SFW_ROOT)
631
632# Specify platform compiler versions for languages
633# that we use (currently only c and c++).
634#
635sparc_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
636$(__GNUC)sparc_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
637sparc_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
638$(__GNUC)sparc_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
639sparc_CPP=		/usr/ccs/lib/cpp
640sparc_AS=		/usr/ccs/bin/as -xregsym=no
641sparc_LD=		/usr/ccs/bin/ld
642sparc_LINT=		$(SPRO_VROOT)/bin/lint
643
644sparcv9_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
645$(__GNUC64)sparcv9_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
646sparcv9_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
647$(__GNUC64)sparcv9_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
648sparcv9_CPP=		/usr/ccs/lib/cpp
649sparcv9_AS=		/usr/ccs/bin/as -xregsym=no
650sparcv9_LD=		/usr/ccs/bin/ld
651sparcv9_LINT=		$(SPRO_VROOT)/bin/lint
652
653# We compile 32-bit objects with cc by default
654i386_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
655$(__GNUC)i386_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
656i386_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
657$(__GNUC)i386_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
658i386_CPP=		/usr/ccs/lib/cpp
659i386_AS=		/usr/ccs/bin/as
660$(__GNUC)i386_AS=	$(ONBLD_TOOLS)/bin/$(MACH)/aw
661i386_LD=		/usr/ccs/bin/ld
662i386_LINT=		$(SPRO_VROOT)/bin/lint
663
664# We compile 64-bit objects with gcc
665amd64_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
666$(__GNUC64)amd64_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
667amd64_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
668$(__GNUC64)amd64_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
669amd64_CPP=		/usr/ccs/lib/cpp
670amd64_AS=		$(ONBLD_TOOLS)/bin/$(MACH)/aw
671amd64_LD=		/usr/ccs/bin/ld
672amd64_LINT=		$(SPRO_VROOT)/bin/lint
673
674NATIVECC=		$($(NATIVE_MACH)_CC)
675NATIVECCC=		$($(NATIVE_MACH)_CCC)
676NATIVECPP=		$($(NATIVE_MACH)_CPP)
677NATIVEAS=		$($(NATIVE_MACH)_AS)
678NATIVELD=		$($(NATIVE_MACH)_LD)
679NATIVELINT=		$($(NATIVE_MACH)_LINT)
680
681#
682# Makefile.master.64 overrides these settings
683#
684CC=			$(NATIVECC)
685CCC=			$(NATIVECCC)
686CPP=			$(NATIVECPP)
687AS=			$(NATIVEAS)
688LD=			$(NATIVELD)
689LINT=			$(NATIVELINT)
690
691# The real compilers used for this build
692CW_CC_CMD=		$(CC) -_compiler
693CW_CCC_CMD=		$(CCC) -_compiler
694REAL_CC=		$(CW_CC_CMD:sh)
695REAL_CCC=		$(CW_CCC_CMD:sh)
696
697# Pass -Y flag to cpp (method of which is release-dependent)
698CCYFLAG=		-Y I,
699
700BDIRECT=	-Bdirect
701BDYNAMIC=	-Bdynamic
702BLOCAL=		-Blocal
703BREDUCE=	-Breduce
704BSTATIC=	-Bstatic
705BSYMBOLIC=	-Bsymbolic
706
707ZCOMBRELOC=	-zcombreloc
708ZDEFS=		-zdefs
709ZIGNORE=	-zignore
710ZINITFIRST=	-zinitfirst
711ZINTERPOSE=	-zinterpose
712ZLAZYLOAD=	-zlazyload
713ZLOADFLTR=	-zloadfltr
714ZMULDEFS=	-zmuldefs
715ZNODEFAULTLIB=	-znodefaultlib
716ZNODEFS=	-znodefs
717ZNODELETE=	-znodelete
718ZNODLOPEN=	-znodlopen
719ZNODUMP=	-znodump
720ZNOLAZYLOAD=	-znolazyload
721ZNORELOC=	-znoreloc
722ZNOVERSION=	-znoversion
723ZREDLOCSYM=	-zredlocsym
724ZTEXT=		-ztext
725
726GSHARED=	-G
727CCMT=		-mt
728
729# Handle different PIC models on different ISAs
730# (May be overridden by lower-level Makefiles)
731
732sparc_C_PICFLAGS =	-K pic
733sparcv9_C_PICFLAGS =	-K pic
734i386_C_PICFLAGS =	-K pic
735amd64_C_PICFLAGS =	-K pic
736C_PICFLAGS =		$($(MACH)_C_PICFLAGS)
737C_PICFLAGS64 =		$($(MACH64)_C_PICFLAGS)
738
739sparc_C_BIGPICFLAGS =	-K PIC
740sparcv9_C_BIGPICFLAGS =	-K PIC
741i386_C_BIGPICFLAGS =	-K PIC
742amd64_C_BIGPICFLAGS =	-K PIC
743C_BIGPICFLAGS =		$($(MACH)_C_BIGPICFLAGS)
744C_BIGPICFLAGS64 =	$($(MACH64)_C_BIGPICFLAGS)
745
746# CC requires there to be no space between '-K' and 'pic' or 'PIC'.
747sparc_CC_PICFLAGS =	-Kpic
748sparcv9_CC_PICFLAGS =	-KPIC
749i386_CC_PICFLAGS = 	-Kpic
750amd64_CC_PICFLAGS = 	-Kpic
751CC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
752CC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)
753
754AS_PICFLAGS=		$(C_PICFLAGS)
755AS_BIGPICFLAGS=		$(C_BIGPICFLAGS)
756
757#
758# Default label for CTF sections
759#
760CTFCVTFLAGS=		-i -L VERSION
761
762#
763# Override to pass module-specific flags to ctfmerge.  Currently used
764# only by krtld to turn on fuzzy matching.
765#
766CTFMRGFLAGS=
767
768CTFCONVERT_O		= $(CTFCONVERT) $(CTFCVTFLAGS) $@
769
770ELFSIGN_O=	$(TRUE)
771ELFSIGN_CRYPTO=	$(ELFSIGN_O)
772ELFSIGN_OBJECT=	$(ELFSIGN_O)
773$(EXPORT_RELEASE_BUILD)ELFSIGN_O =	$(ELFSIGN)
774$(EXPORT_RELEASE_BUILD)ELFSIGN_KEY =	\
775			$(CLOSED)/cmd/cmd-crypto/etc/keys/SUNWosnet
776$(EXPORT_RELEASE_BUILD)ELFSIGN_CERT=	\
777			$(CLOSED)/cmd/cmd-crypto/etc/certs/SUNWosnet
778$(EXPORT_RELEASE_BUILD)ELFSIGN_KEY_LIMITED =	\
779			$(CLOSED)/cmd/cmd-crypto/etc/keys/SUNWosnetLimited
780$(EXPORT_RELEASE_BUILD)ELFSIGN_CERT_LIMITED=	\
781			$(CLOSED)/cmd/cmd-crypto/etc/certs/SUNWosnetLimited
782$(EXPORT_RELEASE_BUILD)ELFSIGN_SEKEY =	\
783			$(CLOSED)/cmd/cmd-crypto/etc/keys/SUNWosnetSolaris
784$(EXPORT_RELEASE_BUILD)ELFSIGN_SECERT=	\
785			$(CLOSED)/cmd/cmd-crypto/etc/certs/SUNWosnetSolaris
786$(EXPORT_RELEASE_BUILD)ELFSIGN_CRYPTO=	$(ELFSIGN_O) sign \
787			$(ELFSIGN_FORMAT_OPTION) \
788			-k $(ELFSIGN_KEY) -c $(ELFSIGN_CERT) -e $@
789$(EXPORT_RELEASE_BUILD)ELFSIGN_CRYPTO_LIMITED=	$(ELFSIGN_O) sign \
790			$(ELFSIGN_FORMAT_OPTION) \
791			-k $(ELFSIGN_KEY_LIMITED) -c $(ELFSIGN_CERT_LIMITED) -e $@
792$(EXPORT_RELEASE_BUILD)ELFSIGN_OBJECT=	$(ELFSIGN_O) sign \
793			$(ELFSIGN_FORMAT_OPTION) \
794			-k $(ELFSIGN_SEKEY) -c $(ELFSIGN_SECERT) -e $@
795
796# Rules (normally from make.rules) and macros which are used for post
797# processing files. Normally, these do stripping of the comment section
798# automatically.
799#    RELEASE_CM:	Should be editted to reflect the release.
800#    POST_PROCESS_O:	Post-processing for `.o' files.
801#    POST_PROCESS_A:	Post-processing for `.a' files (currently null).
802#    POST_PROCESS_SO:	Post-processing for `.so' files.
803#    POST_PROCESS:	Post-processing for executable files (no suffix).
804# Note that these macros are not completely generalized as they are to be
805# used with the file name to be processed following.
806#
807# It is left as an exercise to Release Engineering to embellish the generation
808# of the release comment string.
809#
810#	If this is a standard development build:
811#		compress the comment section (mcs -c)
812#		add the standard comment (mcs -a $(RELEASE_CM))
813#		add the development specific comment (mcs -a $(DEV_CM))
814#
815#	If this is an installation build:
816#		delete the comment section (mcs -d)
817#		add the standard comment (mcs -a $(RELEASE_CM))
818#		add the development specific comment (mcs -a $(DEV_CM))
819#
820#	If this is an release build:
821#		delete the comment section (mcs -d)
822#		add the standard comment (mcs -a $(RELEASE_CM))
823#
824#	The ONVERS macro sets the default value for the VERSION string
825#	within pkginfo.
826#
827# The following list of macros are used in the definition of RELEASE_CM
828# which is used to label all binaries in the build:
829#
830# 	RELEASE		Specific release of the build, eg: 5.2
831#	VERSION		Version of the build (alpha, beta, Generic)
832#	PATCHID		If this is a patch this value should contain
833#			the patchid value (eg: "Generic 100832-01"), otherwise
834#			it will be set to $(VERSION)
835#	RELEASE_DATE	Date of the Release Build
836#	PATCH_DATE	Date the patch was created, if this is blank it
837#			will default to the RELEASE_DATE
838#
839ONVERS=		"11.11"
840RELEASE=	5.11
841VERSION=	SunOS Development
842PATCHID=	$(VERSION)
843RELEASE_DATE=	October 2007
844PATCH_DATE=	$(RELEASE_DATE)
845RELEASE_CM=	"@($(POUND_SIGN))SunOS $(RELEASE) $(PATCHID) $(PATCH_DATE)"
846DEV_CM=		"@($(POUND_SIGN))SunOS Internal Development: \
847`$(ECHO) $$LOGNAME` `date +%Y-%m-%d` `$(ECHO) [\`basename $$CODEMGR_WS\`]`"
848
849PROCESS_COMMENT=		   @?${MCS} -c -a $(RELEASE_CM) -a $(DEV_CM)
850$(STRIP_COMMENTS)PROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
851$(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
852
853STRIP_STABS=			   :
854$(RELEASE_BUILD)STRIP_STABS=	   $(STRIP) -x $@
855
856POST_PROCESS_O=		$(PROCESS_COMMENT) $@
857POST_PROCESS_A=
858POST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
859			$(ELFSIGN_OBJECT)
860POST_PROCESS=		$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
861			$(ELFSIGN_OBJECT)
862
863#
864# The PKGDEFS macro points to the source directory containing the majority
865# of ON's package definitions plus Makefiles with general package creation
866# rules.
867#
868# PKGARCHIVE specifies the default location where packages should be
869# placed if built.
870#
871PKGDEFS=$(SRC)/pkgdefs
872$(RELEASE_BUILD)PKGARCHIVESUFFIX=	-nd
873PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly$(PKGARCHIVESUFFIX)
874
875#	Default build rules which perform comment section post-processing.
876#
877.c:
878	$(LINK.c) -o $@ $< $(LDLIBS)
879	$(POST_PROCESS)
880.c.o:
881	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
882	$(POST_PROCESS_O)
883.c.a:
884	$(COMPILE.c) -o $% $<
885	$(PROCESS_COMMENT) $%
886	$(AR) $(ARFLAGS) $@ $%
887	$(RM) $%
888.s.o:
889	$(COMPILE.s) -o $@ $<
890	$(POST_PROCESS_O)
891.s.a:
892	$(COMPILE.s) -o $% $<
893	$(PROCESS_COMMENT) $%
894	$(AR) $(ARFLAGS) $@ $%
895	$(RM) $%
896.cc:
897	$(LINK.cc) -o $@ $< $(LDLIBS)
898	$(POST_PROCESS)
899.cc.o:
900	$(COMPILE.cc) $(OUTPUT_OPTION) $<
901	$(POST_PROCESS_O)
902.cc.a:
903	$(COMPILE.cc) -o $% $<
904	$(AR) $(ARFLAGS) $@ $%
905	$(PROCESS_COMMENT) $%
906	$(RM) $%
907.y:
908	$(YACC.y) $<
909	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
910	$(POST_PROCESS)
911	$(RM) y.tab.c
912.y.o:
913	$(YACC.y) $<
914	$(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
915	$(POST_PROCESS_O)
916	$(RM) y.tab.c
917.l:
918	$(RM) $*.c
919	$(LEX.l) $< > $*.c
920	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
921	$(POST_PROCESS)
922	$(RM) $*.c
923.l.o:
924	$(RM) $*.c
925	$(LEX.l) $< > $*.c
926	$(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
927	$(POST_PROCESS_O)
928	$(RM) $*.c
929
930.java.class:
931	$(COMPILE.java) $<
932
933#
934# Rules to create message catalogue files from .sh, .ksh, .c, .y, and .l
935# files.  For .sh and .ksh files, we extract all gettext strings with
936# sed(1) (being careful to permit multiple gettext strings on the same
937# line), weed out the dups, and build the catalogue with awk(1).
938#
939
940.sh.po:
941	$(SED) -n -e ":a" 					\
942		  -e "h" 					\
943		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
944		  -e "x"					\
945		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
946		  -e "t a"					\
947	       $< | sort -u | awk '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
948
949.ksh.po:
950	$(SED) -n -e ":a" 					\
951		  -e "h" 					\
952		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
953		  -e "x"					\
954		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
955		  -e "t a"					\
956	       $< | sort -u | awk '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
957
958#
959# When using xgettext, we want messages to go to the default domain,
960# rather than the specified one.  This special version of the
961# COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
962# causing xgettext to put all messages into the default domain.
963#
964CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
965
966.c.i:
967	$(CPPFORPO) $< > $@
968
969.h.i:
970	$(CPPFORPO) $< > $@
971
972.y.i:
973	$(YACC) -d $<
974	$(CPPFORPO) y.tab.c  > $@
975	$(RM) y.tab.c
976
977.l.i:
978	$(LEX) $<
979	$(CPPFORPO) lex.yy.c  > $@
980	$(RM) lex.yy.c
981
982.c.po:
983	$(CPPFORPO) $< > $<.i
984	$(BUILD.po)
985
986.y.po:
987	$(YACC) -d $<
988	$(CPPFORPO) y.tab.c  > $<.i
989	$(BUILD.po)
990	$(RM) y.tab.c
991
992.l.po:
993	$(LEX) $<
994	$(CPPFORPO) lex.yy.c  > $<.i
995	$(BUILD.po)
996	$(RM) lex.yy.c
997
998#
999# Rules to perform stylistic checks
1000#
1001.SUFFIXES: $(SUFFIXES) .x .xml .check .xmlchk
1002
1003.h.check:
1004	$(DOT_H_CHECK)
1005
1006.x.check:
1007	$(DOT_X_CHECK)
1008
1009.xml.xmlchk:
1010	$(MANIFEST_CHECK)
1011
1012#
1013# Rules to process ONC+ Source partial files
1014#
1015%_onc_plus:	%
1016	@$(ECHO) "extracting code from $< ... "
1017	sed -n -e '/ONC_PLUS EXTRACT START/,/ONC_PLUS EXTRACT END/p' $<  > $@
1018
1019#
1020# Include rules to render automated sccs get rules "safe".
1021#
1022include $(SRC)/Makefile.noget
1023