On Wed, Sep 24, 2014 at 2:43 PM, Sarah Denoux <sden...@grame.fr> wrote:

> we just came stepped on this problem with Dominique and it should
> be $(SOVERSION) instead of $(SOVERSION).$(VERSION). Do you want to change
> it or should I ?
>

Ok, now we got that settled, I pulled over the httpdlib `make dynamic`
changes from the faust2 branch as well, and made it all work on Linux, too.

Now to go all the way... Those version numbers in the file names mean
nothing, they're just for humans. To make the dynamic linker aware of the
versioning, it needs to be told about it with the appropriate linker flags
when linking the library. On Linux this is done with the -soname linker
option; I already added that. On the Mac you need to use
-compatibility_version (that's the soversion) and -current_version
(soversion + patchlevel).

Last but not least, the install_name. This is important because
libOSCFaust.dylib is installed in the $prefix/lib/faust subdir which isn't
on the dynamic linker's path. So an application or plugin linking against
the library must be able to find it. On the Mac this works by telling the
linker with the -install_name option about the installed name (including
its install path) of the library, which then encodes it into the .dylib,
which then gets picked up when linking the application, which then tells
the dynamic linker about it when the application is run. (All this is
neither necessary nor supported on Linux, instead an application would
simply specify its own library search path with the -rpath linker option
when linking the application. Note that this is different from the -rpath
option of the Mac linker, which I discuss below.)

The Mac dynamic linker offers several options here. First, one can use an
absolute pathname, that would be something like
/usr/local/lib/faust/libOSCFaust.0.dylib in our case. This should be the
default, but it only works if Faust is actually installed on the target
system.

Second, the following symbolic paths allow an application to ship with its
own copy of libOSCFaust.0.dylib and still have the dynamic linker find it:

- @executable_path: This is relative to the main executable of the
application. This is useful, e.g., for an application like FaustLive, so
that it can be deployed on systems without a "real" Faust installation.

- @loader_path (OS X 10.4+): This is relative to the load path of another
dylib which links against libOSCFaust. This is useful, in particular, for
plugins (LV2, VST, whatever) which are themselves dylibs (as there's no
main executable in this case, or the plugin host may live somewhere else,
@executable_path is often not very useful in this situation).

- @rpath (OS X 10.5+): This makes it possible for an application to supply
its own library search path (via the -rpath linker option).

See, e.g., https://wincent.com/wiki/@executable_path,_@load_path_and_@rpath
for a closer descriptions of these options.

In Pure I mostly use absolute install_names since the target system is
assumed to have at least an installation of the Pure runtime. But with
Faust it makes perfect sense to support the other options as well.

So the way that I implemented this now is that by default, when running
`make dynamic` from Faust's toplevel source directory, the absolute
pathname of the installed libOSCFaust.0.dylib will be used as the
install_name. But you can also chdir to architecture/osclib instead and
just run `make dynamic` there to get no install_name at all (which is how
it gets compiled currently), or run something like `make dynamic
INSTALL_PREFIX=@loader_path/` if you want to compile a version of
libOSCFaust.dylib suitable for distribution with a VST plugin, for instance.

The required changes to the Makefiles are rather modest; I've attached the
diffs against the current master branch for your perusal below.

Ok to commit?

Albert

-- 
Dr. Albert Gr"af
Computer Music Research Group, JGU Mainz, Germany
Email:  aggr...@gmail.com
WWW:    https://plus.google.com/+AlbertGraef
diff --git a/Makefile b/Makefile
index 4a3cb8a..0f3fd44 100644
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ all :
 
 dynamic :
        $(MAKE) -C architecture/httpdlib/src dynamic
-       $(MAKE) -C architecture/osclib dynamic
+       $(MAKE) -C architecture/osclib dynamic PREFIX=$(PREFIX)
 
 httpd :
        $(MAKE) -C architecture/httpdlib/src
diff --git a/architecture/osclib/Makefile b/architecture/osclib/Makefile
index d2e72bc..12a3d67 100644
--- a/architecture/osclib/Makefile
+++ b/architecture/osclib/Makefile
@@ -51,7 +51,7 @@ faust/libOSCFaust.a:
        make -C faust
        
 faust/$(TARGET):
-       make -C faust VERSION=$(VERSION) SOVERSION=$(SOVERSION) MODE=SHARED
+       make -C faust VERSION=$(VERSION) SOVERSION=$(SOVERSION) 
PREFIX=$(PREFIX) MODE=SHARED
        
 clean :
        rm -f liboscpack.a libOSCFaust.a
diff --git a/architecture/osclib/faust/Makefile 
b/architecture/osclib/faust/Makefile
index 8536ddc..7b9e388 100644
--- a/architecture/osclib/faust/Makefile
+++ b/architecture/osclib/faust/Makefile
@@ -6,6 +6,30 @@ VPATH = $(subprojects)
 
 system ?= $(shell uname -s)
 
+# Darwin/OS X: default installation name prefix for the dynamic library. This
+# defaults to the installation prefix (a fixed path) if we have one, but
+# depending on usage (plugin or executable) you may want to keep it empty or
+# use some generic prefix such as @loader_path/ instead (see below).
+
+ifneq ($(PREFIX),)
+INSTALL_PREFIX = $(PREFIX)/lib/faust/
+endif
+
+# Here are some useful alternative options for the installation name prefix
+# (cf., e.g., 
https://wincent.com/wiki/@executable_path,_@load_path_and_@rpath):
+
+# @executable_path: Useful if the dylib is distributed with an application
+# (add path relative to the main executable if needed):
+#INSTALL_PREFIX = @executable_path/
+
+# @loader_path (OS X 10.4+): Useful if the dylib is distributed with a plugin
+# (add path relative to the plugin if needed):
+#INSTALL_PREFIX = @loader_path/
+
+# @rpath (OS X 10.5+): Useful if the dylib is distributed with an application
+# which has an rpath coded into it:
+#INSTALL_PREFIX = @rpath/
+
 ifeq ($(system), Darwin)
 ARCHFLAGS :=  -arch i386 -arch x86_64
 else
@@ -16,6 +40,10 @@ endif
 ifeq ($(MODE), SHARED)
 ifeq ($(system), Darwin)
 TARGET=libOSCFaust.$(VERSION).dylib
+SONAME=libOSCFaust.$(SOVERSION).dylib
+ifneq ($(INSTALL_PREFIX),)
+INSTALL_NAME = -install_name "$(INSTALL_PREFIX)$(SONAME)"
+endif
 else
 TARGET=libOSCFaust.so.$(VERSION)
 SONAME=libOSCFaust.so.$(SOVERSION)
@@ -31,7 +59,7 @@ CXXFLAGS += -Wno-parentheses -I../oscpack -I../oscpack/osc 
$(addprefix -I, $(sub
 all : $(TARGET)
 
 libOSCFaust.$(VERSION).dylib : $(objects)
-       c++ -dynamiclib $(ARCHFLAGS) $(objects) -L.. -loscpack -o 
libOSCFaust.$(VERSION).dylib
+       c++ -dynamiclib $(INSTALL_NAME) -compatibility_version $(SOVERSION) 
-current_version $(VERSION) $(ARCHFLAGS) $(objects) -L.. -loscpack -o 
libOSCFaust.$(VERSION).dylib
 
 libOSCFaust.so.$(VERSION) : $(objects)
        c++ -shared -Wl,-soname,$(SONAME) -fPIC $(ARCHFLAGS) $(objects) -L.. 
-loscpack -o libOSCFaust.so.$(VERSION)
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Faudiostream-devel mailing list
Faudiostream-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/faudiostream-devel

Reply via email to