472N/A# -*- Makefile -*- rules commonly shared among X consolidation open source dirs
472N/A# Copyright (c) 2008, 2015, Oracle
and/or its affiliates. All rights reserved.
472N/A# Permission is hereby granted, free of charge, to any person obtaining a
472N/A# copy of this software and associated documentation files (the "Software"),
919N/A# to deal in the Software without restriction, including without limitation
919N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
919N/A#
and/or sell copies of the Software, and to permit persons to whom the
919N/A# Software is furnished to do so, subject to the following conditions:
919N/A# The above copyright notice and this permission notice (including the next
919N/A# paragraph) shall be included in all copies or substantial portions of the
919N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
919N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
919N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
919N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
919N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
919N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
919N/A# DEALINGS IN THE SOFTWARE.
472N/A# Use ksh93 for shell commands in Makefiles so that builds are the same
472N/A# on Nevada (where
/bin/sh is still ancient Bourne shell) and Indiana
970N/A# The declaration POUND_SIGN is always '#'. This is needed to get around the
970N/A# make feature that '#' is always a comment delimiter, even when escaped or
1003N/A# quoted. We use this macro expansion method to get POUND_SIGN rather than
1003N/A# always breaking out a shell because the general case can cause a noticable
493N/APOUND_SIGN= $(PRE_POUND:pre\%=%)
493N/A# Set default build target to all
472N/A# The infrastructure in the main tree requires Solaris make
493N/A# Different builders want different settings for various options such
472N/A# as branding or download sites. The top-level "make setup" command
970N/A### Machine architecture macros
472N/A# MACH will be either "sparc" or "i386"
MACH32= $(MACH32_$(MACH))
MACH64= $(MACH64_$(MACH))
# Architecture subdirectories
SUBDIR32 = $(SUBDIR32_$(MACH))
SUBDIR64 = $(SUBDIR64_$(MACH))
LIBSUBDIR = $(LIBSUBDIR_$(BUILD_TYPE))
LIBSUBDIR_64 = /$(SUBDIR64)
ARCHLIBSUBDIR = $(LIBSUBDIR)
### Default compiler & options
# Our default compiler is Solaris 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.
# Flags used by either compiler in debug builds
DEBUG_FLAGS_common = -g $(MODTYPE_DEBUG_FLAGS) $(MODULE_DEBUG_FLAGS)
## Solaris Studio compilers
OPT_FLAGS_suncc = -xO4 -xbuiltin=%none -xlibmil -xprefetch -xdepend
OPT_FLAGS_suncc += -xspace -W0,-xglobalstatic
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)
CFLAGS_suncc += -v -xstrconst -features=extensions
CXXFLAGS_suncc = $(DEBUG_OR_OPT_FLAGS_suncc)
CXXFLAGS_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
ARCH_LIB_FLAGS_sparc_suncc = -xregs=no%appl
ARCH_LIB_FLAGS_i386_suncc =
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 =
CC_suncc_parfait = parfait-cc
CXX_suncc_parfait = parfait-CC
CC_gcc_parfait = parfait-gcc
CXX_gcc_parfait = parfait-g++
# If USE_PARFAIT is yes, use _parfait variants
PARFAIT_1 = $(USE_PARFAIT:no=)
PARFAIT_2 = $(PARFAIT_1:yes=$(POUND_SIGN))
$(PARFAIT_2) WITH_PARFAIT=$(POUND_SIGN)
$(WITH_PARFAIT) WITHOUT_PARFAIT=$(POUND_SIGN)
$(WITH_PARFAIT) CHOSEN_COMPILER=$(MODULE_COMPILER)_parfait
$(WITHOUT_PARFAIT) CHOSEN_COMPILER=$(MODULE_COMPILER)
$(WITH_PARFAIT) AR=$(AR_parfait)
$(WITH_PARFAIT) AS=$(AS_parfait)
$(WITH_PARFAIT) LD=$(LD_parfait)
# Additional environment variables needed to build with parfait
PARFAIT_ENV_gcc = PARFAIT_NATIVEGCC="$(GCC)"
PARFAIT_ENV_gcc += PARFAIT_NATIVEGXX="$(GXX)"
PARFAIT_ENV = $(PARFAIT_ENV_$(MODULE_COMPILER))
## Set common variables based on above rules
CC = $(CC_$(CHOSEN_COMPILER))
CXX = $(CXX_$(CHOSEN_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 = $(CPPFLAGS)
LIB_CFLAGS = $(CFLAGS) $(ARCH_LIB_FLAGS)
LIB_CXXFLAGS = $(CXXFLAGS) $(ARCH_LIB_FLAGS)
PROG_CPPFLAGS = $(CPPFLAGS) -DFD_SETSIZE=$(FD_SETSIZE)
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 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_NOEXDATA_sparc = $(MAPFILE_NOEXBSS)
MAPFILE_NOEXDATA = $(MAPFILE_NOEXDATA_$(MACH))
MAPFILES_FOR_ALL = $(MAPFILE_PAGEALIGN) $(MAPFILE_NOEXDATA)
MAPFILES_FOR_PROGS = $(MAPFILE_HEAPALIGN) $(MAPFILE_NOEXBSS)
# Security Extensions file tagging.
# Security Extensions can be explicitly controlled at the binary level via
# tagging. Binaries built with -z <extension>=enable will have the extension
# enabled in the 'tagged-files' model, while binaries built with
# -z <extension>=disable will have it disabled regardless of the model.
# Currently supported extensions are:
# -z aslr Address Space Layout Randomization
# -z nxstack Non-executable Stack
# -z nxheap Non-executable Heap
# -z aslr|nxstack|nxheap are only valid when linking executables.
ZASLR_ENABLE= -z aslr=enable
ZASLR_DISABLE= -z aslr=disable
ZNXSTACK_ENABLE= -z nxstack=enable
ZNXSTACK_DISABLE= -z nxstack=disable
ZNXSTACK= $(ZNXSTACK_ENABLE)
ZNXHEAP_ENABLE= -z nxheap=enable
ZNXHEAP_DISABLE= -z nxheap=disable
ZNXHEAP= $(ZNXHEAP_ENABLE)
# Flags to discard at link time unnecessary dependencies, .o files or
# ELF sections that upstream may have included that we don't use.
ZDISCARD_UNUSED_DEP = -zdiscard-unused=dependencies
ZDISCARD_UNUSED_FIL = -zdiscard-unused=files
ZDISCARD_UNUSED_SEC = -zdiscard-unused=sections
# Common flags for all binaries
DEFAULT_LD_OPTIONS = -z lazyload -B direct -z guidance
DEFAULT_LD_OPTIONS += $(MAPFILES_FOR_ALL)
DEFAULT_LD_OPTIONS += -L$(PROTODIR)$(X11_DIR)/lib$(LIBSUBDIR)
# Strip debug info out of non-debug builds
$(BUILD_DEBUG:yes=$(POUND_SIGN)) DEFAULT_LD_OPTIONS += -z strip-class=debug
DEFAULT_LD_OPTIONS_gcc = $(ZDISCARD_UNUSED_DEP) $(ZDISCARD_UNUSED_FIL)
DEFAULT_LD_OPTIONS += $(DEFAULT_LD_OPTIONS_$(MODULE_COMPILER))
# Ensure required flags for .so's are applied, despite libtool interference
DEFAULT_LD_SHARED_OPTIONS = -z text -z defs
# Ensure we do ASLR tagging & mark
stacks/heaps non-executable on programs
DEFAULT_LD_EXEC_OPTIONS = $(ZASLR) $(ZNXHEAP) $(ZNXSTACK) $(MAPFILES_FOR_PROGS)
## 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)
# Proto directory to install into for packaging
PROTODIR=$(PROTOTOP)/root_$(MACH)
PROTODIR_DEBUG=$(PROTOTOP)/root_$(MACH)-debug
PROTOMETA=$(PROTOTOP)/metadata_$(MACH)
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
X11_FONT_DIR=$(SHARE_FONT_DIR)/X11
TRUETYPE_FONT_DIR=$(SHARE_FONT_DIR)/TrueType
# 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_DIR=$(X11_LIB_DIR)$(X11_SERVERMODS_SUBDIR)
# PKGCONFIG_DIR is constructed of _prefix + ARCHLIBSUBDIR + _suffix
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)
# System-wide directory for packaged release notes
# Directory used for installing tools used during build but not
TOOLS_DIR=$(PROTOTOP)/tools_$(MACH)
# Work around _TIME, _DATE, embedded date chatter in component builds
# to use, set TIME_CONSTANT in the component Makefile and add $(CONSTANT_TIME)
CONSTANT_TIME = LD_PRELOAD_32=$(TOOLS_DIR)/time-$(MACH32).so
CONSTANT_TIME += LD_PRELOAD_64=$(TOOLS_DIR)/time-$(MACH64).so
CONSTANT_TIME += TIME_CONSTANT=$(TIME_CONSTANT)
### Other tools needed to build
# When changing PYTHON_VERSION, check that PYTHON_PKG_VERSION &
# PYTHON_PATH_VERSION are still set correctly in
pkg/Makefile# We want our python modules installed to vendor-packages, not site-packages
# When changing PERL_VERSION, check that PERL_PKG_VERSION is
# perl -p/-n commands treat missing files as warnings, not fatal errors
# Adding the following raises them to errors so that make detects a problem
PERL_MISSING_FILES_ERROR = -e 'BEGIN {$$SIG{__WARN__} = sub { die $$_[0] };}'
# Script used to install files in proto area
# Some modules (such as FreeType 2) require GNU make
# Pick a version of GNU automake, since Solaris includes multiple ones
# 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
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
# it directly here, instead of futzing with command paths in the script
MKFONTDIR=$(MKFONTSCALE) -b -s -l
# 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
START_CMD_ECHO = PS4="" ; set -x
### Sources, in-tree and upstream
# If you need to use a closer mirror for
X.Org or SourceForge, override
XRU_DEFAULT = $(XORG_RELEASES_URL_SET:yes=$(POUND_SIGN))
SFU_DEFAULT = $(SF_DOWNLOADS_URL_SET:yes=$(POUND_SIGN))
FDO_GIT_DEFAULT = $(FDO_GIT_URL_SET:yes=$(POUND_SIGN))
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)
# Most module versions are in the individual makefiles, but the Xserver is
# referenced in multiple places, so it's kept here for easy sharing.
# Current Xorg server source tarball to use sources from:
# Minimum Xorg server version that we expect to be ABI compatible with.
# Usually .99 of the previous minor release series, as that's the convention
# for the development snapshots of the next release series.
# Next highest Xorg server version that we expect to be ABI incompatible with.
# Usually .99 of the current release series, as Xorg tends to break ABI's
# in each minor release train (1.8, 1.9, etc.)
NEXT_XSERVER_VERS=1.14.99
# Version of pkgfmt output rules to apply
# 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 -n ' $(@:print_make_var-%=%)="$($(@:print_make_var-%=%))"'
print_make_vars: $(VARS:%=print_make_var-%)