build: switch to C-based gcc-wrap
[unleashed.git] / usr / src / Makefile.master
blobc4b4f3359ebc0503ca905ede0f66c952709f7ead
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
23 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24 # Copyright (c) 2012 by Delphix. All rights reserved.
25 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
26 # Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
27 # Copyright 2015 Gary Mills
28 # Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
29 # Copyright 2016 Toomas Soome <tsoome@me.com>
32 include $(SRC)/Makefile.cfgparam
35 # Makefile.master, global definitions for system source
37 ROOT=           /proto
40 # Adjunct root, containing an additional proto area to be used for headers
41 # and libraries.
43 ADJUNCT_PROTO=
46 # Adjunct for building things that run on the build machine.
48 NATIVE_ADJUNCT= /usr
51 # RELEASE_BUILD should be cleared for final release builds.
52 # NOT_RELEASE_BUILD is exactly what the name implies.
55 NOT_RELEASE_BUILD=
56 RELEASE_BUILD=                          $(POUND_SIGN)
57 $(RELEASE_BUILD)NOT_RELEASE_BUILD=      $(POUND_SIGN)
58 PATCH_BUILD=                            $(POUND_SIGN)
60 # SPARC_BLD is '#' for an Intel build.
61 # INTEL_BLD is '#' for a Sparc build.
62 SPARC_BLD_1=    $(MACH:i386=$(POUND_SIGN))
63 SPARC_BLD=      $(SPARC_BLD_1:sparc=)
64 INTEL_BLD_1=    $(MACH:sparc=$(POUND_SIGN))
65 INTEL_BLD=      $(INTEL_BLD_1:i386=)
67 # Allow build-time "configuration" to enable or disable some things.
68 # The default is POUND_SIGN, meaning "not enabled".
69 ENABLE_PERL64=          $(POUND_SIGN)
71 # BUILD_TOOLS is the root of all tools including compilers.
72 # ONBLD_TOOLS is the root of all the tools that are part of SUNWonbld.
74 BUILD_TOOLS=            /opt
75 ONBLD_TOOLS=            $(BUILD_TOOLS)/onbld
77 GNUC_ROOT=      /opt/gcc/4.4.4
78 GCCLIBDIR=      $(GNUC_ROOT)/lib
79 GCCLIBDIR64=    $(GNUC_ROOT)/lib/$(MACH64)
81 DOCBOOK_XSL_ROOT=       /usr/share/sgml/docbook/xsl-stylesheets
83 RPCGEN=         /usr/bin/rpcgen
84 STABS=          $(ONBLD_TOOLS)/bin/$(MACH)/stabs
85 ELFEXTRACT=     $(ONBLD_TOOLS)/bin/$(MACH)/elfextract
86 MBH_PATCH=      $(SRCTOP)/tools/mbh_patch/obj/mbh_patch
87 BTXLD=          $(ONBLD_TOOLS)/bin/$(MACH)/btxld
88 # echo(1) and true(1) are specified without absolute paths, so that the shell
89 # spawned by make(1) may use the built-in versions.  This is minimally
90 # problematic, as the shell spawned by make(1) is known and under control, the
91 # only risk being if the shell falls back to $PATH.
93 # We specifically want an echo(1) that does interpolation of escape sequences,
94 # which ksh93, /bin/sh, and bash will all provide.
95 ECHO=           echo
96 TRUE=           true
97 INS=            /usr/bin/install
98 SYMLINK=        /usr/bin/ln -s
99 LN=             /usr/bin/ln
100 MKDIR=          /usr/bin/mkdir
101 CHMOD=          /usr/bin/chmod
102 MV=             /usr/bin/mv -f
103 RM=             /usr/bin/rm -f
104 CUT=            /usr/bin/cut
105 NM=             /usr/bin/nm
106 DIFF=           /usr/bin/diff
107 GREP=           /usr/bin/grep
108 EGREP=          /usr/bin/egrep
109 ELFWRAP=        /usr/bin/elfwrap
110 KSH93=          /usr/bin/ksh93
111 SED=            /usr/bin/sed
112 AWK=            /usr/bin/nawk
113 CP=             /usr/bin/cp -f
114 MCS=            /usr/bin/mcs
115 CAT=            /usr/bin/cat
116 ELFDUMP=        /usr/bin/elfdump
117 M4=             /usr/bin/m4
118 STRIP=          /usr/bin/strip
119 LEX=            /usr/bin/lex
120 LFLAGS=         -n
121 FLEX=           /usr/bin/flex
122 YACC=           /usr/bin/yacc
123 CPP=            $(GNUC_ROOT)/cpp
124 ANSI_CPP=       $(GNUC_ROOT)/bin/cpp
125 CTFCONVERT=     $(ONBLD_TOOLS)/bin/$(MACH)/ctfconvert
126 CTFDIFF=        $(ONBLD_TOOLS)/bin/$(MACH)/ctfdiff
127 CTFMERGE=       $(ONBLD_TOOLS)/bin/$(MACH)/ctfmerge
128 CTFSTABS=       $(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
129 CTFSTRIP=       $(ONBLD_TOOLS)/bin/$(MACH)/ctfstrip
130 NDRGEN=         $(ONBLD_TOOLS)/bin/$(MACH)/ndrgen
131 GENOFFSETS=     $(ONBLD_TOOLS)/bin/genoffsets
132 FIND=           /usr/bin/find
133 PERL=           /usr/bin/perl
134 PERL_VERSION=   5.22
135 PERL_PKGVERS=   -522
136 PERL_ARCH=              i86pc-solaris-64int
137 PERL_ARCH64=    i86pc-solaris-64
138 $(SPARC_BLD)PERL_ARCH=          sun4-solaris-64int
139 $(SPARC_BLD)PERL_ARCH64=        sun4-solaris-64
140 PYTHON_VERSION= 2.7
141 PYTHON_PKGVERS= -27
142 PYTHON=         /usr/bin/python$(PYTHON_VERSION)
143 SORT=           /usr/bin/sort
144 TOUCH=          /usr/bin/touch
145 WC=             /usr/bin/wc
146 XARGS=          /usr/bin/xargs
147 ELFEDIT=        /usr/bin/elfedit
148 DTRACE=         /usr/sbin/dtrace -xnolibs
149 UNIQ=           /usr/bin/uniq
150 TAR=            /usr/bin/tar
151 ASTBINDIR=      /usr/ast/bin
152 MSGCC=          $(ASTBINDIR)/msgcc
153 MSGFMT=         /usr/bin/msgfmt -s
155 FILEMODE=       644
156 DIRMODE=        755
158 # Declare that nothing should be built in parallel.
159 # Individual Makefiles can use the .PARALLEL target to declare otherwise.
160 .NO_PARALLEL:
162 # For stylistic checks
164 # Note that the X and C checks are not used at this time and may need
165 # modification when they are actually used.
167 CSTYLE=         $(ONBLD_TOOLS)/bin/cstyle
168 CSTYLE_TAIL=
169 HDRCHK=         $(ONBLD_TOOLS)/bin/hdrchk
170 HDRCHK_TAIL=
172 DOT_H_CHECK=    \
173         @$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
174         $(HDRCHK) $< $(HDRCHK_TAIL)
176 DOT_X_CHECK=    \
177         @$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
178         $(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)
180 DOT_C_CHECK=    \
181         @$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)
183 MANIFEST_CHECK= \
184         @$(ECHO) "checking $<"; \
185         SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
186         SVCCFG_REPOSITORY=$(SRC)/cmd/svc/seed/global.db \
187         SVCCFG_CONFIGD_PATH=$(SRC)/cmd/svc/configd/svc.configd-native \
188         $(SRC)/cmd/svc/svccfg/svccfg-native validate $<
190 INS.file=       $(INS) -m $(FILEMODE) $< $@
191 INS.dir=        $(INS) -d -m $(DIRMODE) $@
192 # installs and renames at once
194 INS.rename=     $(INS.file)
196 # install a link
197 INSLINKTARGET=  $<
198 INS.link=       $(RM) $@; $(LN) $(INSLINKTARGET) $@
199 INS.symlink=    $(RM) $@; $(SYMLINK) $(INSLINKTARGET) $@
202 # Python bakes the mtime of the .py file into the compiled .pyc and
203 # rebuilds if the baked-in mtime != the mtime of the source file
204 # (rather than only if it's less than), thus when installing python
205 # files we must make certain to not adjust the mtime of the source
206 # (.py) file.
208 INS.pyfile=     $(RM) $@; $(SED) -e "1s:^\#!@PYTHON@:\#!$(PYTHON):" < $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@
210 # MACH must be set in the shell environment per uname -p on the build host
211 # More specific architecture variables should be set in lower makefiles.
213 # MACH64 is derived from MACH, and BUILD64 is set to `#' for
214 # architectures on which we do not build 64-bit versions.
215 # (There are no such architectures at the moment.)
217 # Set BUILD64=# in the environment to disable 64-bit amd64
218 # builds on i386 machines.
220 MACH64_1=       $(MACH:sparc=sparcv9)
221 MACH64=         $(MACH64_1:i386=amd64)
223 MACH32_1=       $(MACH:sparc=sparcv7)
224 MACH32=         $(MACH32_1:i386=i86)
226 sparc_BUILD64=
227 i386_BUILD64=
228 BUILD64=        $($(MACH)_BUILD64)
231 # generate 32-bit addresses in the v9 kernel. Saves memory.
232 CCABS32=                -fno-pic -mcmodel=medlow
234 # generate v9 code which tolerates callers using the v7 ABI, for the sake of
235 # system calls.
236 CC32BITCALLERS=         -massume-32bit-callers
238 # GCC, especially, is increasingly beginning to auto-inline functions and
239 # sadly does so separately not under the general -fno-inline-functions
240 # Additionally, we wish to prevent optimisations which cause GCC to clone
241 # functions -- in particular, these may cause unhelpful symbols to be
242 # emitted instead of function names
243 CCNOAUTOINLINE= -fno-inline-small-functions \
244         -fno-inline-functions-called-once \
245         -fno-ipa-cp
248 # compiler architecture flags.
250 sparc_XARCH=    -m32 -mcpu=v8 -mno-v8plus
251 sparcv9_XARCH=  -m64 -mcpu=v9
252 i386_XARCH=     -m32 -march=pentiumpro
253 amd64_XARCH=    -m64 -Ui386 -U__i386 -mtune=opteron
255 # assembler architecture flags.  Different from compiler architecture flags.
256 sparc_AS_XARCH=         -xarch=v8plus -Dsparc -D__sparc -D__sparcv8
257 sparcv9_AS_XARCH=       -xarch=v9 -Dsparc -D__sparc -D__sparcv9
258 i386_AS_XARCH=          -m32 -Di386 -D__i386
259 amd64_AS_XARCH=         -m64 -Ui386 -U__i386 -D__x86_64 -D__amd64
262 # These flags define what we need to be 'standalone' i.e. -not- part
263 # of the rather more cosy userland environment.  This basically means
264 # the kernel.
266 # XX64  future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
268 sparc_STAND_FLAGS=      -ffreestanding
269 sparcv9_STAND_FLAGS=    -ffreestanding
270 # Disabling MMX also disables 3DNow, disabling SSE also disables all later
271 # additions to SSE (SSE2, AVX ,etc.)
272 NO_SIMD=                -mno-mmx -mno-sse
273 i386_STAND_FLAGS=       -ffreestanding $(NO_SIMD)
274 amd64_STAND_FLAGS=      -ffreestanding -mno-red-zone \
275                         -mcmodel=kernel $(NO_SIMD)
277 SAVEARGS=               -msave-args
278 amd64_STAND_FLAGS       += $(SAVEARGS)
280 STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
281 STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
284 # turn warnings into errors (C)
285 CERRWARN = -Wall -Wextra -Werror
287 CERRWARN += -Wno-missing-braces
288 CERRWARN += -Wno-sign-compare
289 CERRWARN += -Wno-unknown-pragmas
290 CERRWARN += -Wno-unused-parameter
291 CERRWARN += -Wno-missing-field-initializers
293 # Unfortunately, this option can misfire very easily and unfixably.
294 CERRWARN +=     -Wno-array-bounds
296 # DEBUG v. -nd make for frequent unused variables, empty conditions, etc. in
297 # -nd builds
298 $(RELEASE_BUILD)CERRWARN += -Wno-unused
299 $(RELEASE_BUILD)CERRWARN += -Wno-empty-body
302 # turn warnings into errors (C++)
303 CCERRWARN=              -Werror
305 # C99 mode
306 C99_ENABLE=     -std=gnu99
307 C99_DISABLE=    -std=gnu89
308 C99MODE=        $(C99_DISABLE)
310 # In most places, assignments to these macros should be appended with +=
311 # (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
312 sparc_CFLAGS=   $(sparc_XARCH)
313 sparcv9_CFLAGS= $(sparcv9_XARCH)
314 i386_CFLAGS=    $(i386_XARCH)
315 amd64_CFLAGS=   $(amd64_XARCH)
317 sparc_ASFLAGS=  $(sparc_AS_XARCH)
318 sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
319 i386_ASFLAGS=   $(i386_AS_XARCH)
320 amd64_ASFLAGS=  $(amd64_AS_XARCH)
323 sparc_COPTFLAG=         -fno-strict-aliasing \
324         -fno-unit-at-a-time \
325         -fno-optimize-sibling-calls \
326         -O2
327 sparcv9_COPTFLAG=       -fno-strict-aliasing \
328         -fno-unit-at-a-time \
329         -fno-optimize-sibling-calls \
330         -O2
331 i386_COPTFLAG=          -O
332 amd64_COPTFLAG=         -fno-strict-aliasing \
333         -fno-unit-at-a-time \
334         -fno-optimize-sibling-calls \
335         -O2
337 COPTFLAG= $($(MACH)_COPTFLAG)
338 COPTFLAG64= $($(MACH64)_COPTFLAG)
340 # Sometimes we want all symbols and types in debugging information even
341 # if they aren't used.
342 CALLSYMS=       -fno-eliminate-unused-debug-symbols \
343                 -fno-eliminate-unused-debug-types
346 # Flags used to build in debug mode for ctf generation.  Bugs in the Devpro
347 # compilers currently prevent us from building with cc-emitted DWARF.
349 CTF_FLAGS_sparc = -g -Wc,-Qiselect-T1 $(C99MODE) $(CDWARFSTR)
350 CTF_FLAGS_i386  = -g $(C99MODE) $(CDWARFSTR)
352 CTF_FLAGS_sparcv9       = $(CTF_FLAGS_sparc)
353 CTF_FLAGS_amd64         = $(CTF_FLAGS_i386)
355 CTF_FLAGS_amd64 += $(SAVEARGS)
357 CTF_FLAGS_32    = $(CTF_FLAGS_$(MACH))
358 CTF_FLAGS_64    = $(CTF_FLAGS_$(MACH64))
359 CTF_FLAGS       = $(CTF_FLAGS_32)
362 # Flags used with genoffsets
364 GOFLAGS = $(CALLSYMS) \
365         $(CDWARFSTR)
367 OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
368         $(CC) $(GOFLAGS) $(CFLAGS) $(CPPFLAGS)
370 OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
371         $(CC) $(GOFLAGS) $(CFLAGS64) $(CPPFLAGS)
373 sparc_XREGSFLAG         = -mno-app-regs
374 sparcv9_XREGSFLAG       = -mno-app-regs
375 i386_XREGSFLAG          =
376 amd64_XREGSFLAG         =
378 XREGSFLAG               = $($(MACH)_XREGSFLAG)
379 XREGSFLAG64             = $($(MACH64)_XREGSFLAG)
381 # dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
382 # avoids stripping it.
383 SOURCEDEBUG     = $(POUND_SIGN)
384 SRCDBGBLD       = $(SOURCEDEBUG:yes=)
387 # These variables are intended ONLY for use by developers to safely pass extra
388 # flags to the compilers without unintentionally overriding Makefile-set
389 # flags.  They should NEVER be set to any value in a Makefile.
391 # They come last in the associated FLAGS variable such that they can
392 # explicitly override things if necessary, there are gaps in this, but it's
393 # the best we can manage.
395 CUSERFLAGS              =
396 CUSERFLAGS64            = $(CUSERFLAGS)
397 CCUSERFLAGS             =
398 CCUSERFLAGS64           = $(CCUSERFLAGS)
400 CSOURCEDEBUGFLAGS       =
401 CCSOURCEDEBUGFLAGS      =
402 $(SRCDBGBLD)CSOURCEDEBUGFLAGS   = -g
403 $(SRCDBGBLD)CCSOURCEDEBUGFLAGS  = -g
405 CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) \
406                 $(CERRWARN) $(C99MODE) \
407                 $(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
408                 $(CUSERFLAGS)
409 CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) \
410                 $(CERRWARN) $(C99MODE) \
411                 $(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
412                 $(CUSERFLAGS64)
413 ARFLAGS=        rc
415 # Flags that are used to build parts of the code that are subsequently
416 # run on the build machine (also known as the NATIVE_BUILD).
418 NATIVE_CFLAGS=  $(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) \
419                 $(CERRWARN) $(C99MODE) \
420                 $(CCNOAUTOINLINE) \
421                 $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
423 DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"       # For messaging.
424 CPPFLAGS.first= # Please keep empty.  Only lower makefiles should set this.
425 CPPFLAGS.master=$(DTEXTDOM) \
426         $(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
427         $(ADJUNCT_PROTO:%=-I%/usr/include)
428 CPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
429                 $(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
430 CPPFLAGS=       $(CPPFLAGS.first) $(CPPFLAGS.master)
431 AS_CPPFLAGS=    $(CPPFLAGS.first) $(CPPFLAGS.master)
434 # For source message catalogue
436 .SUFFIXES: $(SUFFIXES) .i .po
437 MSGROOT= $(ROOT)/catalog
438 MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
439 MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
440 DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
441 DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
443 CLOBBERFILES += $(POFILE) $(POFILES)
444 COMPILE.cpp= $(CC) -xc -E -C $(CFLAGS) $(CPPFLAGS)
445 XGETTEXT= /usr/bin/xgettext
446 XGETFLAGS= -c TRANSLATION_NOTE
447 BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
448         $(RM)   $@ ;\
449         $(SED) "/^domain/d" < $(<F).po > $@ ;\
450         $(RM) $(<F).po $<.i
453 # This is overwritten by local Makefile when PROG is a list.
455 POFILE= $(PROG).po
457 sparc_CCFLAGS=          -m32 mcpu=v8 mno-v8plus \
458                         -mtunesupersparc \
459                         $(CCERRWARN)
460 sparcv9_CCFLAGS=        $(sparcv9_XARCH) \
461                         $(CCERRWARN)
462 i386_CCFLAGS=           $(CCERRWARN)
463 amd64_CCFLAGS=          $(amd64_XARCH) \
464                         $(CCERRWARN)
466 sparc_CCOPTFLAG=        -O
467 sparcv9_CCOPTFLAG=      -O
468 i386_CCOPTFLAG=         -O
469 amd64_CCOPTFLAG=        -O
471 CCOPTFLAG=      $($(MACH)_CCOPTFLAG)
472 CCOPTFLAG64=    $($(MACH64)_CCOPTFLAG)
473 CCFLAGS=        $(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
474                 $(CCUSERFLAGS)
475 CCFLAGS64=      $(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
476                 $(CCUSERFLAGS64)
481 ELFWRAP_FLAGS   =
482 ELFWRAP_FLAGS64 =       -64
485 # Various mapfiles that are used throughout the build, and delivered to
486 # /usr/lib/ld.
488 MAPFILE.PGA =           $(SRC)/common/mapfiles/common/map.pagealign
489 MAPFILE.FLT =           $(SRC)/common/mapfiles/common/map.filter
490 MAPFILE.LEX =           $(SRC)/common/mapfiles/common/map.lex.yy
493 # Generated mapfiles that are compiler specific, and used throughout the
494 # build.  These mapfiles are not delivered in /usr/lib/ld.
496 MAPFILE.NGB_sparc=      $(SRC)/common/mapfiles/gen/sparc_gcc_map.noexeglobs
497 MAPFILE.NGB_sparcv9=    $(SRC)/common/mapfiles/gen/sparcv9_gcc_map.noexeglobs
498 MAPFILE.NGB_i386=       $(SRC)/common/mapfiles/gen/i386_gcc_map.noexeglobs
499 MAPFILE.NGB_amd64=      $(SRC)/common/mapfiles/gen/amd64_gcc_map.noexeglobs
500 MAPFILE.NGB =           $(MAPFILE.NGB_$(MACH))
503 # A generic interface mapfile name, used by various dynamic objects to define
504 # the interfaces and interposers the object must export.
506 MAPFILE.INT =           mapfile-intf
509 # LDLIBS32 and LDLIBS64 can be set in the environment to override the following
510 # assignments.
512 LDLIBS32 =      $(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
513 LDLIBS32 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
514 LDLIBS.cmd =    $(LDLIBS32)
515 LDLIBS.lib =    $(LDLIBS32)
517 LDLIBS64 =      $(ENVLDLIBS1:%=%/$(MACH64)) \
518                 $(ENVLDLIBS2:%=%/$(MACH64)) \
519                 $(ENVLDLIBS3:%=%/$(MACH64))
520 LDLIBS64 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib/$(MACH64) -L%/lib/$(MACH64))
523 # Define compilation macros.
525 COMPILE.c=      $(CC) $(CFLAGS) $(CPPFLAGS) -c
526 COMPILE64.c=    $(CC) $(CFLAGS64) $(CPPFLAGS) -c
527 COMPILE.cc=     $(CCC) $(CCFLAGS) $(CPPFLAGS) -c
528 COMPILE64.cc=   $(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
529 COMPILE.s=      $(AS) $(ASFLAGS) $(AS_CPPFLAGS)
530 COMPILE64.s=    $(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
531 COMPILE.d=      $(DTRACE) -G -32
532 COMPILE64.d=    $(DTRACE) -G -64
533 COMPILE.b=      $(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
534 COMPILE64.b=    $(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
537 # Link time macros
539 CCNEEDED        = -L$(GCCLIBDIR) -lstdc++ -lgcc_s
540 CCEXTNEEDED     = $(CCNEEDED)
542 LINK.c=         $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
543 LINK64.c=       $(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
544 LINK.cc=        $(CCC) $(CCFLAGS) $(CPPFLAGS) \
545                 $(LDFLAGS) $(CCNEEDED)
546 LINK64.cc=      $(CCC) $(CCFLAGS64) $(CPPFLAGS) \
547                 $(LDFLAGS) $(CCNEEDED)
549 SECLEVEL=       core
551 # For some future builds, NATIVE_MACH and MACH might be different.
552 # Therefore, NATIVE_MACH needs to be redefined in the
553 # environment as `uname -p` to override this macro.
555 # For now at least, we cross-compile amd64 on i386 machines.
556 NATIVE_MACH=    $(MACH:amd64=i386)
558 # Define native compilation macros
561 # Base directory where compilers are located.
562 # Defined here so it can be overridden by developers.
564 GNU_ROOT=               /usr
566 BASIC_CC_ARGS=  -fident \
567                 -finline \
568                 -fno-inline-functions \
569                 -fno-builtin \
570                 -fno-asm \
571                 -fdiagnostics-show-option \
572                 -nodefaultlibs
574 # The SPARC ldd and std instructions require 8-byte alignment of their
575 # address operand.  gcc correctly uses them only when the ABI requires
576 # 8-byte alignment; unfortunately we have a number of pieces of buggy code
577 # that does not conform to the ABI.  This flag makes gcc work more like
578 # Studio with -xmemalign=4.
579 $(SPARC_BLD)BASIC_CC_ARGS += mno-integer-ldd-std
581 BASIC_CC_ARGS += -D__sun
583 BASIC_AS_ARGS=  -x assembler-with-cpp \
584                 -c \
585                 -Wa,--warn \
586                 -Wa,--fatal-warnings \
587                 -Wa,--traditional-format \
588                 -D__GNUC_AS__
590 # Specify platform compiler versions for languages
591 # that we use (currently only c and c++).
593 sparc_CC=               /usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
594 sparc_CCC=              /usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
595 sparc_CPP=              $(GNUC_ROOT)/bin/cpp
596 sparc_AS=               /usr/bin/as -xregsym=no
597 sparc_LD=               /usr/bin/ld
599 sparcv9_CC=             /usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
600 sparcv9_CCC=            /usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
601 sparcv9_CPP=            $(GNUC_ROOT)/bin/cpp
602 sparcv9_AS=             /usr/bin/as -xregsym=no
603 sparcv9_LD=             /usr/bin/ld
605 i386_CC=                /usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
606 i386_CCC=               /usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
607 i386_CPP=               $(GNUC_ROOT)/bin/cpp
608 i386_AS=                $(GNUC_ROOT)/bin/gcc $(BASIC_AS_ARGS)
609 i386_LD=                /usr/bin/ld
611 amd64_CC=               /usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
612 amd64_CCC=              /usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
613 amd64_CPP=              $(GNUC_ROOT)/bin/cpp
614 amd64_AS=               $(GNUC_ROOT)/bin/gcc $(BASIC_AS_ARGS)
615 amd64_LD=               /usr/bin/ld
617 NATIVECC=               $($(NATIVE_MACH)_CC)
618 NATIVECCC=              $($(NATIVE_MACH)_CCC)
619 NATIVECPP=              $($(NATIVE_MACH)_CPP)
620 NATIVEAS=               $($(NATIVE_MACH)_AS)
621 NATIVELD=               $($(NATIVE_MACH)_LD)
624 # Makefile.master.64 overrides these settings
626 CC=                     $(NATIVECC)
627 CCC=                    $(NATIVECCC)
628 CPP=                    $(NATIVECPP)
629 AS=                     $(NATIVEAS)
630 LD=                     $(NATIVELD)
632 CCYFLAG=        -nostdinc
634 LD_BDIRECT=     -Bdirect
635 LD_BDYNAMIC=    -Bdynamic
636 LD_BLOCAL=      -Blocal
637 LD_BNODIRECT=   -Bnodirect
638 LD_BREDUCE=     -Breduce
639 LD_BSTATIC=     -Bstatic
641 BDIRECT=        $(LD_BDIRECT:%=-Wl,%)
642 BDYNAMIC=       $(LD_BDYNAMIC:%=-Wl,%)
643 BLOCAL=         $(LD_BLOCAL:%=-Wl,%)
644 BNODIRECT=      $(LD_BNODIRECT:%=-Wl,%)
645 BREDUCE=        $(LD_BREDUCE:%=-Wl,%)
646 BSTATIC=        $(LD_BSTATIC:%=-Wl,%)
648 LD_ZDEFS=               -zdefs
649 LD_ZDIRECT=             -zdirect
650 LD_ZIGNORE=             -zignore
651 LD_ZINITFIRST=          -zinitfirst
652 LD_ZINTERPOSE=          -zinterpose
653 LD_ZLAZYLOAD=           -zlazyload
654 LD_ZLOADFLTR=           -zloadfltr
655 LD_ZNODEFS=             -znodefs
656 LD_ZNODELETE=           -znodelete
657 LD_ZNODLOPEN=           -znodlopen
658 LD_ZNODUMP=             -znodump
659 LD_ZNOLAZYLOAD=         -znolazyload
660 LD_ZNOLDYNSYM=          -znoldynsym
661 LD_ZNORELOC=            -znoreloc
662 LD_ZNOVERSION=          -znoversion
663 LD_ZRECORD=             -zrecord
664 LD_ZTEXT=               -ztext
666 ZDEFS=          $(LD_ZDEFS:%=-Wl,%)
667 ZDIRECT=        $(LD_ZDIRECT:%=-Wl,%)
668 ZIGNORE=        $(LD_ZIGNORE:%=-Wl,%)
669 ZINITFIRST=     $(LD_ZINITFIRST:%=-Wl,%)
670 ZINTERPOSE=     $(LD_ZINTERPOSE:%=-Wl,%)
671 ZLAZYLOAD=      $(LD_ZLAZYLOAD:%=-Wl,%)
672 ZLOADFLTR=      $(LD_ZLOADFLTR:%=-Wl,%)
673 ZNODEFS=        $(LD_ZNODEFS:%=-Wl,%)
674 ZNODELETE=      $(LD_ZNODELETE:%=-Wl,%)
675 ZNODLOPEN=      $(LD_ZNODLOPEN:%=-Wl,%)
676 ZNODUMP=        $(LD_ZNODUMP:%=-Wl,%)
677 ZNOLAZYLOAD=    $(LD_ZNOLAZYLOAD:%=-Wl,%)
678 ZNOLDYNSYM=     $(LD_ZNOLDYNSYM:%=-Wl,%)
679 NORELOC=        $(LD_ZNORELOC:%=-Wl,%)
680 ZNOVERSION=     $(LD_ZNOVERSION:%=-Wl,%)
681 ZRECORD=        $(LD_ZRECORD:%=-Wl,%)
682 ZTEXT=          $(LD_ZTEXT:%=-Wl,%)
684 GSHARED=        -shared
686 # Handle different PIC models on different ISAs
687 # (May be overridden by lower-level Makefiles)
689 sparc_C_PICFLAGS =      -fpic
690 sparcv9_C_PICFLAGS =    -fpic
691 i386_C_PICFLAGS =       -fpic
692 amd64_C_PICFLAGS =      -fpic
693 C_PICFLAGS =            $($(MACH)_C_PICFLAGS)
694 C_PICFLAGS64 =          $($(MACH64)_C_PICFLAGS)
696 sparc_C_BIGPICFLAGS =   -fPIC
697 sparcv9_C_BIGPICFLAGS = -fPIC
698 i386_C_BIGPICFLAGS =    -fPIC
699 amd64_C_BIGPICFLAGS =   -fPIC
700 C_BIGPICFLAGS =         $($(MACH)_C_BIGPICFLAGS)
701 C_BIGPICFLAGS64 =       $($(MACH64)_C_BIGPICFLAGS)
703 # CC requires there to be no space between '-K' and 'pic' or 'PIC'.
704 sparc_CC_PICFLAGS =     -fpic
705 sparcv9_CC_PICFLAGS =   -fPIC
706 i386_CC_PICFLAGS =      -fpic
707 amd64_CC_PICFLAGS =     -fpic
708 CC_PICFLAGS =           $($(MACH)_CC_PICFLAGS)
709 CC_PICFLAGS64 =         $($(MACH64)_CC_PICFLAGS)
711 AS_PICFLAGS=
712 AS_BIGPICFLAGS=
715 # Default label for CTF sections
717 CTFCVTFLAGS=            -i -L VERSION
720 # Override to pass module-specific flags to ctfmerge.  Currently used only by
721 # krtld to turn on fuzzy matching, and source-level debugging to inhibit
722 # stripping.
724 CTFMRGFLAGS=
726 CTFCONVERT_O            = $(CTFCONVERT) $(CTFCVTFLAGS) $@
728 # Rules (normally from make.rules) and macros which are used for post
729 # processing files. Normally, these do stripping of the comment section
730 # automatically.
731 #    RELEASE_CM:        Should be editted to reflect the release.
732 #    POST_PROCESS_O:    Post-processing for `.o' files.
733 #    POST_PROCESS_A:    Post-processing for `.a' files (currently null).
734 #    POST_PROCESS_SO:   Post-processing for `.so' files.
735 #    POST_PROCESS:      Post-processing for executable files (no suffix).
736 # Note that these macros are not completely generalized as they are to be
737 # used with the file name to be processed following.
739 # It is left as an exercise to Release Engineering to embellish the generation
740 # of the release comment string.
742 #       If this is a standard development build:
743 #               compress the comment section (mcs -c)
744 #               add the standard comment (mcs -a $(RELEASE_CM))
745 #               add the development specific comment (mcs -a $(DEV_CM))
747 #       If this is an installation build:
748 #               delete the comment section (mcs -d)
749 #               add the standard comment (mcs -a $(RELEASE_CM))
750 #               add the development specific comment (mcs -a $(DEV_CM))
752 #       If this is an release build:
753 #               delete the comment section (mcs -d)
754 #               add the standard comment (mcs -a $(RELEASE_CM))
756 # The following list of macros are used in the definition of RELEASE_CM
757 # which is used to label all binaries in the build:
759 #       RELEASE         Specific release of the build, eg: 5.2
760 #       RELEASE_MAJOR   Major version number part of $(RELEASE)
761 #       RELEASE_MINOR   Minor version number part of $(RELEASE)
762 #       VERSION         Version of the build (alpha, beta, Generic)
763 #       PATCHID         If this is a patch this value should contain
764 #                       the patchid value (eg: "Generic 100832-01"), otherwise
765 #                       it will be set to $(VERSION)
766 #       RELEASE_DATE    Date of the Release Build
767 #       PATCH_DATE      Date the patch was created, if this is blank it
768 #                       will default to the RELEASE_DATE
770 SYSNAME=        SunOS
771 RELEASE_MAJOR=  5
772 RELEASE_MINOR=  11
773 RELEASE=        $(RELEASE_MAJOR).$(RELEASE_MINOR)
774 VERSION=        $(SYSNAME) Development
775 PATCHID=        $(VERSION)
776 RELEASE_DATE=   release date not set
777 PATCH_DATE=     $(RELEASE_DATE)
778 RELEASE_CM=     "$(SYSNAME) $(RELEASE) $(PATCHID) $(PATCH_DATE)"
779 DEV_CM=         "$(SYSNAME) Development: non-nightly build"
781 STRIP_STABS=                       $(STRIP) -x $@
782 $(SRCDBGBLD)STRIP_STABS=           :
784 POST_PROCESS_O=         :
785 POST_PROCESS_A=         :
786 POST_PROCESS_SO=        $(STRIP_STABS)
787 POST_PROCESS=           $(STRIP_STABS)
790 # chk4ubin is a tool that inspects a module for a symbol table
791 # ELF section size which can trigger an OBP bug on older platforms.
792 # This problem affects only specific sun4u bootable modules.
794 CHK4UBIN=       $(ONBLD_TOOLS)/bin/$(MACH)/chk4ubin
795 CHK4UBINFLAGS=
796 CHK4UBINARY=    $(CHK4UBIN) $(CHK4UBINFLAGS) $@
799 # PKGARCHIVE specifies the default location where packages should be
800 # placed if built.
802 PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly
805 # The repositories will be created with these publisher settings.  To
806 # update an image to the resulting repositories, this must match the
807 # publisher name provided to "pkg set-publisher."
809 PKGPUBLISHER=   unleashed
811 #       Default build rules which perform comment section post-processing.
814         $(LINK.c) -o $@ $< $(LDLIBS)
815         $(POST_PROCESS)
816 .c.o:
817         $(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
818         $(POST_PROCESS_O)
819 .c.a:
820         $(COMPILE.c) -o $% $<
821         $(AR) $(ARFLAGS) $@ $%
822         $(RM) $%
823 .s.o:
824         $(COMPILE.s) -o $@ $<
825         $(POST_PROCESS_O)
826 .s.a:
827         $(COMPILE.s) -o $% $<
828         $(AR) $(ARFLAGS) $@ $%
829         $(RM) $%
830 .cc:
831         $(LINK.cc) -o $@ $< $(LDLIBS)
832         $(POST_PROCESS)
833 .cc.o:
834         $(COMPILE.cc) $(OUTPUT_OPTION) $<
835         $(POST_PROCESS_O)
836 .cc.a:
837         $(COMPILE.cc) -o $% $<
838         $(AR) $(ARFLAGS) $@ $%
839         $(RM) $%
841         $(YACC.y) $<
842         $(LINK.c) -o $@ y.tab.c $(LDLIBS)
843         $(POST_PROCESS)
844         $(RM) y.tab.c
845 .y.o:
846         $(YACC.y) $<
847         $(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
848         $(POST_PROCESS_O)
849         $(RM) y.tab.c
851         $(RM) $*.c
852         $(LEX.l) $< > $*.c
853         $(LINK.c) -o $@ $*.c -ll $(LDLIBS)
854         $(POST_PROCESS)
855         $(RM) $*.c
856 .l.o:
857         $(RM) $*.c
858         $(LEX.l) $< > $*.c
859         $(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
860         $(POST_PROCESS_O)
861         $(RM) $*.c
863 .bin.o:
864         $(COMPILE.b) -o $@ $<
865         $(POST_PROCESS_O)
867 .java.class:
868         $(COMPILE.java) $<
870 # Bourne and Korn shell script message catalog build rules.
871 # We extract all gettext strings with sed(1) (being careful to permit
872 # multiple gettext strings on the same line), weed out the dups, and
873 # build the catalogue with awk(1).
875 .sh.po .ksh.po:
876         $(SED) -n -e ":a"                               \
877                   -e "h"                                        \
878                   -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"       \
879                   -e "x"                                        \
880                   -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"  \
881                   -e "t a"                                      \
882                $< | sort -u | $(AWK) '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
885 # Python and Perl executable and message catalog build rules.
887 .SUFFIXES: .pl .pm .py .pyc
889 .pl:
890         $(RM) $@;
891         $(SED) -e "s@TEXT_DOMAIN@\"$(TEXT_DOMAIN)\"@" $< > $@;
892         $(CHMOD) +x $@
894 .py:
895         $(RM) $@; $(SED) -e "1s:^\#!@PYTHON@:\#!$(PYTHON):" < $< > $@; $(CHMOD) +x $@
897 .py.pyc:
898         $(RM) $@
899         $(PYTHON) -mpy_compile $<
900         @[ $(<)c = $@ ] || $(MV) $(<)c $@
902 .pl.po .pm.po:
903         $(XGETTEXT) $(XGETFLAGS) -d $(<F) $< ;
904         $(RM)   $@ ;
905         $(SED) "/^domain/d" < $(<F).po > $@ ;
906         $(RM) $(<F).po
909 # When using xgettext, we want messages to go to the default domain,
910 # rather than the specified one.  This special version of the
911 # COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
912 # causing xgettext to put all messages into the default domain.
914 CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
916 .c.i:
917         $(CPPFORPO) $< > $@
919 .h.i:
920         $(CPPFORPO) $< > $@
922 .y.i:
923         $(YACC) -d $<
924         $(CPPFORPO) y.tab.c  > $@
925         $(RM) y.tab.c
927 .l.i:
928         $(LEX) $<
929         $(CPPFORPO) lex.yy.c  > $@
930         $(RM) lex.yy.c
932 .c.po:
933         $(CPPFORPO) $< > $<.i
934         $(BUILD.po)
936 .cc.po:
937         $(CPPFORPO) $< > $<.i
938         $(BUILD.po)
940 .y.po:
941         $(YACC) -d $<
942         $(CPPFORPO) y.tab.c  > $<.i
943         $(BUILD.po)
944         $(RM) y.tab.c
946 .l.po:
947         $(LEX) $<
948         $(CPPFORPO) lex.yy.c  > $<.i
949         $(BUILD.po)
950         $(RM) lex.yy.c
953 # Rules to perform stylistic checks
955 .SUFFIXES: .x .xml .check .xmlchk
957 .h.check:
958         $(DOT_H_CHECK)
960 .x.check:
961         $(DOT_X_CHECK)
963 .xml.xmlchk:
964         $(MANIFEST_CHECK)