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