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