-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildall.sh
115 lines (95 loc) · 3.34 KB
/
buildall.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# builds "hard" prerequisites and llpp
set -e
jobs=1
while getopts j: opt; do
case "$opt" in
j) jobs="$OPTARG";;
?)
printf "usage: $0 [-j N] [opt]\n";
exit 1;;
esac
done
shift $(($OPTIND - 1))
mkdir -p 3rdp
cd 3rdp
root=$(pwd)
lablgl=http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/dist/lablgl-1.04.tar.gz
mupdf3p=http://mupdf.com/download/mupdf-thirdparty-2012-04-23.zip
mupdfrev=a606f714258677688c67e9561b87cc70f9e9b6b0
mudir=mupdf-a606f71
test -d lablGL-1.04 || (wget -nc $lablgl && tar -xzf lablgl-1.04.tar.gz)
if ! test -d $mudir; then
wget -nc \
"http://git.ghostscript.com/?p=mupdf.git;a=snapshot;h=$mupdfrev;sf=tgz" \
-O mupdf-$mupdfrev.tgz && tar -xzf mupdf-$mupdfrev.tgz
fi
test -d $mudir/thirdparty || \
(wget -nc $mupdf3p && unzip -d $mudir $(basename $mupdf3p))
executable_p() {
command -v $1 >/dev/null 2>&1
}
executable_p gmake && make=gmake || make=make
(cd lablGL-1.04 \
&& sed 17d Makefile.config.linux.mdk > Makefile.config \
&& $make lib libopt \
&& $make install \
BINDIR=$root/bin \
LIBDIR=$root/lib/ocaml \
DLLDIR=$root/lib/ocaml/stublibs \
INSTALLDIR=$root/lib/ocaml/lablGL)
(cd $mudir && $make -j "$jobs" build=release)
cd ..
srcpath=$(dirname $0)
sh $srcpath/mkhelp.sh $srcpath/keystoml.ml $srcpath/KEYS > help.ml
tp=$root/$mudir/thirdparty
ccopt="-O"
ccopt="$ccopt -I $tp/jbig2dec"
ccopt="$ccopt -I $tp/jpeg-8d"
ccopt="$ccopt -I $tp/freetype-2.4.9/include"
ccopt="$ccopt -I $tp/openjpeg-1.4/libopenjpeg"
ccopt="$ccopt -I $tp/zlib-1.2.5"
ccopt="$ccopt -I $root/$mudir/fitz -I $root/$mudir/pdf -I $root/$mudir/xps"
ccopt="$ccopt -I $root/$mudir/cbz"
ccopt="$ccopt -include $tp/freetype-2.4.9/include/ft2build.h -D_GNU_SOURCE"
cclib="$cclib -L$root/$mudir/build/release"
cclib="$cclib -lfitz"
cclib="$cclib -lz -ljpeg -lopenjpeg -ljbig2dec -lfreetype"
cclib="$cclib -lX11"
echo Building llpp...
if test "$1" = "opt"; then
cclib="$cclib -lpthread"
executable_p ocamlopt.opt && comp=ocamlopt.opt || comp=ocamlopt
$comp -c -o link.o -ccopt "$ccopt" $srcpath/link.c
$comp -c -o help.cmx help.ml
$comp -c -o wsi.cmi $srcpath/wsi.mli
$comp -c -o wsi.cmx $srcpath/wsi.ml
$comp -c -o parser.cmx $srcpath/parser.ml
$comp -c -o main.cmx -I $root/lib/ocaml/lablGL $srcpath/main.ml
$comp -o llpp \
-I $root/lib/ocaml/lablGL \
str.cmxa unix.cmxa lablgl.cmxa \
link.o \
-cclib "$cclib" \
help.cmx \
parser.cmx \
wsi.cmx \
main.cmx
else
executable_p ocamlc.opt && comp=ocamlc.opt || comp=ocamlc
$comp -c -o link.o -ccopt "$ccopt" $srcpath/link.c
$comp -c -o help.cmo help.ml
$comp -c -o wsi.cmi $srcpath/wsi.mli
$comp -c -o wsi.cmo $srcpath/wsi.ml
$comp -c -o parser.cmo $srcpath/parser.ml
$comp -c -o main.cmo -I $root/lib/ocaml/lablGL $srcpath/main.ml
$comp -custom -o llpp \
-I $root/lib/ocaml/lablGL \
str.cma unix.cma lablgl.cma \
link.o \
-cclib "$cclib" \
help.cmo \
parser.cmo \
wsi.cmo \
main.cmo
fi
echo All done