xref: /titanic_51/usr/src/Makefile.master (revision bb25c06cca41ca78e5fb87fbb8e81d55beb18c95)
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_SEKEY =	\
779			$(CLOSED)/cmd/cmd-crypto/etc/keys/SUNWosnetSolaris
780$(EXPORT_RELEASE_BUILD)ELFSIGN_SECERT=	\
781			$(CLOSED)/cmd/cmd-crypto/etc/certs/SUNWosnetSolaris
782$(EXPORT_RELEASE_BUILD)ELFSIGN_CRYPTO=	$(ELFSIGN_O) sign \
783			$(ELFSIGN_FORMAT_OPTION) \
784			-k $(ELFSIGN_KEY) -c $(ELFSIGN_CERT) -e $@
785$(EXPORT_RELEASE_BUILD)ELFSIGN_OBJECT=	$(ELFSIGN_O) sign \
786			$(ELFSIGN_FORMAT_OPTION) \
787			-k $(ELFSIGN_SEKEY) -c $(ELFSIGN_SECERT) -e $@
788
789# Rules (normally from make.rules) and macros which are used for post
790# processing files. Normally, these do stripping of the comment section
791# automatically.
792#    RELEASE_CM:	Should be editted to reflect the release.
793#    POST_PROCESS_O:	Post-processing for `.o' files.
794#    POST_PROCESS_A:	Post-processing for `.a' files (currently null).
795#    POST_PROCESS_SO:	Post-processing for `.so' files.
796#    POST_PROCESS:	Post-processing for executable files (no suffix).
797# Note that these macros are not completely generalized as they are to be
798# used with the file name to be processed following.
799#
800# It is left as an exercise to Release Engineering to embellish the generation
801# of the release comment string.
802#
803#	If this is a standard development build:
804#		compress the comment section (mcs -c)
805#		add the standard comment (mcs -a $(RELEASE_CM))
806#		add the development specific comment (mcs -a $(DEV_CM))
807#
808#	If this is an installation build:
809#		delete the comment section (mcs -d)
810#		add the standard comment (mcs -a $(RELEASE_CM))
811#		add the development specific comment (mcs -a $(DEV_CM))
812#
813#	If this is an release build:
814#		delete the comment section (mcs -d)
815#		add the standard comment (mcs -a $(RELEASE_CM))
816#
817#	The ONVERS macro sets the default value for the VERSION string
818#	within pkginfo.
819#
820# The following list of macros are used in the definition of RELEASE_CM
821# which is used to label all binaries in the build:
822#
823# 	RELEASE		Specific release of the build, eg: 5.2
824#	VERSION		Version of the build (alpha, beta, Generic)
825#	PATCHID		If this is a patch this value should contain
826#			the patchid value (eg: "Generic 100832-01"), otherwise
827#			it will be set to $(VERSION)
828#	RELEASE_DATE	Date of the Release Build
829#	PATCH_DATE	Date the patch was created, if this is blank it
830#			will default to the RELEASE_DATE
831#
832ONVERS=		"11.11"
833RELEASE=	5.11
834VERSION=	SunOS Development
835PATCHID=	$(VERSION)
836RELEASE_DATE=	October 2007
837PATCH_DATE=	$(RELEASE_DATE)
838RELEASE_CM=	"@($(POUND_SIGN))SunOS $(RELEASE) $(PATCHID) $(PATCH_DATE)"
839DEV_CM=		"@($(POUND_SIGN))SunOS Internal Development: \
840`$(ECHO) $$LOGNAME` `date +%Y-%m-%d` `$(ECHO) [\`basename $$CODEMGR_WS\`]`"
841
842PROCESS_COMMENT=		   @?${MCS} -c -a $(RELEASE_CM) -a $(DEV_CM)
843$(STRIP_COMMENTS)PROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
844$(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
845
846STRIP_STABS=			   :
847$(RELEASE_BUILD)STRIP_STABS=	   $(STRIP) -x $@
848
849POST_PROCESS_O=		$(PROCESS_COMMENT) $@
850POST_PROCESS_A=
851POST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
852			$(ELFSIGN_OBJECT)
853POST_PROCESS=		$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
854			$(ELFSIGN_OBJECT)
855
856#
857# The PKGDEFS macro points to the source directory containing the majority
858# of ON's package definitions plus Makefiles with general package creation
859# rules.
860#
861# PKGARCHIVE specifies the default location where packages should be
862# placed if built.
863#
864PKGDEFS=$(SRC)/pkgdefs
865$(RELEASE_BUILD)PKGARCHIVESUFFIX=	-nd
866PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly$(PKGARCHIVESUFFIX)
867
868#	Default build rules which perform comment section post-processing.
869#
870.c:
871	$(LINK.c) -o $@ $< $(LDLIBS)
872	$(POST_PROCESS)
873.c.o:
874	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
875	$(POST_PROCESS_O)
876.c.a:
877	$(COMPILE.c) -o $% $<
878	$(PROCESS_COMMENT) $%
879	$(AR) $(ARFLAGS) $@ $%
880	$(RM) $%
881.s.o:
882	$(COMPILE.s) -o $@ $<
883	$(POST_PROCESS_O)
884.s.a:
885	$(COMPILE.s) -o $% $<
886	$(PROCESS_COMMENT) $%
887	$(AR) $(ARFLAGS) $@ $%
888	$(RM) $%
889.cc:
890	$(LINK.cc) -o $@ $< $(LDLIBS)
891	$(POST_PROCESS)
892.cc.o:
893	$(COMPILE.cc) $(OUTPUT_OPTION) $<
894	$(POST_PROCESS_O)
895.cc.a:
896	$(COMPILE.cc) -o $% $<
897	$(AR) $(ARFLAGS) $@ $%
898	$(PROCESS_COMMENT) $%
899	$(RM) $%
900.y:
901	$(YACC.y) $<
902	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
903	$(POST_PROCESS)
904	$(RM) y.tab.c
905.y.o:
906	$(YACC.y) $<
907	$(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
908	$(POST_PROCESS_O)
909	$(RM) y.tab.c
910.l:
911	$(RM) $*.c
912	$(LEX.l) $< > $*.c
913	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
914	$(POST_PROCESS)
915	$(RM) $*.c
916.l.o:
917	$(RM) $*.c
918	$(LEX.l) $< > $*.c
919	$(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
920	$(POST_PROCESS_O)
921	$(RM) $*.c
922
923.java.class:
924	$(COMPILE.java) $<
925
926#
927# Rules to create message catalogue files from .sh, .ksh, .c, .y, and .l
928# files.  For .sh and .ksh files, we extract all gettext strings with
929# sed(1) (being careful to permit multiple gettext strings on the same
930# line), weed out the dups, and build the catalogue with awk(1).
931#
932
933.sh.po:
934	$(SED) -n -e ":a" 					\
935		  -e "h" 					\
936		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
937		  -e "x"					\
938		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
939		  -e "t a"					\
940	       $< | sort -u | awk '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
941
942.ksh.po:
943	$(SED) -n -e ":a" 					\
944		  -e "h" 					\
945		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
946		  -e "x"					\
947		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
948		  -e "t a"					\
949	       $< | sort -u | awk '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
950
951#
952# When using xgettext, we want messages to go to the default domain,
953# rather than the specified one.  This special version of the
954# COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
955# causing xgettext to put all messages into the default domain.
956#
957CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
958
959.c.i:
960	$(CPPFORPO) $< > $@
961
962.h.i:
963	$(CPPFORPO) $< > $@
964
965.y.i:
966	$(YACC) -d $<
967	$(CPPFORPO) y.tab.c  > $@
968	$(RM) y.tab.c
969
970.l.i:
971	$(LEX) $<
972	$(CPPFORPO) lex.yy.c  > $@
973	$(RM) lex.yy.c
974
975.c.po:
976	$(CPPFORPO) $< > $<.i
977	$(BUILD.po)
978
979.y.po:
980	$(YACC) -d $<
981	$(CPPFORPO) y.tab.c  > $<.i
982	$(BUILD.po)
983	$(RM) y.tab.c
984
985.l.po:
986	$(LEX) $<
987	$(CPPFORPO) lex.yy.c  > $<.i
988	$(BUILD.po)
989	$(RM) lex.yy.c
990
991#
992# Rules to perform stylistic checks
993#
994.SUFFIXES: $(SUFFIXES) .x .xml .check .xmlchk
995
996.h.check:
997	$(DOT_H_CHECK)
998
999.x.check:
1000	$(DOT_X_CHECK)
1001
1002.xml.xmlchk:
1003	$(MANIFEST_CHECK)
1004
1005#
1006# Rules to process ONC+ Source partial files
1007#
1008%_onc_plus:	%
1009	@$(ECHO) "extracting code from $< ... "
1010	sed -n -e '/ONC_PLUS EXTRACT START/,/ONC_PLUS EXTRACT END/p' $<  > $@
1011
1012#
1013# Include rules to render automated sccs get rules "safe".
1014#
1015include $(SRC)/Makefile.noget
1016