Consistency
[llpp.git] / buildall.sh
blob059459629662e6b22e870b155c5d317b4502fb41
1 # builds "hard" prerequisites and llpp
2 set -e
4 while getopts j: opt; do
5 case "$opt" in
6 j) jobs="-j $OPTARG";;
7 ?)
8 printf "usage: $0 [-j N] [opt]\n";
9 exit 1;;
10 esac
11 done
12 shift $(($OPTIND - 1))
14 mkdir -p 3rdp
15 cd 3rdp
16 root=$(pwd)
18 lablgl=http://wwwfun.kurims.kyoto-u.ac.jp/soft/lsl/dist/lablgl-1.04.tar.gz
19 baseurl="http://git.ghostscript.com/"
21 mupdfrev=42db34aa0892c86e20da1063d7e4b07383fd73fe
22 mudir=mupdf-$(printf "%.7s" $mupdfrev)
23 mutgz=mupdf-$mupdfrev.tgz
24 muurl="${baseurl}?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)
27 test -e $mutgz || wget -nc $muurl -O $mutgz
28 test -d $mudir || tar -xzf $mutgz
30 while read m r; do
31 d=$m-$(printf "%.7s" $r)
32 t=$m-$r.tgz
33 test $m = jbig2dec && p=$m || p=thirdparty/$m
34 u="${baseurl}?p=$p.git;a=snapshot;h=$r;sf=tgz"
35 test -e $t || wget -nc $u -O $t
36 test -e $mudir/thirdparty/$m/README ||
37 (rm -fr $mudir/thirdparty/$m && tar -xzf $t && mv $d $mudir/thirdparty/$m)
38 done <<-EOF
39 freetype 2ef0a19842ae1172bec153225328aaaeaf130a18
40 jbig2dec d02b3649334e59e862b37c70d7d0fa9e086a524c
41 jpeg 219d59dcfd0e6ce8a3d8c5510e29237f0b5078ed
42 openjpeg 21551ac631b469a9110ef79cf2fcba6ff65636f1
43 zlib c16b1b18ddaaf090caf321af831bccac6381a381
44 EOF
46 executable_p() {
47 command -v $1 >/dev/null 2>&1
50 executable_p gmake && make=gmake || make=make
52 (cd lablGL-1.04 \
53 && sed 17d Makefile.config.linux.mdk > Makefile.config \
54 && $make -j 1 lib $(test "$1" = opt && echo libopt) \
55 && $make -j 1 install \
56 BINDIR=$root/bin \
57 LIBDIR=$root/lib/ocaml \
58 DLLDIR=$root/lib/ocaml/stublibs \
59 INSTALLDIR=$root/lib/ocaml/lablGL)
61 (cd $mudir && $make $jobs build=release)
63 cd ..
65 srcpath=$(dirname $0)
67 tp=$root/$mudir/thirdparty
69 ccopt="-O"
70 ccopt="$ccopt -I $tp/jbig2dec"
71 ccopt="$ccopt -I $tp/jpeg"
72 ccopt="$ccopt -I $tp/freetype/include"
73 ccopt="$ccopt -I $tp/openjpeg/libopenjpeg"
74 ccopt="$ccopt -I $tp/zlib"
75 ccopt="$ccopt -I $root/$mudir/fitz -I $root/$mudir/pdf -I $root/$mudir/xps"
76 ccopt="$ccopt -I $root/$mudir/cbz"
78 ccopt="$ccopt -include $tp/freetype/include/ft2build.h -D_GNU_SOURCE"
80 cclib="$cclib -L$root/$mudir/build/release"
81 cclib="$cclib -lfitz"
82 cclib="$cclib -lz -ljpeg -lopenjpeg -ljbig2dec -lfreetype -lpthread"
83 cclib="$cclib -lX11"
85 echo Building llpp...
87 sh $srcpath/mkhelp.sh $srcpath/keystoml.ml $srcpath/KEYS > help.ml
89 if test "$1" = "opt"; then
90 executable_p ocamlopt.opt && comp=ocamlopt.opt || comp=ocamlopt
91 cmsuf=cmx
92 dolink() {
93 $comp -o llpp \
94 -I $root/lib/ocaml/lablGL \
95 str.cmxa unix.cmxa lablgl.cmxa \
96 link.o \
97 -cclib "$cclib" \
98 help.cmx \
99 utils.cmx \
100 parser.cmx \
101 wsi.cmx \
102 main.cmx
104 else
105 executable_p ocamlc.opt && comp=ocamlc.opt || comp=ocamlc
106 cmsuf=cmo
107 dolink() {
108 $comp -custom -o llpp \
109 -I $root/lib/ocaml/lablGL \
110 str.cma unix.cma lablgl.cma \
111 link.o \
112 -cclib "$cclib" \
113 help.cmo \
114 utils.cmo \
115 parser.cmo \
116 wsi.cmo \
117 main.cmo
121 $comp -c -o link.o -ccopt "$ccopt" $srcpath/link.c
122 $comp -c -o help.$cmsuf help.ml
123 $comp -c -o utils.$cmsuf $srcpath/utils.ml
124 $comp -c -o wsi.cmi $srcpath/wsi.mli
125 $comp -c -o wsi.$cmsuf $srcpath/wsi.ml
126 $comp -c -o parser.$cmsuf $srcpath/parser.ml
127 $comp -c -o main.$cmsuf -I $root/lib/ocaml/lablGL $srcpath/main.ml
128 dolink
130 echo All done