#
# 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, 2012, Oracle and/or its affiliates. All rights reserved.
#
#
# Definitions common to libraries.
#
# include global definitions; SRC should be defined in the shell.
# SRC is needed until RFE 1026993 is implemented.
include $(SRC)/Makefile.master
LORDER= lorder
TSORT= tsort
AWK= awk
#
# By default, we define the source directory for libraries to be
# one level up from the ISA-specific directory, where the code is
# actually built. Many libraries define a 'common' directory to
# contain the source. These libraries must redefine SRCDIR as:
# SRCDIR = ../common
# Other variations are possible (../port, ../src, etc).
#
SRCDIR = ..
#
# We define MAPFILES here for the benefit of most libraries, those that
# follow the convention of having source files and other common files
# in the $(SRCDIR) directory. Libraries that do not follow this
# convention must define MAPFILES, or MAPFILEDIR for themselves.
# Libraries that do follow this convention but that need supplemental
# ISA-specific mapfiles can augment MAPFILES like this:
# MAPFILES += mapfile-vers
#
MAPFILEDIR = $(SRCDIR)
MAPFILES = $(MAPFILEDIR)/mapfile-vers
#
# If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
# install rule in lib/Makefile.targ to generate false matches if there
# are any common directory names between / and /usr/include (`xfn' is
# one common example). To prevent this, we set HDRDIR to a directory
# name that will almost surely not exist on the build machine.
#
HDRDIR= /__nonexistent_directory__
#
# We don't build archive (*.a) libraries by default anymore.
# If a component of the build needs to build an archive library
# for its own internal purposes, it can define LIBS for itself
# after including Makefile.lib, like this:
# LIBS = $(LIBRARY)
# or:
# LIBS = $(LIBRARYCCC)
# Archive libraries must not be installed in the proto area.
#
# STUBLIBS parallels LIBS. The default value should suffice unless
# using C++, in which case:
# STUBLIBS = $(DYNLIBCCC)
#
LIBS=
STUBLIBS= $(DYNLIB)
MACHLIBS= $(LIBS:%=$(MACH)/%)
MACHLIBS64= $(LIBS:%=$(MACH64)/%)
DYNLIB= $(LIBRARY:.a=.so$(VERS))
DYNLIBPSR= $(LIBRARY:.a=_psr.so$(VERS))
DYNLIBCCC= $(LIBRARYCCC:.a=.so$(VERS))
LIBLINKS= $(LIBRARY:.a=.so)
LIBLINKSCCC= $(LIBRARYCCC:.a=.so)
LIBNAME= $(LIBRARY:lib%.a=%)
LIBLINKPATH=
LIBNULL= null.a
ROOTHDRDIR= $(ROOT)/usr/include
#
# For a given library, ROOTLIBDIR[64], STUBROOTLIBDIR[64], and LROOTLIBDIR[64]
# reference the proto directories for the library, stub library, and lint
# library, respectively. All of these macros need to be modified collectively.
# To ensure this happens, all are defined in terms of a single macro,
# INSTALL_LIBDIR, which supplies the relative path.
#
# Typically, a given library need only set INSTALL_LIBDIR. In rare cases
# where the 64-bit library does not reside in a $(MACH64) directory
# directly below the 32-bit library, INSTALL_LIBDIR64 must also be set.
#
INSTALL_LIBDIR= usr/lib
INSTALL_LIBDIR64= $(INSTALL_LIBDIR)/$(MACH64)
ROOTLIBDIR= $(ROOT)/$(INSTALL_LIBDIR)
ROOTLIBDIR64= $(ROOT)/$(INSTALL_LIBDIR64)
STUBROOTLIBDIR= $(STUBROOT)/$(INSTALL_LIBDIR)
STUBROOTLIBDIR64= $(STUBROOT)/$(INSTALL_LIBDIR64)
LROOTLIBDIR= $(LROOT)/$(INSTALL_LIBDIR)
LROOTLIBDIR64= $(LROOT)/$(INSTALL_LIBDIR64)
ROOTFS_LIBDIR= $(ROOT)/lib
ROOTFS_LIBDIR64= $(ROOT)/lib/$(MACH64)
STUBROOTFS_LIBDIR= $(STUBROOT)/lib
STUBROOTFS_LIBDIR64= $(STUBROOT)/lib/$(MACH64)
LROOTFS_LIBDIR= $(LROOT)/lib
LROOTFS_LIBDIR64= $(LROOT)/lib/$(MACH64)
ROOTLINTDIR= $(ROOTLIBDIR)
ROOTFS_LINTDIR= $(ROOTFS_LIBDIR)
ROOTFS_LINTDIR64= $(ROOTFS_LIBDIR64)
ROOTHDRS= $(HDRS:%=$(ROOTHDRDIR)/%)
HDRSRCS= $(HDRS:%=$(HDRDIR)/%)
CHECKHDRS= $(HDRSRCS:%.h=%.check)
ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%)
ROOTLIBS64= $(LIBS:%=$(ROOTLIBDIR64)/%)
STUBROOTLIBS= $(STUBLIBS:%=$(STUBROOTLIBDIR)/%)
STUBROOTLIBS64= $(STUBLIBS:%=$(STUBROOTLIBDIR64)/%)
ROOTFS_LIBS= $(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
ROOTFS_LIBS64= $(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
STUBROOTFS_LIBS= $(DYNLIB:%=$(STUBROOTFS_LIBDIR)/%)
STUBROOTFS_LIBS64= $(DYNLIB:%=$(STUBROOTFS_LIBDIR64)/%)
ROOTLINKS= $(ROOTLIBDIR)/$(LIBLINKS)
ROOTLINKS64= $(ROOTLIBDIR64)/$(LIBLINKS)
STUBROOTLINKS= $(STUBROOTLIBDIR)/$(LIBLINKS)
STUBROOTLINKS64= $(STUBROOTLIBDIR64)/$(LIBLINKS)
ROOTFS_LINKS= $(ROOTFS_LIBDIR)/$(LIBLINKS)
ROOTFS_LINKS64= $(ROOTFS_LIBDIR64)/$(LIBLINKS)
STUBROOTFS_LINKS= $(STUBROOTFS_LIBDIR)/$(LIBLINKS)
STUBROOTFS_LINKS64= $(STUBROOTFS_LIBDIR64)/$(LIBLINKS)
ROOTLINKSCCC= $(ROOTLIBDIR)/$(LIBLINKSCCC)
ROOTLINKSCCC64= $(ROOTLIBDIR64)/$(LIBLINKSCCC)
STUBROOTLINKSCCC= $(STUBROOTLIBDIR)/$(LIBLINKSCCC)
STUBROOTLINKSCCC64= $(STUBROOTLIBDIR64)/$(LIBLINKSCCC)
ROOTFS_LINKSCCC= $(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
ROOTFS_LINKSCCC64= $(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%)
ROOTFS_LINT= $(LINTSRC:%=$(ROOTFS_LINTDIR)/%)
ROOTFS_LINT64= $(LINTSRC:%=$(ROOTFS_LINTDIR64)/%)
ROOTMAN3= $(ROOT)/usr/share/man/man3
ROOTMAN3FILES= $(MAN3FILES:%=$(ROOTMAN3)/%)
$(ROOTMAN3FILES) := FILEMODE= 444
# Demo rules
DEMOFILES=
DEMOFILESRCDIR= common
ROOTDEMODIRBASE= __nonexistent_directory__
ROOTDEMODIRS=
ROOTDEMOFILES= $(DEMOFILES:%=$(ROOTDEMODIRBASE)/%)
$(ROOTDEMODIRS) := DIRMODE = 755
LINTLIB= llib-l$(LIBNAME).ln
LINTFLAGS= -uaxm
LINTFLAGS64= -uaxm -m64
LINTSRC= $(LINTLIB:%.ln=%)
LINTOUT= lint.out
ARFLAGS= r
SONAME= $(DYNLIB)
# When using gcc as the primary compiler, pass the link-editor the __GNUC
# mapfile conditional expression predicate for use in handling object
# differences relative to the standard Studio compilers.
ZMAPFILEADD=
$(__GNUC)ZMAPFILEADD = -z mapfile-add=__GNUC
# Inherit the core DYNFLAGS from Makefile.master
HSONAME= -h$(SONAME)
DYNFLAGS= $(HSONAME) $(DYNFLAGS.lib) $(MAPFILES:%=-M%)
LDLIBS= $(LDLIBS.lib)
OBJS= $(OBJECTS:%=objs/%)
PICS= $(OBJECTS:%=pics/%)
# Declare that all library .o's can all be made in parallel.
# The DUMMY target is for those instances where OBJS and PICS
# are empty (to avoid an unconditional .PARALLEL declaration).
.PARALLEL: $(OBJS) $(PICS) DUMMY
# default value for "portable" source
SRCS= $(OBJECTS:%.o=$(SRCDIR)/%.c)
# default build of an archive and a shared object,
# overridden locally when extra processing is needed
BUILD.AR= $(AR) $(ARFLAGS) $@ $(AROBJS)
BUILD.SO= $(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(EXTPICS) $(LDLIBS)
BUILDCCC.SO= $(CCC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(EXTPICS) $(LDLIBS) \
$(CCNEEDED)
STUBBUILD.SO= $(LD) $(MAPFILECLASS) -z stub -o $@ $(GSHARED) $(DYNFLAGS)
# default dynamic library symlink
# IMPORTANT:: If you change INS.liblink OR INS.liblink64 here, then you
# MUST also change the corresponding override definitions in
# $CLOSED/Makefile.tonic.
#
# If you do not do this, then the closedbins build for the OpenSolaris
# community will break. PS, the gatekeepers will be upset too.
#
INS.liblink= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
INS.liblinkccc= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
# default 64-bit dynamic library symlink
INS.liblink64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
#
# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
# processing. We'd like to just conditionally append to POST_PROCESS_O and
# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
# sometimes get appended more than once, which will cause ctfconvert to fail.
# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
# processing should be done.
#
CTFCONVERT_POST = $(TRUE)
CTFMERGE_POST = $(TRUE)
POST_PROCESS_O = @?$(CTFCONVERT_POST)
POST_PROCESS_SO += ; $(CTFMERGE_POST)
CTFMERGE_LIB = $(CTFMERGE) -t -f -L VERSION -o $@ $(PICS)
# conditional assignments
$(OBJS) := sparc_CFLAGS += -xregs=no%appl
$(PICS) := sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS)
$(PICS) := sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS)
$(PICS) := i386_CFLAGS += $(i386_C_PICFLAGS)
$(PICS) := amd64_CFLAGS += $(amd64_C_PICFLAGS)
$(PICS) := CCFLAGS += $(CC_PICFLAGS)
$(PICS) := CPPFLAGS += -DPIC -D_REENTRANT
$(PICS) := sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS)
$(PICS) := amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
$(PICS) := CFLAGS += $(CTF_FLAGS)
$(PICS) := CFLAGS64 += $(CTF_FLAGS)
$(PICS) := CTFCONVERT_POST = $(CTFCONVERT_O)
$(DYNLIB) := CTFMERGE_POST = $(CTFMERGE_LIB)
$(LINTLIB):= LOG = -DLOGGING
$(LIBRARY):= AROBJS = $(OBJS)
$(LIBRARY):= DIR = objs
$(DYNLIB):= DIR = pics
$(DYNLIBCCC):= DIR = pics
SONAMECCC= $(DYNLIBCCC)
HSONAMECCC= -h $(SONAMECCC)
#
# Keep in sync with the standard DYNFLAGS
#
$(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(DYNFLAGS.lib) $(NORUNPATH) \
$(MAPFILES:%=-M%)
stubs/$(DYNLIBCCC):= DYNFLAGS = $(HSONAMECCC) $(DYNFLAGS.lib) $(MAPFILES:%=-M%)
# build rule for "portable" source
objs/%.o pics/%.o: %.c
$(COMPILE.c) -o $@ $<
$(POST_PROCESS_O)
objs/%.o pics/%.o: %.cc
$(COMPILE.cc) -o $@ $<
$(POST_PROCESS_O)
.PRECIOUS: $(LIBS)
# Define the majority text domain in this directory.
TEXT_DOMAIN= SUNW_OST_OSLIB
$(ROOTMAN3)/%: %.sunman
$(INS.rename)
#
# For library source code, we expect that some symbols may not be used or
# may *appear* to be able to rescoped to static; shut lint up. Never add
# a flag here unless you're *sure* that all libraries need to be linted
# with it.
#
LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2
LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2
#
# Target Architecture
#
TARGETMACH= $(MACH)
#
# Allow people to define their own clobber rules. Normal makefiles
# shouldn't override this - they should override $(CLOBBERFILES) instead.
#
CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(DYNLIB).anc \
$(DYNLIB:%=stubs/%) $(DYNLIB:%=stubs/%.anc) $(LIBLINKS:%=stubs/%) \
$(CLOBBERFILES)
#
# The following makefiles rely on macros defined in this file, and must
# not be included without it:
# Makefile.targ
# Makefile.stub.targ
# To enforce proper usage, they contain an assertion based on the following
# definition, and will cause make to exit with an error if it is not present.
#
MAKEFILE_LIB_INCLUDED=$(POUND_SIGN)