#============================================================================
# Rules for library creation
# Copyright (C)2003 by Matze Braun
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#============================================================================
# Suppress ar's noisy report that it created the archive we asked it to create.
if $(AR) && $(AR[2]) = ru { AR = $(AR[1]) ruc ; }
# Library versioning control. When set to "yes", the string in
# LIBRARY_VERSION_TAG will be appended to names of libraries.
LIBRARY_VERSIONING ?= yes ;
LIBRARY_VERSION_TAG ?= "$(PACKAGE_VERSION_LIST[1]).$(PACKAGE_VERSION_LIST[2])" ;
## Library libname : sources [ : options ]
## Build a library out of sourcefiles. All sourcefiles will be passed
## to the Objects rule which tries to compile them into object-files. You
## can create rules for your own filetypes with the UserObject rule. Header
## files will just be ignored. They are only used for MSVC projectfile
## generation.
## Available options are 'shared' if you want to build a shared library on
## platforms which support that. You can specify the 'noinstall' option if
## you don't want an install target generated.
## Don't specify any extensions for the library name, also leave out the
## leading "lib".
## Options:
## noinstall: Do not set up a default installation target.
## independent: The target will not be made a dependency of the libs and
## all targets.
## shared: Create as a shared library on supported platforms.
## nohelp: Do not invoke Help for this target.
## notest: Do not set up unit-testing support for this target.
## optional: Affects handling of the library in cs-config; it is only
## reported as available when actually built.
rule Library
{
local options = $(3) ;
CheckOptions noinstall independent shared nohelp notest optional : $(options) : $() ] ;
local objects ;
local i ;
for i in $(sources)
{
if $(i:S) = $(SUFOBJ)
{
objects += $(i) ;
}
else
{
objects += [ CompileObjects $(i) ] ;
}
}
$() ;
if "$($() ;
}
UnitTestLibDepends $() ;
}
#----------------------------------------------------------------------------
# private part
# LibraryStatic libname : sources : options : decoratedtarget
rule LibraryStatic
{
local objects = $(>) ;
local options = $(3) ;
local target = $(4) ;
# Set LOCATE for the library and its contents. The bound
# value shows up as $(NEEDLIBS) on the Link actions.
# For compatibility, we only do this if the library doesn't
# already have a path.
if ! $(target:D)
{
MakeLocate $(target) $(target)($(objects:BS)) : $(LOCATE.OBJECTS)/libs ;
}
if $(NOARSCAN)
{
# If we can't scan the library to timestamp its contents,
# we have to just make the library depend directly on the
# on-disk object files.
Depends $(target) : $(objects) ;
}
else
{
# If we can scan the library, we make the library depend
# on its members and each member depend on the on-disk
# object file.
Depends $(target) : $(target)($(objects:BS)) ;
local i ;
for i in $(objects)
{
Depends $(target)($(i:BS)) : $(i) ;
}
}
# Generate install rules
if ! [ IsElem noinstall : $(options) ]
{
if "$(RANLIB)"
{
Depends install_lib : [ DoInstall $(target) : $(libdir) : : Ranlib ] ;
}
else
{
Depends install_lib : [ DoInstall $(target) : $(libdir) ] ;
}
# Add to global library list
if [ IsElem optional : $(options) ]
{
INSTALLEDLIBS_OPTIONAL += $() ] ) || ( $(BUILD_SHARED_LIBS) != "yes" )
{
return [ ConstructStaticLibraryTarget $() : shared ] ] ;
}
else
{
return [ ConstructSharedLibraryTarget $() ] ;
}
}
rule ConstructLibraryLinkTarget
{
if ( ! [ IsElem shared : $(>) ] ) || ( $(BUILD_SHARED_LIBS) != "yes" )
{
return [ ConstructStaticLibraryTarget $() : shared ] ] ;
}
else
{
return [ ConstructSharedLibraryLinkLib $() ] ;
}
}
actions together Ranlib
{
$(RANLIB) $(