Simplify
[llpp.git] / configure.sh
blobea8b804d52421d78603e068e735f76e0b9bad57f
1 #!/bin/sh
2 set -e
4 unset cflags
5 buildtype=native
7 usage () {
8 echo "$1"
9 cat 1>&2 <<EOF
10 usage: $0 [-F] [-b build-type] [mudir]
11 options:
12 -F: use fontconfig
13 -b: MuPDF's build type [default native]
15 build-type = debug|release|native
16 mudir = path to MuPDF's git checkout
17 EOF
18 exit $2
21 while getopts eFb: opt; do
22 case $opt in
23 F) fontconfig=true; cflags="$cflags -DUSE_FONTCONFIG";;
24 b) buildtype="$OPTARG";;
25 ?) usage "" 0;;
26 esac
27 done
28 shift $((OPTIND - 1))
30 mupdf="$1"
31 test -e "$mupdf" || usage "Don't know where to find MuPDF's git checkout" 1
33 pkgs="freetype2 zlib openssl libopenjp2" # j(peg|big2dec)?
34 test $fontconfig && pkgs="$pkgs fontconfig" || true
35 pwd=$(pwd -P)
37 expr >/dev/null "$0" : "/.*" && {
38 path="$0"
39 builddir="$pwd"
40 helpcmdl=" -f $(dirname $path)/build.ninja"
41 } || {
42 path="$pwd/$0"
43 builddir="build"
44 helcmdl=""
45 mkdir -p $builddir
47 builddir=$(cd $builddir >/dev/null $builddir && pwd -P)
49 libs="$(pkg-config --libs $pkgs) -ljpeg -ljbig2dec"
51 (cat <<EOF
52 cflags=$cflags $(pkg-config --cflags $pkgs)
53 lflags=$libs
54 srcdir=$(cd >/dev/null $(dirname $0) && pwd -P)
55 buildtype=$buildtype
56 mupdf=$mupdf
57 builddir=$builddir
58 EOF
59 test $(uname -m) = "x86_64" && {
60 echo 'cflags=$cflags -fPIC'
61 echo "mujs=-lmujs"
62 }) >.config || true
64 cat <<EOF
65 Configuration results are saved in $(pwd -P)/.config
66 To build - type: ninja$helpcmdl
67 EOF