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