--- firebird.org/builds/posix/Makefile.in.examples
+++ firebird/builds/posix/Makefile.in.examples
@@ -134,7 +134,7 @@
 	$(LN) $(ISQL) $(EXAMPLES_DEST)/isql$(EXEC_EXT)
 
 $(EXAMPLES_DEST)/empbuild$(EXEC_EXT): $(EMPBLD_Objects) $(COMMON_LIB)
-	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)
+	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ -L$(LIB) $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(call LINK_DARWIN_RPATH,../$(if $(ENABLE_DEBUG),Debug,Release)/firebird)
 
 $(EXAMPLES_DEST)/empbuild.c:	$(EXAMPLES_DEST)/empbuild.fdb $(EXAMPLES_DEST)/empbuild.e
 
--- firebird.org/builds/posix/prefix.darwin_x86_64	2016-08-01 20:02:48.000000000 +0200
+++ firebird/builds/posix/prefix.darwin_x86_64	2016-08-01 21:42:45.000000000 +0200
@@ -27,9 +27,6 @@
 # configure using --with-builtin-tommath
 # or add the relevant -I, -L for an installed version of libtommath
 
-DYLD_LIBRARY_PATH=$(HOME)/icu54/icu/source/lib
-export DYLD_LIBRARY_PATH
-
 #DYLD_PRINT_ENV=1
 #export DYLD_PRINT_ENV

@@ -31,8 +31,8 @@
 MACOSX_DEPLOYMENT_TARGET=10.9
 export MACOSX_DEPLOYMENT_TARGET
 
-PROD_FLAGS=-DDARWIN -pipe -O2 -MMD -fPIC -fno-common -mmacosx-version-min=10.9
-DEV_FLAGS=-ggdb -DDARWIN -pipe -MMD -fPIC -fno-omit-frame-pointer -fno-common -Wall -fno-optimize-sibling-calls -mmacosx-version-min=10.9 -Wno-non-virtual-dtor
+PROD_FLAGS=-DDARWIN -pipe -O2 -MMD -fPIC -fno-common
+DEV_FLAGS=-ggdb -DDARWIN -pipe -MMD -fPIC -fno-omit-frame-pointer -fno-common -Wall -fno-optimize-sibling-calls -Wno-non-virtual-dtor
 CXXFLAGS:=$(CXXFLAGS) -fvisibility-inlines-hidden -fvisibility=hidden -stdlib=libc++ -msse4
 
 EXE_LINK_OPTIONS:=
--- firebird.org/src/common/unicode_util.cpp	2016-07-07 13:55:55.992234709 +0200
+++ firebird/src/common/unicode_util.cpp	2016-08-10 11:25:46.422331020 +0200
@@ -63,8 +63,8 @@
 const char* const ucTemplate = "icuuc%s.dll";
 #endif
 #elif defined(DARWIN)
-const char* const inTemplate = "lib/libicui18n.%s.dylib";
-const char* const ucTemplate = "lib/libicuuc.%s.dylib";
+const char* const inTemplate = "libicui18n.dylib.%s";
+const char* const ucTemplate = "libicuuc.dylib.%s";
 #elif defined(HPUX)
 const char* const inTemplate = "libicui18n.sl.%s";
 const char* const ucTemplate = "libicuuc.sl.%s";
@@ -354,6 +354,16 @@
 	{
 		s.printf(*p, majorVersion, minorVersion);
 		filename.printf(templateName, s.c_str());
+		const char * envpath = getenv("LIBREOFFICE_FIREBIRD_LIB");
+		if(envpath == nullptr)
+		{
+			envpath = getenv("LIBREOFFICE_ICU_LIB");
+		}
+		if(envpath != nullptr)
+		{
+			s = filename.c_str();
+			PathUtils::concatPath(filename, envpath, s.c_str());
+		}
 
 		ModuleLoader::Module* module = ModuleLoader::fixAndLoadModule(NULL, filename);
 		if (module)
--- firebird.org/src/common/utils.cpp	2016-08-16 10:11:10.000000000 +0200
+++ firebird/src/common/utils.cpp	2016-08-16 11:27:09.000000000 +0200
@@ -1027,10 +1027,18 @@
 			return s;
 		}
 
-                // Set relative path to Engine12 dynamic library
+                // Set path to Engine12 dynamic library.
                 if(prefType == Firebird::IConfigManager::DIR_PLUGINS)
                 {
-                    s = name;
+                    const char * const envpath = getenv("LIBREOFFICE_FIREBIRD_LIB");
+                    if(envpath != nullptr)
+                    {
+                        PathUtils::concatPath(s, envpath, name);
+                    }
+                    else
+                    {
+                        s = name;
+                    }
                     return s;
                 }
 	}
