-F full-split
[llpp.git] / buildall.sh
blobff9fb470ca635e7c9e6ecd064c4645cd8ed5bbd2
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/mupdf-thirdparty-2012-03-07.zip
21 mupdfrev=22bbb6e6d3bcd01b164e91ecf500dc9d7305269e
22 mudir=mupdf-22bbb6e
24 test -d lablGL-1.04 || (wget -nc $lablgl && tar -xzf lablgl-1.04.tar.gz)
26 if ! test -d $mudir; then
27 wget -nc \
28 "http://git.ghostscript.com/?p=mupdf.git;a=snapshot;h=$mupdfrev;sf=tgz" \
29 -O mupdf-$mupdfrev.tgz && tar -xzf mupdf-$mupdfrev.tgz
32 test -d $mudir/thirdparty || \
33 (wget -nc $mupdf3p && unzip -d $mudir $(basename $mupdf3p))
35 executable_p() {
36 command -v $1 >/dev/null 2>&1
39 executable_p gmake && make=gmake || make=make
41 (cd lablGL-1.04 \
42 && sed 17d Makefile.config.linux.mdk > Makefile.config \
43 && $make lib libopt \
44 && $make install \
45 BINDIR=$root/bin \
46 LIBDIR=$root/lib/ocaml \
47 DLLDIR=$root/lib/ocaml/stublibs \
48 INSTALLDIR=$root/lib/ocaml/lablGL)
50 (cd $mudir && $make -j "$jobs" build=release)
52 cd ..
54 srcpath=$(dirname $0)
56 sh $srcpath/mkhelp.sh $srcpath/keystoml.ml $srcpath/KEYS > help.ml
58 tp=$root/$mudir/thirdparty
60 ccopt="-O"
61 ccopt="$ccopt -I $tp/jbig2dec"
62 ccopt="$ccopt -I $tp/jpeg-8d"
63 ccopt="$ccopt -I $tp/freetype-2.4.8/include"
64 ccopt="$ccopt -I $tp/openjpeg-1.4/libopenjpeg"
65 ccopt="$ccopt -I $tp/zlib-1.2.5"
66 ccopt="$ccopt -I $root/$mudir/fitz -I $root/$mudir/pdf -I $root/$mudir/xps"
67 ccopt="$ccopt -I $root/$mudir/cbz"
69 ccopt="$ccopt -include $tp/freetype-2.4.8/include/ft2build.h -D_GNU_SOURCE"
71 cclib="$cclib -L$root/$mudir/build/release"
72 cclib="$cclib -lfitz"
73 cclib="$cclib -lz -ljpeg -lopenjpeg -ljbig2dec -lfreetype"
74 cclib="$cclib -lX11"
76 echo Building llpp...
77 if test "$1" = "opt"; then
78 cclib="$cclib -lpthread"
79 executable_p ocamlopt.opt && comp=ocamlopt.opt || comp=ocamlopt
80 $comp -c -o link.o -ccopt "$ccopt" $srcpath/link.c
81 $comp -c -o help.cmx help.ml
82 $comp -c -o wsi.cmi $srcpath/wsi.mli
83 $comp -c -o wsi.cmx $srcpath/wsi.ml
84 $comp -c -o parser.cmx $srcpath/parser.ml
85 $comp -c -o main.cmx -I $root/lib/ocaml/lablGL $srcpath/main.ml
87 $comp -o llpp \
88 -I $root/lib/ocaml/lablGL \
89 str.cmxa unix.cmxa lablgl.cmxa \
90 link.o \
91 -cclib "$cclib" \
92 help.cmx \
93 parser.cmx \
94 wsi.cmx \
95 main.cmx
96 else
97 executable_p ocamlc.opt && comp=ocamlc.opt || comp=ocamlc
98 $comp -c -o link.o -ccopt "$ccopt" $srcpath/link.c
99 $comp -c -o help.cmo help.ml
100 $comp -c -o wsi.cmi $srcpath/wsi.mli
101 $comp -c -o wsi.cmo $srcpath/wsi.ml
102 $comp -c -o parser.cmo $srcpath/parser.ml
103 $comp -c -o main.cmo -I $root/lib/ocaml/lablGL $srcpath/main.ml
105 $comp -custom -o llpp \
106 -I $root/lib/ocaml/lablGL \
107 str.cma unix.cma lablgl.cma \
108 link.o \
109 -cclib "$cclib" \
110 help.cmo \
111 parser.cmo \
112 wsi.cmo \
113 main.cmo
115 echo All done