build: use -fno-ipa-icf -fno-clone-functions for C++ code
[unleashed.git] / usr / src / Makefile.master
blob22f330cdaafbc6aa96e1821ddd14d937ae6856a2
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=      /usr/gcc/7
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 \
246         -fno-ipa-icf -fno-clone-functions
249 # compiler architecture flags.
251 sparc_XARCH=    -m32 -mcpu=v8 -mno-v8plus
252 sparcv9_XARCH=  -m64 -mcpu=v9
253 i386_XARCH=     -m32 -march=pentiumpro
254 amd64_XARCH=    -m64 -Ui386 -U__i386 -mtune=opteron
256 # assembler architecture flags.  Different from compiler architecture flags.
257 sparc_AS_XARCH=         -xarch=v8plus -Dsparc -D__sparc -D__sparcv8
258 sparcv9_AS_XARCH=       -xarch=v9 -Dsparc -D__sparc -D__sparcv9
259 i386_AS_XARCH=          -m32 -Di386 -D__i386
260 amd64_AS_XARCH=         -m64 -Ui386 -U__i386 -D__x86_64 -D__amd64
263 # These flags define what we need to be 'standalone' i.e. -not- part
264 # of the rather more cosy userland environment.  This basically means
265 # the kernel.
267 # XX64  future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
269 sparc_STAND_FLAGS=      -ffreestanding
270 sparcv9_STAND_FLAGS=    -ffreestanding
271 # Disabling MMX also disables 3DNow, disabling SSE also disables all later
272 # additions to SSE (SSE2, AVX ,etc.)
273 NO_SIMD=                -mno-mmx -mno-sse
274 i386_STAND_FLAGS=       -ffreestanding $(NO_SIMD)
275 amd64_STAND_FLAGS=      -ffreestanding -mno-red-zone \
276                         -mcmodel=kernel $(NO_SIMD)
278 SAVEARGS=               -msave-args
279 amd64_STAND_FLAGS       += $(SAVEARGS)
281 STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
282 STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
285 # turn warnings into errors (C)
286 CERRWARN = -Wall -Wextra -Werror
288 CERRWARN += -Wno-missing-braces
289 CERRWARN += -Wno-sign-compare
290 CERRWARN += -Wno-unknown-pragmas
291 CERRWARN += -Wno-unused-parameter
292 CERRWARN += -Wno-missing-field-initializers
294 # Unfortunately, this option can misfire very easily and unfixably.
295 CERRWARN +=     -Wno-array-bounds
297 # DEBUG v. -nd make for frequent unused variables, empty conditions, etc. in
298 # -nd builds
299 $(RELEASE_BUILD)CERRWARN += -Wno-unused
300 $(RELEASE_BUILD)CERRWARN += -Wno-empty-body
303 # turn warnings into errors (C++)
304 CCERRWARN=              -Werror
306 # C99 mode
307 C99_ENABLE=     -std=gnu99
308 C99_DISABLE=    -std=gnu89
309 C99MODE=        $(C99_DISABLE)
311 # In most places, assignments to these macros should be appended with +=
312 # (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
313 sparc_CFLAGS=   $(sparc_XARCH)
314 sparcv9_CFLAGS= $(sparcv9_XARCH)
315 i386_CFLAGS=    $(i386_XARCH)
316 amd64_CFLAGS=   $(amd64_XARCH)
318 sparc_ASFLAGS=  $(sparc_AS_XARCH)
319 sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
320 i386_ASFLAGS=   $(i386_AS_XARCH)
321 amd64_ASFLAGS=  $(amd64_AS_XARCH)
324 sparc_COPTFLAG=         -fno-strict-aliasing \
325         -fno-unit-at-a-time \
326         -fno-optimize-sibling-calls \
327         -O2
328 sparcv9_COPTFLAG=       -fno-strict-aliasing \
329         -fno-unit-at-a-time \
330         -fno-optimize-sibling-calls \
331         -O2
332 i386_COPTFLAG=          -O
333 amd64_COPTFLAG=         -fno-strict-aliasing \
334         -fno-unit-at-a-time \
335         -fno-optimize-sibling-calls \
336         -O2
338 COPTFLAG= $($(MACH)_COPTFLAG)
339 COPTFLAG64= $($(MACH64)_COPTFLAG)
341 # Sometimes we want all symbols and types in debugging information even
342 # if they aren't used.
343 CALLSYMS=       -fno-eliminate-unused-debug-symbols \
344                 -fno-eliminate-unused-debug-types
347 # Flags used to build in debug mode for ctf generation.  Bugs in the Devpro
348 # compilers currently prevent us from building with cc-emitted DWARF.
350 CTF_FLAGS_sparc = -g -Wc,-Qiselect-T1 $(C99MODE) $(CDWARFSTR)
351 CTF_FLAGS_i386  = -g $(C99MODE) $(CDWARFSTR)
353 CTF_FLAGS_sparcv9       = $(CTF_FLAGS_sparc)
354 CTF_FLAGS_amd64         = $(CTF_FLAGS_i386)
356 CTF_FLAGS_amd64 += $(SAVEARGS)
358 CTF_FLAGS_32    = $(CTF_FLAGS_$(MACH))
359 CTF_FLAGS_64    = $(CTF_FLAGS_$(MACH64))
360 CTF_FLAGS       = $(CTF_FLAGS_32)
363 # Flags used with genoffsets
365 GOFLAGS = $(CALLSYMS) \
366         $(CDWARFSTR)
368 OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
369         $(CC) $(GOFLAGS) $(CFLAGS) $(CPPFLAGS)
371 OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
372         $(CC) $(GOFLAGS) $(CFLAGS64) $(CPPFLAGS)
374 sparc_XREGSFLAG         = -mno-app-regs
375 sparcv9_XREGSFLAG       = -mno-app-regs
376 i386_XREGSFLAG          =
377 amd64_XREGSFLAG         =
379 XREGSFLAG               = $($(MACH)_XREGSFLAG)
380 XREGSFLAG64             = $($(MACH64)_XREGSFLAG)
382 # dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
383 # avoids stripping it.
384 SOURCEDEBUG     = $(POUND_SIGN)
385 SRCDBGBLD       = $(SOURCEDEBUG:yes=)
388 # These variables are intended ONLY for use by developers to safely pass extra
389 # flags to the compilers without unintentionally overriding Makefile-set
390 # flags.  They should NEVER be set to any value in a Makefile.
392 # They come last in the associated FLAGS variable such that they can
393 # explicitly override things if necessary, there are gaps in this, but it's
394 # the best we can manage.
396 CUSERFLAGS              =
397 CUSERFLAGS64            = $(CUSERFLAGS)
398 CCUSERFLAGS             =
399 CCUSERFLAGS64           = $(CCUSERFLAGS)
401 CSOURCEDEBUGFLAGS       =
402 CCSOURCEDEBUGFLAGS      =
403 $(SRCDBGBLD)CSOURCEDEBUGFLAGS   = -g
404 $(SRCDBGBLD)CCSOURCEDEBUGFLAGS  = -g
406 CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) \
407                 $(CERRWARN) $(C99MODE) \
408                 $(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
409                 $(CUSERFLAGS)
410 CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) \
411                 $(CERRWARN) $(C99MODE) \
412                 $(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
413                 $(CUSERFLAGS64)
414 ARFLAGS=        rc
416 # Flags that are used to build parts of the code that are subsequently
417 # run on the build machine (also known as the NATIVE_BUILD).
419 NATIVE_CFLAGS=  $(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) \
420                 $(CERRWARN) $(C99MODE) \
421                 $(CCNOAUTOINLINE) \
422                 $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
424 DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"       # For messaging.
425 CPPFLAGS.first= # Please keep empty.  Only lower makefiles should set this.
426 CPPFLAGS.master=$(DTEXTDOM) \
427         $(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
428         $(ADJUNCT_PROTO:%=-I%/usr/include)
429 CPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
430                 $(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
431 CPPFLAGS=       $(CPPFLAGS.first) $(CPPFLAGS.master)
432 AS_CPPFLAGS=    $(CPPFLAGS.first) $(CPPFLAGS.master)
435 # For source message catalogue
437 .SUFFIXES: $(SUFFIXES) .i .po
438 MSGROOT= $(ROOT)/catalog
439 MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
440 MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
441 DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
442 DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
444 CLOBBERFILES += $(POFILE) $(POFILES)
445 COMPILE.cpp= $(CC) -xc -E -C $(CFLAGS) $(CPPFLAGS)
446 XGETTEXT= /usr/bin/xgettext
447 XGETFLAGS= -c TRANSLATION_NOTE
448 BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
449         $(RM)   $@ ;\
450         $(SED) "/^domain/d" < $(<F).po > $@ ;\
451         $(RM) $(<F).po $<.i
454 # This is overwritten by local Makefile when PROG is a list.
456 POFILE= $(PROG).po
458 sparc_CCFLAGS=          -m32 mcpu=v8 mno-v8plus \
459                         -mtunesupersparc \
460                         $(CCERRWARN)
461 sparcv9_CCFLAGS=        $(sparcv9_XARCH) \
462                         $(CCERRWARN)
463 i386_CCFLAGS=           $(CCERRWARN)
464 amd64_CCFLAGS=          $(amd64_XARCH) \
465                         $(CCERRWARN)
467 sparc_CCOPTFLAG=        -O
468 sparcv9_CCOPTFLAG=      -O
469 i386_CCOPTFLAG=         -O
470 amd64_CCOPTFLAG=        -O
472 CCOPTFLAG=      $($(MACH)_CCOPTFLAG)
473 CCOPTFLAG64=    $($(MACH64)_CCOPTFLAG)
474 CCFLAGS=        $(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
475                 $(CCNOAUTOINLINE) \
476                 $(CCUSERFLAGS)
477 CCFLAGS64=      $(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
478                 $(CCNOAUTOINLINE) \
479                 $(CCUSERFLAGS64)
484 ELFWRAP_FLAGS   =
485 ELFWRAP_FLAGS64 =       -64
488 # Various mapfiles that are used throughout the build, and delivered to
489 # /usr/lib/ld.
491 MAPFILE.PGA =           $(SRC)/common/mapfiles/common/map.pagealign
492 MAPFILE.FLT =           $(SRC)/common/mapfiles/common/map.filter
493 MAPFILE.LEX =           $(SRC)/common/mapfiles/common/map.lex.yy
496 # Generated mapfiles that are compiler specific, and used throughout the
497 # build.  These mapfiles are not delivered in /usr/lib/ld.
499 MAPFILE.NGB_sparc=      $(SRC)/common/mapfiles/gen/sparc_gcc_map.noexeglobs
500 MAPFILE.NGB_sparcv9=    $(SRC)/common/mapfiles/gen/sparcv9_gcc_map.noexeglobs
501 MAPFILE.NGB_i386=       $(SRC)/common/mapfiles/gen/i386_gcc_map.noexeglobs
502 MAPFILE.NGB_amd64=      $(SRC)/common/mapfiles/gen/amd64_gcc_map.noexeglobs
503 MAPFILE.NGB =           $(MAPFILE.NGB_$(MACH))
506 # A generic interface mapfile name, used by various dynamic objects to define
507 # the interfaces and interposers the object must export.
509 MAPFILE.INT =           mapfile-intf
512 # LDLIBS32 and LDLIBS64 can be set in the environment to override the following
513 # assignments.
515 LDLIBS32 =      $(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
516 LDLIBS32 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
517 LDLIBS.cmd =    $(LDLIBS32)
518 LDLIBS.lib =    $(LDLIBS32)
520 LDLIBS64 =      $(ENVLDLIBS1:%=%/$(MACH64)) \
521                 $(ENVLDLIBS2:%=%/$(MACH64)) \
522                 $(ENVLDLIBS3:%=%/$(MACH64))
523 LDLIBS64 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib/$(MACH64) -L%/lib/$(MACH64))
526 # Define compilation macros.
528 COMPILE.c=      $(CC) $(CFLAGS) $(CPPFLAGS) -c
529 COMPILE64.c=    $(CC) $(CFLAGS64) $(CPPFLAGS) -c
530 COMPILE.cc=     $(CCC) $(CCFLAGS) $(CPPFLAGS) -c
531 COMPILE64.cc=   $(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
532 COMPILE.s=      $(AS) $(ASFLAGS) $(AS_CPPFLAGS)
533 COMPILE64.s=    $(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
534 COMPILE.d=      $(DTRACE) -G -32
535 COMPILE64.d=    $(DTRACE) -G -64
536 COMPILE.b=      $(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
537 COMPILE64.b=    $(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
540 # Link time macros
542 CCNEEDED        = -L$(GCCLIBDIR) -lstdc++ -lgcc_s
543 CCEXTNEEDED     = $(CCNEEDED)
545 LINK.c=         $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
546 LINK64.c=       $(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
547 LINK.cc=        $(CCC) $(CCFLAGS) $(CPPFLAGS) \
548                 $(LDFLAGS) $(CCNEEDED)
549 LINK64.cc=      $(CCC) $(CCFLAGS64) $(CPPFLAGS) \
550                 $(LDFLAGS) $(CCNEEDED)
552 SECLEVEL=       core
554 # For some future builds, NATIVE_MACH and MACH might be different.
555 # Therefore, NATIVE_MACH needs to be redefined in the
556 # environment as `uname -p` to override this macro.
558 # For now at least, we cross-compile amd64 on i386 machines.
559 NATIVE_MACH=    $(MACH:amd64=i386)
561 # Define native compilation macros
564 # Base directory where compilers are located.
565 # Defined here so it can be overridden by developers.
567 GNU_ROOT=               /usr
569 BASIC_CC_ARGS=  -fident \
570                 -finline \
571                 -fno-inline-functions \
572                 -fno-builtin \
573                 -fno-asm \
574                 -fdiagnostics-show-option \
575                 -nodefaultlibs
577 # The SPARC ldd and std instructions require 8-byte alignment of their
578 # address operand.  gcc correctly uses them only when the ABI requires
579 # 8-byte alignment; unfortunately we have a number of pieces of buggy code
580 # that does not conform to the ABI.  This flag makes gcc work more like
581 # Studio with -xmemalign=4.
582 $(SPARC_BLD)BASIC_CC_ARGS += mno-integer-ldd-std
584 BASIC_CC_ARGS += -D__sun
586 BASIC_AS_ARGS=  -x assembler-with-cpp \
587                 -c \
588                 -Wa,--warn \
589                 -Wa,--fatal-warnings \
590                 -Wa,--traditional-format \
591                 -D__GNUC_AS__
593 # Specify platform compiler versions for languages
594 # that we use (currently only c and c++).
596 sparc_CC=               $(SRC)/tools/scripts/gcc-wrap.sh $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
597 sparc_CCC=              $(SRC)/tools/scripts/gcc-wrap.sh $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
598 sparc_CPP=              $(GNUC_ROOT)/bin/cpp
599 sparc_AS=               /usr/bin/as -xregsym=no
600 sparc_LD=               /usr/bin/ld
602 sparcv9_CC=             $(SRC)/tools/scripts/gcc-wrap.sh $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
603 sparcv9_CCC=            $(SRC)/tools/scripts/gcc-wrap.sh $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
604 sparcv9_CPP=            $(GNUC_ROOT)/bin/cpp
605 sparcv9_AS=             /usr/bin/as -xregsym=no
606 sparcv9_LD=             /usr/bin/ld
608 i386_CC=                $(SRC)/tools/scripts/gcc-wrap.sh $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
609 i386_CCC=               $(SRC)/tools/scripts/gcc-wrap.sh $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
610 i386_CPP=               $(GNUC_ROOT)/bin/cpp
611 i386_AS=                $(GNUC_ROOT)/bin/gcc $(BASIC_AS_ARGS)
612 i386_LD=                /usr/bin/ld
614 amd64_CC=               $(SRC)/tools/scripts/gcc-wrap.sh $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
615 amd64_CCC=              $(SRC)/tools/scripts/gcc-wrap.sh $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
616 amd64_CPP=              $(GNUC_ROOT)/bin/cpp
617 amd64_AS=               $(GNUC_ROOT)/bin/gcc $(BASIC_AS_ARGS)
618 amd64_LD=               /usr/bin/ld
620 NATIVECC=               $($(NATIVE_MACH)_CC)
621 NATIVECCC=              $($(NATIVE_MACH)_CCC)
622 NATIVECPP=              $($(NATIVE_MACH)_CPP)
623 NATIVEAS=               $($(NATIVE_MACH)_AS)
624 NATIVELD=               $($(NATIVE_MACH)_LD)
627 # Makefile.master.64 overrides these settings
629 CC=                     $(NATIVECC)
630 CCC=                    $(NATIVECCC)
631 CPP=                    $(NATIVECPP)
632 AS=                     $(NATIVEAS)
633 LD=                     $(NATIVELD)
635 CCYFLAG=        -nostdinc
637 LD_BDIRECT=     -Bdirect
638 LD_BDYNAMIC=    -Bdynamic
639 LD_BLOCAL=      -Blocal
640 LD_BNODIRECT=   -Bnodirect
641 LD_BREDUCE=     -Breduce
642 LD_BSTATIC=     -Bstatic
644 BDIRECT=        $(LD_BDIRECT:%=-Wl,%)
645 BDYNAMIC=       $(LD_BDYNAMIC:%=-Wl,%)
646 BLOCAL=         $(LD_BLOCAL:%=-Wl,%)
647 BNODIRECT=      $(LD_BNODIRECT:%=-Wl,%)
648 BREDUCE=        $(LD_BREDUCE:%=-Wl,%)
649 BSTATIC=        $(LD_BSTATIC:%=-Wl,%)
651 LD_ZDEFS=               -zdefs
652 LD_ZDIRECT=             -zdirect
653 LD_ZIGNORE=             -zignore
654 LD_ZINITFIRST=          -zinitfirst
655 LD_ZINTERPOSE=          -zinterpose
656 LD_ZLAZYLOAD=           -zlazyload
657 LD_ZLOADFLTR=           -zloadfltr
658 LD_ZNODEFS=             -znodefs
659 LD_ZNODELETE=           -znodelete
660 LD_ZNODLOPEN=           -znodlopen
661 LD_ZNODUMP=             -znodump
662 LD_ZNOLAZYLOAD=         -znolazyload
663 LD_ZNOLDYNSYM=          -znoldynsym
664 LD_ZNORELOC=            -znoreloc
665 LD_ZNOVERSION=          -znoversion
666 LD_ZRECORD=             -zrecord
667 LD_ZTEXT=               -ztext
669 ZDEFS=          $(LD_ZDEFS:%=-Wl,%)
670 ZDIRECT=        $(LD_ZDIRECT:%=-Wl,%)
671 ZIGNORE=        $(LD_ZIGNORE:%=-Wl,%)
672 ZINITFIRST=     $(LD_ZINITFIRST:%=-Wl,%)
673 ZINTERPOSE=     $(LD_ZINTERPOSE:%=-Wl,%)
674 ZLAZYLOAD=      $(LD_ZLAZYLOAD:%=-Wl,%)
675 ZLOADFLTR=      $(LD_ZLOADFLTR:%=-Wl,%)
676 ZNODEFS=        $(LD_ZNODEFS:%=-Wl,%)
677 ZNODELETE=      $(LD_ZNODELETE:%=-Wl,%)
678 ZNODLOPEN=      $(LD_ZNODLOPEN:%=-Wl,%)
679 ZNODUMP=        $(LD_ZNODUMP:%=-Wl,%)
680 ZNOLAZYLOAD=    $(LD_ZNOLAZYLOAD:%=-Wl,%)
681 ZNOLDYNSYM=     $(LD_ZNOLDYNSYM:%=-Wl,%)
682 NORELOC=        $(LD_ZNORELOC:%=-Wl,%)
683 ZNOVERSION=     $(LD_ZNOVERSION:%=-Wl,%)
684 ZRECORD=        $(LD_ZRECORD:%=-Wl,%)
685 ZTEXT=          $(LD_ZTEXT:%=-Wl,%)
687 GSHARED=        -shared
689 # Handle different PIC models on different ISAs
690 # (May be overridden by lower-level Makefiles)
692 sparc_C_PICFLAGS =      -fpic
693 sparcv9_C_PICFLAGS =    -fpic
694 i386_C_PICFLAGS =       -fpic
695 amd64_C_PICFLAGS =      -fpic
696 C_PICFLAGS =            $($(MACH)_C_PICFLAGS)
697 C_PICFLAGS64 =          $($(MACH64)_C_PICFLAGS)
699 sparc_C_BIGPICFLAGS =   -fPIC
700 sparcv9_C_BIGPICFLAGS = -fPIC
701 i386_C_BIGPICFLAGS =    -fPIC
702 amd64_C_BIGPICFLAGS =   -fPIC
703 C_BIGPICFLAGS =         $($(MACH)_C_BIGPICFLAGS)
704 C_BIGPICFLAGS64 =       $($(MACH64)_C_BIGPICFLAGS)
706 # CC requires there to be no space between '-K' and 'pic' or 'PIC'.
707 sparc_CC_PICFLAGS =     -fpic
708 sparcv9_CC_PICFLAGS =   -fPIC
709 i386_CC_PICFLAGS =      -fpic
710 amd64_CC_PICFLAGS =     -fpic
711 CC_PICFLAGS =           $($(MACH)_CC_PICFLAGS)
712 CC_PICFLAGS64 =         $($(MACH64)_CC_PICFLAGS)
714 AS_PICFLAGS=
715 AS_BIGPICFLAGS=
718 # Default label for CTF sections
720 CTFCVTFLAGS=            -i -L VERSION
723 # Override to pass module-specific flags to ctfmerge.  Currently used only by
724 # krtld to turn on fuzzy matching, and source-level debugging to inhibit
725 # stripping.
727 CTFMRGFLAGS=
729 CTFCONVERT_O            = $(CTFCONVERT) $(CTFCVTFLAGS) $@
731 # Rules (normally from make.rules) and macros which are used for post
732 # processing files. Normally, these do stripping of the comment section
733 # automatically.
734 #    RELEASE_CM:        Should be editted to reflect the release.
735 #    POST_PROCESS_O:    Post-processing for `.o' files.
736 #    POST_PROCESS_A:    Post-processing for `.a' files (currently null).
737 #    POST_PROCESS_SO:   Post-processing for `.so' files.
738 #    POST_PROCESS:      Post-processing for executable files (no suffix).
739 # Note that these macros are not completely generalized as they are to be
740 # used with the file name to be processed following.
742 # It is left as an exercise to Release Engineering to embellish the generation
743 # of the release comment string.
745 #       If this is a standard development build:
746 #               compress the comment section (mcs -c)
747 #               add the standard comment (mcs -a $(RELEASE_CM))
748 #               add the development specific comment (mcs -a $(DEV_CM))
750 #       If this is an installation build:
751 #               delete the comment section (mcs -d)
752 #               add the standard comment (mcs -a $(RELEASE_CM))
753 #               add the development specific comment (mcs -a $(DEV_CM))
755 #       If this is an release build:
756 #               delete the comment section (mcs -d)
757 #               add the standard comment (mcs -a $(RELEASE_CM))
759 # The following list of macros are used in the definition of RELEASE_CM
760 # which is used to label all binaries in the build:
762 #       RELEASE         Specific release of the build, eg: 5.2
763 #       RELEASE_MAJOR   Major version number part of $(RELEASE)
764 #       RELEASE_MINOR   Minor version number part of $(RELEASE)
765 #       VERSION         Version of the build (alpha, beta, Generic)
766 #       PATCHID         If this is a patch this value should contain
767 #                       the patchid value (eg: "Generic 100832-01"), otherwise
768 #                       it will be set to $(VERSION)
769 #       RELEASE_DATE    Date of the Release Build
770 #       PATCH_DATE      Date the patch was created, if this is blank it
771 #                       will default to the RELEASE_DATE
773 SYSNAME=        SunOS
774 RELEASE_MAJOR=  5
775 RELEASE_MINOR=  11
776 RELEASE=        $(RELEASE_MAJOR).$(RELEASE_MINOR)
777 VERSION=        $(SYSNAME) Development
778 PATCHID=        $(VERSION)
779 RELEASE_DATE=   release date not set
780 PATCH_DATE=     $(RELEASE_DATE)
781 RELEASE_CM=     "$(SYSNAME) $(RELEASE) $(PATCHID) $(PATCH_DATE)"
782 DEV_CM=         "$(SYSNAME) Development: non-nightly build"
784 STRIP_STABS=                       $(STRIP) -x $@
785 $(SRCDBGBLD)STRIP_STABS=           :
787 POST_PROCESS_O=         :
788 POST_PROCESS_A=         :
789 POST_PROCESS_SO=        $(STRIP_STABS)
790 POST_PROCESS=           $(STRIP_STABS)
793 # chk4ubin is a tool that inspects a module for a symbol table
794 # ELF section size which can trigger an OBP bug on older platforms.
795 # This problem affects only specific sun4u bootable modules.
797 CHK4UBIN=       $(ONBLD_TOOLS)/bin/$(MACH)/chk4ubin
798 CHK4UBINFLAGS=
799 CHK4UBINARY=    $(CHK4UBIN) $(CHK4UBINFLAGS) $@
802 # PKGARCHIVE specifies the default location where packages should be
803 # placed if built.
805 PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly
808 # The repositories will be created with these publisher settings.  To
809 # update an image to the resulting repositories, this must match the
810 # publisher name provided to "pkg set-publisher."
812 PKGPUBLISHER=   unleashed
814 #       Default build rules which perform comment section post-processing.
817         $(LINK.c) -o $@ $< $(LDLIBS)
818         $(POST_PROCESS)
819 .c.o:
820         $(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
821         $(POST_PROCESS_O)
822 .c.a:
823         $(COMPILE.c) -o $% $<
824         $(AR) $(ARFLAGS) $@ $%
825         $(RM) $%
826 .s.o:
827         $(COMPILE.s) -o $@ $<
828         $(POST_PROCESS_O)
829 .s.a:
830         $(COMPILE.s) -o $% $<
831         $(AR) $(ARFLAGS) $@ $%
832         $(RM) $%
833 .cc:
834         $(LINK.cc) -o $@ $< $(LDLIBS)
835         $(POST_PROCESS)
836 .cc.o:
837         $(COMPILE.cc) $(OUTPUT_OPTION) $<
838         $(POST_PROCESS_O)
839 .cc.a:
840         $(COMPILE.cc) -o $% $<
841         $(AR) $(ARFLAGS) $@ $%
842         $(RM) $%
844         $(YACC.y) $<
845         $(LINK.c) -o $@ y.tab.c $(LDLIBS)
846         $(POST_PROCESS)
847         $(RM) y.tab.c
848 .y.o:
849         $(YACC.y) $<
850         $(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
851         $(POST_PROCESS_O)
852         $(RM) y.tab.c
854         $(RM) $*.c
855         $(LEX.l) $< > $*.c
856         $(LINK.c) -o $@ $*.c -ll $(LDLIBS)
857         $(POST_PROCESS)
858         $(RM) $*.c
859 .l.o:
860         $(RM) $*.c
861         $(LEX.l) $< > $*.c
862         $(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
863         $(POST_PROCESS_O)
864         $(RM) $*.c
866 .bin.o:
867         $(COMPILE.b) -o $@ $<
868         $(POST_PROCESS_O)
870 .java.class:
871         $(COMPILE.java) $<
873 # Bourne and Korn shell script message catalog build rules.
874 # We extract all gettext strings with sed(1) (being careful to permit
875 # multiple gettext strings on the same line), weed out the dups, and
876 # build the catalogue with awk(1).
878 .sh.po .ksh.po:
879         $(SED) -n -e ":a"                               \
880                   -e "h"                                        \
881                   -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"       \
882                   -e "x"                                        \
883                   -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"  \
884                   -e "t a"                                      \
885                $< | sort -u | $(AWK) '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
888 # Python and Perl executable and message catalog build rules.
890 .SUFFIXES: .pl .pm .py .pyc
892 .pl:
893         $(RM) $@;
894         $(SED) -e "s@TEXT_DOMAIN@\"$(TEXT_DOMAIN)\"@" $< > $@;
895         $(CHMOD) +x $@
897 .py:
898         $(RM) $@; $(SED) -e "1s:^\#!@PYTHON@:\#!$(PYTHON):" < $< > $@; $(CHMOD) +x $@
900 .py.pyc:
901         $(RM) $@
902         $(PYTHON) -mpy_compile $<
903         @[ $(<)c = $@ ] || $(MV) $(<)c $@
905 .pl.po .pm.po:
906         $(XGETTEXT) $(XGETFLAGS) -d $(<F) $< ;
907         $(RM)   $@ ;
908         $(SED) "/^domain/d" < $(<F).po > $@ ;
909         $(RM) $(<F).po
912 # When using xgettext, we want messages to go to the default domain,
913 # rather than the specified one.  This special version of the
914 # COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
915 # causing xgettext to put all messages into the default domain.
917 CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
919 .c.i:
920         $(CPPFORPO) $< > $@
922 .h.i:
923         $(CPPFORPO) $< > $@
925 .y.i:
926         $(YACC) -d $<
927         $(CPPFORPO) y.tab.c  > $@
928         $(RM) y.tab.c
930 .l.i:
931         $(LEX) $<
932         $(CPPFORPO) lex.yy.c  > $@
933         $(RM) lex.yy.c
935 .c.po:
936         $(CPPFORPO) $< > $<.i
937         $(BUILD.po)
939 .cc.po:
940         $(CPPFORPO) $< > $<.i
941         $(BUILD.po)
943 .y.po:
944         $(YACC) -d $<
945         $(CPPFORPO) y.tab.c  > $<.i
946         $(BUILD.po)
947         $(RM) y.tab.c
949 .l.po:
950         $(LEX) $<
951         $(CPPFORPO) lex.yy.c  > $<.i
952         $(BUILD.po)
953         $(RM) lex.yy.c
956 # Rules to perform stylistic checks
958 .SUFFIXES: .x .xml .check .xmlchk
960 .h.check:
961         $(DOT_H_CHECK)
963 .x.check:
964         $(DOT_X_CHECK)
966 .xml.xmlchk:
967         $(MANIFEST_CHECK)