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

@ -45,8 +45,8 @@
# Will install the package directly $WM_THIRD_PARTY_DIR # Will install the package directly $WM_THIRD_PARTY_DIR
# Some comments about package relocation: # Some comments about package relocation:
# By using this prefix for the Prefix: parameter in this file, you will make this # By using this prefix for the Prefix: parameter in this file, you will make this
# package relocatable. # package relocatable.
# #
# This is fine, as long as your software is itself relocatable. # This is fine, as long as your software is itself relocatable.
# #
@ -55,7 +55,7 @@
# Ref: http://sourceware.org/autobook/autobook/autobook_80.html # Ref: http://sourceware.org/autobook/autobook/autobook_80.html
# #
# In that case, if you ever change the value of the $WM_THIRD_PARTY_DIR, you will # In that case, if you ever change the value of the $WM_THIRD_PARTY_DIR, you will
# not be able to reutilize this RPM, even though it is relocatable. You will need to # not be able to reutilize this RPM, even though it is relocatable. You will need to
# regenerate the RPM. # regenerate the RPM.
# #
%define _prefix %{_WM_THIRD_PARTY_DIR} %define _prefix %{_WM_THIRD_PARTY_DIR}
@ -115,6 +115,14 @@ Patch1: ParMGridGen-1.0.patch
cp ./MGridGen/IMlib/libIMlib.* $RPM_BUILD_ROOT/%{_installPrefix}/lib cp ./MGridGen/IMlib/libIMlib.* $RPM_BUILD_ROOT/%{_installPrefix}/lib
cp ./MGridGen/Lib/libMGridGen.* $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" # Creation of foam-extend specific .csh and .sh files"
echo "" echo ""
@ -161,7 +169,7 @@ DOT_CSH_EOF
#finally, generate a .tgz file for systems where using rpm for installing packages #finally, generate a .tgz file for systems where using rpm for installing packages
# as a non-root user might be a problem. # as a non-root user might be a problem.
(mkdir -p %{_topdir}/TGZS/%{_target_cpu}; cd $RPM_BUILD_ROOT/%{_prefix}; tar -zcvf %{_topdir}/TGZS/%{_target_cpu}/%{name}-%{version}.tgz packages/%{name}-%{version}) (mkdir -p %{_topdir}/TGZS/%{_target_cpu}; cd $RPM_BUILD_ROOT/%{_prefix}; tar -zcvf %{_topdir}/TGZS/%{_target_cpu}/%{name}-%{version}.tgz packages/%{name}-%{version})
%clean %clean
rm -rf %{buildroot} rm -rf %{buildroot}

View file

@ -134,6 +134,14 @@ Patch0: libccmio-2.6.1.patch_0
mv ${libsdir}/* $RPM_BUILD_ROOT/%{_installPrefix}/lib mv ${libsdir}/* $RPM_BUILD_ROOT/%{_installPrefix}/lib
cp libccmio/*.h $RPM_BUILD_ROOT/%{_installPrefix}/include/libccmio 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" # Creation of foam-extend specific .csh and .sh files"
echo "" echo ""

View file

@ -44,8 +44,8 @@
# Will install the package directly $WM_THIRD_PARTY_DIR # Will install the package directly $WM_THIRD_PARTY_DIR
# Some comments about package relocation: # Some comments about package relocation:
# By using this prefix for the Prefix: parameter in this file, you will make this # By using this prefix for the Prefix: parameter in this file, you will make this
# package relocatable. # package relocatable.
# #
# This is fine, as long as your software is itself relocatable. # This is fine, as long as your software is itself relocatable.
# #
@ -54,7 +54,7 @@
# Ref: http://sourceware.org/autobook/autobook/autobook_80.html # Ref: http://sourceware.org/autobook/autobook/autobook_80.html
# #
# In that case, if you ever change the value of the $WM_THIRD_PARTY_DIR, you will # In that case, if you ever change the value of the $WM_THIRD_PARTY_DIR, you will
# not be able to reutilize this RPM, even though it is relocatable. You will need to # not be able to reutilize this RPM, even though it is relocatable. You will need to
# regenerate the RPM. # regenerate the RPM.
# #
%define _prefix %{_WM_THIRD_PARTY_DIR} %define _prefix %{_WM_THIRD_PARTY_DIR}
@ -113,6 +113,12 @@ Patch1: scotch-6.0.4_patch_darwin
make -j $WM_NCOMPPROCS ptscotch AR="$WM_CC" make -j $WM_NCOMPPROCS ptscotch AR="$WM_CC"
%install %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 cd src
mkdir -p $RPM_BUILD_ROOT%{_installPrefix} mkdir -p $RPM_BUILD_ROOT%{_installPrefix}
make install prefix=$RPM_BUILD_ROOT%{_installPrefix} make install prefix=$RPM_BUILD_ROOT%{_installPrefix}

View file

@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "dlLibraryTable.H" #include "dlLibraryTable.H"
#include "OSspecific.H"
#include <dlfcn.h> #include <dlfcn.h>
@ -71,11 +72,43 @@ bool Foam::dlLibraryTable::open(const fileName& functionLibName)
dlopen(functionLibName.c_str(), RTLD_LAZY|RTLD_GLOBAL); dlopen(functionLibName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
#ifdef darwin #ifdef darwin
if(!functionLibPtr && functionLibName.ext()=="so") { // If failing to load under OS X, let's try some obvious variations
fileName lName=functionLibName.lessExt()+".dylib"; // before giving up completely
fileName osxFileName(functionLibName);
if(!functionLibPtr && functionLibName.ext()=="so")
{
osxFileName=functionLibName.lessExt()+".dylib";
functionLibPtr = 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 #elif defined mingw
if(!functionLibPtr && functionLibName.ext()=="so") { if(!functionLibPtr && functionLibName.ext()=="so") {
fileName lName=functionLibName.lessExt()+".dll"; fileName lName=functionLibName.lessExt()+".dll";

View file

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