Provide more feedback and be more conistent when reading .Xauthority
[llpp.git] / buildall.sh
blob9303138dc719c185a144d1d0c44b817d1a204aea
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=a1a37ae36043d8dba89cecfa345119ad32f81b9e
22 mudir=mupdf-a1a37ae
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 lib $(test "$1" = opt && echo libopt) \
43 && $make 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 sh $srcpath/mkhelp.sh $srcpath/keystoml.ml $srcpath/KEYS > help.ml
62 tp=$root/$mudir/thirdparty
64 ccopt="-O"
65 ccopt="$ccopt -I $tp/jbig2dec"
66 ccopt="$ccopt -I $tp/jpeg-8d"
67 ccopt="$ccopt -I $tp/freetype-2.4.10/include"
68 ccopt="$ccopt -I $tp/openjpeg-1.4/libopenjpeg"
69 ccopt="$ccopt -I $tp/zlib-1.2.5"
70 ccopt="$ccopt -I $root/$mudir/fitz -I $root/$mudir/pdf -I $root/$mudir/xps"
71 ccopt="$ccopt -I $root/$mudir/cbz"
73 ccopt="$ccopt -include $tp/freetype-2.4.10/include/ft2build.h -D_GNU_SOURCE"
75 cclib="$cclib -L$root/$mudir/build/release"
76 cclib="$cclib -lfitz"
77 cclib="$cclib -lz -ljpeg -lopenjpeg -ljbig2dec -lfreetype -lpthread"
78 cclib="$cclib -lX11"
80 echo Building llpp...
81 if test "$1" = "opt"; then
82 executable_p ocamlopt.opt && comp=ocamlopt.opt || comp=ocamlopt
83 cmsuf=cmx
84 dolink() {
85 $comp -o llpp \
86 -I $root/lib/ocaml/lablGL \
87 str.cmxa unix.cmxa lablgl.cmxa \
88 link.o \
89 -cclib "$cclib" \
90 help.cmx \
91 parser.cmx \
92 wsi.cmx \
93 main.cmx
95 else
96 executable_p ocamlc.opt && comp=ocamlc.opt || comp=ocamlc
97 cmsuf=cmo
98 dolink() {
99 $comp -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
111 $comp -c -o link.o -ccopt "$ccopt" $srcpath/link.c
112 $comp -c -o help.$cmsuf help.ml
113 $comp -c -o wsi.cmi $srcpath/wsi.mli
114 $comp -c -o wsi.$cmsuf $srcpath/wsi.ml
115 $comp -c -o parser.$cmsuf $srcpath/parser.ml
116 $comp -c -o main.$cmsuf -I $root/lib/ocaml/lablGL $srcpath/main.ml
117 dolink
119 echo All done