2007-07-18 17:21:52 +04:00
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
# Part of Equinox Desktop Environment (EDE).
|
|
|
|
# Copyright (c) 2000-2007 EDE Authors.
|
|
|
|
#
|
|
|
|
# This program is licensed under terms of the
|
|
|
|
# GNU General Public License version 2 or newer.
|
|
|
|
# See COPYING for details.
|
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
SUFOBJ_SHARED = ".lo" ;
|
|
|
|
SUFLIB_SHARED = ".so" ;
|
|
|
|
SUFLA_SHARED = ".la" ;
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2007-07-20 19:48:49 +04:00
|
|
|
# StaticLibrary [lib-name] : [source-files] ;
|
2007-07-18 17:21:52 +04:00
|
|
|
rule StaticLibrary
|
|
|
|
{
|
|
|
|
Library $(<) : $(>) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
rule SharedLibraryFromObjects
|
|
|
|
{
|
2009-01-26 15:31:01 +03:00
|
|
|
local _i _l _l_so _l_la _s ;
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# Add grist to file names
|
|
|
|
_s = [ FGristFiles $(3) ] ;
|
|
|
|
_l = $(1:S=$(SUFLIB_SHARED).$(2)) ;
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# for sonames; it accept only libname.so
|
|
|
|
_l_so = $(1:S=$(SUFLIB_SHARED)) ;
|
|
|
|
_l_so = $(_l_so:BSR=) ;
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# libname.la file
|
|
|
|
_l_la = $(_l_so:S=$(SUFLA_SHARED)) ;
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# library depends on its member objects
|
|
|
|
if $(KEEPOBJS) {
|
|
|
|
LocalDepends obj : $(_s) ;
|
|
|
|
} else {
|
|
|
|
LocalDepends lib : $(_l) ;
|
2007-07-18 17:21:52 +04:00
|
|
|
}
|
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# 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 ! $(_l:D) {
|
|
|
|
MakeLocate $(_l) : $(LOCATE_TARGET) ;
|
|
|
|
}
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# we never scan shared libraries for member objects
|
|
|
|
LocalDepends $(_l) : $(_s) ;
|
|
|
|
|
|
|
|
# clean library
|
|
|
|
LocalClean clean : $(_l) ;
|
|
|
|
|
|
|
|
if $(OS) = "SOLARIS" {
|
|
|
|
# solaris have other options for soname creation
|
|
|
|
LINKFLAGS on $(_l) = -h $(_l_so) -G [ on $(_l) return $(LINKFLAGS) ] ;
|
|
|
|
} else {
|
|
|
|
# let linker knows we are making shared library by adding -shared and -Wl,-soname libname.so flags
|
|
|
|
LINKFLAGS on $(_l) = -Wl,-soname,$(_l_so) -shared [ on $(_l) return $(LINKFLAGS) ] ;
|
2007-07-18 17:21:52 +04:00
|
|
|
}
|
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# make it
|
|
|
|
Link $(_l) : $(_s) ;
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# make a link
|
|
|
|
SymLink $(_l_so) : $(_l) ;
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# let link be created in directory where libname.so.X.X.X exists
|
|
|
|
MakeLocate $(_l_so) : $(_l:D) ;
|
|
|
|
LocalDepends lib : $(_l_so) ;
|
|
|
|
|
|
|
|
# generate libname.la file
|
|
|
|
DLNAME1 on $(_l_la) = $(_l_so) ;
|
|
|
|
DLNAME2 on $(_l_la) = $(_l:BSR=) ;
|
|
|
|
GenLa $(_l_la) ;
|
|
|
|
LocalClean clean : $(_l_la) ;
|
|
|
|
LocalClean clean : $(_l_so) ;
|
|
|
|
|
|
|
|
# let libname.la be created in directory where libname.so.X.X.X exists
|
|
|
|
MakeLocate $(_l_la) : $(_l:D) ;
|
|
|
|
LocalDepends lib : $(_l_la) ;
|
2007-07-18 17:21:52 +04:00
|
|
|
}
|
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
rule SharedObjects
|
2007-07-18 17:21:52 +04:00
|
|
|
{
|
2009-01-26 15:31:01 +03:00
|
|
|
# temporary replace SUFOBJ since Objects rule use it
|
|
|
|
local SUFOBJ = $(SUFOBJ_SHARED) ;
|
2007-07-20 19:48:49 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
ObjectCcFlags $(<) : -fPIC ;
|
|
|
|
ObjectC++Flags $(<) : -fPIC ;
|
2007-07-18 17:21:52 +04:00
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# call the normal Objects rule
|
|
|
|
Objects $(<) ;
|
2007-07-18 17:21:52 +04:00
|
|
|
}
|
|
|
|
|
2009-01-26 15:31:01 +03:00
|
|
|
# SharedLibrary [library] : [version] : [source] ;
|
|
|
|
# Creates shared library ala libtool
|
|
|
|
rule SharedLibrary
|
2007-07-18 17:21:52 +04:00
|
|
|
{
|
2009-01-26 15:31:01 +03:00
|
|
|
if ! $(UNIX) {
|
|
|
|
Exit "Don't know how to build shared libraries on this platform" ;
|
2007-07-18 17:21:52 +04:00
|
|
|
}
|
2009-01-26 15:31:01 +03:00
|
|
|
|
|
|
|
SharedLibraryFromObjects $(1) : $(2) : $(3:S=$(SUFOBJ_SHARED)) ;
|
|
|
|
SharedObjects $(3) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
# .la files are generated by libtool and we emulate that too
|
|
|
|
# NOTE: jam will discard comments that should be written to the file
|
|
|
|
# so instead plain '#' is used '@@#' and later is replaced with sed
|
|
|
|
actions GenLa
|
|
|
|
{
|
|
|
|
today=`date`
|
|
|
|
|
|
|
|
cat > "$(<).tmp" <<EOF
|
|
|
|
@@# $(<:D=) - a libtool library file
|
|
|
|
@@# Generated by 'EDE jam build' on: $today
|
|
|
|
|
|
|
|
@@# The name that we can dlopen(3).
|
|
|
|
dlname='$(DLNAME1)'
|
|
|
|
|
|
|
|
@@# Names of this library.
|
|
|
|
library_names='$(DLNAME2) $(DLNAME1)'
|
|
|
|
|
|
|
|
@@# The name of the static archive.
|
|
|
|
old_library=''
|
|
|
|
|
|
|
|
@@# Libraries that this one depends upon.
|
|
|
|
dependency_libs=''
|
|
|
|
|
|
|
|
@@# Is this already installed library.
|
|
|
|
installed=yes
|
|
|
|
|
|
|
|
@@# Files to dlopen/dlpreopen.
|
|
|
|
dlopen=''
|
|
|
|
dlpreopen=''
|
|
|
|
|
|
|
|
@@# Directory that this library needs to be installed in:
|
|
|
|
libdir='$(libdir)'
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat "$(<).tmp" | $(SED) 's/^@@#/#/g' > "$(<)"
|
|
|
|
$(RM) "$(<).tmp"
|
2007-07-18 17:21:52 +04:00
|
|
|
}
|