Shrug
[llpp.git] / buildall.sh
blob9d567be53206c12c0d5778e7e9af86252c00a8aa
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 baseurl="http://git.ghostscript.com/"
22 mupdfrev=1b4b5fdfa6b74827631d42efd2a61226125f036b
23 submodules="freetype jbig2dec jpeg openjpeg zlib"
24 freetyperev=2ef0a19842ae1172bec153225328aaaeaf130a18
25 jbig2decrev=3e6c1b0670740be3b138228dcc134bf5e6c1eceb
26 jpegrev=219d59dcfd0e6ce8a3d8c5510e29237f0b5078ed
27 openjpegrev=d5693f4ec8635d81defc92619c02134b6b785b06
28 zlibrev=c16b1b18ddaaf090caf321af831bccac6381a381
30 mudir=mupdf-$(printf "%.7s" $mupdfrev)
31 mutgz=mupdf-$mupdfrev.tgz
32 muurl="${baseurl}?p=mupdf.git;a=snapshot;h=$mupdfrev;sf=tgz"
34 test -d lablGL-1.04 || (wget -nc $lablgl && tar -xzf lablgl-1.04.tar.gz)
36 test -e $mutgz || wget -nc $muurl -O $mutgz
37 test -d $mudir || tar -xzf $mutgz
39 for m in $submodules; do
40 eval r=\$${m}rev
41 d=$m-$(printf "%.7s" $r)
42 t=$m-$r.tgz
43 p=$m
44 test $m = jbig2dec || p=thirdparty/$m
45 u="${baseurl}?p=$p.git;a=snapshot;h=$r;sf=tgz"
46 test -e $t || wget -nc $u -O $t
47 rm -fr $mudir/thirdparty/$m
48 tar -xzf $t && mv $d $mudir/thirdparty/$m
49 done
51 executable_p() {
52 command -v $1 >/dev/null 2>&1
55 executable_p gmake && make=gmake || make=make
57 (cd lablGL-1.04 \
58 && sed 17d Makefile.config.linux.mdk > Makefile.config \
59 && $make -j 1 lib $(test "$1" = opt && echo libopt) \
60 && $make -j 1 install \
61 BINDIR=$root/bin \
62 LIBDIR=$root/lib/ocaml \
63 DLLDIR=$root/lib/ocaml/stublibs \
64 INSTALLDIR=$root/lib/ocaml/lablGL)
66 (cd $mudir && $make -j "$jobs" build=release)
68 cd ..
70 srcpath=$(dirname $0)
72 tp=$root/$mudir/thirdparty
74 ccopt="-O"
75 ccopt="$ccopt -I $tp/jbig2dec"
76 ccopt="$ccopt -I $tp/jpeg"
77 ccopt="$ccopt -I $tp/freetype/include"
78 ccopt="$ccopt -I $tp/openjpeg/libopenjpeg"
79 ccopt="$ccopt -I $tp/zlib"
80 ccopt="$ccopt -I $root/$mudir/fitz -I $root/$mudir/pdf -I $root/$mudir/xps"
81 ccopt="$ccopt -I $root/$mudir/cbz"
83 ccopt="$ccopt -include $tp/freetype/include/ft2build.h -D_GNU_SOURCE"
85 cclib="$cclib -L$root/$mudir/build/release"
86 cclib="$cclib -lfitz"
87 cclib="$cclib -lz -ljpeg -lopenjpeg -ljbig2dec -lfreetype -lpthread"
88 cclib="$cclib -lX11"
90 echo Building llpp...
92 sh $srcpath/mkhelp.sh $srcpath/keystoml.ml $srcpath/KEYS > help.ml
94 if test "$1" = "opt"; then
95 executable_p ocamlopt.opt && comp=ocamlopt.opt || comp=ocamlopt
96 cmsuf=cmx
97 dolink() {
98 $comp -o llpp \
99 -I $root/lib/ocaml/lablGL \
100 str.cmxa unix.cmxa lablgl.cmxa \
101 link.o \
102 -cclib "$cclib" \
103 help.cmx \
104 utils.cmx \
105 parser.cmx \
106 wsi.cmx \
107 main.cmx
109 else
110 executable_p ocamlc.opt && comp=ocamlc.opt || comp=ocamlc
111 cmsuf=cmo
112 dolink() {
113 $comp -custom -o llpp \
114 -I $root/lib/ocaml/lablGL \
115 str.cma unix.cma lablgl.cma \
116 link.o \
117 -cclib "$cclib" \
118 help.cmo \
119 utils.cmo \
120 parser.cmo \
121 wsi.cmo \
122 main.cmo
126 $comp -c -o link.o -ccopt "$ccopt" $srcpath/link.c
127 $comp -c -o help.$cmsuf help.ml
128 $comp -c -o utils.$cmsuf $srcpath/utils.ml
129 $comp -c -o wsi.cmi $srcpath/wsi.mli
130 $comp -c -o wsi.$cmsuf $srcpath/wsi.ml
131 $comp -c -o parser.$cmsuf $srcpath/parser.ml
132 $comp -c -o main.$cmsuf -I $root/lib/ocaml/lablGL $srcpath/main.ml
133 dolink
135 echo All done