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 (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>
  30 # Copyright 2018 OmniOS Community Edition (OmniOSce) Association.
  31 # Copyright 2019, Joyent, Inc.
  32 # Copyright 2019 RackTop Systems.
  33 #
  34 
  35 #
  36 # Makefile.master, global definitions for system source
  37 #
  38 ROOT=           /proto
  39 
  40 #
  41 # Adjunct root, containing an additional proto area to be used for headers
  42 # and libraries.
  43 #
  44 ADJUNCT_PROTO=
  45 # HAVE_ADJUNCT_PROTO - ADJUNCT_PROTO is set to a non-default value
  46 # NO_ADJUNCT_PROTO - ADJUNCT_PROTO is unset
  47 #
  48 # This works by replacing any value in ADJUNCT_PROTO with POUND_SIGN, which
  49 # only happens if it has some value, and then setting HAVE_ADJUNCT_PROTO
  50 # oppositely.
  51 NO_ADJUNCT_PROTO=$(ADJUNCT_PROTO:%=$(POUND_SIGN))
  52 $(NO_ADJUNCT_PROTO)HAVE_ADJUNCT_PROTO=$(POUND_SIGN)
  53 
  54 #
  55 # Adjunct for building things that run on the build machine.
  56 #
  57 NATIVE_ADJUNCT= /usr
  58 
  59 #
  60 # RELEASE_BUILD should be cleared for final release builds.
  61 # NOT_RELEASE_BUILD is exactly what the name implies.
  62 #
  63 # __GNUC toggles the building of ON components using gcc and related tools.
  64 # Normally set to `#', set it to `' to do gcc build.
  65 #
  66 # The declaration POUND_SIGN is always '#'. This is needed to get around the
  67 # make feature that '#' is always a comment delimiter, even when escaped or
  68 # quoted. We use this macro expansion method to get POUND_SIGN rather than
  69 # always breaking out a shell because the general case can cause a noticable
  70 # slowdown in build times when so many Makefiles include Makefile.master.
  71 #
  72 # While the majority of users are expected to override the setting below
  73 # with an env file (via nightly or bldenv), if you aren't building that way
  74 # (ie, you're using "ws" or some other bootstrapping method) then you need
  75 # this definition in order to avoid the subshell invocation mentioned above.
  76 #
  77 
  78 PRE_POUND=                              pre\#
  79 POUND_SIGN=                             $(PRE_POUND:pre\%=%)
  80 
  81 NOT_RELEASE_BUILD=
  82 RELEASE_BUILD=                          $(POUND_SIGN)
  83 $(RELEASE_BUILD)NOT_RELEASE_BUILD=      $(POUND_SIGN)
  84 PATCH_BUILD=                            $(POUND_SIGN)
  85 
  86 # SPARC_BLD is '#' for an Intel build.
  87 # INTEL_BLD is '#' for a Sparc build.
  88 SPARC_BLD_1=    $(MACH:i386=$(POUND_SIGN))
  89 SPARC_BLD=      $(SPARC_BLD_1:sparc=)
  90 INTEL_BLD_1=    $(MACH:sparc=$(POUND_SIGN))
  91 INTEL_BLD=      $(INTEL_BLD_1:i386=)
  92 
  93 # The variables below control the compilers used during the build.
  94 # There are a number of permutations.
  95 #
  96 # __GNUC and __SUNC control (and indicate) the primary compiler.  Whichever
  97 # one is not POUND_SIGN is the primary, with the other as the shadow.  They
  98 # may also be used to control entirely compiler-specific Makefile assignments.
  99 # __GNUC and GCC are the default.
 100 #
 101 # __GNUC64 indicates that the 64bit build should use the GNU C compiler.
 102 # There is no Sun C analogue.
 103 #
 104 # The following version-specific options are operative regardless of which
 105 # compiler is primary, and control the versions of the given compilers to be
 106 # used.  They also allow compiler-version specific Makefile fragments.
 107 #
 108 
 109 __SUNC=                 $(POUND_SIGN)
 110 $(__SUNC)__GNUC=        $(POUND_SIGN)
 111 __GNUC64=               $(__GNUC)
 112 
 113 # Allow build-time "configuration" to enable or disable some things.
 114 # The default is POUND_SIGN, meaning "not enabled". If the environment
 115 # passes in an override like ENABLE_SMB_PRINTING= (empty) that will
 116 # uncomment things in the lower Makefiles to enable the feature.
 117 ENABLE_SMB_PRINTING=    $(POUND_SIGN)
 118 
 119 # CLOSED is the root of the tree that contains source which isn't released
 120 # as open source
 121 CLOSED=         $(SRC)/../closed
 122 
 123 # BUILD_TOOLS is the root of all tools including compilers.
 124 # ONBLD_TOOLS is the root of all the tools that are part of SUNWonbld.
 125 
 126 BUILD_TOOLS=            /ws/onnv-tools
 127 ONBLD_TOOLS=            $(BUILD_TOOLS)/onbld
 128 
 129 # define runtime JAVA_HOME, primarily for cmd/pools/poold
 130 JAVA_HOME=      /usr/java
 131 # define buildtime JAVA_ROOT
 132 JAVA_ROOT=      /usr/java
 133 # Build uses java7 by default.  Pass one the variables below set to empty
 134 # string in the environment to override.
 135 BLD_JAVA_6=     $(POUND_SIGN)
 136 BLD_JAVA_8=     $(POUND_SIGN)
 137 
 138 GNUC_ROOT=      /usr/gcc/7
 139 GCCLIBDIR=      $(GNUC_ROOT)/lib
 140 GCCLIBDIR64=    $(GNUC_ROOT)/lib/$(MACH64)
 141 
 142 DOCBOOK_XSL_ROOT=       /usr/share/sgml/docbook/xsl-stylesheets
 143 
 144 RPCGEN=         /usr/bin/rpcgen
 145 STABS=          $(ONBLD_TOOLS)/bin/$(MACH)/stabs
 146 ELFEXTRACT=     $(ONBLD_TOOLS)/bin/$(MACH)/elfextract
 147 MBH_PATCH=      $(ONBLD_TOOLS)/bin/$(MACH)/mbh_patch
 148 BTXLD=          $(ONBLD_TOOLS)/bin/$(MACH)/btxld
 149 VTFONTCVT=      $(ONBLD_TOOLS)/bin/$(MACH)/vtfontcvt
 150 # echo(1) and true(1) are specified without absolute paths, so that the shell
 151 # spawned by make(1) may use the built-in versions.  This is minimally
 152 # problematic, as the shell spawned by make(1) is known and under control, the
 153 # only risk being if the shell falls back to $PATH.
 154 #
 155 # We specifically want an echo(1) that does interpolation of escape sequences,
 156 # which ksh93, /bin/sh, and bash will all provide.
 157 ECHO=           echo
 158 TRUE=           true
 159 INS=            $(ONBLD_TOOLS)/bin/$(MACH)/install
 160 SYMLINK=        /usr/bin/ln -s
 161 LN=             /usr/bin/ln
 162 MKDIR=          /usr/bin/mkdir
 163 CHMOD=          /usr/bin/chmod
 164 MV=             /usr/bin/mv -f
 165 RM=             /usr/bin/rm -f
 166 CUT=            /usr/bin/cut
 167 NM=             /usr/ccs/bin/nm
 168 DIFF=           /usr/bin/diff
 169 GREP=           /usr/bin/grep
 170 EGREP=          /usr/bin/egrep
 171 ELFWRAP=        /usr/bin/elfwrap
 172 KSH93=          /usr/bin/ksh93
 173 SED=            /usr/bin/sed
 174 AWK=            /usr/bin/nawk
 175 CP=             /usr/bin/cp -f
 176 MCS=            /usr/ccs/bin/mcs
 177 CAT=            /usr/bin/cat
 178 ELFDUMP=        /usr/ccs/bin/elfdump
 179 M4=             /usr/bin/m4
 180 GM4=            /usr/bin/gm4
 181 STRIP=          /usr/ccs/bin/strip
 182 LEX=            /usr/ccs/bin/lex
 183 FLEX=           /usr/bin/flex
 184 YACC=           /usr/ccs/bin/yacc
 185 BISON=          /usr/bin/bison
 186 CPP=            /usr/lib/cpp
 187 ANSI_CPP=       $(GNUC_ROOT)/bin/cpp
 188 JAVAC=          $(JAVA_ROOT)/bin/javac
 189 JAVAH=          $(JAVA_ROOT)/bin/javah
 190 JAVADOC=        $(JAVA_ROOT)/bin/javadoc
 191 RMIC=           $(JAVA_ROOT)/bin/rmic
 192 JAR=            $(JAVA_ROOT)/bin/jar
 193 CTFCONVERT=     $(ONBLD_TOOLS)/bin/$(MACH)/ctfconvert
 194 CTFDIFF=        $(ONBLD_TOOLS)/bin/$(MACH)/ctfdiff
 195 CTFMERGE=       $(ONBLD_TOOLS)/bin/$(MACH)/ctfmerge
 196 CTFSTABS=       $(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
 197 CTFSTRIP=       $(ONBLD_TOOLS)/bin/$(MACH)/ctfstrip
 198 NDRGEN=         $(ONBLD_TOOLS)/bin/$(MACH)/ndrgen
 199 GENOFFSETS=     $(ONBLD_TOOLS)/bin/genoffsets
 200 XREF=           $(ONBLD_TOOLS)/bin/xref
 201 FIND=           /usr/bin/find
 202 PERL=           /usr/bin/perl
 203 PERL_VERSION=   5.10.0
 204 PERL_PKGVERS=   -510
 205 PERL_MACH=      i86pc
 206 $(SPARC_BLD)PERL_MACH=  sun4
 207 PERL_VARIANT=
 208 PERL_ARCH=      $(PERL_MACH)-solaris$(PERL_VARIANT)-64int
 209 PERL_ARCH64=    $(PERL_MACH)-solaris$(PERL_VARIANT)-64
 210 PYTHON_VERSION= 2.7
 211 PYTHON_PKGVERS= -27
 212 PYTHON_SUFFIX=
 213 PYTHON=         /usr/bin/python$(PYTHON_VERSION)
 214 PYTHON3_VERSION=        3.5
 215 PYTHON3_PKGVERS=        -35
 216 PYTHON3_SUFFIX=         m
 217 PYTHON3=                /usr/bin/python$(PYTHON3_VERSION)
 218 $(BUILDPY3TOOLS)TOOLS_PYTHON=           $(PYTHON3)
 219 $(BUILDPY2TOOLS)TOOLS_PYTHON=           $(PYTHON)
 220 SORT=           /usr/bin/sort
 221 TR=             /usr/bin/tr
 222 TOUCH=          /usr/bin/touch
 223 WC=             /usr/bin/wc
 224 XARGS=          /usr/bin/xargs
 225 ELFEDIT=        /usr/bin/elfedit
 226 DTRACE=         /usr/sbin/dtrace -xnolibs
 227 UNIQ=           /usr/bin/uniq
 228 TAR=            /usr/bin/tar
 229 ASTBINDIR=      /usr/ast/bin
 230 MSGCC=          $(ASTBINDIR)/msgcc
 231 MSGFMT=         /usr/bin/msgfmt -s
 232 LCDEF=          $(ONBLD_TOOLS)/bin/$(MACH)/localedef
 233 TIC=            $(ONBLD_TOOLS)/bin/$(MACH)/tic
 234 ZIC=            $(ONBLD_TOOLS)/bin/$(MACH)/zic
 235 OPENSSL=        /usr/bin/openssl
 236 CPCGEN=         $(ONBLD_TOOLS)/bin/$(MACH)/cpcgen
 237 
 238 DEFAULT_CONSOLE_COLOR=                                  \
 239         -DDEFAULT_ANSI_FOREGROUND=ANSI_COLOR_WHITE      \
 240         -DDEFAULT_ANSI_BACKGROUND=ANSI_COLOR_BLACK
 241 
 242 FILEMODE=       644
 243 DIRMODE=        755
 244 
 245 # Declare that nothing should be built in parallel.
 246 # Individual Makefiles can use the .PARALLEL target to declare otherwise.
 247 .NO_PARALLEL:
 248 
 249 # For stylistic checks
 250 #
 251 # Note that the X and C checks are not used at this time and may need
 252 # modification when they are actually used.
 253 #
 254 CSTYLE=         $(ONBLD_TOOLS)/bin/cstyle
 255 CSTYLE_TAIL=
 256 HDRCHK=         $(ONBLD_TOOLS)/bin/hdrchk
 257 HDRCHK_TAIL=
 258 JSTYLE=         $(ONBLD_TOOLS)/bin/jstyle
 259 
 260 DOT_H_CHECK=    \
 261         @$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
 262         $(HDRCHK) $< $(HDRCHK_TAIL)
 263 
 264 DOT_X_CHECK=    \
 265         @$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
 266         $(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)
 267 
 268 DOT_C_CHECK=    \
 269         @$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)
 270 
 271 MANIFEST_CHECK= \
 272         @$(ECHO) "checking $<"; \
 273         SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
 274         SVCCFG_REPOSITORY=$(SRC)/cmd/svc/seed/global.db \
 275         SVCCFG_CONFIGD_PATH=$(SRC)/cmd/svc/configd/svc.configd-native \
 276         $(SRC)/cmd/svc/svccfg/svccfg-native validate $<
 277 
 278 INS.file=       $(RM) $@; $(INS) -s -m $(FILEMODE) -f $(@D) $<
 279 INS.dir=        $(INS) -s -d -m $(DIRMODE) $@
 280 # installs and renames at once
 281 #
 282 INS.rename=     $(INS.file); $(MV) $(@D)/$(<F) $@
 283 
 284 # install a link
 285 INSLINKTARGET=  $<
 286 INS.link=       $(RM) $@; $(LN) $(INSLINKTARGET) $@
 287 INS.symlink=    $(RM) $@; $(SYMLINK) $(INSLINKTARGET) $@
 288 
 289 # The path to python that will be used for the shebang line when installing
 290 # python scripts to the proto area. This is overridden by makefiles to
 291 # select to the correct version.
 292 PYSHEBANG=      $(PYTHON)
 293 $(BUILDPY3)PYSHEBANG=   $(PYTHON3)
 294 $(BUILDPY2)PYSHEBANG=   $(PYTHON)
 295 
 296 #
 297 # Python bakes the mtime of the .py file into the compiled .pyc and
 298 # rebuilds if the baked-in mtime != the mtime of the source file
 299 # (rather than only if it's less than), thus when installing python
 300 # files we must make certain to not adjust the mtime of the source
 301 # (.py) file.
 302 #
 303 INS.pyfile=     $(RM) $@; $(SED) \
 304                 -e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
 305                 -e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
 306                 < $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@
 307 
 308 # MACH must be set in the shell environment per uname -p on the build host
 309 # More specific architecture variables should be set in lower makefiles.
 310 #
 311 # MACH64 is derived from MACH, and BUILD64 is set to `#' for
 312 # architectures on which we do not build 64-bit versions.
 313 # (There are no such architectures at the moment.)
 314 #
 315 # Set BUILD64=# in the environment to disable 64-bit amd64
 316 # builds on i386 machines.
 317 
 318 MACH64_1=       $(MACH:sparc=sparcv9)
 319 MACH64=         $(MACH64_1:i386=amd64)
 320 
 321 MACH32_1=       $(MACH:sparc=sparcv7)
 322 MACH32=         $(MACH32_1:i386=i86)
 323 
 324 sparc_BUILD64=
 325 i386_BUILD64=
 326 BUILD64=        $($(MACH)_BUILD64)
 327 
 328 #
 329 # C compiler mode. Future compilers may change the default on us,
 330 # so force extended ANSI mode globally. Lower level makefiles can
 331 # override this by setting CCMODE.
 332 #
 333 CCMODE=                 -Xa
 334 CCMODE64=               -Xa
 335 
 336 #
 337 # C compiler verbose mode. This is so we can enable it globally,
 338 # but turn it off in the lower level makefiles of things we cannot
 339 # (or aren't going to) fix.
 340 #
 341 CCVERBOSE=              -v
 342 
 343 # set this to the secret flag "-Wc,-Qiselect-v9abiwarn=1" to get warnings
 344 # from the compiler about places the -xarch=v9 may differ from -xarch=v9c.
 345 V9ABIWARN=
 346 
 347 # set this to the secret flag "-Wc,-Qiselect-regsym=0" to disable register
 348 # symbols (used to detect conflicts between objects that use global registers)
 349 # we disable this now for safety, and because genunix doesn't link with
 350 # this feature (the v9 default) enabled.
 351 #
 352 # REGSYM is separate since the C++ driver syntax is different.
 353 CCREGSYM=               -Wc,-Qiselect-regsym=0
 354 CCCREGSYM=              -Qoption cg -Qiselect-regsym=0
 355 
 356 # Prevent the removal of static symbols by the SPARC code generator (cg).
 357 # The x86 code generator (ube) does not remove such symbols and as such
 358 # using this workaround is not applicable for x86.
 359 #
 360 CCSTATICSYM=            -Wc,-Qassembler-ounrefsym=0
 361 #
 362 # generate 32-bit addresses in the v9 kernel. Saves memory.
 363 CCABS32=                -Wc,-xcode=abs32
 364 #
 365 # generate v9 code which tolerates callers using the v7 ABI, for the sake of
 366 # system calls.
 367 CC32BITCALLERS=         -_gcc=-massume-32bit-callers
 368 
 369 # GCC, especially, is increasingly beginning to auto-inline functions and
 370 # sadly does so separately not under the general -fno-inline-functions
 371 # Additionally, we wish to prevent optimisations which cause GCC to clone
 372 # functions -- in particular, these may cause unhelpful symbols to be
 373 # emitted instead of function names
 374 CCNOAUTOINLINE= \
 375         -_gcc=-fno-inline-small-functions \
 376         -_gcc=-fno-inline-functions-called-once \
 377         -_gcc=-fno-ipa-cp \
 378         -_gcc7=-fno-ipa-icf \
 379         -_gcc8=-fno-ipa-icf \
 380         -_gcc9=-fno-ipa-icf \
 381         -_gcc7=-fno-clone-functions \
 382         -_gcc8=-fno-clone-functions \
 383         -_gcc9=-fno-clone-functions
 384 
 385 # GCC may put functions in different named sub-sections of .text based on
 386 # their presumed calling frequency.  At least in the kernel, where we actually
 387 # deliver relocatable objects, we don't want this to happen.
 388 #
 389 # Since at present we don't benefit from this even in userland, we disable it globally,
 390 # but the application of this may move into usr/src/uts/ in future.
 391 CCNOREORDER=    \
 392         -_gcc7=-fno-reorder-functions \
 393         -_gcc8=-fno-reorder-functions \
 394         -_gcc9=-fno-reorder-functions
 395 
 396 #
 397 # gcc has a rather aggressive optimization on by default that infers loop
 398 # bounds based on undefined behavior (!!).  This can lead to some VERY
 399 # surprising optimizations -- ones that may be technically correct in the
 400 # strictest sense but also result in incorrect program behavior.  We turn
 401 # this optimization off, with extreme prejudice.
 402 #
 403 CCNOAGGRESSIVELOOPS= \
 404         -_gcc7=-fno-aggressive-loop-optimizations \
 405         -_gcc8=-fno-aggressive-loop-optimizations \
 406         -_gcc9=-fno-aggressive-loop-optimizations
 407 
 408 # One optimization the compiler might perform is to turn this:
 409 #       #pragma weak foo
 410 #       extern int foo;
 411 #       if (&foo)
 412 #               foo = 5;
 413 # into
 414 #       foo = 5;
 415 # Since we do some of this (foo might be referenced in common kernel code
 416 # but provided only for some cpu modules or platforms), we disable this
 417 # optimization.
 418 #
 419 sparc_CCUNBOUND = -Wd,-xsafe=unboundsym
 420 i386_CCUNBOUND  =
 421 CCUNBOUND       = $($(MACH)_CCUNBOUND)
 422 
 423 #
 424 # compiler '-xarch' flag. This is here to centralize it and make it
 425 # overridable for testing.
 426 sparc_XARCH=    -m32
 427 sparcv9_XARCH=  -m64
 428 i386_XARCH=     -m32
 429 amd64_XARCH=    -m64 -Ui386 -U__i386
 430 
 431 # assembler '-xarch' flag.  Different from compiler '-xarch' flag.
 432 sparc_AS_XARCH=         -xarch=v8plus
 433 sparcv9_AS_XARCH=       -xarch=v9
 434 i386_AS_XARCH=
 435 amd64_AS_XARCH=         -xarch=amd64 -P -Ui386 -U__i386
 436 
 437 #
 438 # These flags define what we need to be 'standalone' i.e. -not- part
 439 # of the rather more cosy userland environment.  This basically means
 440 # the kernel.
 441 #
 442 # XX64  future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
 443 #
 444 sparc_STAND_FLAGS=      -_gcc=-ffreestanding
 445 sparcv9_STAND_FLAGS=    -_gcc=-ffreestanding
 446 # Disabling MMX also disables 3DNow, disabling SSE also disables all later
 447 # additions to SSE (SSE2, AVX ,etc.)
 448 NO_SIMD=                -_gcc=-mno-mmx -_gcc=-mno-sse
 449 i386_STAND_FLAGS=       -_gcc=-ffreestanding $(NO_SIMD)
 450 amd64_STAND_FLAGS=      -xmodel=kernel $(NO_SIMD)
 451 
 452 SAVEARGS=               -Wu,-save_args
 453 amd64_STAND_FLAGS       += $(SAVEARGS)
 454 
 455 STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
 456 STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)
 457 
 458 #
 459 # disable the incremental linker
 460 ILDOFF=                 -xildoff
 461 #
 462 XFFLAG=                 -xF=%all
 463 XESS=                   -xs
 464 XSTRCONST=              -xstrconst
 465 
 466 #
 467 # turn warnings into errors (C)
 468 CERRWARN = -errtags=yes -errwarn=%all
 469 CERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
 470 CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
 471 
 472 CERRWARN += -_gcc=-Wno-missing-braces
 473 CERRWARN += -_gcc=-Wno-sign-compare
 474 CERRWARN += -_gcc=-Wno-unknown-pragmas
 475 CERRWARN += -_gcc=-Wno-unused-parameter
 476 CERRWARN += -_gcc=-Wno-missing-field-initializers
 477 
 478 # Unfortunately, this option can misfire very easily and unfixably.
 479 CERRWARN +=     -_gcc=-Wno-array-bounds
 480 
 481 # gcc4 lacks -Wno-maybe-uninitialized
 482 CNOWARN_UNINIT = -_gcc4=-Wno-uninitialized \
 483     -_gcc7=-Wno-maybe-uninitialized \
 484     -_gcc8=-Wno-maybe-uninitialized \
 485     -_gcc9=-Wno-maybe-uninitialized
 486 
 487 CERRWARN += -_smatch=-p=illumos_user
 488 include $(SRC)/Makefile.smatch
 489 
 490 #
 491 # turn warnings into errors (C++)
 492 CCERRWARN = -errtags=yes -errwarn=%all
 493 CCERRWARN += -erroff=E_EMPTY_TRANSLATION_UNIT
 494 CCERRWARN += -erroff=E_STATEMENT_NOT_REACHED
 495 
 496 CCERRWARN += -_gcc=-Wno-missing-braces
 497 CCERRWARN += -_gcc=-Wno-sign-compare
 498 CCERRWARN += -_gcc=-Wno-unknown-pragmas
 499 CCERRWARN += -_gcc=-Wno-unused-parameter
 500 CCERRWARN += -_gcc=-Wno-missing-field-initializers
 501 
 502 # C standard.  Keep Studio flags until we get rid of lint.
 503 CSTD_GNU89=     -xc99=%none
 504 CSTD_GNU99=     -xc99=%all
 505 CSTD=           $(CSTD_GNU89)
 506 C99LMODE=       $(CSTD:-xc99%=-Xc99%)
 507 
 508 # In most places, assignments to these macros should be appended with +=
 509 # (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
 510 sparc_CFLAGS=   $(sparc_XARCH) $(CCSTATICSYM)
 511 sparcv9_CFLAGS= $(sparcv9_XARCH) -dalign $(CCVERBOSE) $(V9ABIWARN) $(CCREGSYM) \
 512                 $(CCSTATICSYM)
 513 i386_CFLAGS=    $(i386_XARCH)
 514 amd64_CFLAGS=   $(amd64_XARCH)
 515 
 516 sparc_ASFLAGS=  $(sparc_AS_XARCH)
 517 sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
 518 i386_ASFLAGS=   $(i386_AS_XARCH)
 519 amd64_ASFLAGS=  $(amd64_AS_XARCH)
 520 
 521 #
 522 sparc_COPTFLAG=         -xO3
 523 sparcv9_COPTFLAG=       -xO3
 524 i386_COPTFLAG=          -O
 525 amd64_COPTFLAG=         -xO3
 526 
 527 COPTFLAG= $($(MACH)_COPTFLAG)
 528 COPTFLAG64= $($(MACH64)_COPTFLAG)
 529 
 530 # When -g is used, the compiler globalizes static objects
 531 # (gives them a unique prefix). Disable that.
 532 CNOGLOBAL= -W0,-noglobal
 533 
 534 # Direct the Sun Studio compiler to use a static globalization prefix based on the
 535 # name of the module rather than something unique. Otherwise, objects
 536 # will not build deterministically, as subsequent compilations of identical
 537 # source will yeild objects that always look different.
 538 #
 539 # In the same spirit, this will also remove the date from the N_OPT stab.
 540 CGLOBALSTATIC= -W0,-xglobalstatic
 541 
 542 # Sometimes we want all symbols and types in debugging information even
 543 # if they aren't used.
 544 CALLSYMS=       -W0,-xdbggen=no%usedonly
 545 
 546 #
 547 # We force the compilers to generate the debugging information best understood
 548 # by the CTF tools.  With Sun Studio this is stabs due to bugs in the Studio
 549 # compilers.  With GCC this is DWARF v2.
 550 #
 551 DEBUGFORMAT=    -_cc=-xdebugformat=stabs -_gcc=-gdwarf-2
 552 
 553 #
 554 # Ask the compiler to include debugging information
 555 #
 556 CCGDEBUG= -g $(DEBUGFORMAT)
 557 
 558 #
 559 # Flags used to build in debug mode for ctf generation.
 560 #
 561 CTF_FLAGS_sparc = $(CCGDEBUG) -Wc,-Qiselect-T1 $(CSTD) $(CNOGLOBAL)
 562 CTF_FLAGS_i386  = $(CCGDEBUG) $(CSTD) $(CNOGLOBAL)
 563 
 564 CTF_FLAGS_sparcv9       = $(CTF_FLAGS_sparc)
 565 CTF_FLAGS_amd64         = $(CTF_FLAGS_i386)
 566 
 567 # Sun Studio produces broken userland code when saving arguments.
 568 $(__GNUC)CTF_FLAGS_amd64 += $(SAVEARGS)
 569 
 570 CTF_FLAGS_32    = $(CTF_FLAGS_$(MACH))
 571 CTF_FLAGS_64    = $(CTF_FLAGS_$(MACH64))
 572 CTF_FLAGS       = $(CTF_FLAGS_32)
 573 
 574 #
 575 # Flags used with genoffsets
 576 #
 577 GENOFFSETS_FLAGS = $(CALLSYMS)
 578 
 579 OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
 580         $(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
 581         $(CFLAGS) $(CPPFLAGS)
 582 
 583 OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
 584         $(CW) --noecho $(CW_CC_COMPILERS) -- $(GENOFFSETS_FLAGS) \
 585         $(CFLAGS64) $(CPPFLAGS)
 586 
 587 #
 588 # tradeoff time for space (smaller is better)
 589 #
 590 sparc_SPACEFLAG         = -xspace -W0,-Lt
 591 sparcv9_SPACEFLAG       = -xspace -W0,-Lt
 592 i386_SPACEFLAG          = -xspace
 593 amd64_SPACEFLAG         =
 594 
 595 SPACEFLAG               = $($(MACH)_SPACEFLAG)
 596 SPACEFLAG64             = $($(MACH64)_SPACEFLAG)
 597 
 598 #
 599 # The Sun Studio 11 compiler has changed the behaviour of integer
 600 # wrap arounds and so a flag is needed to use the legacy behaviour
 601 # (without this flag panics/hangs could be exposed within the source).
 602 #
 603 sparc_IROPTFLAG         = -W2,-xwrap_int
 604 sparcv9_IROPTFLAG       = -W2,-xwrap_int
 605 i386_IROPTFLAG          =
 606 amd64_IROPTFLAG         =
 607 
 608 IROPTFLAG               = $($(MACH)_IROPTFLAG)
 609 IROPTFLAG64             = $($(MACH64)_IROPTFLAG)
 610 
 611 sparc_XREGSFLAG         = -xregs=no%appl
 612 sparcv9_XREGSFLAG       = -xregs=no%appl
 613 i386_XREGSFLAG          =
 614 amd64_XREGSFLAG         =
 615 
 616 XREGSFLAG               = $($(MACH)_XREGSFLAG)
 617 XREGSFLAG64             = $($(MACH64)_XREGSFLAG)
 618 
 619 # dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
 620 # avoids stripping it.
 621 SOURCEDEBUG     = $(POUND_SIGN)
 622 SRCDBGBLD       = $(SOURCEDEBUG:yes=)
 623 
 624 #
 625 # These variables are intended ONLY for use by developers to safely pass extra
 626 # flags to the compilers without unintentionally overriding Makefile-set
 627 # flags.  They should NEVER be set to any value in a Makefile.
 628 #
 629 # They come last in the associated FLAGS variable such that they can
 630 # explicitly override things if necessary, there are gaps in this, but it's
 631 # the best we can manage.
 632 #
 633 CUSERFLAGS              =
 634 CUSERFLAGS64            = $(CUSERFLAGS)
 635 CCUSERFLAGS             =
 636 CCUSERFLAGS64           = $(CCUSERFLAGS)
 637 
 638 CSOURCEDEBUGFLAGS       =
 639 CCSOURCEDEBUGFLAGS      =
 640 $(SRCDBGBLD)CSOURCEDEBUGFLAGS   = $(CCGDEBUG) -xs
 641 $(SRCDBGBLD)CCSOURCEDEBUGFLAGS  = $(CCGDEBUG) -xs
 642 
 643 CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
 644                 $(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG) \
 645                 $(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
 646                 $(CCNOAGGRESSIVELOOPS) \
 647                 $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
 648 CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
 649                 $(ILDOFF) $(CERRWARN) $(CSTD) $(CCUNBOUND) $(IROPTFLAG64) \
 650                 $(CGLOBALSTATIC) $(CCNOAUTOINLINE) $(CCNOREORDER) \
 651                 $(CCNOAGGRESSIVELOOPS) \
 652                 $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS64)
 653 #
 654 # Flags that are used to build parts of the code that are subsequently
 655 # run on the build machine (also known as the NATIVE_BUILD).
 656 #
 657 NATIVE_CFLAGS=  $(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
 658                 $(ILDOFF) $(CERRWARN) $(CSTD) $($(NATIVE_MACH)_CCUNBOUND) \
 659                 $(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE) \
 660                 $(CCNOREORDER) $(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)
 661 
 662 NATIVE_CCFLAGS= $(CCOPTFLAG) $($(NATIVE_MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
 663                 $(CCUSERFLAGS)
 664 
 665 DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"       # For messaging.
 666 DTS_ERRNO=-D_TS_ERRNO
 667 CPPFLAGS.first= # Please keep empty.  Only lower makefiles should set this.
 668 CPPFLAGS.master=$(DTEXTDOM) $(DTS_ERRNO) \
 669         $(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
 670         $(ADJUNCT_PROTO:%=-I%/usr/include)
 671 CPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
 672                 $(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
 673 CPPFLAGS=       $(CPPFLAGS.first) $(CPPFLAGS.master)
 674 AS_CPPFLAGS=    $(CPPFLAGS.first) $(CPPFLAGS.master)
 675 JAVAFLAGS=      -source 1.6 -target 1.6 -Xlint:deprecation,-options
 676 
 677 #
 678 # For source message catalogue
 679 #
 680 .SUFFIXES: $(SUFFIXES) .i .po
 681 MSGROOT= $(ROOT)/catalog
 682 MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
 683 MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
 684 DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
 685 DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)
 686 
 687 CLOBBERFILES += $(POFILE) $(POFILES)
 688 COMPILE.cpp= $(CC) -E -C $(CFLAGS) $(CPPFLAGS)
 689 XGETTEXT= /usr/bin/xgettext
 690 XGETFLAGS= -c TRANSLATION_NOTE
 691 GNUXGETTEXT= /usr/gnu/bin/xgettext
 692 GNUXGETFLAGS= --add-comments=TRANSLATION_NOTE --keyword=_ \
 693         --strict --no-location --omit-header
 694 BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
 695         $(RM)   $@ ;\
 696         $(SED) "/^domain/d" < $(<F).po > $@ ;\
 697         $(RM) $(<F).po $<.i
 698 
 699 #
 700 # This is overwritten by local Makefile when PROG is a list.
 701 #
 702 POFILE= $(PROG).po
 703 
 704 sparc_CCFLAGS=          $(sparc_XARCH) -cg92 -compat=4 \
 705                         -Qoption ccfe -messages=no%anachronism \
 706                         $(CCERRWARN)
 707 sparcv9_CCFLAGS=        $(sparcv9_XARCH) -dalign -compat=5 \
 708                         -Qoption ccfe -messages=no%anachronism \
 709                         -Qoption ccfe -features=no%conststrings \
 710                         $(CCCREGSYM) \
 711                         $(CCERRWARN)
 712 i386_CCFLAGS=           $(i386_XARCH) -compat=4 \
 713                         -Qoption ccfe -messages=no%anachronism \
 714                         -Qoption ccfe -features=no%conststrings \
 715                         $(CCERRWARN)
 716 amd64_CCFLAGS=          $(amd64_XARCH) -compat=5 \
 717                         -Qoption ccfe -messages=no%anachronism \
 718                         -Qoption ccfe -features=no%conststrings \
 719                         $(CCERRWARN)
 720 
 721 sparc_CCOPTFLAG=        -O
 722 sparcv9_CCOPTFLAG=      -O
 723 i386_CCOPTFLAG=         -O
 724 amd64_CCOPTFLAG=        -O
 725 
 726 CCOPTFLAG=      $($(MACH)_CCOPTFLAG)
 727 CCOPTFLAG64=    $($(MACH64)_CCOPTFLAG)
 728 CCFLAGS=        $(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
 729                 $(CCUSERFLAGS)
 730 CCFLAGS64=      $(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
 731                 $(CCUSERFLAGS64)
 732 
 733 #
 734 #
 735 #
 736 ELFWRAP_FLAGS   =
 737 ELFWRAP_FLAGS64 =       -64
 738 
 739 #
 740 # Various mapfiles that are used throughout the build, and delivered to
 741 # /usr/lib/ld.
 742 #
 743 MAPFILE.NED_i386 =      $(SRC)/common/mapfiles/common/map.noexdata
 744 MAPFILE.NED_sparc =
 745 MAPFILE.NED =           $(MAPFILE.NED_$(MACH))
 746 MAPFILE.PGA =           $(SRC)/common/mapfiles/common/map.pagealign
 747 MAPFILE.NES =           $(SRC)/common/mapfiles/common/map.noexstk
 748 MAPFILE.FLT =           $(SRC)/common/mapfiles/common/map.filter
 749 MAPFILE.LEX =           $(SRC)/common/mapfiles/common/map.lex.yy
 750 
 751 #
 752 # Generated mapfiles that are compiler specific, and used throughout the
 753 # build.  These mapfiles are not delivered in /usr/lib/ld.
 754 #
 755 MAPFILE.NGB_sparc=      $(SRC)/common/mapfiles/gen/sparc_cc_map.noexeglobs
 756 $(__GNUC64)MAPFILE.NGB_sparc= \
 757                         $(SRC)/common/mapfiles/gen/sparc_gcc_map.noexeglobs
 758 MAPFILE.NGB_sparcv9=    $(SRC)/common/mapfiles/gen/sparcv9_cc_map.noexeglobs
 759 $(__GNUC64)MAPFILE.NGB_sparcv9= \
 760                         $(SRC)/common/mapfiles/gen/sparcv9_gcc_map.noexeglobs
 761 MAPFILE.NGB_i386=       $(SRC)/common/mapfiles/gen/i386_cc_map.noexeglobs
 762 $(__GNUC64)MAPFILE.NGB_i386= \
 763                         $(SRC)/common/mapfiles/gen/i386_gcc_map.noexeglobs
 764 MAPFILE.NGB_amd64=      $(SRC)/common/mapfiles/gen/amd64_cc_map.noexeglobs
 765 $(__GNUC64)MAPFILE.NGB_amd64= \
 766                         $(SRC)/common/mapfiles/gen/amd64_gcc_map.noexeglobs
 767 MAPFILE.NGB =           $(MAPFILE.NGB_$(MACH))
 768 
 769 #
 770 # A generic interface mapfile name, used by various dynamic objects to define
 771 # the interfaces and interposers the object must export.
 772 #
 773 MAPFILE.INT =           mapfile-intf
 774 
 775 #
 776 # LDLIBS32 and LDLIBS64 can be set in the environment to override the following
 777 # assignments.
 778 #
 779 # These environment settings make sure that no libraries are searched outside
 780 # of the local workspace proto area:
 781 #       LDLIBS32=-YP,$ROOT/lib:$ROOT/usr/lib
 782 #       LDLIBS64=-YP,$ROOT/lib/$MACH64:$ROOT/usr/lib/$MACH64
 783 #
 784 LDLIBS32 =      $(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
 785 LDLIBS32 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
 786 LDLIBS.cmd =    $(LDLIBS32)
 787 LDLIBS.lib =    $(LDLIBS32)
 788 
 789 LDLIBS64 =      $(ENVLDLIBS1:%=%/$(MACH64)) \
 790                 $(ENVLDLIBS2:%=%/$(MACH64)) \
 791                 $(ENVLDLIBS3:%=%/$(MACH64))
 792 LDLIBS64 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib/$(MACH64) -L%/lib/$(MACH64))
 793 
 794 #
 795 # Define compilation macros.
 796 #
 797 COMPILE.c=      $(CC) $(CFLAGS) $(CPPFLAGS) -c
 798 COMPILE64.c=    $(CC) $(CFLAGS64) $(CPPFLAGS) -c
 799 COMPILE.cc=     $(CCC) $(CCFLAGS) $(CPPFLAGS) -c
 800 COMPILE64.cc=   $(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
 801 COMPILE.s=      $(AS) $(ASFLAGS) $(AS_CPPFLAGS)
 802 COMPILE64.s=    $(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
 803 COMPILE.d=      $(DTRACE) -G -32
 804 COMPILE64.d=    $(DTRACE) -G -64
 805 COMPILE.b=      $(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
 806 COMPILE64.b=    $(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
 807 
 808 CLASSPATH=      .
 809 COMPILE.java=   $(JAVAC) $(JAVAFLAGS) -classpath $(CLASSPATH)
 810 
 811 #
 812 # Link time macros
 813 #
 814 CCNEEDED                = -lC
 815 CCEXTNEEDED             = -lCrun -lCstd
 816 $(__GNUC)CCNEEDED       = -L$(GCCLIBDIR) -lstdc++ -lgcc_s
 817 $(__GNUC)CCEXTNEEDED    = $(CCNEEDED)
 818 
 819 CCNEEDED64              = -lCrun
 820 CCEXTNEEDED64           = -lCrun -lCstd
 821 $(__GNUC64)CCNEEDED64   = -L$(GCCLIBDIR) -lstdc++ -lgcc_s
 822 $(__GNUC64)CCEXTNEEDED  = $(CCNEEDED64)
 823 
 824 # Libraries we expect to use natively on the build machine
 825 NATIVE_LIBS=
 826 
 827 LDCHECKS                = $(ZASSERTDEFLIB) $(ZGUIDANCE) $(ZFATALWARNINGS)
 828 LDCHECKS                += $(NATIVE_LIBS:%=$(ZASSERTDEFLIB)=%)
 829 
 830 LINK.c=                 $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
 831 LINK64.c=               $(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS) $(LDCHECKS)
 832 NORUNPATH=              -norunpath -nolib
 833 LINK.cc=                $(CCC) $(CCFLAGS) $(CPPFLAGS) $(NORUNPATH) \
 834                         $(LDFLAGS) $(CCNEEDED) $(LDCHECKS)
 835 LINK64.cc=              $(CCC) $(CCFLAGS64) $(CPPFLAGS) $(NORUNPATH) \
 836                         $(LDFLAGS) $(CCNEEDED64) $(LDCHECKS)
 837 
 838 #
 839 # lint macros
 840 #
 841 # Note that the undefine of __PRAGMA_REDEFINE_EXTNAME can be removed once
 842 # ON is built with a version of lint that has the fix for 4484186.
 843 #
 844 ALWAYS_LINT_DEFS =      -errtags=yes -s
 845 ALWAYS_LINT_DEFS +=     -erroff=E_PTRDIFF_OVERFLOW
 846 ALWAYS_LINT_DEFS +=     -erroff=E_ASSIGN_NARROW_CONV
 847 ALWAYS_LINT_DEFS +=     -U__PRAGMA_REDEFINE_EXTNAME
 848 ALWAYS_LINT_DEFS +=     $(C99LMODE)
 849 ALWAYS_LINT_DEFS +=     -errsecurity=$(SECLEVEL)
 850 ALWAYS_LINT_DEFS +=     -erroff=E_SEC_CREAT_WITHOUT_EXCL
 851 ALWAYS_LINT_DEFS +=     -erroff=E_SEC_FORBIDDEN_WARN_CREAT
 852 # XX64 -- really only needed for amd64 lint
 853 ALWAYS_LINT_DEFS +=     -erroff=E_ASSIGN_INT_TO_SMALL_INT
 854 ALWAYS_LINT_DEFS +=     -erroff=E_CAST_INT_CONST_TO_SMALL_INT
 855 ALWAYS_LINT_DEFS +=     -erroff=E_CAST_INT_TO_SMALL_INT
 856 ALWAYS_LINT_DEFS +=     -erroff=E_CAST_TO_PTR_FROM_INT
 857 ALWAYS_LINT_DEFS +=     -erroff=E_COMP_INT_WITH_LARGE_INT
 858 ALWAYS_LINT_DEFS +=     -erroff=E_INTEGRAL_CONST_EXP_EXPECTED
 859 ALWAYS_LINT_DEFS +=     -erroff=E_PASS_INT_TO_SMALL_INT
 860 ALWAYS_LINT_DEFS +=     -erroff=E_PTR_CONV_LOSES_BITS
 861 
 862 # This forces lint to pick up note.h and sys/note.h from Devpro rather than
 863 # from the proto area.  The note.h that ON delivers would disable NOTE().
 864 ONLY_LINT_DEFS =        -I$(SPRO_VROOT)/prod/include/lint
 865 
 866 SECLEVEL=       core
 867 LINT.c=         $(LINT) $(ONLY_LINT_DEFS) $(LINTFLAGS) $(CPPFLAGS) \
 868                 $(ALWAYS_LINT_DEFS)
 869 LINT64.c=       $(LINT) $(ONLY_LINT_DEFS) $(LINTFLAGS64) $(CPPFLAGS) \
 870                 $(ALWAYS_LINT_DEFS)
 871 LINT.s=         $(LINT.c)
 872 
 873 # For some future builds, NATIVE_MACH and MACH might be different.
 874 # Therefore, NATIVE_MACH needs to be redefined in the
 875 # environment as `uname -p` to override this macro.
 876 #
 877 # For now at least, we cross-compile amd64 on i386 machines.
 878 NATIVE_MACH=    $(MACH:amd64=i386)
 879 NATIVE_MACH64=  $(MACH64)
 880 
 881 # Define native compilation macros
 882 #
 883 
 884 # Base directory where compilers are loaded.
 885 # Defined here so it can be overridden by developer.
 886 #
 887 SPRO_ROOT=              $(BUILD_TOOLS)/SUNWspro
 888 SPRO_VROOT=             $(SPRO_ROOT)/SS12
 889 GNU_ROOT=               /usr
 890 
 891 $(__GNUC)PRIMARY_CC=    gcc7,$(GNUC_ROOT)/bin/gcc,gnu
 892 $(__SUNC)PRIMARY_CC=    studio12,$(SPRO_VROOT)/bin/cc,sun
 893 $(__GNUC)PRIMARY_CCC=   gcc7,$(GNUC_ROOT)/bin/g++,gnu
 894 $(__SUNC)PRIMARY_CCC=   studio12,$(SPRO_VROOT)/bin/CC,sun
 895 
 896 CW_CC_COMPILERS=        $(PRIMARY_CC:%=--primary %) $(SHADOW_CCS:%=--shadow %)
 897 CW_CCC_COMPILERS=       $(PRIMARY_CCC:%=--primary %) $(SHADOW_CCCS:%=--shadow %)
 898 
 899 CW_LINKER=              --linker $(LD)
 900 
 901 # Till SS12u1 formally becomes the NV CBE, LINT is hard
 902 # coded to be picked up from the $SPRO_ROOT/sunstudio12.1/
 903 # location. Impacted variables are sparc_LINT, sparcv9_LINT,
 904 # i386_LINT, amd64_LINT.
 905 # Reset them when SS12u1 is rolled out.
 906 #
 907 
 908 # Specify platform compiler versions for languages
 909 # that we use (currently only c and c++).
 910 #
 911 CW=                     $(ONBLD_TOOLS)/bin/$(MACH)/cw
 912 
 913 BUILD_CC=               $(CW) $(CW_LINKER) $(CW_CC_COMPILERS) --
 914 BUILD_CCC=              $(CW) -C $(CW_LINKER) $(CW_CCC_COMPILERS) --
 915 BUILD_CPP=              /usr/ccs/lib/cpp
 916 BUILD_LD=               $(ONBLD_TOOLS)/bin/$(MACH)/ld
 917 BUILD_LINT=             $(SPRO_ROOT)/sunstudio12.1/bin/lint
 918 
 919 $(MACH)_CC=             $(BUILD_CC)
 920 $(MACH)_CCC=            $(BUILD_CCC)
 921 $(MACH)_CPP=            $(BUILD_CPP)
 922 $(MACH)_LD=             $(BUILD_LD)
 923 $(MACH)_LINT=           $(BUILD_LINT)
 924 $(MACH64)_CC=           $(BUILD_CC)
 925 $(MACH64)_CCC=          $(BUILD_CCC)
 926 $(MACH64)_CPP=          $(BUILD_CPP)
 927 $(MACH64)_LD=           $(BUILD_LD)
 928 $(MACH64)_LINT=         $(BUILD_LINT)
 929 
 930 sparc_AS=               /usr/ccs/bin/as -xregsym=no
 931 sparcv9_AS=             $($(MACH)_AS)
 932 
 933 i386_AS=                /usr/ccs/bin/as
 934 $(__GNUC)i386_AS=       $(ONBLD_TOOLS)/bin/$(MACH)/aw
 935 amd64_AS=               $(ONBLD_TOOLS)/bin/$(MACH)/aw
 936 
 937 NATIVECC=               $($(NATIVE_MACH)_CC)
 938 NATIVECCC=              $($(NATIVE_MACH)_CCC)
 939 NATIVECPP=              $($(NATIVE_MACH)_CPP)
 940 NATIVEAS=               $($(NATIVE_MACH)_AS)
 941 NATIVELD=               $($(NATIVE_MACH)_LD)
 942 NATIVELINT=             $($(NATIVE_MACH)_LINT)
 943 
 944 NATIVECC64=             $($(NATIVE_MACH64)_CC)
 945 NATIVECCC64=            $($(NATIVE_MACH64)_CCC)
 946 NATIVECPP64=            $($(NATIVE_MACH64)_CPP)
 947 NATIVEAS64=             $($(NATIVE_MACH64)_AS)
 948 NATIVELD64=             $($(NATIVE_MACH64)_LD)
 949 NATIVELINT64=           $($(NATIVE_MACH64)_LINT)
 950 
 951 #
 952 # Makefile.master.64 overrides these settings
 953 #
 954 CC=                     $(NATIVECC)
 955 CCC=                    $(NATIVECCC)
 956 CPP=                    $(NATIVECPP)
 957 AS=                     $(NATIVEAS)
 958 LD=                     $(NATIVELD)
 959 LINT=                   $(NATIVELINT)
 960 
 961 CC64=                   $(NATIVECC64)
 962 CCC64=                  $(NATIVECCC64)
 963 CPP64=                  $(NATIVECPP64)
 964 AS64=                   $(NATIVEAS64)
 965 LD64=                   $(NATIVELD64)
 966 LINT64=                 $(NATIVELINT64)
 967 
 968 # Pass -Y flag to cpp (method of which is release-dependent)
 969 CCYFLAG=                -Y I,
 970 
 971 BDIRECT=        -Bdirect
 972 BDYNAMIC=       -Bdynamic
 973 BLOCAL=         -Blocal
 974 BNODIRECT=      -Bnodirect
 975 BREDUCE=        -Breduce
 976 BSTATIC=        -Bstatic
 977 
 978 ZDEFS=          -zdefs
 979 ZDIRECT=        -zdirect
 980 ZIGNORE=        -zignore
 981 ZINITFIRST=     -zinitfirst
 982 ZINTERPOSE=     -zinterpose
 983 ZLAZYLOAD=      -zlazyload
 984 ZLOADFLTR=      -zloadfltr
 985 ZMULDEFS=       -zmuldefs
 986 ZNODEFAULTLIB=  -znodefaultlib
 987 ZNODEFS=        -znodefs
 988 ZNODELETE=      -znodelete
 989 ZNODLOPEN=      -znodlopen
 990 ZNODUMP=        -znodump
 991 ZNOLAZYLOAD=    -znolazyload
 992 ZNOLDYNSYM=     -znoldynsym
 993 ZNORELOC=       -znoreloc
 994 ZNOVERSION=     -znoversion
 995 ZRECORD=        -zrecord
 996 ZREDLOCSYM=     -zredlocsym
 997 ZTEXT=          -ztext
 998 ZVERBOSE=       -zverbose
 999 ZASSERTDEFLIB=  -zassert-deflib
1000 ZGUIDANCE=      -zguidance
1001 ZFATALWARNINGS= -zfatal-warnings
1002 
1003 GSHARED=        -G
1004 CCMT=           -mt
1005 
1006 # Handle different PIC models on different ISAs
1007 # (May be overridden by lower-level Makefiles)
1008 
1009 sparc_C_PICFLAGS =      -fpic
1010 sparcv9_C_PICFLAGS =    -fpic
1011 i386_C_PICFLAGS =       -fpic
1012 amd64_C_PICFLAGS =      -fpic
1013 C_PICFLAGS =            $($(MACH)_C_PICFLAGS)
1014 C_PICFLAGS64 =          $($(MACH64)_C_PICFLAGS)
1015 
1016 sparc_C_BIGPICFLAGS =   -fPIC
1017 sparcv9_C_BIGPICFLAGS = -fPIC
1018 i386_C_BIGPICFLAGS =    -fPIC
1019 amd64_C_BIGPICFLAGS =   -fPIC
1020 C_BIGPICFLAGS =         $($(MACH)_C_BIGPICFLAGS)
1021 C_BIGPICFLAGS64 =       $($(MACH64)_C_BIGPICFLAGS)
1022 
1023 # CC requires there to be no space between '-K' and 'pic' or 'PIC'.
1024 # and does not support -f
1025 sparc_CC_PICFLAGS =     -_cc=-Kpic -_gcc=-fpic
1026 sparcv9_CC_PICFLAGS =   -_cc=-KPIC -_gcc=-fPIC
1027 i386_CC_PICFLAGS =      -_cc=-Kpic -_gcc=-fpic
1028 amd64_CC_PICFLAGS =     -_cc=-Kpic -_gcc=-fpic
1029 CC_PICFLAGS =           $($(MACH)_CC_PICFLAGS)
1030 CC_PICFLAGS64 =         $($(MACH64)_CC_PICFLAGS)
1031 
1032 AS_PICFLAGS=            -K pic
1033 AS_BIGPICFLAGS=         -K PIC
1034 
1035 #
1036 # Default label for CTF sections
1037 #
1038 CTFCVTFLAGS=            -L VERSION
1039 
1040 #
1041 # Override to pass module-specific flags to ctfmerge.  Currently used only by
1042 # krtld to turn on fuzzy matching, and source-level debugging to inhibit
1043 # stripping.
1044 #
1045 CTFMRGFLAGS=
1046 
1047 CTFCONVERT_O            = $(CTFCONVERT) $(CTFCVTFLAGS) $@
1048 
1049 # Rules (normally from make.rules) and macros which are used for post
1050 # processing files. Normally, these do stripping of the comment section
1051 # automatically.
1052 #    RELEASE_CM:        Should be edited to reflect the release.
1053 #    POST_PROCESS_O:    Post-processing for `.o' files (typically C source)
1054 #    POST_PROCESS_S_O:  Post-processing for `.o' files built from asssembly
1055 #    POST_PROCESS_CC_O: Post-processing for `.o' files built from C++
1056 #    POST_PROCESS_A:            Post-processing for `.a' files (currently null).
1057 #    POST_PROCESS_SO:   Post-processing for `.so' files.
1058 #    POST_PROCESS:      Post-processing for executable files (no suffix).
1059 #
1060 # Note that these macros are not completely generalized as they are to be
1061 # used with the file name to be processed following.
1062 #
1063 # It is left as an exercise to Release Engineering to embellish the generation
1064 # of the release comment string.
1065 #
1066 #       If this is a standard development build:
1067 #               compress the comment section (mcs -c)
1068 #               add the standard comment (mcs -a $(RELEASE_CM))
1069 #               add the development specific comment (mcs -a $(DEV_CM))
1070 #
1071 #       If this is an installation build:
1072 #               delete the comment section (mcs -d)
1073 #               add the standard comment (mcs -a $(RELEASE_CM))
1074 #               add the development specific comment (mcs -a $(DEV_CM))
1075 #
1076 #       If this is an release build:
1077 #               delete the comment section (mcs -d)
1078 #               add the standard comment (mcs -a $(RELEASE_CM))
1079 #
1080 # The following list of macros are used in the definition of RELEASE_CM
1081 # which is used to label all binaries in the build:
1082 #
1083 #       RELEASE         Specific release of the build, eg: 5.2
1084 #       RELEASE_MAJOR   Major version number part of $(RELEASE)
1085 #       RELEASE_MINOR   Minor version number part of $(RELEASE)
1086 #       VERSION         Version of the build (alpha, beta, Generic)
1087 #       PATCHID         If this is a patch this value should contain
1088 #                       the patchid value (eg: "Generic 100832-01"), otherwise
1089 #                       it will be set to $(VERSION)
1090 #       RELEASE_DATE    Date of the Release Build
1091 #       PATCH_DATE      Date the patch was created, if this is blank it
1092 #                       will default to the RELEASE_DATE
1093 #
1094 RELEASE_MAJOR=  5
1095 RELEASE_MINOR=  11
1096 RELEASE=        $(RELEASE_MAJOR).$(RELEASE_MINOR)
1097 VERSION=        SunOS Development
1098 PATCHID=        $(VERSION)
1099 RELEASE_DATE=   release date not set
1100 PATCH_DATE=     $(RELEASE_DATE)
1101 RELEASE_CM=     "@($(POUND_SIGN))SunOS $(RELEASE) $(PATCHID) $(PATCH_DATE)"
1102 DEV_CM=         "@($(POUND_SIGN))SunOS Internal Development: non-nightly build"
1103 UTS_LABEL=      $(RELEASE)
1104 
1105 PROCESS_COMMENT=  @?${MCS} -d -a $(RELEASE_CM) -a $(DEV_CM)
1106 $(RELEASE_BUILD)PROCESS_COMMENT=   @?${MCS} -d -a $(RELEASE_CM)
1107 
1108 STRIP_STABS=                       $(STRIP) -x $@
1109 $(SRCDBGBLD)STRIP_STABS=           :
1110 
1111 POST_PROCESS_O=
1112 POST_PROCESS_S_O=
1113 POST_PROCESS_CC_O=
1114 POST_PROCESS_A=
1115 POST_PROCESS_SO=        $(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
1116                         $(ELFSIGN_OBJECT)
1117 POST_PROCESS=           $(PROCESS_COMMENT) $@ ; $(STRIP_STABS) ; \
1118                         $(ELFSIGN_OBJECT)
1119 
1120 #
1121 # chk4ubin is a tool that inspects a module for a symbol table
1122 # ELF section size which can trigger an OBP bug on older platforms.
1123 # This problem affects only specific sun4u bootable modules.
1124 #
1125 CHK4UBIN=       $(ONBLD_TOOLS)/bin/$(MACH)/chk4ubin
1126 CHK4UBINFLAGS=
1127 CHK4UBINARY=    $(CHK4UBIN) $(CHK4UBINFLAGS) $@
1128 
1129 #
1130 # PKGARCHIVE specifies the default location where packages should be
1131 # placed if built.
1132 #
1133 $(RELEASE_BUILD)PKGARCHIVESUFFIX=       -nd
1134 PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly$(PKGARCHIVESUFFIX)
1135 
1136 #
1137 # The repositories will be created with these publisher settings.  To
1138 # update an image to the resulting repositories, this must match the
1139 # publisher name provided to "pkg set-publisher."
1140 #
1141 PKGPUBLISHER_REDIST=    on-nightly
1142 PKGPUBLISHER_NONREDIST= on-extra
1143 
1144 #       Default build rules which perform comment section post-processing.
1145 #
1146 .c:
1147         $(LINK.c) -o $@ $< $(LDLIBS)
1148         $(POST_PROCESS)
1149 .c.o:
1150         $(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
1151         $(POST_PROCESS_O)
1152 .c.a:
1153         $(COMPILE.c) -o $% $<
1154         $(PROCESS_COMMENT) $%
1155         $(AR) $(ARFLAGS) $@ $%
1156         $(RM) $%
1157 .s.o:
1158         $(COMPILE.s) -o $@ $<
1159         $(POST_PROCESS_S_O)
1160 .s.a:
1161         $(COMPILE.s) -o $% $<
1162         $(PROCESS_COMMENT) $%
1163         $(AR) $(ARFLAGS) $@ $%
1164         $(RM) $%
1165 .cc:
1166         $(LINK.cc) -o $@ $< $(LDLIBS)
1167         $(POST_PROCESS)
1168 .cc.o:
1169         $(COMPILE.cc) $(OUTPUT_OPTION) $<
1170         $(POST_PROCESS_CC_O)
1171 .cc.a:
1172         $(COMPILE.cc) -o $% $<
1173         $(AR) $(ARFLAGS) $@ $%
1174         $(PROCESS_COMMENT) $%
1175         $(RM) $%
1176 .y:
1177         $(YACC.y) $<
1178         $(LINK.c) -o $@ y.tab.c $(LDLIBS)
1179         $(POST_PROCESS)
1180         $(RM) y.tab.c
1181 .y.o:
1182         $(YACC.y) $<
1183         $(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
1184         $(POST_PROCESS_O)
1185         $(RM) y.tab.c
1186 .l:
1187         $(RM) $*.c
1188         $(LEX.l) $< > $*.c
1189         $(LINK.c) -o $@ $*.c -ll $(LDLIBS)
1190         $(POST_PROCESS)
1191         $(RM) $*.c
1192 .l.o:
1193         $(RM) $*.c
1194         $(LEX.l) $< > $*.c
1195         $(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
1196         $(POST_PROCESS_O)
1197         $(RM) $*.c
1198 
1199 .bin.o:
1200         $(COMPILE.b) -o $@ $<
1201         $(POST_PROCESS_O)
1202 
1203 .java.class:
1204         $(COMPILE.java) $<
1205 
1206 # Bourne and Korn shell script message catalog build rules.
1207 # We extract all gettext strings with sed(1) (being careful to permit
1208 # multiple gettext strings on the same line), weed out the dups, and
1209 # build the catalogue with awk(1).
1210 
1211 .sh.po .ksh.po:
1212         $(SED) -n -e ":a"                                       \
1213                   -e "h"                                        \
1214                   -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"       \
1215                   -e "x"                                        \
1216                   -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"  \
1217                   -e "t a"                                      \
1218                $< | sort -u | $(AWK) '{ print "msgid\t" $$0 "\nmsgstr" }' > $@
1219 
1220 #
1221 # Python and Perl executable and message catalog build rules.
1222 #
1223 .SUFFIXES: .pl .pm .py .pyc
1224 
1225 .pl:
1226         $(RM) $@;
1227         $(SED) -e "s@TEXT_DOMAIN@\"$(TEXT_DOMAIN)\"@" $< > $@;
1228         $(CHMOD) +x $@
1229 
1230 .py:
1231         $(RM) $@; $(SED) \
1232                 -e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
1233                 -e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
1234                 < $< > $@; $(CHMOD) +x $@
1235 
1236 .py.pyc:
1237         $(RM) $@
1238         $(PYTHON) -mpy_compile $<
1239         @[ $(<)c = $@ ] || $(MV) $(<)c $@
1240 
1241 .py.po:
1242         $(GNUXGETTEXT) $(GNUXGETFLAGS) -d $(<F:%.py=%) $< ;
1243 
1244 .pl.po .pm.po:
1245         $(XGETTEXT) $(XGETFLAGS) -d $(<F) $< ;
1246         $(RM)   $@ ;
1247         $(SED) "/^domain/d" < $(<F).po > $@ ;
1248         $(RM) $(<F).po
1249 
1250 #
1251 # When using xgettext, we want messages to go to the default domain,
1252 # rather than the specified one.  This special version of the
1253 # COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
1254 # causing xgettext to put all messages into the default domain.
1255 #
1256 CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)
1257 
1258 .c.i:
1259         $(CPPFORPO) $< > $@
1260 
1261 .h.i:
1262         $(CPPFORPO) $< > $@
1263 
1264 .y.i:
1265         $(YACC) -d $<
1266         $(CPPFORPO) y.tab.c  > $@
1267         $(RM) y.tab.c
1268 
1269 .l.i:
1270         $(LEX) $<
1271         $(CPPFORPO) lex.yy.c  > $@
1272         $(RM) lex.yy.c
1273 
1274 .c.po:
1275         $(CPPFORPO) $< > $<.i
1276         $(BUILD.po)
1277 
1278 .cc.po:
1279         $(CPPFORPO) $< > $<.i
1280         $(BUILD.po)
1281 
1282 .y.po:
1283         $(YACC) -d $<
1284         $(CPPFORPO) y.tab.c  > $<.i
1285         $(BUILD.po)
1286         $(RM) y.tab.c
1287 
1288 .l.po:
1289         $(LEX) $<
1290         $(CPPFORPO) lex.yy.c  > $<.i
1291         $(BUILD.po)
1292         $(RM) lex.yy.c
1293 
1294 #
1295 # Rules to perform stylistic checks
1296 #
1297 .SUFFIXES: .x .xml .check .xmlchk
1298 
1299 .h.check:
1300         $(DOT_H_CHECK)
1301 
1302 .x.check:
1303         $(DOT_X_CHECK)
1304 
1305 .xml.xmlchk:
1306         $(MANIFEST_CHECK)