Adjustments for Mac OSX El Capitan and the new System Integrity Protection (SIP)

feature which is enabled by default.
This commit is contained in:
Martin Beaudoin 2015-10-22 12:25:49 -04:00
parent ff8fa8c270
commit c2a0ba6539
5 changed files with 66 additions and 11 deletions

View file

@ -115,6 +115,14 @@ Patch1: ParMGridGen-1.0.patch
cp ./MGridGen/IMlib/libIMlib.* $RPM_BUILD_ROOT/%{_installPrefix}/lib
cp ./MGridGen/Lib/libMGridGen.* $RPM_BUILD_ROOT/%{_installPrefix}/lib
%ifos darwin
# Making sure to set the shared library identification name to the full path
# System Integrity Protection (SIP) enabled systems (OS X El Capitan)
# require this
install_name_tool -id %{_installPrefix}/lib/libIMlib.dylib $RPM_BUILD_ROOT/%{_installPrefix}/lib/libIMlib.dylib
install_name_tool -id %{_installPrefix}/lib/libMGridGen.dylib $RPM_BUILD_ROOT/%{_installPrefix}/lib/libMGridGen.dylib
%endif
# Creation of foam-extend specific .csh and .sh files"
echo ""

View file

@ -134,6 +134,14 @@ Patch0: libccmio-2.6.1.patch_0
mv ${libsdir}/* $RPM_BUILD_ROOT/%{_installPrefix}/lib
cp libccmio/*.h $RPM_BUILD_ROOT/%{_installPrefix}/include/libccmio
%ifos darwin
# Making sure to set the shared library identification name to the full path
# System Integrity Protection (SIP) enabled systems (OS X El Capitan)
# require this
install_name_tool -id %{_installPrefix}/lib/libadf_ccmio.dylib $RPM_BUILD_ROOT/%{_installPrefix}/lib/libadf_ccmio.dylib
install_name_tool -id %{_installPrefix}/lib/libccmio.dylib $RPM_BUILD_ROOT/%{_installPrefix}/lib/libccmio.dylib
%endif
# Creation of foam-extend specific .csh and .sh files"
echo ""

View file

@ -113,6 +113,12 @@ Patch1: scotch-6.0.4_patch_darwin
make -j $WM_NCOMPPROCS ptscotch AR="$WM_CC"
%install
%ifos darwin
# Making sure to set the shared library identification name to the full path
# System Integrity Protection (SIP) enabled systems (OS X El Capitan)
# require this
find . -name \*.dylib | xargs -I{} -n 1 bash -c 'bn=$(basename $1) ; install_name_tool -id %{_installPrefix}/lib/${bn} $1' -- {}
%endif
cd src
mkdir -p $RPM_BUILD_ROOT%{_installPrefix}
make install prefix=$RPM_BUILD_ROOT%{_installPrefix}

View file

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "dlLibraryTable.H"
#include "OSspecific.H"
#include <dlfcn.h>
@ -71,11 +72,43 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
dlopen(functionLibName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
#ifdef darwin
if(!functionLibPtr && functionLibName.ext()=="so") {
fileName lName=functionLibName.lessExt()+".dylib";
// If failing to load under OS X, let's try some obvious variations
// before giving up completely
fileName osxFileName(functionLibName);
if(!functionLibPtr && functionLibName.ext()=="so")
{
osxFileName=functionLibName.lessExt()+".dylib";
functionLibPtr =
dlopen(lName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
dlopen(osxFileName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
}
// If unsuccessful, which might be the case under Mac OSX 10.11 (El
// Capitan) with System Integrity Protection (SIP) enabled, let's try
// building a full path using well-known environment variables. This is
// the last resort, unless you provide the full pathname yourself.
if (!functionLibPtr)
{
fileName l_LIBBIN_Name =
getEnv("FOAM_LIBBIN")/osxFileName;
functionLibPtr =
dlopen(l_LIBBIN_Name.c_str(), RTLD_LAZY|RTLD_GLOBAL);
}
if (!functionLibPtr)
{
fileName l_SITE_LIBBIN_Name =
getEnv("FOAM_SITE_LIBBIN")/osxFileName;
functionLibPtr =
dlopen(l_SITE_LIBBIN_Name.c_str(), RTLD_LAZY|RTLD_GLOBAL);
}
if (!functionLibPtr)
{
fileName l_USER_LIBBIN_Name =
getEnv("FOAM_USER_LIBBIN")/osxFileName;
functionLibPtr =
dlopen(l_USER_LIBBIN_Name.c_str(), RTLD_LAZY|RTLD_GLOBAL);
}
#elif defined mingw
if(!functionLibPtr && functionLibName.ext()=="so") {
fileName lName=functionLibName.lessExt()+".dll";

View file

@ -183,7 +183,7 @@ $(LIB).$(SO): $(OBJECTS)
@rm -f so_locations
ifeq ($(WM_ARCH_BASE),darwin)
@cd $(OBJECTS_DIR) ; \
$(LINKLIBSO) $(LOCAL_OBJECTS) -L$(LIB_WM_OPTIONS_DIR) $(LIB_LIBS) $(GLIB_LIBS) -install_name $(notdir $(LIB)).$(SO) -o $(LIB).$(SO)
$(LINKLIBSO) $(LOCAL_OBJECTS) -L$(LIB_WM_OPTIONS_DIR) $(LIB_LIBS) $(GLIB_LIBS) -install_name $(LIB).$(SO) -o $(LIB).$(SO)
else ifeq ($(WM_ARCH_BASE),mingw)
@cd $(OBJECTS_DIR) ; \
$(LINKLIBSO) $(LOCAL_OBJECTS) -L$(LIB_WM_OPTIONS_DIR) $(LIB_LIBS) $(GLIB_LIBS) $(EXTRA_LIBS) -o $(LIB).$(SO) -Wl,--out-implib,$(LIB).a