Cosmetics
[llpp/slowscroll.git] / buildall.sh
blob05c3d04b730a96adbc953a6df99b421cad30d09b
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 mupdf3p=http://mupdf.com/download/archive/mupdf-thirdparty-2012-08-14.zip
21 mupdfrev=386c713b83f8788a80bb165431bf598b982385b3
22 mudir=mupdf-$(printf "%.7s" $mupdfrev)
23 mutgz=mupdf-$mupdfrev.tgz
24 muurl="http://git.ghostscript.com/?p=mupdf.git;a=snapshot;h=$mupdfrev;sf=tgz"
26 test -d lablGL-1.04 || (wget -nc $lablgl && tar -xzf lablgl-1.04.tar.gz)
28 test -e $mutgz || wget -nc $muurl -O $mutgz
29 test -e $(basename $mupdf3p) || wget -nc $mupdf3p
30 test -d $mudir || tar -xzf $(basename $mutgz)
31 test -d $mudir/thirdparty/openjpeg-1.5.0-patched || \
32 unzip -o -d $mudir $(basename $mupdf3p)
34 executable_p() {
35 command -v $1 >/dev/null 2>&1
38 executable_p gmake && make=gmake || make=make
40 (cd lablGL-1.04 \
41 && sed 17d Makefile.config.linux.mdk > Makefile.config \
42 && $make -j 1 lib $(test "$1" = opt && echo libopt) \
43 && $make -j 1 install \
44 BINDIR=$root/bin \
45 LIBDIR=$root/lib/ocaml \
46 DLLDIR=$root/lib/ocaml/stublibs \
47 INSTALLDIR=$root/lib/ocaml/lablGL)
49 (cd $mudir && $make -j "$jobs" build=release \
50 FREETYPE_DIR=thirdparty/freetype-2.4.10 \
51 JBIG2DEC_DIR=thirdparty/jbig2dec \
52 JPEG_DIR=thirdparty/jpeg-9 \
53 OPENJPEG_DIR=thirdparty/openjpeg-1.5.0-patched \
54 ZLIB_DIR=thirdparty/zlib-1.2.7)
56 cd ..
58 srcpath=$(dirname $0)
60 tp=$root/$mudir/thirdparty
62 ccopt="-O"
63 ccopt="$ccopt -I $tp/jbig2dec"
64 ccopt="$ccopt -I $tp/jpeg-8d"
65 ccopt="$ccopt -I $tp/freetype-2.4.10/include"
66 ccopt="$ccopt -I $tp/openjpeg-1.4/libopenjpeg"
67 ccopt="$ccopt -I $tp/zlib-1.2.5"
68 ccopt="$ccopt -I $root/$mudir/fitz -I $root/$mudir/pdf -I $root/$mudir/xps"
69 ccopt="$ccopt -I $root/$mudir/cbz"
71 ccopt="$ccopt -include $tp/freetype-2.4.10/include/ft2build.h -D_GNU_SOURCE"
73 cclib="$cclib -L$root/$mudir/build/release"
74 cclib="$cclib -lfitz"
75 cclib="$cclib -lz -ljpeg -lopenjpeg -ljbig2dec -lfreetype -lpthread"
76 cclib="$cclib -lX11"
78 echo Building llpp...
80 sh $srcpath/mkhelp.sh $srcpath/keystoml.ml $srcpath/KEYS > help.ml
82 if test "$1" = "opt"; then
83 executable_p ocamlopt.opt && comp=ocamlopt.opt || comp=ocamlopt
84 cmsuf=cmx
85 dolink() {
86 $comp -o llpp \
87 -I $root/lib/ocaml/lablGL \
88 str.cmxa unix.cmxa lablgl.cmxa \
89 link.o \
90 -cclib "$cclib" \
91 help.cmx \
92 parser.cmx \
93 wsi.cmx \
94 main.cmx
96 else
97 executable_p ocamlc.opt && comp=ocamlc.opt || comp=ocamlc
98 cmsuf=cmo
99 dolink() {
100 $comp -custom -o llpp \
101 -I $root/lib/ocaml/lablGL \
102 str.cma unix.cma lablgl.cma \
103 link.o \
104 -cclib "$cclib" \
105 help.cmo \
106 parser.cmo \
107 wsi.cmo \
108 main.cmo
112 $comp -c -o link.o -ccopt "$ccopt" $srcpath/link.c
113 $comp -c -o help.$cmsuf help.ml
114 $comp -c -o wsi.cmi $srcpath/wsi.mli
115 $comp -c -o wsi.$cmsuf $srcpath/wsi.ml
116 $comp -c -o parser.$cmsuf $srcpath/parser.ml
117 $comp -c -o main.$cmsuf -I $root/lib/ocaml/lablGL $srcpath/main.ml
118 dolink
120 echo All done