| 1 | #!/bin/bash |
| 2 | ## change path gfortran lib in freefem install |
| 3 | ## usage : change-dylibgfortran oldlibdir newlibdir libnam1 libnam2 list of dylyb file pathname to change ... |
| 4 | ## F. hecht sep. 2023 on MoOS Ventura , Monterey |
| 5 | ## remark the file $oldlibdir/$libnam1 , ... must exist ... |
| 6 | |
| 7 | newdir=$1 |
| 8 | shift |
| 9 | listlib=`cd $newdir ; ls *dylib` |
| 10 | echo listlib : $listlib |
| 11 | for ff in $@; do |
| 12 | ch=0 |
| 13 | for lib in $listlib ; do |
| 14 | new=$newdir/$lib |
| 15 | nnl=`otool -L $ff|grep $lib |awk '{print $1}'` |
| 16 | old="wrong" |
| 17 | case $nnl in |
| 18 | /* ) old=$nnl |
| 19 | esac |
| 20 | nn=`otool -L $ff|grep "$old" |wc -l` |
| 21 | # otool -L $ff| grep brew |
| 22 | # echo $ff $lib $nn "$old" "$new" |
| 23 | if test $nn -ne 0 -a "$old" != "$new" ; then |
| 24 | # echo ..change $old to $new in $ff |
| 25 | ch=1 |
| 26 | echo change $old to $new in $ff |
| 27 | install_name_tool -change $old $new $ff |
| 28 | fi |
| 29 | done |
| 30 | if test $ch -eq 1 ; then |
| 31 | codesign --remove-signature $ff |
| 32 | codesign -s - $ff |
| 33 | fi |
| 34 | done |