7071400 X gate needs to workaround -xregs=no%appl bug 7030022 in Studio 12.1 compilers
# -*- Makefile -*- rules commonly shared among X consolidation open source dirs
# Makefile.init has definitions that are needed before the module/modtype rules
#
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#
# Use ksh93 for shell commands in Makefiles so that builds are the same
# on Nevada (where /bin/sh is still ancient Bourne shell) and Indiana
# (where /bin/sh is ksh93)
SHELL=/usr/bin/ksh93
# Borrowed from Solaris OS/Net makefile.master:
# The declaration POUND_SIGN is always '#'. This is needed to get around the
# make feature that '#' is always a comment delimiter, even when escaped or
# quoted. We use this macro expansion method to get POUND_SIGN rather than
# always breaking out a shell because the general case can cause a noticable
# slowdown in build times when so many Makefiles include Makefile.init.
#
PRE_POUND= pre\#
POUND_SIGN= $(PRE_POUND:pre\%=%)
# Set default build target to all
default: all
# The infrastructure in the main tree requires Solaris make
$(error You must use Solaris make, not GNU make in this build - make sure /usr/ccs/bin or /usr/bin is ahead of /usr/gnu/bin in $$PATH)
### Build options
# Different builders want different settings for various options such
# as branding or download sites. The top-level "make setup" command
# sets the Makefile.options link to point to a included Makefile to
# set these up.
include "Makefile.options"
### Machine architecture macros
# MACH will be either "sparc" or "i386"
MACH=$(TARGET_ARCH:-%=%)
MACH32_sparc = sparc
MACH64_sparc = sparcv9
MACH32_i386 = i386
MACH64_i386 = amd64
MACH32= $(MACH32_$(MACH))
MACH64= $(MACH64_$(MACH))
# Architecture subdirectories
SUBDIR32_sparc = sparcv8
SUBDIR64_sparc = sparcv9
SUBDIR32_i386 = i86
SUBDIR64_i386 = amd64
SUBDIR32 = $(SUBDIR32_$(MACH))
SUBDIR64 = $(SUBDIR64_$(MACH))
LIBSUBDIR = $(LIBSUBDIR_$(BUILD_TYPE))
LIBSUBDIR_32 = # None
LIBSUBDIR_64 = /$(SUBDIR64)
ARCHLIBSUBDIR = $(LIBSUBDIR)
### Default compiler & options
# Our default compiler is Sun Studio, but if you want to default to GNU
# compilers, you can change this here - some modules with specific
# requirements override this in their makefiles with MODULE_COMPILER.
DEFAULT_COMPILER = suncc
# Flags used by either compiler in debug builds
DEBUG_FLAGS_common = -g $(MODTYPE_DEBUG_FLAGS) $(MODULE_DEBUG_FLAGS)
## Sun Studio
CC_suncc = cc
CXX_suncc = CC
OPT_FLAGS_suncc = -xO4 -W2,-Rext_tail_dup -xbuiltin=%none -xlibmil -xprefetch \
-xdepend -xspace
DEBUG_FLAGS_suncc = $(DEBUG_FLAGS_common)
$(BUILD_DEBUG:yes=) DEBUG_OR_OPT_FLAGS_suncc = $(DEBUG_FLAGS_suncc)
$(BUILD_DEBUG:yes=$(POUND_SIGN)) DEBUG_OR_OPT_FLAGS_suncc = $(OPT_FLAGS_suncc)
CFLAGS_suncc = $(DEBUG_OR_OPT_FLAGS_suncc) -v -xstrconst \
-features=extensions
CXXFLAGS_suncc = $(DEBUG_OR_OPT_FLAGS_suncc) +w2 -norunpath \
-features=extensions
# -D__<arch>__ flags are to match gcc definitions that are used in much
# of the upstream open source code base
ARCH_FLAGS_sparc_suncc = -xarch=sparc -D__sparc__
ARCH32_FLAGS_sparc_suncc = -m32
ARCH64_FLAGS_sparc_suncc = -m64
# -xregs=no%frameptr is required on x86 when compiling at -xO4 or higher to
# avoid losing stack frame pointers so you can't get stack traces or debug
ARCH_FLAGS_i386_suncc = -xregs=no%frameptr
ARCH32_FLAGS_i386_suncc = -m32 -xarch=sse2 -D__i386__
ARCH64_FLAGS_i386_suncc = -m64 -xarch=sse2 -D__amd64__
# SPARC ABI requires system libraries not use application registers
# The normal/documented flag for this is -xregs=no%appl, but for now,
# we use "-Qoption cg -xregs=no%appl" to workaround bug 7030022 in
# the Studio 12.1 compilers that fails to honor the normal option.
ARCH_LIB_FLAGS_sparc_suncc = -Qoption cg -xregs=no%appl
ARCH_LIB_FLAGS_i386_suncc =
## GNU Compilers
GCC = /usr/sfw/bin/gcc
GXX = /usr/sfw/bin/g++
CC_gcc = $(GCC)
CXX_gcc = $(GXX)
OPT_FLAGS_gcc = -O3
DEBUG_FLAGS_gcc = $(DEBUG_FLAGS_common)
$(BUILD_DEBUG:yes=) DEBUG_OR_OPT_FLAGS_gcc = $(DEBUG_FLAGS_gcc)
$(BUILD_DEBUG:yes=$(POUND_SIGN)) DEBUG_OR_OPT_FLAGS_gcc = $(OPT_FLAGS_gcc)
WARNFLAGS_gcc = -Wall -Wno-unknown-pragmas
CFLAGS_gcc = $(DEBUG_OR_OPT_FLAGS_gcc) \
-fno-omit-frame-pointer $(WARNFLAGS_gcc)
CXXFLAGS_gcc = $(DEBUG_OR_OPT_FLAGS_gcc) \
-fno-omit-frame-pointer $(WARNFLAGS_gcc)
ARCH32_FLAGS_sparc_gcc = -mcpu=ultrasparc -m32
ARCH64_FLAGS_sparc_gcc = -mcpu=ultrasparc -m64
ARCH32_FLAGS_i386_gcc = -march=pentium4 -m32
ARCH64_FLAGS_i386_gcc = -march=opteron -m64
# SPARC ABI requires system libraries not use application registers
ARCH_LIB_FLAGS_sparc_gcc = -mno-app-regs
ARCH_LIB_FLAGS_i386_gcc =
## Set common variables based on above rules
CC = $(CC_$(MODULE_COMPILER))
CXX = $(CXX_$(MODULE_COMPILER))
CFLAGS = $(CFLAGS_$(MODULE_COMPILER)) $(ARCH_FLAGS)
CXXFLAGS = $(CXXFLAGS_$(MODULE_COMPILER)) $(ARCH_FLAGS)
ARCH32_FLAGS = $(ARCH32_FLAGS_$(MACH)_$(MODULE_COMPILER))
ARCH32_FLAGS += $(ARCH_FLAGS_$(MACH)_$(MODULE_COMPILER))
ARCH64_FLAGS = $(ARCH64_FLAGS_$(MACH)_$(MODULE_COMPILER))
ARCH64_FLAGS += $(ARCH_FLAGS_$(MACH)_$(MODULE_COMPILER))
ARCH_LIB_FLAGS = $(ARCH_LIB_FLAGS_$(MACH)_$(MODULE_COMPILER))
# Flags for specific binary types
LIB_CPPFLAGS = -D_REENTRANT
LIB_CFLAGS = $(CFLAGS) $(ARCH_LIB_FLAGS)
LIB_CXXFLAGS = $(CXXFLAGS) $(ARCH_LIB_FLAGS)
PROG_CPPFLAGS = -DFD_SETSIZE=$(FD_SETSIZE)
PROG_CFLAGS = $(CFLAGS)
PROG_CXXFLAGS = $(CXXFLAGS)
# Default FD_SETSIZE - 1024 was the 32-bit default and was big enough
# <sys/select.h> makes the 64-bit default be 65536 which is way too big,
# and eats a lot of memory for fd_sets and cpu doing operations on them
FD_SETSIZE_DEFAULT = $(FD_SETSIZE_SET:yes=$(POUND_SIGN))
$(FD_SETSIZE_DEFAULT) FD_SETSIZE = 1024
### Linker flags
# Linker mapfiles to link with for better performance & security
# SPARC architecture requires PLT section in .data be executable, so
# we can only make .bss, not all of .data no-exec on SPARC
MAPFILE_NOEXBSS = -M /usr/lib/ld/map.noexbss
MAPFILE_NOEXDATA_sparc = $(MAPFILE_NOEXBSS)
MAPFILE_NOEXDATA_i386 = -M /usr/lib/ld/map.noexdata
MAPFILE_NOEXDATA = $(MAPFILE_NOEXDATA_$(MACH))
MAPFILE_NOEXSTACK = -M /usr/lib/ld/map.noexstk
MAPFILE_PAGEALIGN = -M /usr/lib/ld/map.pagealign
MAPFILE_HEAPALIGN = -M /usr/lib/ld/map.bssalign
MAPFILES_FOR_ALL = $(MAPFILE_PAGEALIGN) $(MAPFILE_NOEXDATA)
MAPFILES_FOR_PROGS = $(MAPFILE_HEAPALIGN) $(MAPFILE_NOEXSTACK) \
$(MAPFILE_NOEXBSS)
# Common flags for all binaries
LDFLAGS_common = -z combreloc -z lazyload $(MAPFILES_FOR_ALL)
# LIB_REQUIRED_LDFLAGS are forced on via LD_OPTIONS to override libtool when
# building libraries.
LIB_REQUIRED_LDFLAGS = -z text -z defs
LIB_LDFLAGS_common = $(LDFLAGS_common) $(LIB_REQUIRED_LDFLAGS)
# Flags for programs
PROG_LDFLAGS_common = $(LDFLAGS_common) $(MAPFILES_FOR_PROGS) -B direct
# Sun Studio recognizes the common linker flags without -Wl, and
# Sun Studio CC can't handle -Wl,-flag,option format, so just pass directly
LDFLAGS_suncc = $(LDFLAGS_common)
LIB_LDFLAGS_suncc = $(LIB_LDFLAGS_common)
PROG_LDFLAGS_suncc = $(PROG_LDFLAGS_common)
# gcc requires additional library path for libgcc_s.so
DEFAULT_LDFLAGS_gcc = -L/usr/sfw/lib$(ARCHLIBSUBDIR) \
-R/usr/sfw/lib$(ARCHLIBSUBDIR)
# Need to use -Wl,.. to pass linker flags through gcc
GCC_CONVERT_LDFLAGS_CMD=sed -e 's/-M /-Wl,-M,/g' -e 's/-B /-Wl,-B,/g'
GCC_LDFLAGS_CMD=echo $(LDFLAGS_common) | $(GCC_CONVERT_LDFLAGS_CMD)
LDFLAGS_gcc=$(GCC_LDFLAGS_CMD:sh) $(DEFAULT_LDFLAGS_gcc)
GCC_LIB_LDFLAGS_CMD=echo $(LIB_LDFLAGS_common) | $(GCC_CONVERT_LDFLAGS_CMD)
LIB_LDFLAGS_gcc=$(GCC_LIB_LDFLAGS_CMD:sh)
GCC_PROG_LDFLAGS_CMD=echo $(PROG_LDFLAGS_common) | $(GCC_CONVERT_LDFLAGS_CMD)
PROG_LDFLAGS_gcc=$(GCC_PROG_LDFLAGS_CMD:sh)
LDFLAGS=$(LDFLAGS_$(MODULE_COMPILER))
LIB_LDFLAGS=$(LIB_LDFLAGS_$(MODULE_COMPILER))
PROG_LDFLAGS=$(PROG_LDFLAGS_$(MODULE_COMPILER))
## Commonly added options
# Link with X server private libraries like libXfont & libfontenc
X11_SERVERLIBS_LDFLAGS= -L$(PROTODIR)$(X11_SERVERLIBS_DIR)$(ARCHLIBSUBDIR) \
-R$(X11_SERVERLIBS_DIR)$(ARCHLIBSUBDIR)
### Directory paths
# Proto directory to install into for packaging
PROTOTOP=$(TOP)/proto
PROTODIR=$(PROTOTOP)/root_$(MACH)
PROTOMETA=$(PROTOTOP)/metadata_$(MACH)
SMF_MANIFEST_DIR=/lib/svc/manifest
SMF_METHOD_DIR=/lib/svc/method
X11_DIR=/usr
X11_BIN_DIR=$(X11_DIR)/bin
X11_LIB_DIR=$(X11_DIR)/lib
X11_INCLUDES_DIR=$(X11_DIR)/include
XORG_SDK_INCLUDES_DIR=$(X11_INCLUDES_DIR)/xorg
X11_X11LIB_DIR=$(X11_LIB_DIR)/X11
SHARE_FONT_DIR=/usr/share/fonts
X11_FONT_DIR=$(SHARE_FONT_DIR)/X11
X11_FONT_CATALOGUE=/etc/X11/fontpath.d
TRUETYPE_FONT_DIR=$(SHARE_FONT_DIR)/TrueType
X11_DOC_DIR=/usr/share/doc/X11
X11_LOCALE_DIR=$(X11_DIR)/share/locale
X11_MAN_DIR=$(X11_DIR)/share/man
X11_ACLOCAL_DIR=$(X11_DIR)/share/aclocal
X11_LC_MESSAGES_DIR=$(X11_LOCALE_DIR)/C/LC_MESSAGES
# Subdirectory of /usr/lib for X server private libraries
X11_SERVERLIBS_SUBDIR=/xorg
X11_SERVERLIBS_DIR=$(X11_LIB_DIR)$(X11_SERVERLIBS_SUBDIR)
# Subdirectory of /usr/lib for X server loadable modules
X11_SERVERMODS_SUBDIR=/xorg/modules
X11_SERVERMODS_DIR=$(X11_LIB_DIR)$(X11_SERVERMODS_SUBDIR)
MESA_XSERVERMODS_DIR=$(X11_LIB_DIR)/mesa/modules
# PKGCONFIG_DIR is constructed of _prefix + ARCHLIBSUBDIR + _suffix
PKGCONFIG_DIR_prefix=/usr/lib
PKGCONFIG_DIR_suffix=/pkgconfig
PKGCONFIG_DIR=$(PKGCONFIG_DIR_prefix)$(ARCHLIBSUBDIR)$(PKGCONFIG_DIR_suffix)
PKGCONFIG_DIR_32=$(PKGCONFIG_DIR_prefix)$(PKGCONFIG_DIR_suffix)
PKGCONFIG_DIR_64=$(PKGCONFIG_DIR_prefix)/$(SUBDIR64)$(PKGCONFIG_DIR_suffix)
PKGCONFIG_DIR_SHARE=/usr/share$(PKGCONFIG_DIR_suffix)
# Directory used for installing tools used during build but not
# delivered in packages
TOOLS_DIR=$(PROTOTOP)/tools_$(MACH)
TOOLS_ACLOCAL_DIR=$(TOOLS_DIR)/share/aclocal
### Other tools needed to build
## Python tools & paths
# When changing PYTHON_VERSION, check that PYTHON_PKG_VERSION &
# PYTHON_PATH_VERSION are still set correctly in pkg/Makefile
PYTHON_VERSION=2.6
PYTHON=/usr/bin/python$(PYTHON_VERSION)
PYTHON_PATH=$(PROTODIR)/usr/lib/python$(PYTHON_VERSION)/vendor-packages:$(PROTODIR)/usr/lib/python$(PYTHON_VERSION)/site-packages:/usr/lib/python$(PYTHON_VERSION)/vendor-packages:/usr/lib/python$(PYTHON_VERSION)/site-packages
## Perl tools & paths
# When changing PERL_VERSION, check that PERL_PKG_VERSION is
# still set correctly in pkg/Makefile
PERL_VERSION = 5.12
PERL = /usr/perl5/$(PERL_VERSION)/bin/perl
# Script used to install files in proto area
INSTALL_SCRIPT=$(TOP)/open-src/common/install-sh -c
# Some modules (such as FreeType 2) require GNU make
GNUMAKE = gmake
# Directory to find tools used during build, even when installing to a
# temporary dest dir, such as during 'make manifest'
PROTOTOOLSDIR=$(PROTODIR)
# Some modules use lndir to merge in sources from Sun specific directories
LNDIR=$(PROTOTOOLSDIR)$(X11_BIN_DIR)/lndir
# Commands to run font utilities from proto area
MKFONTDIR=$(PROTOTOOLSDIR)$(X11_BIN_DIR)/mkfontdir
MKFONTSCALE=$(PROTOTOOLSDIR)$(X11_BIN_DIR)/mkfontscale
INSTALLALIAS=$(PROTOTOOLSDIR)$(X11_X11LIB_DIR)/installalias
FC_QUERY=$(PROTOTOOLSDIR)$(X11_BIN_DIR)/fc-query
FC_SCAN=$(PROTOTOOLSDIR)$(X11_BIN_DIR)/fc-scan
# Script fragment to start echoing commands in shell sequences in make rules
# Sets PS4 to "" so output isn't prepended with "+ " and looks like normal
# make output
START_CMD_ECHO = PS4="" ; set -x
### Sources, in-tree and upstream
TARBALLDIR=$(TOP)/open-src/tarballs
WGET=/usr/sfw/bin/wget --no-check-certificate
GIT=git
# If you need to use a closer mirror for X.Org or SourceForge, override
# these in your Makefile.options file
XRU_DEFAULT = $(XORG_RELEASES_URL_SET:yes=$(POUND_SIGN))
$(XRU_DEFAULT) XORG_RELEASES_URL=http://www.x.org/releases/individual
SFU_DEFAULT = $(SF_DOWNLOADS_URL_SET:yes=$(POUND_SIGN))
$(SFU_DEFAULT) SF_DOWNLOADS_URL=http://downloads.sourceforge.net/project
# Git repositories hosted on freedesktop.org (X.Org, Mesa, pixman, etc.)
FDO_GIT_DEFAULT = $(FDO_GIT_URL_SET:yes=$(POUND_SIGN))
$(FDO_GIT_DEFAULT) FDO_GIT_URL=http://anongit.freedesktop.org/git
XORG_GIT_DEFAULT = $(XORG_GIT_URL_SET:yes=$(POUND_SIGN))
$(XORG_GIT_DEFAULT) XORG_GIT_URL=$(FDO_GIT_URL)/xorg
# Target created when sources are unpacked
UNPACK_FILE = .unpack_done
UNPACK_TARGET = $(SOURCE_DIR)/$(UNPACK_FILE)
### Misc rules
# For use in debugging or calling from scripts like the code review helper
# Use such as: make print_make_vars VARS="MODTYPE MODULE_NAME"
# or: make print_make_vars BUILD_TYPE=32 VARS=SOURCE_DIR
print_make_var-%:
@print -n ' $(@:print_make_var-%=%)="$($(@:print_make_var-%=%))"'
print_make_vars: $(VARS:%=print_make_var-%)
@print '\n'