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