forked from alavrik/piqi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·134 lines (111 loc) · 3.2 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/sh
# "prefix" path for installing "piqi" and "piqic-ocaml" executables
PREFIX=/usr/local
# path for installing Piqi OCaml libraries. If not set, the ocamlfind
# destination directory path will be used. Such path is determined by
# OCAMLFIND_DESTDIR environment variable or by ocamlfind config. You can run
# "ocamlfind printconf destdir" to see the current setting.
OCAML_LIBDIR=
usage() {
echo "
Configuration:
-h, --help display this help and exit
--host HOST cross-compile toolchain prefix, e.g. i686-w64-mingw32
Installation directories:
--prefix PREFIX install piqi executables in PREFIX/bin/
[/usr/local]
--ocaml-libdir DIR install OCaml libraries to DIR
[\`ocamlfind printconf destdir\`]
"
}
while [ "$#" != "0" ]
do
opt="$1"
case "$opt" in
--*=*)
opt_value=`expr "X$opt" : '[^=]*=\(.*\)'`
;;
--*)
shift
opt_value="$1"
;;
esac
case "$opt" in
--prefix | --prefix=*)
PREFIX="$opt_value"
;;
--ocaml-libdir | --ocaml-libdir=*)
OCAML_LIBDIR="$opt_value"
;;
--host | --host=*)
SYSTEM_HOST="$opt_value"
;;
-h|-help|--help)
usage
exit 0
;;
*)
echo "configure: run 'configure -h' to get help" 1>&2
exit 1
;;
esac
shift
done
if [ -z "$SYSTEM_HOST" ]
then
OCAMLFIND=ocamlfind
else
# cross-compilation toolchain
OCAMLFIND=$SYSTEM_HOST-ocamlfind
fi
OF=`which $OCAMLFIND`
if [ $? -ne 0 ]
then
echo "configure: error: failed to find ${OCAMLFIND}. See INSTALL for details" 1>&2
exit 1
fi
echo "found $OCAMLFIND: $OF"
M=Makefile.config
# configure options
echo "# Makefile.config generated by ./configure" > $M
echo >> $M
echo "PIQI_PREFIX=$PREFIX" >> $M
echo "PIQI_OCAML_DESTDIR=$OCAML_LIBDIR" >> $M
echo >> $M
# build environment
echo "export PIQI_ROOT := `pwd`" >> $M
# temporary build directory
echo "export PIQI_BUILD := \$(PIQI_ROOT)/build" >> $M
# path to .piqi files
echo "export PIQI_PATH := \$(PIQI_ROOT)" >> $M
echo >> $M
# we have to define these for cross-compilation
if [ -n "$SYSTEM_HOST" ]
then
echo "export OCAMLFIND := $SYSTEM_HOST-ocamlfind" >> $M
echo "export AR := $SYSTEM_HOST-ar" >> $M
echo "STRIP := $SYSTEM_HOST-strip" >> $M
# skipping everything else in cross-compilation mode; namely, we have to
# cross-compile deps that come with the package
echo "export SYSTEM := unix" >> $M
exit
fi
# detecting the type of OCaml toolchain
system="`ocamlc -config 2>/dev/null | grep system | sed 's/system: //'`"
echo "export SYSTEM := $system" >> $M
echo >> $M
echo "detected $system OCaml toolchain"
# figure out which dependencies we need to build
echo "checking whether necessary dependencies are already installed..."
for i in xmlm ulex easy-format
do
dir="`ocamlfind query $i 2>/dev/null`"
if [ $? -eq 0 ]
then
echo "$i is installed in $dir"
echo "SKIP-$i = 1" >> $M
else
echo "$i is not installed; it will be built during \"make deps\""
fi
done
# ex: sw=4 ts=4 et