xref: /titanic_50/usr/src/Makefile.master (revision 44bed9d7e21975b68d41a2a54db2aa0581429ca6)
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# prevent static symbols being optimized out
283CCSTATICSYM=		-Wc,-Qassembler-ounrefsym=0
284#
285# generate 32-bit addresses in the v9 kernel. Saves memory.
286CCABS32=		-Wc,-xcode=abs32
287
288# One optimization the compiler might perform is to turn this:
289#	#pragma weak foo
290#	extern int foo;
291#	if (&foo)
292#		foo = 5;
293# into
294#	foo = 5;
295# Since we do some of this (foo might be referenced in common kernel code
296# but provided only for some cpu modules or platforms), we disable this
297# optimization.
298#
299sparc_CCUNBOUND	= -Wd,-xsafe=unboundsym
300i386_CCUNBOUND	=
301CCUNBOUND	= $($(MACH)_CCUNBOUND)
302
303#
304# compiler '-xarch' flag. This is here to centralize it and make it
305# overridable for testing.
306sparc_XARCH=		-xarch=v8
307sparcv9_XARCH=		-xarch=v9
308i386_XARCH=
309amd64_XARCH=		-xarch=amd64 -Ui386 -U__i386
310
311# assembler '-xarch' flag.  Different from compiler '-xarch' flag.
312sparc_AS_XARCH=		-xarch=v8plus
313sparcv9_AS_XARCH=	-xarch=v9
314i386_AS_XARCH=
315amd64_AS_XARCH=		-xarch=amd64 -P -Ui386 -U__i386
316
317#
318# These flags define what we need to be 'standalone' i.e. -not- part
319# of the rather more cosy userland environment.  This basically means
320# the kernel.
321#
322# XX64	future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
323#
324sparc_STAND_FLAGS=	-_gcc=-ffreestanding
325sparcv9_STAND_FLAGS=	-_gcc=-ffreestanding
326i386_STAND_FLAGS=	-_gcc=-ffreestanding
327amd64_STAND_FLAGS=	-Wu,-xmodel=kernel
328
329SAVEARGS=		-Wu,-save_args
330amd64_STAND_FLAGS	+= $(SAVEARGS)
331
332STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
333STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
334
335#
336# disable the incremental linker
337ILDOFF=			-xildoff
338#
339XDEPEND=		-xdepend
340XFFLAG=			-xF
341XESS=			-xs
342XSTRCONST=		-xstrconst
343
344#
345# turn warnings into errors (C)
346CERRWARN = -errtags=yes -errwarn=%all
347CERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
348CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
349
350#
351# turn warnings into errors (C++)
352CCERRWARN=		-xwe
353
354# C99 mode
355C99_ENABLE=	-xc99=%all
356C99_DISABLE=	-xc99=%none
357C99MODE=	$(C99_DISABLE)
358C99LMODE=	$(C99MODE:-xc99%=-Xc99%)
359
360# In most places, assignments to these macros should be appended with +=
361# (CPPFLAGS.master allows values to be prepended to CPPFLAGS).
362sparc_CFLAGS=	$(sparc_XARCH)
363sparcv9_CFLAGS=	$(sparcv9_XARCH) -dalign $(CCVERBOSE) $(V9ABIWARN) $(CCREGSYM) \
364		$(CCSTATICSYM)
365i386_CFLAGS=	$(i386_XARCH)
366amd64_CFLAGS=	$(amd64_XARCH)
367
368sparc_ASFLAGS=	$(sparc_AS_XARCH)
369sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
370i386_ASFLAGS=	$(i386_AS_XARCH)
371amd64_ASFLAGS=	$(amd64_AS_XARCH)
372
373#
374sparc_COPTFLAG=		-xO3
375sparcv9_COPTFLAG=	-xO3
376i386_COPTFLAG=		-O
377amd64_COPTFLAG=		-xO3
378
379COPTFLAG= $($(MACH)_COPTFLAG)
380COPTFLAG64= $($(MACH64)_COPTFLAG)
381
382# When -g is used, the compiler globalizes static objects
383# (gives them a unique prefix). Disable that.
384CNOGLOBAL= -W0,-noglobal
385
386# Normally, gcc uses indirect DWARF strings to save space.  However,
387# this causes relocations that ctfconvert cannot handle.  Disable this.
388CDWARFSTR=	-_gcc=-fno-dwarf2-indirect-strings
389
390# Sometimes we want all symbols and types in debugging information even
391# if they aren't used.
392CALLSYMS=	-W0,-xdbggen=no%usedonly
393
394#
395# Default debug format for Sun Studio 11 is dwarf, so force it to
396# generate stabs.
397#
398DEBUGFORMAT=	-xdebugformat=stabs
399
400#
401# Flags used to build in debug mode for ctf generation.  Bugs in the Devpro
402# compilers currently prevent us from building with cc-emitted DWARF.
403#
404CTF_FLAGS_sparc	= -g -Wc,-Qiselect-T1 $(C99MODE) $(CNOGLOBAL) $(CDWARFSTR)
405CTF_FLAGS_i386	= -g $(C99MODE) $(CNOGLOBAL) $(CDWARFSTR)
406CTF_FLAGS	= $(CTF_FLAGS_$(MACH)) $(DEBUGFORMAT)
407
408#
409# Flags used with genoffsets
410#
411GOFLAGS = -_noecho \
412	$(CALLSYMS) \
413	$(CDWARFSTR)
414
415OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
416	$(CC) $(GOFLAGS) $(CFLAGS) $(CPPFLAGS)
417
418OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
419	$(CC) $(GOFLAGS) $(CFLAGS64) $(CPPFLAGS)
420
421#
422# tradeoff time for space (smaller is better)
423#
424sparc_SPACEFLAG		= -xspace -W0,-Lt
425sparcv9_SPACEFLAG	= -xspace -W0,-Lt
426i386_SPACEFLAG		= -xspace
427amd64_SPACEFLAG		=
428
429SPACEFLAG		= $($(MACH)_SPACEFLAG)
430SPACEFLAG64		= $($(MACH64)_SPACEFLAG)
431
432#
433# The Sun Studio 11 compiler has changed the behaviour of integer
434# wrap arounds and so a flag is needed to use the legacy behaviour
435# (without this flag panics/hangs could be exposed within the source).
436#
437sparc_IROPTFLAG		= -W2,-xwrap_int
438sparcv9_IROPTFLAG	= -W2,-xwrap_int
439i386_IROPTFLAG		=
440amd64_IROPTFLAG		=
441
442IROPTFLAG		= $($(MACH)_IROPTFLAG)
443IROPTFLAG64		= $($(MACH64)_IROPTFLAG)
444
445sparc_XREGSFLAG		= -xregs=no%appl
446sparcv9_XREGSFLAG	= -xregs=no%appl
447i386_XREGSFLAG		=
448amd64_XREGSFLAG		=
449
450XREGSFLAG		= $($(MACH)_XREGSFLAG)
451XREGSFLAG64		= $($(MACH64)_XREGSFLAG)
452
453CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
454		$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG)
455CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
456		$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG64)
457NATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
458		$(ILDOFF) $(CERRWARN) $(C99MODE) $($(NATIVE_MACH)_CCUNBOUND)
459
460DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
461DTS_ERRNO=-D_TS_ERRNO
462CPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
463	$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4)
464CPPFLAGS=	$(CPPFLAGS.master)
465AS_CPPFLAGS=	$(CPPFLAGS.master)
466JAVAFLAGS=	-deprecation
467
468#
469# For source message catalogue
470#
471.SUFFIXES: $(SUFFIXES) .i .po
472MSGROOT= $(ROOT)/catalog
473MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
474MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
475DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
476DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
477
478CLOBBERFILES += $(POFILE) $(POFILES)
479COMPILE.cpp= $(CC) -E -C $(CFLAGS) $(CPPFLAGS)
480XGETTEXT= /usr/bin/xgettext
481XGETFLAGS= -c TRANSLATION_NOTE
482BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
483	$(RM)	$@ ;\
484	sed "/^domain/d" < $(<F).po > $@ ;\
485	$(RM) $(<F).po $<.i
486#
487# This is overwritten by local Makefile when PROG is a list.
488#
489POFILE= $(PROG).po
490
491sparc_CCFLAGS=		-cg92 -compat=4 \
492			-Qoption ccfe -messages=no%anachronism \
493			$(CCERRWARN)
494sparcv9_CCFLAGS=	$(sparcv9_XARCH) -dalign -compat=5 \
495			-Qoption ccfe -messages=no%anachronism \
496			-Qoption ccfe -features=no%conststrings \
497			$(CCCREGSYM) \
498			$(CCERRWARN)
499i386_CCFLAGS=		-compat=4 \
500			-Qoption ccfe -messages=no%anachronism \
501			-Qoption ccfe -features=no%conststrings \
502			$(CCERRWARN)
503amd64_CCFLAGS=		$(amd64_XARCH) -compat=5 \
504			-Qoption ccfe -messages=no%anachronism \
505			-Qoption ccfe -features=no%conststrings \
506			$(CCERRWARN)
507
508sparc_CCOPTFLAG=	-O
509sparcv9_CCOPTFLAG=	-O
510i386_CCOPTFLAG=		-O
511amd64_CCOPTFLAG=	-O
512
513CCOPTFLAG=	$($(MACH)_CCOPTFLAG)
514CCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
515CCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS)
516CCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS)
517#
518# Used by Makefile.cmd, Makefile.lib and Makefile.ucbcmd
519#
520PGA_MAPFILE =	$(SRC)/cmd/sgs/mapfiles/$(MACH)/map.pagealign
521#
522#
523# LDLIBS32 can be set in the environment to override the following assignment.
524# LDLIBS64 can be set to override the assignment made in Makefile.master.64.
525# These environment settings make sure that no libraries are searched outside
526# of the local workspace proto area:
527#	LDLIBS32=-YP,$ROOT/lib:$ROOT/usr/lib
528#	LDLIBS64=-YP,$ROOT/lib/$MACH64:$ROOT/usr/lib/$MACH64
529#
530LDLIBS32 =	$(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
531LDLIBS.cmd = 	$(LDLIBS32)
532LDLIBS.lib =	$(LDLIBS32)
533#
534# Define compilation macros.
535#
536COMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
537COMPILE64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) -c
538COMPILE.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) -c
539COMPILE64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
540COMPILE.s=	$(AS) $(ASFLAGS) $(AS_CPPFLAGS)
541COMPILE64.s=	$(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
542COMPILE.d=	$(DTRACE) -G -32
543COMPILE64.d=	$(DTRACE) -G -64
544
545CLASSPATH=	.
546COMPILE.java=	$(JAVAC) $(JAVAFLAGS) -classpath $(CLASSPATH)
547
548#
549# Link time macros
550#
551CCNEEDED		= -lC
552$(__GNUC)CCNEEDED	= -L$(SFWLIBDIR) -R$(SFWLIBDIR) -lstdc++ -lgcc_s
553
554LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
555LINK64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
556NORUNPATH=	-norunpath -nolib
557LINK.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) $(NORUNPATH) \
558		$(LDFLAGS) $(CCNEEDED)
559LINK64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) $(NORUNPATH) \
560		$(LDFLAGS) $(CCNEEDED)
561
562#
563# lint macros
564#
565# Note that the undefine of __PRAGMA_REDEFINE_EXTNAME can be removed once
566# ON is built with a version of lint that has the fix for 4484186.
567#
568ALWAYS_LINT_DEFS =	-errtags=yes -s
569ALWAYS_LINT_DEFS +=	-erroff=E_PTRDIFF_OVERFLOW
570ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_NARROW_CONV
571ALWAYS_LINT_DEFS +=	-U__PRAGMA_REDEFINE_EXTNAME
572ALWAYS_LINT_DEFS +=	$(C99LMODE)
573ALWAYS_LINT_DEFS +=	-errsecurity=$(SECLEVEL)
574ALWAYS_LINT_DEFS +=	-erroff=E_SEC_CREAT_WITHOUT_EXCL
575ALWAYS_LINT_DEFS +=	-erroff=E_SEC_FORBIDDEN_WARN_CREAT
576# XX64 -- really only needed for amd64 lint
577ALWAYS_LINT_DEFS +=	-erroff=E_ASSIGN_INT_TO_SMALL_INT
578ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_CONST_TO_SMALL_INT
579ALWAYS_LINT_DEFS +=	-erroff=E_CAST_INT_TO_SMALL_INT
580ALWAYS_LINT_DEFS +=	-erroff=E_CAST_TO_PTR_FROM_INT
581ALWAYS_LINT_DEFS +=	-erroff=E_COMP_INT_WITH_LARGE_INT
582ALWAYS_LINT_DEFS +=	-erroff=E_INTEGRAL_CONST_EXP_EXPECTED
583ALWAYS_LINT_DEFS +=	-erroff=E_PASS_INT_TO_SMALL_INT
584ALWAYS_LINT_DEFS +=	-erroff=E_PTR_CONV_LOSES_BITS
585
586SECLEVEL=	core
587LINT.c=		$(LINT) $(LINTFLAGS) $(CPPFLAGS) $(ALWAYS_LINT_DEFS)
588LINT64.c=	$(LINT) $(LINTFLAGS64) $(CPPFLAGS) $(ALWAYS_LINT_DEFS)
589LINT.s=		$(LINT.c)
590
591# For some future builds, NATIVE_MACH and MACH might be different.
592# Therefore, NATIVE_MACH needs to be redefined in the
593# environment as `uname -p` to override this macro.
594#
595# For now at least, we cross-compile amd64 on i386 machines.
596NATIVE_MACH=	$(MACH:amd64=i386)
597
598# Define native compilation macros
599#
600
601# Base directory where compilers are loaded.
602# Defined here so it can be overridden by developer.
603#
604SPRO_ROOT=		$(BUILD_TOOLS)/SUNWspro
605SPRO_VROOT=		$(SPRO_ROOT)/SS11
606GNU_ROOT=		$(SFW_ROOT)
607
608# Specify platform compiler versions for languages
609# that we use (currently only c and c++).
610#
611sparc_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
612$(__GNUC)sparc_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
613sparc_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
614$(__GNUC)sparc_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
615sparc_CPP=		/usr/ccs/lib/cpp
616sparc_AS=		/usr/ccs/bin/as -xregsym=no
617sparc_LD=		/usr/ccs/bin/ld
618sparc_LINT=		$(SPRO_VROOT)/bin/lint
619
620sparcv9_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
621$(__GNUC64)sparcv9_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
622sparcv9_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
623$(__GNUC64)sparcv9_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
624sparcv9_CPP=		/usr/ccs/lib/cpp
625sparcv9_AS=		/usr/ccs/bin/as -xregsym=no
626sparcv9_LD=		/usr/ccs/bin/ld
627sparcv9_LINT=		$(SPRO_VROOT)/bin/lint
628
629# We compile 32-bit objects with cc by default
630i386_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
631$(__GNUC)i386_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
632i386_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
633$(__GNUC)i386_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
634i386_CPP=		/usr/ccs/lib/cpp
635i386_AS=		/usr/ccs/bin/as
636$(__GNUC)i386_AS=	$(ONBLD_TOOLS)/bin/$(MACH)/aw
637i386_LD=		/usr/ccs/bin/ld
638i386_LINT=		$(SPRO_VROOT)/bin/lint
639
640# We compile 64-bit objects with gcc
641amd64_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
642$(__GNUC64)amd64_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
643amd64_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
644$(__GNUC64)amd64_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
645amd64_CPP=		/usr/ccs/lib/cpp
646amd64_AS=		$(ONBLD_TOOLS)/bin/$(MACH)/aw
647amd64_LD=		/usr/ccs/bin/ld
648amd64_LINT=		$(SPRO_VROOT)/bin/lint
649
650NATIVECC=		$($(NATIVE_MACH)_CC)
651NATIVECCC=		$($(NATIVE_MACH)_CCC)
652NATIVECPP=		$($(NATIVE_MACH)_CPP)
653NATIVEAS=		$($(NATIVE_MACH)_AS)
654NATIVELD=		$($(NATIVE_MACH)_LD)
655NATIVELINT=		$($(NATIVE_MACH)_LINT)
656
657#
658# Makefile.master.64 overrides these settings
659#
660CC=			$(NATIVECC)
661CCC=			$(NATIVECCC)
662CPP=			$(NATIVECPP)
663AS=			$(NATIVEAS)
664LD=			$(NATIVELD)
665LINT=			$(NATIVELINT)
666
667# The real compilers used for this build
668CW_CC_CMD=		$(CC) -_compiler
669CW_CCC_CMD=		$(CCC) -_compiler
670REAL_CC=		$(CW_CC_CMD:sh)
671REAL_CCC=		$(CW_CCC_CMD:sh)
672
673# Pass -Y flag to cpp (method of which is release-dependent)
674CCYFLAG=		-Y I,
675
676BDIRECT=	-Bdirect
677BDYNAMIC=	-Bdynamic
678BLOCAL=		-Blocal
679BREDUCE=	-Breduce
680BSTATIC=	-Bstatic
681BSYMBOLIC=	-Bsymbolic
682
683ZCOMBRELOC=	-zcombreloc
684ZDEFS=		-zdefs
685ZIGNORE=	-zignore
686ZINITFIRST=	-zinitfirst
687ZINTERPOSE=	-zinterpose
688ZLAZYLOAD=	-zlazyload
689ZLOADFLTR=	-zloadfltr
690ZMULDEFS=	-zmuldefs
691ZNODEFAULTLIB=	-znodefaultlib
692ZNODEFS=	-znodefs
693ZNODELETE=	-znodelete
694ZNODLOPEN=	-znodlopen
695ZNODUMP=	-znodump
696ZNOLAZYLOAD=	-znolazyload
697ZNORELOC=	-znoreloc
698ZNOVERSION=	-znoversion
699ZREDLOCSYM=	-zredlocsym
700ZTEXT=		-ztext
701
702GSHARED=	-G
703CCMT=		-mt
704
705# Handle different PIC models on different ISAs
706# (May be overridden by lower-level Makefiles)
707
708sparc_C_PICFLAGS =	-K pic
709sparcv9_C_PICFLAGS =	-K pic
710i386_C_PICFLAGS =	-K pic
711amd64_C_PICFLAGS =	-K pic
712C_PICFLAGS =		$($(MACH)_C_PICFLAGS)
713C_PICFLAGS64 =		$($(MACH64)_C_PICFLAGS)
714
715sparc_C_BIGPICFLAGS =	-K PIC
716sparcv9_C_BIGPICFLAGS =	-K PIC
717i386_C_BIGPICFLAGS =	-K PIC
718amd64_C_BIGPICFLAGS =	-K PIC
719C_BIGPICFLAGS =		$($(MACH)_C_BIGPICFLAGS)
720C_BIGPICFLAGS64 =	$($(MACH64)_C_BIGPICFLAGS)
721
722# CC requires there to be no space between '-K' and 'pic' or 'PIC'.
723sparc_CC_PICFLAGS =	-Kpic
724sparcv9_CC_PICFLAGS =	-KPIC
725i386_CC_PICFLAGS = 	-Kpic
726amd64_CC_PICFLAGS = 	-Kpic
727CC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
728CC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)
729
730AS_PICFLAGS=		$(C_PICFLAGS)
731AS_BIGPICFLAGS=		$(C_BIGPICFLAGS)
732
733#
734# Default label for CTF sections
735#
736CTFCVTFLAGS=		-i -L VERSION
737
738#
739# Override to pass module-specific flags to ctfmerge.  Currently used
740# only by krtld to turn on fuzzy matching.
741#
742CTFMRGFLAGS=
743
744CTFCONVERT_O		= $(CTFCONVERT) $(CTFCVTFLAGS) $@
745
746ELFSIGN_O=	$(TRUE)
747ELFSIGN_CRYPTO=	$(ELFSIGN_O)
748ELFSIGN_OBJECT=	$(ELFSIGN_O)
749$(EXPORT_RELEASE_BUILD)ELFSIGN_O =	$(ELFSIGN)
750$(EXPORT_RELEASE_BUILD)ELFSIGN_KEY =	\
751			$(CLOSED)/cmd/cmd-crypto/etc/keys/SUNWosnet
752$(EXPORT_RELEASE_BUILD)ELFSIGN_CERT=	\
753			$(CLOSED)/cmd/cmd-crypto/etc/certs/SUNWosnet
754$(EXPORT_RELEASE_BUILD)ELFSIGN_SEKEY =	\
755			$(CLOSED)/cmd/cmd-crypto/etc/keys/SUNWosnetSolaris
756$(EXPORT_RELEASE_BUILD)ELFSIGN_SECERT=	\
757			$(CLOSED)/cmd/cmd-crypto/etc/certs/SUNWosnetSolaris
758$(EXPORT_RELEASE_BUILD)ELFSIGN_CRYPTO=	$(ELFSIGN_O) sign \
759			$(ELFSIGN_FORMAT_OPTION) \
760			-k $(ELFSIGN_KEY) -c $(ELFSIGN_CERT) -e $@
761$(EXPORT_RELEASE_BUILD)ELFSIGN_OBJECT=	$(ELFSIGN_O) sign \
762			$(ELFSIGN_FORMAT_OPTION) \
763			-k $(ELFSIGN_SEKEY) -c $(ELFSIGN_SECERT) -e $@
764
765# Rules (normally from make.rules) and macros which are used for post
766# processing files. Normally, these do stripping of the comment section
767# automatically.
768#    RELEASE_CM:	Should be editted to reflect the release.
769#    POST_PROCESS_O:	Post-processing for `.o' files.
770#    POST_PROCESS_A:	Post-processing for `.a' files (currently null).
771#    POST_PROCESS_SO:	Post-processing for `.so' files.
772#    POST_PROCESS:	Post-processing for executable files (no suffix).
773# Note that these macros are not completely generalized as they are to be
774# used with the file name to be processed following.
775#
776# It is left as an exercise to Release Engineering to embellish the generation
777# of the release comment string.
778#
779#	If this is a standard development build:
780#		compress the comment section (mcs -c)
781#		add the standard comment (mcs -a $(RELEASE_CM))
782#		add the development specific comment (mcs -a $(DEV_CM))
783#
784#	If this is an installation build:
785#		delete the comment section (mcs -d)
786#		add the standard comment (mcs -a $(RELEASE_CM))
787#		add the development specific comment (mcs -a $(DEV_CM))
788#
789#	If this is an release build:
790#		delete the comment section (mcs -d)
791#		add the standard comment (mcs -a $(RELEASE_CM))
792#
793#	The ONVERS macro sets the default value for the VERSION string
794#	within pkginfo.
795#
796# The following list of macros are used in the definition of RELEASE_CM
797# which is used to label all binaries in the build:
798#
799# 	RELEASE		Specific release of the build, eg: 5.2
800#	VERSION		Version of the build (alpha, beta, Generic)
801#	PATCHID		If this is a patch this value should contain
802#			the patchid value (eg: "Generic 100832-01"), otherwise
803#			it will be set to $(VERSION)
804#	RELEASE_DATE	Date of the Release Build
805#	PATCH_DATE	Date the patch was created, if this is blank it
806#			will default to the RELEASE_DATE
807#
808ONVERS=		"11.11"
809RELEASE=	5.11
810VERSION=	SunOS Development
811PATCHID=	$(VERSION)
812RELEASE_DATE=	October 2007
813PATCH_DATE=	$(RELEASE_DATE)
814RELEASE_CM=	"@($(POUND_SIGN))SunOS $(RELEASE) $(PATCHID) $(PATCH_DATE)"
815DEV_CM=		"@($(POUND_SIGN))SunOS Internal Development: \
816`$(ECHO) $$LOGNAME` `date +%Y-%m-%d` `$(ECHO) [\`basename $$CODEMGR_WS\`]`"
817
818PROCESS_COMMENT=		   @?${MCS} -c -a $(RELEASE_CM) -a $(DEV_CM)
819$(STRIP_COMMENTS)PROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
820$(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
821
822STRIP_STABS=			   :
823$(RELEASE_BUILD)STRIP_STABS=	   $(STRIP) -x $@
824
825POST_PROCESS_O=		$(PROCESS_COMMENT) $@
826POST_PROCESS_A=
827POST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
828			$(ELFSIGN_OBJECT)
829POST_PROCESS=		$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
830			$(ELFSIGN_OBJECT)
831
832#
833# The PKGDEFS macro points to the source directory containing the majority
834# of ON's package definitions plus Makefiles with general package creation
835# rules.
836#
837# PKGARCHIVE specifies the default location where packages should be
838# placed if built.
839#
840PKGDEFS=$(SRC)/pkgdefs
841$(RELEASE_BUILD)PKGARCHIVESUFFIX=	-nd
842PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly$(PKGARCHIVESUFFIX)
843
844#	Default build rules which perform comment section post-processing.
845#
846.c:
847	$(LINK.c) -o $@ $< $(LDLIBS)
848	$(POST_PROCESS)
849.c.o:
850	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
851	$(POST_PROCESS_O)
852.c.a:
853	$(COMPILE.c) -o $% $<
854	$(PROCESS_COMMENT) $%
855	$(AR) $(ARFLAGS) $@ $%
856	$(RM) $%
857.s.o:
858	$(COMPILE.s) -o $@ $<
859	$(POST_PROCESS_O)
860.s.a:
861	$(COMPILE.s) -o $% $<
862	$(PROCESS_COMMENT) $%
863	$(AR) $(ARFLAGS) $@ $%
864	$(RM) $%
865.cc:
866	$(LINK.cc) -o $@ $< $(LDLIBS)
867	$(POST_PROCESS)
868.cc.o:
869	$(COMPILE.cc) $(OUTPUT_OPTION) $<
870	$(POST_PROCESS_O)
871.cc.a:
872	$(COMPILE.cc) -o $% $<
873	$(AR) $(ARFLAGS) $@ $%
874	$(PROCESS_COMMENT) $%
875	$(RM) $%
876.y:
877	$(YACC.y) $<
878	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
879	$(POST_PROCESS)
880	$(RM) y.tab.c
881.y.o:
882	$(YACC.y) $<
883	$(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
884	$(POST_PROCESS_O)
885	$(RM) y.tab.c
886.l:
887	$(RM) $*.c
888	$(LEX.l) $< > $*.c
889	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
890	$(POST_PROCESS)
891	$(RM) $*.c
892.l.o:
893	$(RM) $*.c
894	$(LEX.l) $< > $*.c
895	$(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
896	$(POST_PROCESS_O)
897	$(RM) $*.c
898
899.java.class:
900	$(COMPILE.java) $<
901
902#
903# Rules to create message catalogue files from .sh, .c, .y, and .l files.
904# For .sh files, we extract all gettext strings with sed(1) (being careful
905# to permit multiple gettext strings on the same line), weed out the dups,
906# and build the catalogue with awk(1).
907#
908
909.sh.po:
910	$(SED) -n -e ":a" 					\
911		  -e "h" 					\
912		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
913		  -e "x"					\
914		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
915		  -e "t a"					\
916	       $< | sort -u | awk '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
917
918#
919# When using xgettext, we want messages to go to the default domain,
920# rather than the specified one.  This special version of the
921# COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
922# causing xgettext to put all messages into the default domain.
923#
924CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
925
926.c.i:
927	$(CPPFORPO) $< > $@
928
929.h.i:
930	$(CPPFORPO) $< > $@
931
932.y.i:
933	$(YACC) -d $<
934	$(CPPFORPO) y.tab.c  > $@
935	$(RM) y.tab.c
936
937.l.i:
938	$(LEX) $<
939	$(CPPFORPO) lex.yy.c  > $@
940	$(RM) lex.yy.c
941
942.c.po:
943	$(CPPFORPO) $< > $<.i
944	$(BUILD.po)
945
946.y.po:
947	$(YACC) -d $<
948	$(CPPFORPO) y.tab.c  > $<.i
949	$(BUILD.po)
950	$(RM) y.tab.c
951
952.l.po:
953	$(LEX) $<
954	$(CPPFORPO) lex.yy.c  > $<.i
955	$(BUILD.po)
956	$(RM) lex.yy.c
957
958#
959# Rules to perform stylistic checks
960#
961.SUFFIXES: $(SUFFIXES) .x .xml .check .xmlchk
962
963.h.check:
964	$(DOT_H_CHECK)
965
966.x.check:
967	$(DOT_X_CHECK)
968
969.xml.xmlchk:
970	$(MANIFEST_CHECK)
971
972#
973# Rules to process ONC+ Source partial files
974#
975%_onc_plus:	%
976	@$(ECHO) "extracting code from $< ... "
977	sed -n -e '/ONC_PLUS EXTRACT START/,/ONC_PLUS EXTRACT END/p' $<  > $@
978
979#
980# Include rules to render automated sccs get rules "safe".
981#
982include $(SRC)/Makefile.noget
983