File: macosx_bundle_fixup.sh

package info (click to toggle)
swi-prolog 9.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 82,408 kB
  • sloc: ansic: 387,503; perl: 359,326; cpp: 6,613; lisp: 6,247; java: 5,540; sh: 3,147; javascript: 2,668; python: 1,900; ruby: 1,594; yacc: 845; makefile: 428; xml: 317; sed: 12; sql: 6
file content (53 lines) | stat: -rwxr-xr-x 1,348 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
app=$1

if [ -z "$app" ]; then
  echo "Usage: $0 app"
  exit 1
fi

ARCH=$($app/Contents/MacOS/swipl --arch)
moduledir=$app/Contents/swipl/lib/$ARCH
frameworkdir=$app/Contents/Frameworks

# macdeployqt appears to copy libjvm.dylib.  We
# do not want that.
if [ -f $frameworkdir/libjvm.dylib ]; then
  printf "Removing libjvm.dylib from bundle\n"
  rm $frameworkdir/libjvm.dylib
fi

printf "Adding Macport dylibs to modules in $moduledir\n"

changeset="$(echo $moduledir/*) $app/Contents/MacOS/swipl"
while [ ! -z "$changeset" ]; do
  newchanges=
  for f in $changeset; do
    case "$(file $f)" in
      *Mach-O*)
        opt_dep=$(otool -L $f |
		  grep '\(/opt/local\|/deps/\)' |
		  grep -v libjvm |
		  awk '{print $1}')
        if [ ! -z "$opt_dep" ]; then
          change=""
          for dep in $opt_dep; do
            file="$frameworkdir/$(basename $dep)"
            if [ ! -f $file ]; then
              printf "   Adding $dep ... "
              cp $dep $frameworkdir
              chmod 755 $file
              newchanges="$newchanges $file"
              printf 'ok\n'
            fi
            change="$change -change $dep @rpath/$(basename $dep)"
          done
          if [ ! -z "$change" ]; then
            install_name_tool $change $f
          fi
        fi
        ;;
      *)
    esac
  done
  changeset="$newchanges"
done