Skip to content

Commit c51aefe

Browse files
committed
Darwin: pack dynamic libraries along with the exe
This solves the any insufficiencies that Homebrew has or might has regarding the handling of such shared library dependencies.
1 parent 954df7b commit c51aefe

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

fancydiff.cabal

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ category: Console
1212
build-type: Custom
1313
cabal-version: >=1.10
1414

15+
flag static
16+
manual: True
17+
default: False
18+
1519
library
1620
hs-source-dirs: src
1721
ghc-options: -Wall -O2 -rtsopts
@@ -66,6 +70,8 @@ executable fancydiff
6670
, transformers >= 0.4.2.0
6771
, optparse-applicative
6872
default-language: Haskell2010
73+
if flag(static)
74+
ld-options: -v
6975

7076
test-suite fancydiff-test
7177
type: exitcode-stdio-1.0

packaging/darwin

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,34 @@ pack() {
3939
pdir=${t}/PACK/${tarball}
4040

4141
mkdir -p ${pdir}/bin
42-
cp -a ${exe_path} ${pdir}/bin/fancydiff
42+
cat - > ${pdir}/bin/fancydiff <<EOF
43+
#!/bin/bash
44+
45+
t=\${BASH_SOURCE[0]}
46+
d=\$(dirname \${t})
47+
dl=\$(dirname \${d})/deps
48+
export DYLD_LIBRARY_PATH=\${dl}
49+
exec \${d}/../exe/fancydiff "\$@"
50+
51+
EOF
52+
chmod a+x ${pdir}/bin/fancydiff
53+
mkdir -p ${pdir}/deps
54+
55+
for i in $(otool -L ${exe_path} | grep /usr/local | awk -F" " '{print $1}') ; do
56+
d=$(dirname ${i})
57+
b=$(basename ${i})
58+
for j in $(ls -1 ${d}) ; do
59+
if [[ "$(readlink $d/$j)" == "$b" ]] ; then
60+
ln -s ${b} ${pdir}/deps/${j}
61+
fi
62+
done
63+
cp $i ${pdir}/deps
64+
done
65+
66+
mkdir -p ${pdir}/exe
67+
cp -a ${exe_path} ${pdir}/exe/fancydiff
4368
cp -a ${t}/../LICENSE ${pdir}/LICENSE.txt
4469

45-
mkdir -p ${pdir}/doc
4670
cp -a ${t}/../doc ${pdir}/doc
4771
cp -a ${t}/../README.md ${pdir}
4872

@@ -80,14 +104,13 @@ class Fancydiff < Formula
80104
version "${tag}"
81105
82106
depends_on :arch => :x86_64
83-
depends_on "icu4c"
84-
depends_on "openssl"
85107
86108
bottle :unneeded
87109
88110
def install
89-
bin.install "bin/fancydiff"
90-
doc.install Dir["doc/*"]
111+
doc.install Dir["doc/*", "README.md", "LICENSE.txt"]
112+
libexec.install Dir["bin", "exe", "deps"]
113+
bin.write_exec_script Dir["#{libexec}/bin/*"]
91114
end
92115
end
93116

0 commit comments

Comments
 (0)