Makefile.inc revision 156
0N/A# -*- Makefile -*- rules commonly shared among X consolidation open source dirs
0N/A#
98N/A# Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
0N/A# Use subject to license terms.
0N/A#
0N/A# Permission is hereby granted, free of charge, to any person obtaining a
0N/A# copy of this software and associated documentation files (the
0N/A# "Software"), to deal in the Software without restriction, including
0N/A# without limitation the rights to use, copy, modify, merge, publish,
0N/A# distribute, and/or sell copies of the Software, and to permit persons
0N/A# to whom the Software is furnished to do so, provided that the above
0N/A# copyright notice(s) and this permission notice appear in all copies of
0N/A# the Software and that both the above copyright notice(s) and this
0N/A# permission notice appear in supporting documentation.
0N/A#
0N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
0N/A# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0N/A# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
0N/A# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
0N/A# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
0N/A# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
0N/A# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
0N/A# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
0N/A# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0N/A#
0N/A# Except as contained in this notice, the name of a copyright holder
0N/A# shall not be used in advertising or otherwise to promote the sale, use
0N/A# or other dealings in this Software without prior written authorization
0N/A# of the copyright holder.
0N/A#
156N/A# @(#)Makefile.inc 1.76 07/05/15
0N/A#
0N/A
156N/A# Borrowed from Solaris OS/Net makefile.master:
156N/A# The declaration POUND_SIGN is always '#'. This is needed to get around the
156N/A# make feature that '#' is always a comment delimiter, even when escaped or
156N/A# quoted. The only way of generating this is the :sh macro mechanism. Note
156N/A# however that in general :sh macros should be avoided in makefiles that are
156N/A# widely included into other makefiles, as the resulting shell executions can
156N/A# cause a noticable slowdown in build times.
156N/A#
156N/APOUND_SIGN:sh= echo \\043
156N/A
156N/A# BUILD_DATE:sh=date +'%e-%B-%Y'
156N/A# BUILD_ID = X11 for Solaris Nevada, built $(BUILD_DATE)
156N/A
156N/A### Machine architecture macros
156N/A
156N/A# MACH will be either "sparc" or "i386"
156N/AMACH:sh=uname -p
156N/A
156N/A# ARCH will be either "sun4" or "i386" - mainly used in $(PROTODIR)
156N/AARCH=$(MACH:sparc=sun4)
156N/A
156N/AMACH32_sparc = sparc
156N/AMACH64_sparc = sparcv9
156N/AMACH32_i386 = i386
156N/AMACH64_i386 = amd64
156N/A
156N/AMACH32= $(MACH32_$(MACH))
156N/AMACH64= $(MACH64_$(MACH))
0N/A
0N/A### Default compiler & options
0N/ACC = cc
90N/AGCC = /usr/sfw/bin/gcc
47N/ACXX = CC
70N/ADEFAULT_OPT_CFLAGS = -xO4 -xbuiltin -xlibmil -xprefetch \
70N/A -xdepend -xstrconst
0N/AOPT_CFLAGS = $(DEFAULT_OPT_CFLAGS)
0N/ACFLAGS = -v -mc $(OPT_CFLAGS) $(ARCH_FLAGS)
0N/ALDFLAGS = -z combreloc -z lazyload $(MAPFILES_FOR_ALL)
0N/A
0N/A### Flags for libraries to meet various Solaris requirements
0N/A#
0N/A# REQUIRED_LDFLAGS are forced on via LD_OPTIONS to override libtool when
0N/A# building libraries.
0N/A#
0N/ALIB_CFLAGS = $(CFLAGS) -D_REENTRANT $(ARCH_LIB_FLAGS)
0N/ALIB_REQUIRED_LDFLAGS = -z text -z defs
0N/ALIB_LDFLAGS = $(LDFLAGS) $(LIB_REQUIRED_LDFLAGS)
0N/A
0N/A# Flags for programs
47N/APROG_CFLAGS = $(CFLAGS)
17N/APROG_LDFLAGS = $(LDFLAGS) $(MAPFILES_FOR_PROGS) -B direct
0N/A
0N/A# Linker mapfiles to link with for better performance & security
0N/A# SPARC archicteture requires PLT section in .data be executable, so
0N/A# we can only make .bss, not all of .data no-exec on SPARC
0N/AMAPFILE_DIR = $(TOP)/common/mapfiles/
0N/AMAPFILE_NOEXBSS = $(MAPFILE_DIR)/map.noexbss
156N/AMAPFILE_NOEXDATA_sparc = $(MAPFILE_NOEXBSS)
156N/AMAPFILE_NOEXDATA_i386 = /usr/lib/ld/map.noexdata
156N/AMAPFILE_NOEXDATA = $(MAPFILE_NOEXDATA_$(MACH))
0N/A
0N/AMAPFILES_FOR_ALL = -M /usr/lib/ld/map.pagealign -M $(MAPFILE_NOEXDATA)
0N/AMAPFILES_FOR_PROGS = -M /usr/lib/ld/map.bssalign -M /usr/lib/ld/map.noexstk \
0N/A -M $(MAPFILE_NOEXBSS)
0N/A
0N/A### Architecture specific flags
156N/ADEFAULT_ARCH32_FLAGS_sparc = -xarch=v8plus
156N/ADEFAULT_ARCH64_FLAGS_sparc = -xarch=v9
156N/ADEFAULT_ARCH_LIB_FLAGS_sparc = -xregs=no%appl
0N/A
0N/A# -xregs=no%frameptr is required on x86 when compiling at -xO4 or higher to
0N/A# avoid losing stack frame pointers so you can't get stack traces or debug
156N/ADEFAULT_ARCH32_FLAGS_i386 = -xpentium -xregs=no%frameptr
156N/ADEFAULT_ARCH64_FLAGS_i386 = -xarch=generic64 -xregs=no%frameptr
156N/ADEFAULT_ARCH_LIB_FLAGS_i386 =
0N/A
156N/AARCH32_FLAGS = $(DEFAULT_ARCH32_FLAGS_$(MACH))
156N/AARCH64_FLAGS = $(DEFAULT_ARCH64_FLAGS_$(MACH))
156N/AARCH_LIB_FLAGS = $(DEFAULT_ARCH_LIB_FLAGS_$(MACH))
0N/A
90N/A### Flags for gcc
90N/ADEFAULT_GCC_CFLAGS = -O3 -fno-omit-frame-pointer -Wall
156N/ADEFAULT_ARCH32_GCC_FLAGS_sparc = -mcpu=ultrasparc -m32
156N/ADEFAULT_ARCH64_GCC_FLAGS_sparc = -mcpu=ultrasparc -m64
156N/ADEFAULT_ARCH32_GCC_FLAGS_i386 = -march=i686 -m32
156N/ADEFAULT_ARCH64_GCC_FLAGS_i386 = -march=opteron -m64
156N/AARCH32_GCC_FLAGS=$(DEFAULT_ARCH32_GCC_FLAGS_$(MACH))
156N/AARCH64_GCC_FLAGS=$(DEFAULT_ARCH64_GCC_FLAGS_$(MACH))
90N/A
90N/A# Need to use -Wl,.. to pass linker flags through gcc
90N/AGCC_LDFLAGS_CMD=echo $(LDFLAGS) | \
90N/A sed -e 's/-M /-Wl,-M,/g' -e 's/-B /-Wl,-B,/g'
90N/AGCC_LDFLAGS=$(GCC_LDFLAGS_CMD:sh)
90N/AGCC_LIB_LDFLAGS_CMD=echo $(LIB_LDFLAGS) | \
90N/A sed -e 's/-M /-Wl,-M,/g' -e 's/-B /-Wl,-B,/g'
90N/AGCC_LIB_LDFLAGS=$(GCC_LIB_LDFLAGS_CMD:sh)
90N/AGCC_PROG_LDFLAGS_CMD=echo $(PROG_LDFLAGS) | \
90N/A sed -e 's/-M /-Wl,-M,/g' -e 's/-B /-Wl,-B,/g'
90N/AGCC_PROG_LDFLAGS=$(GCC_PROG_LDFLAGS_CMD:sh)
90N/A
90N/A
156N/ASUBDIR32_sparc = sparcv8
156N/ASUBDIR32_i386 = i386
156N/ASUBDIR64_sparc = sparcv9
156N/ASUBDIR64_i386 = amd64
156N/ASUBDIR32 = $(SUBDIR32_$(MACH))
156N/ASUBDIR64 = $(SUBDIR64_$(MACH))
0N/A
40N/A
0N/A### Proto directory to install into for packaging
0N/APROTODIR=$(TOP)/../proto-$(ARCH)-svr4
0N/A
0N/A# Common subdirs
0N/AOW_DIR=/usr/openwin
0N/AOW_X11LIB_DIR=$(OW_DIR)/lib/X11
0N/A
0N/AFONT_DIR=$(OW_X11LIB_DIR)/fonts
0N/ATRUETYPE_DIR=$(FONT_DIR)/TrueType
0N/A
8N/AX11_DIR=/usr/X11
8N/AX11_INCLUDES_DIR=$(X11_DIR)/include
98N/AX11_DOC_DIR=$(X11_DIR)/share/doc
90N/AX11_LOCALE_DIR=$(X11_DIR)/share/locale
90N/AX11_LC_MESSAGES_DIR=$(X11_LOCALE_DIR)/C/LC_MESSAGES
90N/A# Subdirectory of /usr/X11/lib for X server private libraries
90N/AX11_SERVERLIBS_SUBDIR=/X11/xserver
98N/AX11_SERVERLIBS_DIR=$(X11_DIR)/lib$(X11_SERVERLIBS_SUBDIR)
98N/A
98N/A# Subdirectory of /usr/X11/lib for X server loadable modules
98N/AX11_SERVERMODS_SUBDIR=/modules
98N/AX11_SERVERMODS_DIR=$(X11_DIR)/lib$(X11_SERVERMODS_SUBDIR)
98N/A
156N/AMODULE_subdir_sparc=
156N/AMODULE_subdir_i386=$(ARCHLIBSUBDIR)
156N/AMODULE_subdir=$(MODULE_subdir_$(MACH))
98N/A
98N/A# Directory used for installing tools used during build but not
98N/A# delivered in packages
98N/ATOOLS_DIR=/tools
8N/A
0N/A### Default rules
0N/A
0N/ABUILD_DIR_32 = build_32
0N/ABUILD_DIR_64 = build_64
0N/A
156N/A# Set default build type to 32-bit if not set in module makefile
156N/ABUILD_TYPES_DEFAULT = $(BUILD_TYPES_SET:yes=$(POUND_SIGN))
156N/A$(BUILD_TYPES_DEFAULT) BUILD_TYPES=32
156N/A
0N/Aall: $(BUILD_TYPES:%=source_%) $(BUILD_TYPES:%=build_%)
0N/Ainstall: $(BUILD_TYPES:%=install_%)
0N/A
0N/Aclean: $(BUILD_TYPES:%=clean_%)
0N/A
0N/Aclean_32::
0N/A -rm -rf $(BUILD_DIR_32)
0N/A
0N/Aclean_64::
0N/A -rm -rf $(BUILD_DIR_64)
0N/A
0N/Abuild_gen: $(BUILD_TARGETS)
0N/A
0N/Abuild_32::
90N/A $(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_32) ARCH_FLAGS="$(ARCH32_FLAGS)" $(BUILD_32_FLAGS) build_gen
0N/A
0N/Abuild_64::
90N/A $(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_64) ARCH_FLAGS="$(ARCH64_FLAGS)" LIBSUBDIR=/$(SUBDIR64) ARCHLIBSUBDIR=/$(SUBDIR64) $(BUILD_64_FLAGS) build_gen
0N/A
90N/Ainstall_32:: build_32
90N/A $(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_32) ARCH_FLAGS="$(ARCH32_FLAGS)" $(BUILD_32_FLAGS) install_gen
0N/A
90N/Ainstall_64:: build_64
90N/A $(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_64) ARCH_FLAGS="$(ARCH64_FLAGS)" LIBSUBDIR=/64 ARCHLIBSUBDIR=/$(SUBDIR64) $(BUILD_64_FLAGS) install_gen
0N/A
0N/Adebug:
0N/A $(MAKE) $(MFLAGS) all OPT_FLAGS="-g"
0N/A
0N/A### Unpack source and apply patches
0N/A
0N/Asource: $(BUILD_TYPES:%=source_%)
0N/Asource_32: $(BUILD_DIR_32)/.unpack_done
0N/Asource_64: $(BUILD_DIR_64)/.unpack_done
0N/A
0N/AUNPACK_TARGET = $(BUILD_DIR)/.unpack_done
0N/A
0N/A$(BUILD_DIR_32)/.unpack_done:
0N/A $(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_32) source_gen
0N/A
0N/A$(BUILD_DIR_64)/.unpack_done:
0N/A $(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_64) source_gen
0N/A
90N/AFIX_PC_OPS= \
90N/A -e 's|-L\$${libdir}|-L\$${libdir} -R\$${libdir}|;' \
90N/A -e 's|Requires.private: .*$$||;'
90N/A
90N/A# -e 's|^prefix=@prefix@|prefix=\$$\{top_builddir\}@prefix@|'
90N/A
0N/Asource_gen::
0N/A mkdir -p $(BUILD_DIR)
98N/A @if [ "x$(SOURCE_TARBALL_NAME)" != "xNONE" ] ; then \
98N/A if [ "x$(SOURCE_UNCOMPRESS)" = "x" ] ; then \
98N/A echo "bzcat $(SOURCE_TARBALL) | (cd $(BUILD_DIR) ; tar -xf - )" ; \
98N/A ( bzcat $(SOURCE_TARBALL) | (cd $(BUILD_DIR) ; tar -xf - )) ; \
98N/A else \
98N/A echo "$(SOURCE_UNCOMPRESS) $(SOURCE_TARBALL) | (cd $(BUILD_DIR) ; tar -xf - )" ; \
98N/A ( $(SOURCE_UNCOMPRESS) $(SOURCE_TARBALL) | (cd $(BUILD_DIR) ; tar -xf - )) ; \
98N/A fi ; \
0N/A fi
0N/A @if [ "x$(SOURCE_PATCHES)" != "x" ] ; then \
0N/A for p in $(SOURCE_PATCHES) x ; do \
0N/A if [ "$$p" != "x" ] ; then \
90N/A PATCH_CMD=`echo $$p | awk -F, '{if (NF > 1) FLAGS = $$2; else FLAGS="-p0" ; printf "gpatch -d $(SOURCE_DIR) %s < %s\n", FLAGS, $$1}'` ; \
90N/A echo "$${PATCH_CMD}" ; \
90N/A eval $${PATCH_CMD} ; \
0N/A fi ; \
0N/A done ; \
0N/A fi
40N/A @if [ "x$(SUNTOUCHED_MANPAGES)" != "x" ] ; then \
40N/A echo "/usr/perl5/bin/perl $(TOP)/common/suntouch-manpages.pl \
40N/A $(SUNTOUCH_MAN_FLAGS) $(SUNTOUCHED_MANPAGES)" ; \
40N/A (cd $(SOURCE_DIR) && \
40N/A /usr/perl5/bin/perl $(TOP)/common/suntouch-manpages.pl \
40N/A $(SUNTOUCH_MAN_FLAGS) $(SUNTOUCHED_MANPAGES) ) ; \
40N/A fi
70N/A @if [ "x$(FIX_PC_FILES)" != "x" ] ; then \
90N/A echo "/usr/perl5/bin/perl -i.orig -p \
90N/A $(FIX_PC_OPS) $(FIX_PC_FILES)" ; \
70N/A (cd $(SOURCE_DIR) && \
90N/A /usr/perl5/bin/perl -i.orig -p \
90N/A $(FIX_PC_OPS) $(FIX_PC_FILES) ); \
70N/A fi
0N/A touch $(BUILD_DIR)/.unpack_done
0N/A
0N/A
0N/A### Source tarballs & downloading if necessary
0N/A
0N/ATARBALLDIR=$(TOP)/tarballs
0N/AWGET=/usr/sfw/bin/wget
0N/ASOURCE_TARBALL=$(TARBALLDIR)/$(SOURCE_TARBALL_NAME)
0N/A
24N/AXORG_RELEASES_URL=http://xorg.freedesktop.org/releases/individual
156N/ASF_DOWNLOADS_URL=http://easynews.dl.sourceforge.net/sourceforge
156N/A
156N/A# Set default download location if not set in module makefile
156N/ASOURCE_URL_DEFAULT = $(SOURCE_URL_SET:yes=$(POUND_SIGN))
156N/A$(SOURCE_URL_DEFAULT) SOURCE_URL=$(XORG_RELEASES_URL)/$(SOURCE_TARBALL_DIR)/$(SOURCE_TARBALL_NAME)
8N/A
0N/Adownload:
0N/A if [ ! -f $(SOURCE_TARBALL) ] ; then \
0N/A $(WGET) -O $(SOURCE_TARBALL) $(SOURCE_URL) ;\
0N/A fi
0N/A
40N/A### Generate mapfiles to limit/version exported symbols in libraries
40N/A
40N/ASPEC2MAP= /usr/lib/abi/spec2map
40N/A
40N/ASPECMAP= mapfile.vers.$(LIBNAME)
40N/ASPECFILE= spec/$(LIBNAME).spec
40N/AVERSFILE= spec/versions
40N/A
40N/A$(BUILD_DIR_32)/$(SPECMAP): $(SPECFILE) $(VERSFILE)
40N/A $(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_32) MACH=$(MACH32) spec_gen
40N/A
40N/A$(BUILD_DIR_64)/$(SPECMAP): $(SPECFILE) $(VERSFILE)
40N/A $(MAKE) $(MFLAGS) BUILD_DIR=$(BUILD_DIR_64) MACH=$(MACH64) spec_gen
40N/A
40N/Aspec_gen:
40N/A $(SPEC2MAP) -a $(MACH) -v $(VERSFILE) -p -l $(LIBNAME) \
40N/A -o $(BUILD_DIR)/$(SPECMAP) $(SPECFILE)
40N/A
0N/A### Other tools needed to build
0N/A
0N/A# Some modules (such as FreeType 2) require GNU make
0N/AGNUMAKE = gmake
0N/A
0N/A$(GNUMAKE):
0N/A @echo "Checking for GNU make:"
0N/A $(GNUMAKE) --version
0N/A
90N/A# Some modules use lndir to merge in sources from Sun specific directories
90N/ALNDIR=$(PROTODIR)/usr/X11/bin/lndir
90N/A
90N/A$(LNDIR):
90N/A (cd $(TOP)/util/lndir && $(MAKE) $(MFLAGS) install)
90N/A
98N/ADOCBOOKUTIL_BINDIR=$(PROTODIR)$(TOOLS_DIR)/bin
98N/ADOCBOOK2HTML=$(DOCBOOKUTIL_BINDIR)/dockbook2html
98N/A
98N/A$(DOCBOOK2HTML):
98N/A (cd $(TOP)/doc/docbook-utils && $(MAKE) $(MFLAGS) install)
98N/A
40N/A### Dependencies
0N/A
40N/A# Almost everything depends on the headers in xproto
40N/AXPROTO_DEP=$(PROTODIR)/usr/lib/$(ARCHLIBSUBDIR)/pkgconfig/xproto.pc
40N/A
40N/A$(XPROTO_DEP):
40N/A @echo "Installing dependency proto/X11"
40N/A (cd $(TOP)/proto/X11 ; make install)
40N/A
47N/A### Useful rules for maintaining patch sets
47N/A
47N/A# regenerate patches against new baseline to reduce messages about hunks
47N/A# having fuzz or offsets when applying patches - new patches will be in new/
47N/A
90N/Aregen-patches:
47N/A CUR_LIST=""
47N/A rm -rf tmp-regen
47N/A make SOURCE_PATCHES="$(CUR_LIST)" BUILD_DIR=tmp-regen source_gen
47N/A mkdir -p new
47N/A for f in $(SOURCE_PATCHES) ; do \
90N/A p=`echo $$f | sed 's/,.*$$//'` ; \
90N/A echo '=================' $$p ; \
47N/A rm -rf prev ; \
47N/A mv tmp-regen prev ; \
47N/A $(MAKE) SOURCE_PATCHES="$${CUR_LIST} $$f" BUILD_DIR=tmp-regen source_gen ; \
47N/A awk '/^--- / {exit} \
47N/A /^diff -u/ {exit} \
90N/A {print}' $$p > new/$$p ; \
98N/A gdiff -urp -x '*~' -x '*.orig' ./prev ./tmp-regen \
47N/A | sed -e 's% \./prev$(SOURCE_DIR)/% %' -e 's% \./tmp-regen$(SOURCE_DIR)/% %' \
47N/A | grep -v '^Common subdirectories:' \
47N/A | grep -v '^Only in ' \
90N/A >> new/$$p ; \
90N/A CUR_LIST="$${CUR_LIST} new/$$p" ; \
47N/A done
47N/A rm -rf tmp-regen