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