[4871] | 1 | |
---|
| 2 | set exec_prefix @exec_prefix@ |
---|
| 3 | set libdir @libdir@ |
---|
| 4 | set bindir @bindir@ |
---|
| 5 | |
---|
| 6 | set topdir [lindex $argv 0] |
---|
| 7 | |
---|
| 8 | set os $tcl_platform(os) |
---|
| 9 | if { $os == "Linux" } { |
---|
| 10 | proc change_path { file } { |
---|
| 11 | if { [catch {exec chrpath $file 2> /dev/null} rpath] == 0 } { |
---|
| 12 | global libdir |
---|
| 13 | if { [regexp -- ".*PATH=$libdir" $rpath] } { |
---|
| 14 | if { ![file writable $file] } { |
---|
| 15 | file attributes $file -permissions u+w |
---|
| 16 | } |
---|
| 17 | exec chrpath -r {$ORIGIN/../lib} $file |
---|
| 18 | } |
---|
| 19 | } |
---|
| 20 | } |
---|
| 21 | foreach i [glob -nocomplain [file join $topdir bin *]] { |
---|
| 22 | change_path $i |
---|
| 23 | } |
---|
| 24 | foreach i [glob -nocomplain $topdir/lib/*.so $topdir/lib/*/*.so] { |
---|
| 25 | change_path $i |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | } elseif { $os == "Darwin" } { |
---|
| 29 | |
---|
| 30 | proc change_path { file } { |
---|
| 31 | if { [catch {exec otool -L $file 2> /dev/null} rpaths] == 0 } { |
---|
| 32 | global libdir |
---|
| 33 | set pattern [format {^\t(%s/lib[a-zA-Z0-9\._\-]+dylib)} $libdir] |
---|
| 34 | foreach line [split $rpaths \n] { |
---|
| 35 | if { [regexp -- $pattern $line match libpath] } { |
---|
| 36 | if { ![file writable $file] } { |
---|
| 37 | file attributes $file -permissions u+w |
---|
| 38 | } |
---|
| 39 | set lib [file tail $libpath] |
---|
| 40 | exec install_name_tool -change $libpath \ |
---|
| 41 | @executable_path/../lib/$lib $file |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | proc change_no_path { file } { |
---|
| 47 | if { [catch {exec otool -L $file 2> /dev/null} rpaths] == 0 } { |
---|
| 48 | set pattern {^\t(lib[a-zA-Z0-9\._\-]+dylib)} |
---|
| 49 | foreach line [split $rpaths \n] { |
---|
| 50 | if { [regexp -- $pattern $line match lib] } { |
---|
| 51 | if { ![file writable $file] } { |
---|
| 52 | file attributes $file -permissions u+w |
---|
| 53 | } |
---|
| 54 | exec install_name_tool -change $lib \ |
---|
| 55 | @executable_path/../lib/$lib $file |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | foreach i [glob -nocomplain $topdir/MacOS/* $topdir/bin/*] { |
---|
| 61 | change_path $i |
---|
| 62 | } |
---|
| 63 | foreach i [glob -nocomplain $topdir/lib/*.dylib $topdir/lib/*/*.dylib] { |
---|
| 64 | change_path $i |
---|
| 65 | change_no_path $i |
---|
| 66 | } |
---|
| 67 | } |
---|