forked from mwotton/heroku-buildpack-haskell
-
Notifications
You must be signed in to change notification settings - Fork 32
/
precompile-binaries.sh
66 lines (53 loc) · 1.91 KB
/
precompile-binaries.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
# libgmp hack
mkdir -p $HOME/usr/lib
ln -s /usr/lib/libgmp.so.3 $HOME/usr/lib/libgmp.so
# ghc
curl --silent http://www.haskell.org/ghc/dist/7.4.1/ghc-7.4.1-x86_64-unknown-linux.tar.bz2|tar xj
cd ghc-7.4.1/
./configure --prefix=$HOME/ghc --with-gmp-libraries=$HOME/usr/lib
make install
cd ..
# GHC space trimming (risky business)
# Remove haddock and hpc - no docs or coverage
rm $HOME/ghc/bin/haddock*
rm $HOME/ghc/lib/ghc-7.4.1/haddock
rm -r $HOME/ghc/lib/ghc-7.4.1/html
rm -r $HOME/ghc/lib/ghc-7.4.1/latex
# rm $HOME/ghc/bin/hp*
# rm -r $HOME/ghc/lib/ghc-7.4.1/hp*
# rm -r $HOME/ghc/lib/ghc-7.4.1/package.conf.d/hpc-0.5.1.1-*
# rm -r $HOME/ghc/lib/ghc-7.4.1/ghc-7.4.1
# rm -r $HOME/ghc/lib/ghc-7.4.1/package.conf.d/ghc-7.4.1-*
# rm -r $HOME/ghc/lib/ghc-7.4.1/package.conf.d/package.cache
echo "" > $HOME/ghc/lib/ghc-7.4.1/ghc-usage.txt
echo "" > $HOME/ghc/lib/ghc-7.4.1/ghci-usage.txt
# Remove duplicate libs
find $HOME/ghc/lib -name "*_p.a" -delete
find $HOME/ghc/lib -name "*.p_hi" -delete
find $HOME/ghc/lib -name "*.dyn_hi" -delete
find $HOME/ghc/lib -name "*HS*.so" -delete
find $HOME/ghc/lib -name "*HS*.o" -delete
find $HOME/ghc/lib -name "*_debug.a" -delete
# Don't need man or doc
rm -rf $HOME/ghc/share
# Strip binaries
strip --strip-unneeded $HOME/ghc/lib/ghc-7.4.1/{run,}ghc
export PATH=$PATH:$HOME/ghc/bin
# ldconfig for linker hack
ghc-pkg describe base > base.package.conf
sed -i "s/ld-options:/ld-options:\ -L\/app\/usr\/lib/" base.package.conf
ghc-pkg update base.package.conf
# cabal-install
curl --silent http://hackage.haskell.org/packages/archive/cabal-install/1.16.0.1/cabal-install-1.16.0.1.tar.gz|tar xz
cd cabal-install-1.16.0.1/
sh bootstrap.sh
cd ..
export PATH=$PATH:$HOME/.cabal
# Install a binary that Yesod needs separately
cabal update
cabal install happy
find $HOME/.cabal -name "*HS*.o" -delete
rm -rf $HOME/.cabal/{config,share,packages,logs}
tar cvzf ghc.tar.gz ghc
tar cvzf cabal.tar.gz .cabal