summaryrefslogtreecommitdiff
path: root/bin/build-binary-dist.sh
blob: cf8caf2181298f2abaf06c7862f409f63aee8af0 (plain)
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
#! /bin/bash

### This script builds a binary distribution tarball of GF from the source
### package that this script is a part of. It assumes that you have installed
### the Haskell Platform, version 2013.2.0.0 or 2012.4.0.0.

os=$(uname)     # Operating system name (e.g. Darwin or Linux)
hw=$(uname -m)  # Hardware name (e.g. i686 or x86_64)

# GF version number:
ver=$(grep -i ^version: gf.cabal | sed -e 's/version://' -e 's/ //g')

destdir=/tmp/gf-binary-dist-$$     # assemble binary dist here
prefix=/usr/local                  # where to install
targz=gf-$ver-bin-$hw-$os.tar.gz   # the final tar file

extralib="$destdir$prefix/lib"
extrainclude="$destdir$prefix/include"
extra="--extra-lib-dirs=$extralib --extra-include-dirs=$extrainclude"

set -e                             # Stop if an error occurs
set -x                             # print commands before exuting them

## First configure & build the C run-time system
pushd src/runtime/c
bash setup.sh configure --prefix=$prefix
bash setup.sh build
bash setup.sh install prefix=$destdir$prefix
popd

## Build the python binding to the C run-time system
pushd src/runtime/python
EXTRA_INCLUDE_DIRS="$extrainclude" EXTRA_LIB_DIRS="$extralib" python setup.py build
python setup.py install --prefix=$destdir$prefix
popd

## Build the Java binding to the C run-time system
pushd src/runtime/java
# not implemented yet
popd

## Build GF, with C run-time support enabled
cabal install --only-dependencies
cabal configure --prefix=$prefix -fserver -fc-runtime $extra
DYLD_LIBRARY_PATH="$extralib" LD_LIBRARY_PATH="$extralib" cabal build
DYLD_LIBRARY_PATH="$extralib" LD_LIBRARY_PATH="$extralib" cabal copy --destdir=$destdir

tar -C $destdir/$prefix -zcf $targz .
echo "Created $targz, consider renaming it to something more user friendly"
rm -r $destdir