Skip to content

Instantly share code, notes, and snippets.

@JayKickliter
Created July 4, 2014 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JayKickliter/4c5c70f47be75a20e43e to your computer and use it in GitHub Desktop.
Save JayKickliter/4c5c70f47be75a20e43e to your computer and use it in GitHub Desktop.
ippLibPath = "/opt/intel/composer_xe_2013_sp1.3.166/ipp/lib"
originalFolder = pwd()
cd( ippLibPath )
function fix_ipp_dylib( dylibFileName, path )
correct_id = joinpath( ippLibPath, dylibFileName ) # we want all the dylib ID's to have the full path
cmd_get_id = `otool -DX $dylibFileName` # Get the dylib's ID (we want it to be path+filename)
cmd_set_id = `install_name_tool -id $correct_id $dylibFileName`
results = readlines( cmd_get_id )
original_id = strip( results[1] ) # The first line is a header, the second is the dylib's ID
println( dylibFileName, ":")
if original_id == "./" * dylibFileName # Has the ID not been fixed yet?
run( cmd_set_id )
println( "\tChanged ID from: ", original_id, " to: ", correct_id )
else
println( "\tHas the correct ID: ", original_id )
end
cmd_get_dependencies = `otool -LX $dylibFileName`
dependencies = readlines( cmd_get_dependencies )
if length( dependencies ) < 2 # the first line is the ID of the dylib, nothing to do if only one line # TODO: Is this true?
return
end
deps_to_change = {}
dependency_pattern = r"\s+\./(lib.+\.dylib)" # looking for a depended such as " ./libippcore-8.1.dylib", we need to expand that path
for dependency in dependencies
m = match( dependency_pattern, dependency )
if m != nothing
push!( deps_to_change, m.captures[1] )
end
end
for dependency in deps_to_change
correct_dependency = joinpath( path, dependency )
cmd_fix_dependency = `install_name_tool -change ./$dependency $correct_dependency $dylibFileName`
run( cmd_fix_dependency )
println("\tChanged dependency from: ./", dependency, " to: ", correct_dependency)
end
end
files = readdir( "/opt/intel/composer_xe_2013_sp1.3.166/ipp/lib" )
dylibs = filter!( r".+-\d\.\d\.dylib", files ) # Remove folders and symbolic links
for dylib in dylibs
fix_ipp_dylib( dylib, ippLibPath )
end
cd( originalFolder )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment