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