view usr/src/Makefile.master @ 20604:76b6299aa623

Merge illumos-gate
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sun, 05 May 2019 16:25:23 -0400
parents e1ed8d6406d3 628a13d9b7eb
children 7799eb65ec02
line wrap: on
line source

#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
# Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright 2015 Gary Mills
# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
# Copyright 2016 Toomas Soome <tsoome@me.com>
#

include $(SRC)/Makefile.cfgparam

#
# Makefile.master, global definitions for system source
#
ROOT=		/proto

#
# Adjunct root, containing an additional proto area to be used for headers
# and libraries.
#
ADJUNCT_PROTO=

#
# Adjunct for building things that run on the build machine.
#
NATIVE_ADJUNCT=	/usr

#
# RELEASE_BUILD should be cleared for final release builds.
# NOT_RELEASE_BUILD is exactly what the name implies.
#

NOT_RELEASE_BUILD=
RELEASE_BUILD=				$(POUND_SIGN)
$(RELEASE_BUILD)NOT_RELEASE_BUILD=	$(POUND_SIGN)
PATCH_BUILD=				$(POUND_SIGN)

# SPARC_BLD is '#' for an Intel build.
# INTEL_BLD is '#' for a Sparc build.
SPARC_BLD_1=    $(MACH:i386=$(POUND_SIGN))
SPARC_BLD=      $(SPARC_BLD_1:sparc=)
INTEL_BLD_1=    $(MACH:sparc=$(POUND_SIGN))
INTEL_BLD=      $(INTEL_BLD_1:i386=)

# Allow build-time "configuration" to enable or disable some things.
# The default is POUND_SIGN, meaning "not enabled".
ENABLE_PERL64=		$(POUND_SIGN)

# BUILD_TOOLS is the root of all tools including compilers.
# ONBLD_TOOLS is the root of all the tools that are part of SUNWonbld.

BUILD_TOOLS=		/opt
ONBLD_TOOLS=		$(BUILD_TOOLS)/onbld

GNUC_ROOT=	/opt/gcc/4.4.4
GCCLIBDIR=	$(GNUC_ROOT)/lib
GCCLIBDIR64=	$(GNUC_ROOT)/lib/$(MACH64)

DOCBOOK_XSL_ROOT=	/usr/share/sgml/docbook/xsl-stylesheets

RPCGEN=		/usr/bin/rpcgen
ELFEXTRACT=	$(ONBLD_TOOLS)/bin/$(MACH)/elfextract
MBH_PATCH=	$(SRCTOP)/tools/mbh_patch/obj/mbh_patch
BTXLD=		$(ONBLD_TOOLS)/bin/$(MACH)/btxld
VTFONTCVT=	/usr/bin/vtfontcvt
# echo(1) and true(1) are specified without absolute paths, so that the shell
# spawned by make(1) may use the built-in versions.  This is minimally
# problematic, as the shell spawned by make(1) is known and under control, the
# only risk being if the shell falls back to $PATH.
#
# We specifically want an echo(1) that does interpolation of escape sequences,
# which ksh, /bin/sh, and bash will all provide.
ECHO=		echo
TRUE=		true
INS=		/usr/bin/install
SYMLINK=	/usr/bin/ln -s
LN=		/usr/bin/ln
MKDIR=		/usr/bin/mkdir
CHMOD=		/usr/bin/chmod
MV=		/usr/bin/mv -f
RM=		/usr/bin/rm -f
CUT=		/usr/bin/cut
NM=		/usr/bin/nm
DIFF=		/usr/bin/diff
GREP=		/usr/bin/grep
EGREP=		/usr/bin/egrep
ELFWRAP=	/usr/bin/elfwrap
SED=		/usr/bin/sed
AWK=		/usr/bin/nawk
CP=		/usr/bin/cp -f
MCS=		/usr/bin/mcs
CAT=            /usr/bin/cat
ELFDUMP=	/usr/bin/elfdump
M4=		/usr/bin/m4
STRIP=		/usr/bin/strip
LEX=		/usr/bin/lex
LFLAGS=		-n
FLEX=		/usr/bin/flex
YACC=		/usr/bin/yacc
CPP=		$(GNUC_ROOT)/cpp
ANSI_CPP=	$(GNUC_ROOT)/bin/cpp
CTFCONVERT=	/usr/bin/ctfconvert
CTFDIFF=	/usr/bin/ctfdiff
CTFMERGE=	/usr/bin/ctfmerge
CTFSTABS=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstabs
CTFSTRIP=	$(ONBLD_TOOLS)/bin/$(MACH)/ctfstrip
NDRGEN=		$(ONBLD_TOOLS)/bin/$(MACH)/ndrgen
GENOFFSETS=	$(ONBLD_TOOLS)/bin/genoffsets
FIND=		/usr/bin/find
PERL=		/usr/bin/perl
PERL_VERSION=	5.22
PERL_PKGVERS=	-522
PERL_ARCH=		i86pc-solaris-64int
PERL_ARCH64=	i86pc-solaris-64
$(SPARC_BLD)PERL_ARCH=		sun4-solaris-64int
$(SPARC_BLD)PERL_ARCH64=	sun4-solaris-64
PYTHON_VERSION=	2.7
PYTHON_PKGVERS=	-27
PYTHON_SUFFIX=
PYTHON=		/usr/bin/python$(PYTHON_VERSION)
PYTHON3_VERSION=	3.5
PYTHON3_PKGVERS=	-35
PYTHON3_SUFFIX=		m
PYTHON3=		/usr/bin/python$(PYTHON3_VERSION)
$(BUILDPY3TOOLS)TOOLS_PYTHON=		$(PYTHON3)
$(BUILDPY2TOOLS)TOOLS_PYTHON=		$(PYTHON)
SORT=		/usr/bin/sort
TOUCH=		/usr/bin/touch
WC=		/usr/bin/wc
XARGS=		/usr/bin/xargs
ELFEDIT=	/usr/bin/elfedit
DTRACE=		/usr/sbin/dtrace -xnolibs
UNIQ=		/usr/bin/uniq
TAR=		/usr/bin/tar
ASTBINDIR=	/usr/ast/bin
MSGCC=		$(ASTBINDIR)/msgcc
MSGFMT=		/usr/bin/msgfmt -s

FILEMODE=	644
DIRMODE=	755

# Declare that nothing should be built in parallel.
# Individual Makefiles can use the .PARALLEL target to declare otherwise.
.NO_PARALLEL:

# For stylistic checks
#
# Note that the X and C checks are not used at this time and may need
# modification when they are actually used.
#
CSTYLE=		$(ONBLD_TOOLS)/bin/cstyle
CSTYLE_TAIL=
HDRCHK=		$(ONBLD_TOOLS)/bin/hdrchk
HDRCHK_TAIL=

DOT_H_CHECK=	\
	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL); \
	$(HDRCHK) $< $(HDRCHK_TAIL)

DOT_X_CHECK=	\
	@$(ECHO) "checking $<"; $(RPCGEN) -C -h $< | $(CSTYLE) $(CSTYLE_TAIL); \
	$(RPCGEN) -C -h $< | $(HDRCHK) $< $(HDRCHK_TAIL)

DOT_C_CHECK=	\
	@$(ECHO) "checking $<"; $(CSTYLE) $< $(CSTYLE_TAIL)

MANIFEST_CHECK=	\
	@$(ECHO) "checking $<"; \
	SVCCFG_DTD=$(SRC)/cmd/svc/dtd/service_bundle.dtd.1 \
	SVCCFG_REPOSITORY=$(SRC)/cmd/svc/seed/global.db \
	SVCCFG_CONFIGD_PATH=$(SRC)/cmd/svc/configd/svc.configd-native \
	$(SRC)/cmd/svc/svccfg/svccfg-native validate $<

INS.file=	$(INS) -m $(FILEMODE) $< $@
INS.dir=	$(INS) -d -m $(DIRMODE) $@
# installs and renames at once
#
INS.rename=	$(INS.file)

# install a link
INSLINKTARGET=	$<
INS.link=	$(RM) $@; $(LN) $(INSLINKTARGET) $@
INS.symlink=	$(RM) $@; $(SYMLINK) $(INSLINKTARGET) $@

# The path to python that will be used for the shebang line when installing
# python scripts to the proto area. This is overridden by makefiles to
# select to the correct version.
PYSHEBANG=	$(PYTHON)

#
# Python bakes the mtime of the .py file into the compiled .pyc and
# rebuilds if the baked-in mtime != the mtime of the source file
# (rather than only if it's less than), thus when installing python
# files we must make certain to not adjust the mtime of the source
# (.py) file.
#
INS.pyfile=	$(RM) $@; $(SED) \
		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
		< $< > $@; $(CHMOD) $(FILEMODE) $@; $(TOUCH) -r $< $@

# MACH must be set in the shell environment per uname -p on the build host
# More specific architecture variables should be set in lower makefiles.
#
# MACH64 is derived from MACH, and BUILD64 is set to `#' for
# architectures on which we do not build 64-bit versions.
# (There are no such architectures at the moment.)
#
# Set BUILD64=# in the environment to disable 64-bit amd64
# builds on i386 machines.

MACH64_1=	$(MACH:sparc=sparcv9)
MACH64=		$(MACH64_1:i386=amd64)

MACH32_1=	$(MACH:sparc=sparcv7)
MACH32=		$(MACH32_1:i386=i386)

sparc_BUILD64=
i386_BUILD64=
BUILD64=	$($(MACH)_BUILD64)

#
# generate 32-bit addresses in the v9 kernel. Saves memory.
CCABS32=		-fno-pic -mcmodel=medlow
#
# generate v9 code which tolerates callers using the v7 ABI, for the sake of
# system calls.
CC32BITCALLERS=		-massume-32bit-callers

# GCC, especially, is increasingly beginning to auto-inline functions and
# sadly does so separately not under the general -fno-inline-functions
# Additionally, we wish to prevent optimisations which cause GCC to clone
# functions -- in particular, these may cause unhelpful symbols to be
# emitted instead of function names
CCNOAUTOINLINE= -fno-inline-small-functions \
	-fno-inline-functions-called-once \
	-fno-ipa-cp

#
# compiler architecture flags.
#
sparc_XARCH=	-m32 -mcpu=v8 -mno-v8plus
sparcv9_XARCH=	-m64 -mcpu=v9
i386_XARCH=	-m32 -march=pentiumpro
amd64_XARCH=	-m64 -Ui386 -U__i386 -mtune=opteron

# assembler architecture flags.  Different from compiler architecture flags.
sparc_AS_XARCH=		-xarch=v8plus -Dsparc -D__sparc -D__sparcv8
sparcv9_AS_XARCH=	-xarch=v9 -Dsparc -D__sparc -D__sparcv9
i386_AS_XARCH=		-m32 -Di386 -D__i386
amd64_AS_XARCH=		-m64 -Ui386 -U__i386 -D__x86_64 -D__amd64

#
# These flags define what we need to be 'standalone' i.e. -not- part
# of the rather more cosy userland environment.  This basically means
# the kernel.
#
# XX64	future versions of gcc will make -mcmodel=kernel imply -mno-red-zone
#
sparc_STAND_FLAGS=	-ffreestanding
sparcv9_STAND_FLAGS=	-ffreestanding
# Disabling MMX also disables 3DNow, disabling SSE also disables all later
# additions to SSE (SSE2, AVX ,etc.)
NO_SIMD=		-mno-mmx -mno-sse
i386_STAND_FLAGS=	-ffreestanding $(NO_SIMD)
amd64_STAND_FLAGS=	-ffreestanding -mno-red-zone \
			-mcmodel=kernel $(NO_SIMD)

SAVEARGS=		-msave-args
amd64_STAND_FLAGS	+= $(SAVEARGS)

STAND_FLAGS_32 = $($(MACH)_STAND_FLAGS)
STAND_FLAGS_64 = $($(MACH64)_STAND_FLAGS)

#
# turn warnings into errors (C)
CERRWARN = -Wall -Wextra -Werror

CERRWARN += -Wno-missing-braces
CERRWARN += -Wno-sign-compare
CERRWARN += -Wno-unknown-pragmas
CERRWARN += -Wno-unused-parameter
CERRWARN += -Wno-missing-field-initializers

# Unfortunately, this option can misfire very easily and unfixably.
CERRWARN +=	-Wno-array-bounds

# DEBUG v. -nd make for frequent unused variables, empty conditions, etc. in
# -nd builds
$(RELEASE_BUILD)CERRWARN += -Wno-unused
$(RELEASE_BUILD)CERRWARN += -Wno-empty-body

#
# turn warnings into errors (C++)
CCERRWARN=		-Werror

# C standard.
CSTD_GNU89=	-std=gnu89
CSTD_GNU99=	-std=gnu99
CSTD=		$(CSTD_GNU89)

# In most places, assignments to these macros should be appended with +=
# (CPPFLAGS.first allows values to be prepended to CPPFLAGS).
sparc_CFLAGS=	$(sparc_XARCH)
sparcv9_CFLAGS=	$(sparcv9_XARCH)
i386_CFLAGS=	$(i386_XARCH)
amd64_CFLAGS=	$(amd64_XARCH)

sparc_ASFLAGS=	$(sparc_AS_XARCH)
sparcv9_ASFLAGS=$(sparcv9_AS_XARCH)
i386_ASFLAGS=	$(i386_AS_XARCH)
amd64_ASFLAGS=	$(amd64_AS_XARCH)

#
sparc_COPTFLAG=		-fno-strict-aliasing \
	-fno-unit-at-a-time \
	-fno-optimize-sibling-calls \
	-O2
sparcv9_COPTFLAG=	-fno-strict-aliasing \
	-fno-unit-at-a-time \
	-fno-optimize-sibling-calls \
	-O2
i386_COPTFLAG=		-O
amd64_COPTFLAG=		-fno-strict-aliasing \
	-fno-unit-at-a-time \
	-fno-optimize-sibling-calls \
	-O2

COPTFLAG= $($(MACH)_COPTFLAG)
COPTFLAG64= $($(MACH64)_COPTFLAG)

# Sometimes we want all symbols and types in debugging information even
# if they aren't used.
CALLSYMS=	-fno-eliminate-unused-debug-symbols \
		-fno-eliminate-unused-debug-types

#
# Flags used to build in debug mode for ctf generation.  Bugs in the Devpro
# compilers currently prevent us from building with cc-emitted DWARF.
#
CTF_FLAGS_sparc	= -g -Wc,-Qiselect-T1 $(CSTD) $(CDWARFSTR)
CTF_FLAGS_i386	= -g $(CSTD) $(CDWARFSTR)

CTF_FLAGS_sparcv9	= $(CTF_FLAGS_sparc)
CTF_FLAGS_amd64		= $(CTF_FLAGS_i386)

CTF_FLAGS_amd64 += $(SAVEARGS)

CTF_FLAGS_32	= $(CTF_FLAGS_$(MACH))
CTF_FLAGS_64	= $(CTF_FLAGS_$(MACH64))
CTF_FLAGS	= $(CTF_FLAGS_32)

#
# Flags used with genoffsets
#
GOFLAGS = $(CALLSYMS) \
	$(CDWARFSTR)

OFFSETS_CREATE = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
	$(CC) $(GOFLAGS) $(CFLAGS) $(CPPFLAGS)

OFFSETS_CREATE64 = $(GENOFFSETS) -s $(CTFSTABS) -r $(CTFCONVERT) \
	$(CC) $(GOFLAGS) $(CFLAGS64) $(CPPFLAGS)

sparc_XREGSFLAG		= -mno-app-regs
sparcv9_XREGSFLAG	= -mno-app-regs
i386_XREGSFLAG		=
amd64_XREGSFLAG		=

XREGSFLAG		= $($(MACH)_XREGSFLAG)
XREGSFLAG64		= $($(MACH64)_XREGSFLAG)

# dmake SOURCEDEBUG=yes ... enables source-level debugging information, and
# avoids stripping it.
SOURCEDEBUG	= $(POUND_SIGN)
SRCDBGBLD	= $(SOURCEDEBUG:yes=)

#
# These variables are intended ONLY for use by developers to safely pass extra
# flags to the compilers without unintentionally overriding Makefile-set
# flags.  They should NEVER be set to any value in a Makefile.
#
# They come last in the associated FLAGS variable such that they can
# explicitly override things if necessary, there are gaps in this, but it's
# the best we can manage.
#
CUSERFLAGS		=
CUSERFLAGS64		= $(CUSERFLAGS)
CCUSERFLAGS		=
CCUSERFLAGS64		= $(CCUSERFLAGS)

CSOURCEDEBUGFLAGS	=
CCSOURCEDEBUGFLAGS	=
$(SRCDBGBLD)CSOURCEDEBUGFLAGS	= -g
$(SRCDBGBLD)CCSOURCEDEBUGFLAGS	= -g

CFLAGS=         $(COPTFLAG) $($(MACH)_CFLAGS) \
		$(CERRWARN) $(CSTD) \
		$(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
		$(CUSERFLAGS)
CFLAGS64=       $(COPTFLAG64) $($(MACH64)_CFLAGS) \
		$(CERRWARN) $(CSTD) \
		$(CCNOAUTOINLINE) $(CSOURCEDEBUGFLAGS) \
		$(CUSERFLAGS64)
ARFLAGS=	rc
#
# Flags that are used to build parts of the code that are subsequently
# run on the build machine (also known as the NATIVE_BUILD).
#
NATIVE_CFLAGS=	$(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) \
		$(CERRWARN) $(CSTD) \
		$(CCNOAUTOINLINE) \
		$(CSOURCEDEBUGFLAGS) $(CUSERFLAGS)

DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\"	# For messaging.
CPPFLAGS.first=	# Please keep empty.  Only lower makefiles should set this.
CPPFLAGS.master=$(DTEXTDOM) \
	$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) $(ENVCPPFLAGS4) \
	$(ADJUNCT_PROTO:%=-I%/usr/include)
CPPFLAGS.native=$(ENVCPPFLAGS1) $(ENVCPPFLAGS2) $(ENVCPPFLAGS3) \
		$(ENVCPPFLAGS4) -I$(NATIVE_ADJUNCT)/include
CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)
AS_CPPFLAGS=	$(CPPFLAGS.first) $(CPPFLAGS.master)

#
# For source message catalogue
#
.SUFFIXES: $(SUFFIXES) .i .po
MSGROOT= $(ROOT)/catalog
MSGDOMAIN= $(MSGROOT)/$(TEXT_DOMAIN)
MSGDOMAINPOFILE = $(MSGDOMAIN)/$(POFILE)
DCMSGDOMAIN= $(MSGROOT)/LC_TIME/$(TEXT_DOMAIN)
DCMSGDOMAINPOFILE = $(DCMSGDOMAIN)/$(DCFILE:.dc=.po)

CLOBBERFILES += $(POFILE) $(POFILES)
COMPILE.cpp= $(CC) -xc -E -C $(CFLAGS) $(CPPFLAGS)
XGETTEXT= /usr/bin/xgettext
XGETFLAGS= -c TRANSLATION_NOTE
BUILD.po= $(XGETTEXT) $(XGETFLAGS) -d $(<F) $<.i ;\
	$(RM)	$@ ;\
	$(SED) "/^domain/d" < $(<F).po > $@ ;\
	$(RM) $(<F).po $<.i

#
# This is overwritten by local Makefile when PROG is a list.
#
POFILE= $(PROG).po

sparc_CCFLAGS=		-m32 mcpu=v8 mno-v8plus \
			-mtunesupersparc \
			$(CCERRWARN)
sparcv9_CCFLAGS=	$(sparcv9_XARCH) \
			$(CCERRWARN)
i386_CCFLAGS=		$(i386_XARCH) $(CCERRWARN)
amd64_CCFLAGS=		$(amd64_XARCH) \
			$(CCERRWARN)

sparc_CCOPTFLAG=	-O
sparcv9_CCOPTFLAG=	-O
i386_CCOPTFLAG=		-O
amd64_CCOPTFLAG=	-O

CCOPTFLAG=	$($(MACH)_CCOPTFLAG)
CCOPTFLAG64=	$($(MACH64)_CCOPTFLAG)
CCFLAGS=	$(CCOPTFLAG) $($(MACH)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
		$(CCUSERFLAGS)
CCFLAGS64=	$(CCOPTFLAG64) $($(MACH64)_CCFLAGS) $(CCSOURCEDEBUGFLAGS) \
		$(CCUSERFLAGS64)

#
#
#
ELFWRAP_FLAGS	=
ELFWRAP_FLAGS64	=	-64

#
# Various mapfiles that are used throughout the build, and delivered to
# /usr/lib/ld.
#
MAPFILE.PGA =		$(SRC)/common/mapfiles/common/map.pagealign
MAPFILE.FLT =		$(SRC)/common/mapfiles/common/map.filter
MAPFILE.LEX =		$(SRC)/common/mapfiles/common/map.lex.yy

#
# Generated mapfiles that are compiler specific, and used throughout the
# build.  These mapfiles are not delivered in /usr/lib/ld.
#
MAPFILE.NGB_sparc=	$(SRC)/common/mapfiles/gen/sparc_gcc_map.noexeglobs
MAPFILE.NGB_sparcv9=	$(SRC)/common/mapfiles/gen/sparcv9_gcc_map.noexeglobs
MAPFILE.NGB_i386=	$(SRC)/common/mapfiles/gen/i386_gcc_map.noexeglobs
MAPFILE.NGB_amd64=	$(SRC)/common/mapfiles/gen/amd64_gcc_map.noexeglobs
MAPFILE.NGB =		$(MAPFILE.NGB_$(MACH))

#
# A generic interface mapfile name, used by various dynamic objects to define
# the interfaces and interposers the object must export.
#
MAPFILE.INT =		mapfile-intf

#
# LDLIBS32 and LDLIBS64 can be set in the environment to override the following
# assignments.
#
LDLIBS32 =	$(ENVLDLIBS1) $(ENVLDLIBS2) $(ENVLDLIBS3)
LDLIBS32 +=	$(ADJUNCT_PROTO:%=-L%/usr/lib -L%/lib)
LDLIBS.cmd = 	$(LDLIBS32)
LDLIBS.lib =	$(LDLIBS32)

LDLIBS64 =	$(ENVLDLIBS1:%=%/$(MACH64)) \
		$(ENVLDLIBS2:%=%/$(MACH64)) \
		$(ENVLDLIBS3:%=%/$(MACH64))
LDLIBS64 +=     $(ADJUNCT_PROTO:%=-L%/usr/lib/$(MACH64) -L%/lib/$(MACH64))

#
# Define compilation macros.
#
COMPILE.c=	$(CC) $(CFLAGS) $(CPPFLAGS) -c
COMPILE64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) -c
COMPILE.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) -c
COMPILE64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) -c
COMPILE.s=	$(AS) $(ASFLAGS) $(AS_CPPFLAGS)
COMPILE32.s=	$(AS) $(ASFLAGS) $($(MACH32)_AS_XARCH) $(AS_CPPFLAGS)
COMPILE64.s=	$(AS) $(ASFLAGS) $($(MACH64)_AS_XARCH) $(AS_CPPFLAGS)
COMPILE.d=	$(DTRACE) -G -32
COMPILE64.d=	$(DTRACE) -G -64
COMPILE.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))
COMPILE64.b=	$(ELFWRAP) $(ELFWRAP_FLAGS$(CLASS))

#
# Link time macros
#
CCNEEDED	= -L$(GCCLIBDIR) -lstdc++ -lgcc
CCEXTNEEDED	= $(CCNEEDED)

LINK.c=		$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
LINK64.c=	$(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
LINK.cc=	$(CCC) $(CCFLAGS) $(CPPFLAGS) \
		$(LDFLAGS) $(CCNEEDED)
LINK64.cc=	$(CCC) $(CCFLAGS64) $(CPPFLAGS) \
		$(LDFLAGS) $(CCNEEDED)

SECLEVEL=	core

NATIVE_MACH=	$(MACH64)

# Define native compilation macros
#

# Base directory where compilers are located.
# Defined here so it can be overridden by developers.
#
GNU_ROOT=		/usr

BASIC_CC_ARGS=	-fident \
		-finline \
		-fno-inline-functions \
		-fno-builtin \
		-fno-asm \
		-fdiagnostics-show-option

# The SPARC ldd and std instructions require 8-byte alignment of their
# address operand.  gcc correctly uses them only when the ABI requires
# 8-byte alignment; unfortunately we have a number of pieces of buggy code
# that does not conform to the ABI.  This flag makes gcc work more like
# Studio with -xmemalign=4.
$(SPARC_BLD)BASIC_CC_ARGS += mno-integer-ldd-std

BASIC_CC_ARGS += -D__sun

BASIC_AS_ARGS=	-x assembler-with-cpp \
		-c \
		-Wa,--warn \
		-Wa,--fatal-warnings \
		-Wa,--traditional-format \
		-D__GNUC_AS__

# Specify platform compiler versions for languages
# that we use (currently only c and c++).
#
sparc_CC=		/usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
sparc_CCC=		/usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
sparc_CPP=		$(GNUC_ROOT)/bin/cpp
sparc_AS=		/usr/bin/as -xregsym=no
sparc_LD=		/usr/bin/ld.sun

sparcv9_CC=		/usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS)
sparcv9_CCC=		/usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
sparcv9_CPP=		$(GNUC_ROOT)/bin/cpp
sparcv9_AS=		/usr/bin/as -xregsym=no
sparcv9_LD=		/usr/bin/ld.sun

i386_CC=		/usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS) -nodefaultlibs
i386_CCC=		/usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
i386_CPP=		$(GNUC_ROOT)/bin/cpp
i386_AS=		$(GNUC_ROOT)/bin/gcc $(BASIC_AS_ARGS)
i386_LD=		/usr/bin/ld.sun

amd64_CC=		/usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/gcc $(BASIC_CC_ARGS) -nodefaultlibs
amd64_CCC=		/usr/libexec/unleashed/gcc-wrap $(GNUC_ROOT)/bin/g++ $(BASIC_CC_ARGS)
amd64_CPP=		$(GNUC_ROOT)/bin/cpp
amd64_AS=		$(GNUC_ROOT)/bin/gcc $(BASIC_AS_ARGS)
amd64_LD=		/usr/bin/ld.sun

NATIVECC=		$($(NATIVE_MACH)_CC)
NATIVECCC=		$($(NATIVE_MACH)_CCC)
NATIVECPP=		$($(NATIVE_MACH)_CPP)
NATIVEAS=		$($(NATIVE_MACH)_AS)
NATIVELD=		$($(NATIVE_MACH)_LD)

#
# Makefile.master.64 overrides these settings
#
CC=			$(NATIVECC)
CCC=			$(NATIVECCC)
CPP=			$(NATIVECPP)
AS=			$(NATIVEAS)
LD=			$(NATIVELD)

CCYFLAG=	-nostdinc

LD_BDIRECT=	-Bdirect
LD_BDYNAMIC=	-Bdynamic
LD_BLOCAL=	-Blocal
LD_BNODIRECT=	-Bnodirect
LD_BREDUCE=	-Breduce
LD_BSTATIC=	-Bstatic

BDIRECT=	$(LD_BDIRECT:%=-Wl,%)
BDYNAMIC=	$(LD_BDYNAMIC:%=-Wl,%)
BLOCAL=		$(LD_BLOCAL:%=-Wl,%)
BNODIRECT=	$(LD_BNODIRECT:%=-Wl,%)
BREDUCE=	$(LD_BREDUCE:%=-Wl,%)
BSTATIC=	$(LD_BSTATIC:%=-Wl,%)

LD_ZDEFS=		-zdefs
LD_ZDIRECT=		-zdirect
LD_ZIGNORE=		-zignore
LD_ZINITFIRST=		-zinitfirst
LD_ZINTERPOSE=		-zinterpose
LD_ZLAZYLOAD=		-zlazyload
LD_ZLOADFLTR=		-zloadfltr
LD_ZNODEFS=		-znodefs
LD_ZNODELETE=		-znodelete
LD_ZNODLOPEN=		-znodlopen
LD_ZNODUMP=		-znodump
LD_ZNOLAZYLOAD=		-znolazyload
LD_ZNOLDYNSYM=		-znoldynsym
LD_ZNORELOC=		-znoreloc
LD_ZNOVERSION=		-znoversion
LD_ZRECORD=		-zrecord
LD_ZTEXT=		-ztext

ZDEFS=		$(LD_ZDEFS:%=-Wl,%)
ZDIRECT=	$(LD_ZDIRECT:%=-Wl,%)
ZIGNORE=	$(LD_ZIGNORE:%=-Wl,%)
ZINITFIRST=	$(LD_ZINITFIRST:%=-Wl,%)
ZINTERPOSE=	$(LD_ZINTERPOSE:%=-Wl,%)
ZLAZYLOAD=	$(LD_ZLAZYLOAD:%=-Wl,%)
ZLOADFLTR=	$(LD_ZLOADFLTR:%=-Wl,%)
ZNODEFS=	$(LD_ZNODEFS:%=-Wl,%)
ZNODELETE=	$(LD_ZNODELETE:%=-Wl,%)
ZNODLOPEN=	$(LD_ZNODLOPEN:%=-Wl,%)
ZNODUMP=	$(LD_ZNODUMP:%=-Wl,%)
ZNOLAZYLOAD=	$(LD_ZNOLAZYLOAD:%=-Wl,%)
ZNOLDYNSYM=	$(LD_ZNOLDYNSYM:%=-Wl,%)
NORELOC=	$(LD_ZNORELOC:%=-Wl,%)
ZNOVERSION=	$(LD_ZNOVERSION:%=-Wl,%)
ZRECORD=	$(LD_ZRECORD:%=-Wl,%)
ZTEXT=		$(LD_ZTEXT:%=-Wl,%)

GSHARED=	-shared

# Handle different PIC models on different ISAs
# (May be overridden by lower-level Makefiles)

sparc_C_PICFLAGS =	-fpic
sparcv9_C_PICFLAGS =	-fpic
i386_C_PICFLAGS =	-fpic
amd64_C_PICFLAGS =	-fpic
C_PICFLAGS =		$($(MACH)_C_PICFLAGS)
C_PICFLAGS64 =		$($(MACH64)_C_PICFLAGS)

sparc_C_BIGPICFLAGS =	-fPIC
sparcv9_C_BIGPICFLAGS =	-fPIC
i386_C_BIGPICFLAGS =	-fPIC
amd64_C_BIGPICFLAGS =	-fPIC
C_BIGPICFLAGS =		$($(MACH)_C_BIGPICFLAGS)
C_BIGPICFLAGS64 =	$($(MACH64)_C_BIGPICFLAGS)

# CC requires there to be no space between '-K' and 'pic' or 'PIC'.
sparc_CC_PICFLAGS =	-fpic
sparcv9_CC_PICFLAGS =	-fPIC
i386_CC_PICFLAGS = 	-fpic
amd64_CC_PICFLAGS = 	-fpic
CC_PICFLAGS =		$($(MACH)_CC_PICFLAGS)
CC_PICFLAGS64 =		$($(MACH64)_CC_PICFLAGS)

AS_PICFLAGS=
AS_BIGPICFLAGS=

#
# Default label for CTF sections
#
CTFCVTFLAGS=		-i -L VERSION

#
# Override to pass module-specific flags to ctfmerge.  Currently used only by
# krtld to turn on fuzzy matching, and source-level debugging to inhibit
# stripping.
#
CTFMRGFLAGS=

CTFCONVERT_O		= $(CTFCONVERT) $(CTFCVTFLAGS) $@

# Rules (normally from make.rules) and macros which are used for post
# processing files. Normally, these do stripping of the comment section
# automatically.
#    RELEASE_CM:	Should be editted to reflect the release.
#    POST_PROCESS_O:	Post-processing for `.o' files.
#    POST_PROCESS_A:	Post-processing for `.a' files (currently null).
#    POST_PROCESS_SO:	Post-processing for `.so' files.
#    POST_PROCESS:	Post-processing for executable files (no suffix).
# Note that these macros are not completely generalized as they are to be
# used with the file name to be processed following.
#
# It is left as an exercise to Release Engineering to embellish the generation
# of the release comment string.
#
#	If this is a standard development build:
#		compress the comment section (mcs -c)
#		add the standard comment (mcs -a $(RELEASE_CM))
#		add the development specific comment (mcs -a $(DEV_CM))
#
#	If this is an installation build:
#		delete the comment section (mcs -d)
#		add the standard comment (mcs -a $(RELEASE_CM))
#		add the development specific comment (mcs -a $(DEV_CM))
#
#	If this is an release build:
#		delete the comment section (mcs -d)
#		add the standard comment (mcs -a $(RELEASE_CM))
#
# The following list of macros are used in the definition of RELEASE_CM
# which is used to label all binaries in the build:
#
# 	RELEASE		Specific release of the build, eg: 5.2
#	RELEASE_MAJOR	Major version number part of $(RELEASE)
#	RELEASE_MINOR	Minor version number part of $(RELEASE)
#	VERSION		Version of the build (alpha, beta, Generic)
#	PATCHID		If this is a patch this value should contain
#			the patchid value (eg: "Generic 100832-01"), otherwise
#			it will be set to $(VERSION)
#	RELEASE_DATE	Date of the Release Build
#	PATCH_DATE	Date the patch was created, if this is blank it
#			will default to the RELEASE_DATE
#
SYSNAME=	SunOS
RELEASE_MAJOR=	5
RELEASE_MINOR=	11
RELEASE=	$(RELEASE_MAJOR).$(RELEASE_MINOR)
VERSION=	$(SYSNAME) Development
PATCHID=	$(VERSION)
RELEASE_DATE=	release date not set
PATCH_DATE=	$(RELEASE_DATE)
RELEASE_CM=	"$(SYSNAME) $(RELEASE) $(PATCHID) $(PATCH_DATE)"
DEV_CM=		"$(SYSNAME) Development: non-nightly build"

STRIP_STABS=			   $(STRIP) -x $@
$(SRCDBGBLD)STRIP_STABS=	   :

POST_PROCESS_O=         :
POST_PROCESS_A=         :
POST_PROCESS_SO=	$(STRIP_STABS)
POST_PROCESS=		$(STRIP_STABS)

#
# PKGARCHIVE specifies the default location where packages should be
# placed if built.
#
PKGARCHIVE=$(SRC)/../../packages/$(MACH)/nightly

#
# The repositories will be created with these publisher settings.  To
# update an image to the resulting repositories, this must match the
# publisher name provided to "pkg set-publisher."
#
PKGPUBLISHER=	unleashed

#	Default build rules which perform comment section post-processing.
#
.c:
	$(LINK.c) -o $@ $< $(LDLIBS)
	$(POST_PROCESS)
.c.o:
	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
	$(POST_PROCESS_O)
.c.a:
	$(COMPILE.c) -o $% $<
	$(AR) $(ARFLAGS) $@ $%
	$(RM) $%
.s.o:
	$(COMPILE.s) -o $@ $<
	$(POST_PROCESS_O)
.s.a:
	$(COMPILE.s) -o $% $<
	$(AR) $(ARFLAGS) $@ $%
	$(RM) $%
.cc:
	$(LINK.cc) -o $@ $< $(LDLIBS)
	$(POST_PROCESS)
.cc.o:
	$(COMPILE.cc) $(OUTPUT_OPTION) $<
	$(POST_PROCESS_O)
.cc.a:
	$(COMPILE.cc) -o $% $<
	$(AR) $(ARFLAGS) $@ $%
	$(RM) $%
.y:
	$(YACC.y) $<
	$(LINK.c) -o $@ y.tab.c $(LDLIBS)
	$(POST_PROCESS)
	$(RM) y.tab.c
.y.o:
	$(YACC.y) $<
	$(COMPILE.c) -o $@ y.tab.c $(CTFCONVERT_HOOK)
	$(POST_PROCESS_O)
	$(RM) y.tab.c
.l:
	$(RM) $*.c
	$(LEX.l) $< > $*.c
	$(LINK.c) -o $@ $*.c -ll $(LDLIBS)
	$(POST_PROCESS)
	$(RM) $*.c
.l.o:
	$(RM) $*.c
	$(LEX.l) $< > $*.c
	$(COMPILE.c) -o $@ $*.c $(CTFCONVERT_HOOK)
	$(POST_PROCESS_O)
	$(RM) $*.c

.bin.o:
	$(COMPILE.b) -o $@ $<
	$(POST_PROCESS_O)

.java.class:
	$(COMPILE.java) $<

# Bourne and Korn shell script message catalog build rules.
# We extract all gettext strings with sed(1) (being careful to permit
# multiple gettext strings on the same line), weed out the dups, and
# build the catalogue with awk(1).

.sh.po .ksh.po:
	$(SED) -n -e ":a" 				\
		  -e "h" 					\
		  -e "s/.*gettext *\(\"[^\"]*\"\).*/\1/p"	\
		  -e "x"					\
		  -e "s/\(.*\)gettext *\"[^\"]*\"\(.*\)/\1\2/"	\
		  -e "t a"					\
	       $< | sort -u | $(AWK) '{ print "msgid\t" $$0 "\nmsgstr" }' > $@

#
# Python and Perl executable and message catalog build rules.
#
.SUFFIXES: .pl .pm .py .pyc

.pl:
	$(RM) $@;
	$(SED) -e "s@TEXT_DOMAIN@\"$(TEXT_DOMAIN)\"@" $< > $@;
	$(CHMOD) +x $@

.py:
	$(RM) $@; $(SED) \
		-e "1s:^\#!@PYTHON@:\#!$(PYSHEBANG):" \
		-e "1s:^\#!@TOOLS_PYTHON@:\#!$(TOOLS_PYTHON):" \
		< $< > $@; $(CHMOD) +x $@

.py.pyc:
	$(RM) $@
	$(PYTHON) -mpy_compile $<
	@[ $(<)c = $@ ] || $(MV) $(<)c $@

.pl.po .pm.po:
	$(XGETTEXT) $(XGETFLAGS) -d $(<F) $< ;
	$(RM)	$@ ;
	$(SED) "/^domain/d" < $(<F).po > $@ ;
	$(RM) $(<F).po

#
# When using xgettext, we want messages to go to the default domain,
# rather than the specified one.  This special version of the
# COMPILE.cpp macro effectively prevents expansion of TEXT_DOMAIN,
# causing xgettext to put all messages into the default domain.
#
CPPFORPO=$(COMPILE.cpp:\"$(TEXT_DOMAIN)\"=TEXT_DOMAIN)

.c.i:
	$(CPPFORPO) $< > $@

.h.i:
	$(CPPFORPO) $< > $@

.y.i:
	$(YACC) -d $<
	$(CPPFORPO) y.tab.c  > $@
	$(RM) y.tab.c

.l.i:
	$(LEX) $<
	$(CPPFORPO) lex.yy.c  > $@
	$(RM) lex.yy.c

.c.po:
	$(CPPFORPO) $< > $<.i
	$(BUILD.po)

.cc.po:
	$(CPPFORPO) $< > $<.i
	$(BUILD.po)

.y.po:
	$(YACC) -d $<
	$(CPPFORPO) y.tab.c  > $<.i
	$(BUILD.po)
	$(RM) y.tab.c

.l.po:
	$(LEX) $<
	$(CPPFORPO) lex.yy.c  > $<.i
	$(BUILD.po)
	$(RM) lex.yy.c

#
# Rules to perform stylistic checks
#
.SUFFIXES: .x .xml .check .xmlchk

.h.check:
	$(DOT_H_CHECK)

.x.check:
	$(DOT_X_CHECK)

.xml.xmlchk:
	$(MANIFEST_CHECK)