xref: /titanic_52/usr/src/Makefile.master (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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.
110__GNUC64=
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
121SFWLIBDIR=	$(SFW_ROOT)/lib
122SFWLIBDIR64=	$(SFW_ROOT)/lib/$(MACH64)
123
124RPCGEN=		/usr/bin/rpcgen
125STABS=		$(ONBLD_TOOLS)/bin/$(MACH)/stabs
126ECHO=		echo
127INS=		install
128TRUE=		true
129SYMLINK=	/usr/bin/ln -s
130LN=		/usr/bin/ln
131CHMOD=		/usr/bin/chmod
132CHOWN=		$(TRUE)
133CHGRP=		$(TRUE)
134MV=		/usr/bin/mv -f
135RM=		/usr/bin/rm -f
136GREP=		/usr/bin/grep
137SED=		/usr/bin/sed
138NAWK=		/usr/bin/nawk
139CP=		/usr/bin/cp -f
140MCS=		/usr/ccs/bin/mcs
141CAT=            /usr/bin/cat
142M4=		/usr/ccs/bin/m4
143STRIP=		/usr/ccs/bin/strip
144LEX=		/usr/ccs/bin/lex
145YACC=		/usr/ccs/bin/yacc
146CPP=		/usr/lib/cpp
147JAVAC=		$(JAVA_ROOT)/bin/javac
148JAVAH=		$(JAVA_ROOT)/bin/javah
149JAVADOC=	$(JAVA_ROOT)/bin/javadoc
150RMIC=		$(JAVA_ROOT)/bin/rmic
151JAR=		$(JAVA_ROOT)/bin/jar
152CTFCONVERT=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfconvert
153CTFMERGE=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfmerge
154CTFSTABS=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
155GENOFFSETS=	$(ONBLD_TOOLS)/bin/genoffsets
156CTFCVTPTBL=	$(ONBLD_TOOLS)/bin/ctfcvtptbl
157CTFFINDMOD=	$(ONBLD_TOOLS)/bin/ctffindmod
158XREF=		$(ONBLD_TOOLS)/bin/xref
159FIND=		/usr/bin/find
160PERL=		/usr/bin/perl
161SORT=		/usr/bin/sort
162TOUCH=		/usr/bin/touch
163WC=		/usr/bin/wc
164XARGS=		/usr/bin/xargs
165ELFSIGN=	/usr/bin/elfsign
166DTRACE=		/usr/sbin/dtrace
167
168FILEMODE=	644
169DIRMODE=	755
170
171# Note: owner and group for proto area objects is no longer set by
172# Makefiles at all.  These have no real effect and are kept here for
173# transition purposes.  They (along with CH, CHOWN, and CHGRP) should be
174# removed early in the s11 development cycle.
175OWNER=		root
176GROUP=		bin
177
178#
179# The version of the patch makeup table optimized for build-time use.  Used
180# during patch builds only.
181$(PATCH_BUILD)PMTMO_FILE=$(SRC)/patch_makeup_table.mo
182
183# Declare that nothing should be built in parallel.
184# Individual Makefiles can use the .PARALLEL target to declare otherwise.
185.NO_PARALLEL:
186
187# For stylistic checks
188#
189# Note that the X and C checks are not used at this time and may need
190# modification when they are actually used.
191#
192CSTYLE=		cstyle
193CSTYLE_TAIL=
194HDRCHK=		hdrchk
195HDRCHK_TAIL=
196JSTYLE=		jstyle
197
198DOT_H_CHECK=	\
199	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
200	$(HDRCHK) $< $(HDRCHK_TAIL)
201
202DOT_X_CHECK=	\
203	@$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
204	$(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)
205
206DOT_C_CHECK=	\
207	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)
208
209MANIFEST_CHECK=	\
210	@$(ECHO) "checking $<"; \
211	SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
212	$(SRC)/cmd/svc/svccfg/svccfg-native validate $<
213
214INS.file=	$(RM) $@; $(INS) -s -m $(FILEMODE) -f $(@D) $<
215INS.dir=	$(INS) -s -d -m $(DIRMODE) $@
216# installs and renames at once
217#
218INS.rename=	$(INS.file); $(MV) $(@D)/$(<F) $@
219
220# install a link
221INSLINKTARGET=	$<
222INS.link=	$(RM) $@; $(LN) $(INSLINKTARGET) $@
223
224# MACH must be set in the shell environment per uname -p on the build host
225# More specific architecture variables should be set in lower makefiles.
226#
227# MACH64 is derived from MACH, and BUILD64 is set to `#' for
228# architectures on which we do not build 64-bit versions.
229# (There are no such architectures at the moment.)
230#
231# Set BUILD64=# in the environment to disable 64-bit amd64
232# builds on i386 machines.
233
234MACH64_1=	$(MACH:sparc=sparcv9)
235MACH64=		$(MACH64_1:i386=amd64)
236
237MACH32_1=	$(MACH:sparc=sparcv7)
238MACH32=		$(MACH32_1:i386=i86)
239
240sparc_BUILD64=
241i386_BUILD64=
242BUILD64=	$($(MACH)_BUILD64)
243
244#
245# C compiler mode. Future compilers may change the default on us,
246# so force extended ANSI mode globally. Lower level makefiles can
247# override this by setting CCMODE.
248#
249CCMODE=			-Xa
250CCMODE64=		-Xa
251
252#
253# C compiler verbose mode. This is so we can enable it globally,
254# but turn it off in the lower level makefiles of things we cannot
255# (or aren't going to) fix.
256#
257CCVERBOSE=		-v
258
259# set this to the secret flag "-Wc,-Qiselect-v9abiwarn=1" to get warnings
260# from the compiler about places the -xarch=v9 may differ from -xarch=v9c.
261V9ABIWARN=
262
263# set this to the secret flag "-Wc,-Qiselect-regsym=0" to disable register
264# symbols (used to detect conflicts between objects that use global registers)
265# we disable this now for safety, and because genunix doesn't link with
266# this feature (the v9 default) enabled.
267#
268# REGSYM is separate since the C++ driver syntax is different.
269CCREGSYM=		-Wc,-Qiselect-regsym=0
270CCCREGSYM=		-Qoption cg -Qiselect-regsym=0
271
272#
273# generate 32-bit addresses in the v9 kernel. Saves memory.
274CCABS32=		-Wc,-xcode=abs32
275
276# One optimization the compiler might perform is to turn this:
277#	#pragma weak foo
278#	extern int foo;
279#	if (&foo)
280#		foo = 5;
281# into
282#	foo = 5;
283# Since we do some of this (foo might be referenced in common kernel code
284# but provided only for some cpu modules or platforms), we disable this
285# optimization.
286#
287sparc_CCUNBOUND	= -Wd,-xsafe=unboundsym
288i386_CCUNBOUND	=
289CCUNBOUND	= $($(MACH)_CCUNBOUND)
290
291#
292# compiler '-xarch' flag. This is here to centralize it and make it
293# overridable for testing.
294sparc_XARCH=		-xarch=v8
295sparcv9_XARCH=		-xarch=v9
296i386_XARCH=
297amd64_XARCH=		-xarch=amd64 -Ui386 -U__i386
298
299# assembler '-xarch' flag.  Different from compiler '-xarch' flag.
300sparc_AS_XARCH=		-xarch=v8
301sparcv9_AS_XARCH=	-xarch=v9
302i386_AS_XARCH=
303amd64_AS_XARCH=		-xarch=amd64 -P -Ui386 -U__i386
304
305#
306# These flags define what we need to be 'standalone' i.e. -not- part
307# of the rather more cosy userland environment.  This basically means
308# the kernel.
309#
310# XX64	future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
311#
312sparc_STAND_FLAGS=
313sparcv9_STAND_FLAGS=
314i386_STAND_FLAGS=	-_gcc=-ffreestanding
315amd64_STAND_FLAGS=	-Wu,-xmodel=kernel
316
317SAVEARGS=		-Wu,-save_args
318$(__GNUC64)SAVEARGS=
319amd64_STAND_FLAGS	+= $(SAVEARGS)
320
321STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
322STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
323
324#
325# disable the incremental linker
326ILDOFF=			-xildoff
327#
328XDEPEND=		-xdepend
329XFFLAG=			-xF
330XESS=			-xs
331XSTRCONST=		-xstrconst
332
333#
334# turn warnings into errors (C)
335CERRWARN = -errtags=yes -errwarn=%all
336CERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
337CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
338
339#
340# turn warnings into errors (C++)
341CCERRWARN=		-xwe
342
343# C99 mode
344C99_ENABLE=	-xc99=%all
345C99_DISABLE=	-xc99=%none
346C99MODE=	$(C99_DISABLE)
347C99LMODE=	-Xc99=%none
348
349# In most places, assignments to these macros should be appended with +=
350# (CPPFLAGS.master allows values to be prepended to CPPFLAGS).
351sparc_CFLAGS=	$(sparc_XARCH)
352sparcv9_CFLAGS=	$(sparcv9_XARCH) -dalign $(CCVERBOSE) $(V9ABIWARN) $(CCREGSYM)
353i386_CFLAGS=	$(i386_XARCH)
354amd64_CFLAGS=	$(amd64_XARCH)
355
356sparc_ASFLAGS=	$(sparc_AS_XARCH)
357sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
358i386_ASFLAGS=	$(i386_AS_XARCH)
359amd64_ASFLAGS=	$(amd64_AS_XARCH)
360
361#
362sparc_COPTFLAG=		-xO3
363sparcv9_COPTFLAG=	-xO3
364i386_COPTFLAG=		-O
365amd64_COPTFLAG=		-O
366
367COPTFLAG= $($(MACH)_COPTFLAG)
368COPTFLAG64= $($(MACH64)_COPTFLAG)
369
370# When -g is used, the compiler globalizes static objects
371# (gives them a unique prefix). Disable that.
372CNOGLOBAL= -W0,-noglobal
373
374#
375# Flags used to build in debug mode for ctf generation.  Bugs in the Devpro
376# compilers currently prevent us from building with cc-emitted DWARF.
377#
378CTF_FLAGS_sparc	= -g -Wc,-Qiselect-T1 $(C99MODE) $(CNOGLOBAL)
379CTF_FLAGS_i386	= -g $(C99MODE) $(CNOGLOBAL)
380CTF_FLAGS	= $(CTF_FLAGS_$(MACH))
381
382#
383# Flags used with genoffsets
384#
385GOFLAGS =
386$(INTEL_BLD)GOFLAGS = -_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# XX64  What to do about libstdc++ for g++ ???
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=		$(SPRO_VROOT)/bin/cc
574sparc_CCC=		$(SPRO_VROOT)/bin/CC
575sparc_CPP=		/usr/ccs/lib/cpp
576sparc_AS=		/usr/ccs/bin/as -xregsym=no
577sparc_LD=		/usr/ccs/bin/ld
578sparc_LINT=		$(SPRO_VROOT)/bin/lint
579
580sparcv9_CC=		$(SPRO_VROOT)/bin/cc
581sparcv9_CCC=		$(SPRO_VROOT)/bin/CC
582sparcv9_CPP=		/usr/ccs/lib/cpp
583sparcv9_AS=		/usr/ccs/bin/as -xregsym=no
584sparcv9_LD=		/usr/ccs/bin/ld
585sparcv9_LINT=		$(SPRO_VROOT)/bin/lint
586
587# We compile 32-bit objects with cc by default
588i386_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
589$(__GNUC)i386_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
590i386_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
591$(__GNUC)i386_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
592i386_CPP=		/usr/ccs/lib/cpp
593i386_AS=		/usr/ccs/bin/as
594$(__GNUC)i386_AS=	$(ONBLD_TOOLS)/bin/$(MACH)/aw
595i386_LD=		/usr/ccs/bin/ld
596i386_LINT=		$(SPRO_VROOT)/bin/lint
597
598# We compile 64-bit objects with gcc
599amd64_CC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_cc
600$(__GNUC64)amd64_CC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_gcc
601amd64_CCC=		$(ONBLD_TOOLS)/bin/$(MACH)/cw -_CC
602$(__GNUC64)amd64_CCC=	$(ONBLD_TOOLS)/bin/$(MACH)/cw -_g++
603amd64_CPP=		/usr/ccs/lib/cpp
604amd64_AS=		$(ONBLD_TOOLS)/bin/$(MACH)/aw
605amd64_LD=		/usr/ccs/bin/ld
606amd64_LINT=		$(SPRO_ROOT)/SOS10-EA/bin/lint
607
608NATIVECC=		$($(NATIVE_MACH)_CC)
609NATIVECCC=		$($(NATIVE_MACH)_CCC)
610NATIVECPP=		$($(NATIVE_MACH)_CPP)
611NATIVEAS=		$($(NATIVE_MACH)_AS)
612NATIVELD=		$($(NATIVE_MACH)_LD)
613NATIVELINT=		$($(NATIVE_MACH)_LINT)
614
615#
616# Makefile.master.64 overrides these settings
617#
618CC=			$(NATIVECC)
619CCC=			$(NATIVECCC)
620CPP=			$(NATIVECPP)
621AS=			$(NATIVEAS)
622LD=			$(NATIVELD)
623LINT=			$(NATIVELINT)
624
625# Pass -Y flag to cpp (method of which is release-dependent)
626CCYFLAG=		-Y I,
627
628BDIRECT=	-Bdirect
629BDYNAMIC=	-Bdynamic
630BLOCAL=		-Blocal
631BREDUCE=	-Breduce
632BSTATIC=	-Bstatic
633BSYMBOLIC=	-Bsymbolic
634
635ZCOMBRELOC=	-zcombreloc
636ZDEFS=		-zdefs
637ZIGNORE=	-zignore
638ZINITFIRST=	-zinitfirst
639ZINTERPOSE=	-zinterpose
640ZLAZYLOAD=	-zlazyload
641ZLOADFLTR=	-zloadfltr
642ZMULDEFS=	-zmuldefs
643ZNODEFAULTLIB=	-znodefaultlib
644ZNODEFS=	-znodefs
645ZNODELETE=	-znodelete
646ZNODLOPEN=	-znodlopen
647ZNODUMP=	-znodump
648ZNOLAZYLOAD=	-znolazyload
649ZNOVERSION=	-znoversion
650ZREDLOCSYM=	-zredlocsym
651ZTEXT=		-ztext
652
653GSHARED=	-G
654CCMT=		-mt
655
656# Handle different PIC models on different ISAs
657# (May be overridden by lower-level Makefiles)
658
659sparc_C_PICFLAGS =	-K pic
660sparcv9_C_PICFLAGS =	-K pic
661i386_C_PICFLAGS =	-K pic
662amd64_C_PICFLAGS =	-K pic
663C_PICFLAGS =		$($(MACH)_C_PICFLAGS)
664C_PICFLAGS64 =		$($(MACH64)_C_PICFLAGS)
665
666sparc_C_BIGPICFLAGS =	-K PIC
667sparcv9_C_BIGPICFLAGS =	-K PIC
668i386_C_BIGPICFLAGS =	-K PIC
669amd64_C_BIGPICFLAGS =	-K PIC
670C_BIGPICFLAGS =		$($(MACH)_C_BIGPICFLAGS)
671C_BIGPICFLAGS64 =	$($(MACH64)_C_BIGPICFLAGS)
672
673# CC requires there to be no space between '-K' and 'pic' or 'PIC'.
674sparc_CC_PICFLAGS =	-Kpic
675sparcv9_CC_PICFLAGS =	-KPIC
676i386_CC_PICFLAGS = 	-Kpic
677amd64_CC_PICFLAGS = 	-Kpic
678CC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
679CC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)
680
681AS_PICFLAGS=		$(C_PICFLAGS)
682AS_BIGPICFLAGS=		$(C_BIGPICFLAGS)
683
684#
685# Default label for CTF sections
686#
687CTFCVTFLAGS=		-i -L VERSION
688
689#
690# Override to pass module-specific flags to ctfmerge.  Currently used
691# only by krtld to turn on fuzzy matching.
692#
693CTFMRGFLAGS=
694
695CTFCONVERT_O		= $(CTFCONVERT) $(CTFCVTFLAGS) $@
696
697ELFSIGN_O=	$(TRUE)
698ELFSIGN_CRYPTO=	$(ELFSIGN_O)
699ELFSIGN_OBJECT=	$(ELFSIGN_O)
700# EXPORT DELETE START
701# Note: The setting of ELFSIGN_O, etc. to $(TRUE) above must stay outside
702# of the export src markers.  The real setting for non source product builds
703# is inside the markers.
704# This is needed to reduce the amount of changes to Makefiles elsewhere
705# in the source tree (particularly in uts/{sparc,intel})
706ELFSIGN_O =	$(ELFSIGN)
707ELFSIGN_KEY =	$(SRC)/cmd/cmd-crypto/etc/keys/SUNWosnet
708ELFSIGN_CERT=	$(SRC)/cmd/cmd-crypto/etc/certs/SUNWosnet
709ELFSIGN_SEKEY =	$(SRC)/cmd/cmd-crypto/etc/keys/SUNWosnetSolaris
710ELFSIGN_SECERT=	$(SRC)/cmd/cmd-crypto/etc/certs/SUNWosnetSolaris
711ELFSIGN_CRYPTO=	$(ELFSIGN_O) sign $(ELFSIGN_FORMAT_OPTION) \
712			-k $(ELFSIGN_KEY) -c $(ELFSIGN_CERT) -e $@
713ELFSIGN_OBJECT=	$(ELFSIGN_O) sign $(ELFSIGN_FORMAT_OPTION) \
714			-k $(ELFSIGN_SEKEY) -c $(ELFSIGN_SECERT) -e $@
715# EXPORT DELETE END
716
717# Rules (normally from make.rules) and macros which are used for post
718# processing files. Normally, these do stripping of the comment section
719# automatically.
720#    RELEASE_CM:	Should be editted to reflect the release.
721#    POST_PROCESS_O:	Post-processing for `.o' files.
722#    POST_PROCESS_A:	Post-processing for `.a' files (currently null).
723#    POST_PROCESS_SO:	Post-processing for `.so' files.
724#    POST_PROCESS:	Post-processing for executable files (no suffix).
725# Note that these macros are not completely generalized as they are to be
726# used with the file name to be processed following.
727#
728# It is left as an exercise to Release Engineering to embellish the generation
729# of the release comment string.
730#
731#	If this is a standard development build:
732#		compress the comment section (mcs -c)
733#		add the standard comment (mcs -a $(RELEASE_CM))
734#		add the development specific comment (mcs -a $(DEV_CM))
735#
736#	If this is an installation build:
737#		delete the comment section (mcs -d)
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 release build:
742#		delete the comment section (mcs -d)
743#		add the standard comment (mcs -a $(RELEASE_CM))
744#
745#	The ONVERS macro sets the default value for the VERSION string
746#	within pkginfo.
747#
748# The following list of macros are used in the definition of RELEASE_CM
749# which is used to label all binaries in the build:
750#
751# 	RELEASE		Specific release of the build, eg: 5.2
752#	VERSION		Version of the build (alpha, beta, Generic)
753#	PATCHID		If this is a patch this value should contain
754#			the patchid value (eg: "Generic 100832-01"), otherwise
755#			it will be set to $(VERSION)
756#	RELEASE_DATE	Date of the Release Build
757#	PATCH_DATE	Date the patch was created, if this is blank it
758#			will default to the RELEASE_DATE
759#
760ONVERS=		"11.11"
761RELEASE=	5.11
762VERSION=	SunOS Development
763PATCHID=	$(VERSION)
764RELEASE_DATE=	October 2007
765PATCH_DATE=	$(RELEASE_DATE)
766RELEASE_CM=	"@($(POUND_SIGN))SunOS $(RELEASE) $(PATCHID) $(PATCH_DATE)"
767DEV_CM=		"@($(POUND_SIGN))SunOS Internal Development: \
768`$(ECHO) $$LOGNAME` `date +%Y-%m-%d` `$(ECHO) [\`basename $$CODEMGR_WS\`]`"
769
770PROCESS_COMMENT=		   @?${MCS} -c -a $(RELEASE_CM) -a $(DEV_CM)
771$(STRIP_COMMENTS)PROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
772$(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
773
774STRIP_STABS=			   :
775$(RELEASE_BUILD)STRIP_STABS=	   $(STRIP) -x $@
776
777POST_PROCESS_O=		$(PROCESS_COMMENT) $@
778POST_PROCESS_A=
779POST_PROCESS_SO=	$(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
780			$(ELFSIGN_OBJECT)
781POST_PROCESS=		$(PROCESS_COMMENT) $@ ; $(ELFSIGN_OBJECT)
782
783#
784# The PKGDEFS macro points to the source directory containing the majority
785# of ON's package definitions plus Makefiles with general package creation
786# rules.
787#
788# PKGARCHIVE specifies the default location where packages should be
789# placed if built.
790#
791PKGDEFS=$(SRC)/pkgdefs
792$(RELEASE_BUILD)PKGARCHIVESUFFIX=	-nd
793PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly$(PKGARCHIVESUFFIX)
794
795#	Default build rules which perform comment section post-processing.
796#
797.c:
798	$(LINK.c) -o $@ $< $(LDLIBS)
799	$(POST_PROCESS)
800.c.o:
801	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
802	$(POST_PROCESS_O)
803.c.a:
804	$(COMPILE.c) -o $% $<
805	$(PROCESS_COMMENT) $%
806	$(AR) $(ARFLAGS) $@ $%
807	$(RM) $%
808.s.o:
809	$(COMPILE.s) -o $@ $<
810	$(POST_PROCESS_O)
811.s.a:
812	$(COMPILE.s) -o $% $<
813	$(PROCESS_COMMENT) $%
814	$(AR) $(ARFLAGS) $@ $%
815	$(RM) $%
816.cc:
817	$(LINK.cc) -o $@ $< $(LDLIBS)
818	$(POST_PROCESS)
819.cc.o:
820	$(COMPILE.cc) $(OUTPUT_OPTION) $<
821	$(POST_PROCESS_O)
822.cc.a:
823	$(COMPILE.cc) -o $% $<
824	$(AR) $(ARFLAGS) $@ $%
825	$(PROCESS_COMMENT) $%
826	$(RM) $%
827.y:
828	$(YACC.y) $<
829	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
830	$(POST_PROCESS)
831	$(RM) y.tab.c
832.y.o:
833	$(YACC.y) $<
834	$(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
835	$(POST_PROCESS_O)
836	$(RM) y.tab.c
837.l:
838	$(RM) $*.c
839	$(LEX.l) $< > $*.c
840	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
841	$(POST_PROCESS)
842	$(RM) $*.c
843.l.o:
844	$(RM) $*.c
845	$(LEX.l) $< > $*.c
846	$(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
847	$(POST_PROCESS_O)
848	$(RM) $*.c
849
850.java.class:
851	$(COMPILE.java) $<
852
853#
854# Rules to create message catalogue files from .sh, .c, .y, and .l files.
855# For .sh files, we extract all gettext strings with sed(1) (being careful
856# to permit multiple gettext strings on the same line), weed out the dups,
857# and build the catalogue with awk(1).
858#
859
860.sh.po:
861	$(SED) -n -e ":a" 					\
862		  -e "h" 					\
863		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
864		  -e "x"					\
865		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
866		  -e "t a"					\
867	       $< | sort -u | awk '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
868
869#
870# When using xgettext, we want messages to go to the default domain,
871# rather than the specified one.  This special version of the
872# COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
873# causing xgettext to put all messages into the default domain.
874#
875CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
876
877.c.i:
878	$(CPPFORPO) $< > $@
879
880.h.i:
881	$(CPPFORPO) $< > $@
882
883.y.i:
884	$(YACC) -d $<
885	$(CPPFORPO) y.tab.c  > $@
886	$(RM) y.tab.c
887
888.l.i:
889	$(LEX) $<
890	$(CPPFORPO) lex.yy.c  > $@
891	$(RM) lex.yy.c
892
893.c.po:
894	$(CPPFORPO) $< > $<.i
895	$(BUILD.po)
896
897.y.po:
898	$(YACC) -d $<
899	$(CPPFORPO) y.tab.c  > $<.i
900	$(BUILD.po)
901	$(RM) y.tab.c
902
903.l.po:
904	$(LEX) $<
905	$(CPPFORPO) lex.yy.c  > $<.i
906	$(BUILD.po)
907	$(RM) lex.yy.c
908
909#
910# Rules to perform stylistic checks
911#
912.SUFFIXES: $(SUFFIXES) .x .xml .check .xmlchk
913
914.h.check:
915	$(DOT_H_CHECK)
916
917.x.check:
918	$(DOT_X_CHECK)
919
920.xml.xmlchk:
921	$(MANIFEST_CHECK)
922
923#
924# Rules to process ONC+ Source partial files
925#
926%_onc_plus:	%
927	@$(ECHO) "extracting code from $< ... "
928	sed -n -e '/ONC_PLUS EXTRACT START/,/ONC_PLUS EXTRACT END/p' $<  > $@
929