File: post-compile.sh

package info (click to toggle)
eccodes 2.44.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 150,248 kB
  • sloc: cpp: 163,056; ansic: 26,308; sh: 21,602; f90: 6,854; perl: 6,363; python: 5,087; java: 2,226; javascript: 1,427; yacc: 854; fortran: 543; lex: 359; makefile: 285; xml: 183; awk: 66
file content (26 lines) | stat: -rwxr-xr-x 1,131 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
#!/bin/bash

# NOTE for macos, we additionally fix the install names. For linux we don't need to, since the rpath is already pointing
# to the current directory and there is no strict install name check. The libs were copied already in the precompile
# step

set -euo pipefail

if [ "$(uname)" = "Darwin" ] ; then
    BASE="/tmp/eccodes/target/eccodes/lib"
    for e in $(ls $BASE/*dylib) ; do
        echo "Fixing deps of $e"
        for p in libopenjp libaec libpng ; do
            # check that the lib $e has $p as a dependency, but also that $e is *not* $p itself
            if (otool -l $e | grep "name.*$p.*offset" >/dev/null 2>/dev/null) && (echo $e | grep -v $p >/dev/null 2>/dev/null) ; then
                ORIG_NAME=$(otool -l $e | grep "name.*$p.*" | sed 's/.*name \(.*\) (offset.*)/\1/')
                ORIG_BASE=$(basename $ORIG_NAME)
                echo "Fixing $p as a dependency of $e: $ORIG_NAME => @rpath/$ORIG_BASE"
                install_name_tool -change $ORIG_NAME '@rpath/'$ORIG_BASE $e
            else
                echo "$e does not have $p as dependency"
            fi

        done
    done
fi