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