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