configure

changeset 463
a2452d3bd828
child 467
66f145f5c932
equal deleted inserted replaced
462:c6fd961b98f9 463:a2452d3bd828
1 #!/bin/sh
2
3 # Defaults
4
5 PREFIX=/usr/local
6 SYSCONFDIR="$PREFIX/etc/prosody"
7 LUA_SUFFIX=""
8 LUA_DIR="/usr"
9 LUA_BINDIR="/usr/bin"
10 LUA_INCDIR="/usr/include"
11 LUA_LIBDIR="/usr/lib"
12 IDN_LIB=idn
13 OPENSSL_LIB=ssl
14
15 # Help
16
17 show_help() {
18 cat <<EOF
19 Configure Prosody prior to building.
20
21 --help This help.
22 --prefix=DIR Prefix where Prosody should be installed.
23 Default is $PREFIX
24 --sysconfdir=DIR Location where the config file should be installed.
25 Default is \$PREFIX/etc/prosody
26 --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames.
27 Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...)
28 --with-lua=PREFIX Use Lua from given prefix.
29 Default is $LUA_DIR
30 --with-lua-include=DIR You can also specify Lua's includes dir.
31 Default is \$LUA_DIR/include
32 --with-lua-lib=DIR You can also specify Lua's libraries dir.
33 Default is \$LUA_DIR/lib
34 --with-idn=LIB The name of the IDN library to link with.
35 Default is $IDN_LIB
36 --with-ssl=LIB The name of the SSL to link with.
37 Default is $OPENSSL_LIB
38 --require-config Will cause Prosody to refuse to run when
39 it fails to find a configuration file
40 EOF
41 }
42
43
44 while [ "$1" ]
45 do
46 value="`echo $1 | sed 's/.*=\(.*\)/\1/'`"
47 if echo "$value" | grep -q "~"
48 then
49 echo
50 echo '*WARNING*: the "~" sign is not expanded in flags.'
51 echo 'If you mean the home directory, use $HOME instead.'
52 echo
53 fi
54 case "$1" in
55 --help)
56 show_help
57 exit 0
58 ;;
59 --prefix=*)
60 PREFIX="$value"
61 PREFIX_SET=yes
62 ;;
63 --require-config)
64 REQUIRE_CONFIG=yes
65 ;;
66 --lua-suffix=*)
67 LUA_SUFFIX="$value"
68 LUA_SUFFIX_SET=yes
69 ;;
70 --with-lua=*)
71 LUA_DIR="$value"
72 LUA_DIR_SET=yes
73 ;;
74 --with-lua-include=*)
75 LUA_INCDIR="$value"
76 LUA_INCDIR_SET=yes
77 ;;
78 --with-lua-lib=*)
79 LUA_LIBDIR="$value" LUA_LIBDIR_SET=yes
80 ;;
81 --with-idn=*)
82 IDN_LIB="$value"
83 ;;
84 --with-ssl=*)
85 OPENSSL_LIB="$value"
86 ;;
87 *)
88 echo "Error: Unknown flag: $1"
89 exit 1
90 ;;
91 esac
92 shift
93 done
94
95 if [ "$PREFIX_SET" = "yes" -a ! "$SYSCONFDIR_SET" = "yes" ]
96 then
97 if [ "$PREFIX" = "/usr" ]
98 then SYSCONFDIR=/etc/prosody
99 else SYSCONFDIR=$PREFIX/etc/prosody
100 fi
101 fi
102
103 find_program() {
104 path="$PATH"
105 item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`"
106 path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`"
107 found="no"
108 while [ "$item" ]
109 do
110 if [ -e "$item/$1" ]
111 then
112 found="yes"
113 break
114 fi
115 item="`echo "$path" | sed 's/\([^:]*\):.*/\1/'`"
116 path="`echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p'`"
117 done
118 if [ "$found" = "yes" ]
119 then
120 echo "$item"
121 else
122 echo ""
123 fi
124 }
125
126 if [ "$LUA_SUFFIX_SET" != "yes" ]
127 then
128 for suffix in "" "5.1" "51" ""
129 do
130 LUA_SUFFIX="$suffix"
131 if [ "$LUA_DIR_SET" = "yes" ]
132 then
133 if [ -e "$LUA_DIR/bin/lua$suffix" ]
134 then
135 find_lua="$LUA_DIR"
136 fi
137 else
138 find_lua=`find_program lua$suffix`
139 fi
140 if [ "$find_lua" ]
141 then
142 echo "Lua interpreter found: $find_lua/lua$suffix..."
143 break
144 fi
145 done
146 fi
147
148 if ! [ "$LUA_DIR_SET" = "yes" ]
149 then
150 echo -n "Looking for Lua... "
151 if [ ! "$find_lua" ]
152 then
153 find_lua=`find_program lua$LUA_SUFFIX`
154 echo "lua$LUA_SUFFIX found in \$PATH: $find_lua"
155 fi
156 if [ "$find_lua" ]
157 then
158 LUA_DIR=`dirname $find_lua`
159 LUA_BINDIR="$find_lua"
160 else
161 echo "lua$LUA_SUFFIX not found in \$PATH."
162 echo "You may want to use the flags --with-lua and/or --lua-suffix. See --help."
163 exit 1
164 fi
165 fi
166
167 if ! [ "$LUA_INCDIR_SET" = "yes" ]
168 then
169 LUA_INCDIR="$LUA_DIR/include"
170 fi
171
172 if ! [ "$LUA_LIBDIR_SET" = "yes" ]
173 then
174 LUA_LIBDIR="$LUA_DIR/lib"
175 fi
176
177 if [ "$LUA_DIR_SET" = "yes" ]
178 then
179 LUA_BINDIR="$LUA_DIR/bin"
180 fi
181
182 echo -n "Checking Lua includes... "
183 lua_h="$LUA_INCDIR/lua.h"
184 if [ -e "$lua_h" ]
185 then
186 echo "lua.h found in $lua_h"
187 else
188 echo "lua.h not found (looked in $lua_h)"
189 echo "You may want to use the flag --with-lua-include. See --help."
190 exit 1
191 fi
192
193 find_helper() {
194 explanation="$1"
195 shift
196 tried="$*"
197 while [ "$1" ]
198 do
199 found=`find_program "$1"`
200 if [ "$found" ]
201 then
202 echo "$1 found at $found"
203 HELPER=$1
204 return
205 fi
206 shift
207 done
208 echo "Could not find a $explanation. Tried: $tried."
209 echo "Make sure one of them is installed and available in your PATH."
210 exit 1
211 }
212
213 # Write config
214
215 echo "Writing configuration..."
216 echo
217
218 cat <<EOF > config.unix
219 # This file was automatically generated by the configure script.
220 # Run "./configure --help" for details.
221
222 PREFIX=$PREFIX
223 SYSCONFDIR=$SYSCONFDIR
224 LUA_SUFFIX=$LUA_SUFFIX
225 LUA_DIR=$LUA_DIR
226 LUA_INCDIR=$LUA_INCDIR
227 LUA_LIBDIR=$LUA_LIBDIR
228 LUA_BINDIR=$LUA_BINDIR
229 REQUIRE_CONFIG=$REQUIRE_CONFIG
230 IDN_LIB=$IDN_LIB
231 OPENSSL_LIB=$OPENSSL_LIB
232
233 EOF
234
235 echo "Installation prefix: $PREFIX"
236 echo "Prosody configuration directory: $SYSCONFDIR"
237 echo "Using Lua from: $LUA_DIR"
238
239 make clean > /dev/null 2> /dev/null
240
241 echo
242 echo "Done. You can now run 'make' to build."
243 echo

mercurial