Refactor and fix some issues
[llpp.git] / buildall.sh
blobedd42d46fee6b257f41483997af5ff65769ebc9e
1 # builds "hard" prerequisites and llpp
2 set -e
4 jobs=1
5 while getopts j: opt; do
6 case "$opt" in
7 j) jobs="$OPTARG";;
8 ?)
9 printf "usage: $0 [-j N] [opt]\n";
10 exit 1;;
11 esac
12 done
13 shift $((OPTIND - 1))
15 mkdir -p 3rdp
16 cd 3rdp
17 root=$(pwd)
19 lablgl=http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/dist/lablgl-1.04.tar.gz
20 mupdf=git://git.ghostscript.com/mupdf.git
21 mupdf3p=http://mupdf.com/download/mupdf-thirdparty-2012-01-27.zip
22 mupdfrev=7d181099272d9c0e92c4488ceaa95b0d8bd10f1e
24 test -d lablGL-1.04 || (wget -nc $lablgl && tar -xzf lablgl-1.04.tar.gz)
25 if ! test -f mupdf-$mupdfrev.tgz; then
26 wget -nc \
27 "http://git.ghostscript.com/?p=mupdf.git;a=snapshot;h=$mupdfrev;sf=tgz" \
28 -O mupdf-$mupdfrev.tgz
29 tar xfz mupdf-$mupdfrev.tgz
32 test -d mupdf/thirdparty || \
33 (wget -nc $mupdf3p && unzip -d mupdf $(basename $mupdf3p))
35 make=$(gmake -v >/dev/null 2>&1 && echo gmake || echo make)
37 (cd lablGL-1.04 \
38 && cat Makefile.config.linux.mdk > Makefile.config \
39 && $make lib libopt \
40 && $make install \
41 BINDIR=$root/bin \
42 LIBDIR=$root/lib/ocaml \
43 DLLDIR=$root/lib/ocaml/stublibs \
44 INSTALLDIR=$root/lib/ocaml/lablGL)
46 (cd mupdf && $make -j "$jobs" build=release)
48 cd ..
50 srcpath=$(dirname $0)
52 sh mkhelp.sh $srcpath/keystoml.ml $srcpath/KEYS > help.ml
54 tp=$root/mupdf/thirdparty
56 ccopt="-O"
57 ccopt="$ccopt -I $tp/jbig2dec"
58 ccopt="$ccopt -I $tp/jpeg-8d"
59 ccopt="$ccopt -I $tp/freetype-2.4.8/include"
60 ccopt="$ccopt -I $tp/openjpeg-1.4/libopenjpeg"
61 ccopt="$ccopt -I $tp/zlib-1.2.5"
62 ccopt="$ccopt -I $root/mupdf/fitz -I $root/mupdf/pdf -I $root/mupdf/xps"
63 ccopt="$ccopt -I $root/mupdf/cbz"
65 ccopt="$ccopt -include ft2build.h -D_GNU_SOURCE"
67 cclib="$cclib -L$root/mupdf/build/release"
68 cclib="$cclib -lfitz"
69 cclib="$cclib -lz -ljpeg -lopenjpeg -ljbig2dec -lfreetype"
70 cclib="$cclib -lX11"
72 echo Building llpp...
73 if test "$1" = "opt"; then
74 cclib="$cclib -lpthread"
75 ocamlopt -c -o link.o -ccopt "$ccopt" $srcpath/link.c
76 ocamlopt -c -o help.cmx help.ml
77 ocamlopt -c -o wsi.cmi $srcpath/wsi.mli
78 ocamlopt -c -o wsi.cmx $srcpath/wsi.ml
79 ocamlopt -c -o parser.cmx $srcpath/parser.ml
80 ocamlopt -c -o main.cmx -I $root/lib/ocaml/lablGL $srcpath/main.ml
82 ocamlopt -o llpp \
83 -I $root/lib/ocaml/lablGL \
84 str.cmxa unix.cmxa lablgl.cmxa \
85 link.o \
86 -cclib "$cclib" \
87 help.cmx \
88 parser.cmx \
89 wsi.cmx \
90 main.cmx
91 else
92 ocamlc -c -o link.o -ccopt "$ccopt" $srcpath/link.c
93 ocamlc -c -o help.cmo help.ml
94 ocamlc -c -o wsi.cmi $srcpath/wsi.mli
95 ocamlc -c -o wsi.cmo $srcpath/wsi.ml
96 ocamlc -c -o parser.cmo $srcpath/parser.ml
97 ocamlc -c -o main.cmo -I $root/lib/ocaml/lablGL $srcpath/main.ml
99 ocamlc -custom -o llpp \
100 -I $root/lib/ocaml/lablGL \
101 str.cma unix.cma lablgl.cma \
102 link.o \
103 -cclib "$cclib" \
104 help.cmo \
105 parser.cmo \
106 wsi.cmo \
107 main.cmo
109 echo All done