Comparison

configure @ 7942:21a25b29ebeb

configure: Merge with configure from LuaRocks (which it was originally based on apparently)
author Kim Alvefur <zash@zash.se>
date Thu, 02 Mar 2017 22:58:34 +0100
parent 7935:96fa5ef5d613
child 7943:da791f11e20c
comparison
equal deleted inserted replaced
7941:8067828e7e40 7942:21a25b29ebeb
40 Default is \$PREFIX/etc/prosody 40 Default is \$PREFIX/etc/prosody
41 --libdir=DIR Location where the server files should be stored. 41 --libdir=DIR Location where the server files should be stored.
42 Default is \$PREFIX/lib 42 Default is \$PREFIX/lib
43 --datadir=DIR Location where the server data should be stored. 43 --datadir=DIR Location where the server data should be stored.
44 Default is \$PREFIX/var/lib/prosody 44 Default is \$PREFIX/var/lib/prosody
45 --lua-version=VERSION Use specific Lua version: 5.1, 5.2, or 5.3
46 Default is auto-detected.
45 --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. 47 --lua-suffix=SUFFIX Versioning suffix to use in Lua filenames.
46 Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) 48 Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...)
47 --with-lua=PREFIX Use Lua from given prefix. 49 --with-lua=PREFIX Use Lua from given prefix.
48 Default is $LUA_DIR 50 Default is auto-detected (the parent directory of \$LUA_BINDIR).
51 --with-lua-bin=DIR You can also specify Lua's bin dir.
52 Default is the directory of the auto-detected Lua interpreter,
53 or \$LUA_DIR/bin if --with-lua is used.
49 --runwith=BINARY What Lua binary to set as runtime environment. 54 --runwith=BINARY What Lua binary to set as runtime environment.
50 Default is $RUNWITH 55 Default is $RUNWITH
51 --with-lua-include=DIR You can also specify Lua's includes dir. 56 --with-lua-include=DIR You can also specify Lua's includes dir.
52 Default is \$LUA_DIR/include 57 Default is \$LUA_DIR/include
53 --with-lua-lib=DIR You can also specify Lua's libraries dir. 58 --with-lua-lib=DIR You can also specify Lua's libraries dir.
76 it fails to find a configuration file 81 it fails to find a configuration file
77 --no-example-certs Disables generation of example certificates. 82 --no-example-certs Disables generation of example certificates.
78 EOF 83 EOF
79 } 84 }
80 85
81 86 # Helper functions
82 while [ "$1" ] 87
88 find_program() {
89 prog=`command -v "$1" 2>/dev/null`
90 if [ -n "$prog" ]
91 then
92 dirname "$prog"
93 fi
94 }
95
96 die() {
97 echo "$*"
98 echo
99 echo "configure failed."
100 echo
101 exit 1
102 }
103
104 find_helper() {
105 explanation="$1"
106 shift
107 tried="$*"
108 while [ -n "$1" ]
83 do 109 do
84 value="$(echo "$1" | sed 's/[^=]*=\(.*\)/\1/')" 110 found=`find_program "$1"`
85 if echo "$value" | grep -q "~" 111 if [ -n "$found" ]
112 then
113 echo "$1 found at $found"
114 HELPER=$1
115 return
116 fi
117 shift
118 done
119 echo "Could not find $explanation. Tried: $tried."
120 die "Make sure one of them is installed and available in your PATH."
121 }
122
123 case `echo -n x` in
124 -n*) echo_n_flag='';;
125 *) echo_n_flag='-n';;
126 esac
127
128 echo_n() {
129 echo $echo_n_flag "$*"
130 }
131
132 # ----------------------------------------------------------------------------
133 # MAIN PROGRAM
134 # ----------------------------------------------------------------------------
135
136 # Parse options
137
138 while [ -n "$1" ]
139 do
140 value="`echo $1 | sed 's/[^=]*.\(.*\)/\1/'`"
141 key="`echo $1 | sed 's/=.*//'`"
142 if `echo "$value" | grep "~" >/dev/null 2>/dev/null`
86 then 143 then
87 echo 144 echo
88 echo '*WARNING*: the "~" sign is not expanded in flags.' 145 echo '*WARNING*: the "~" sign is not expanded in flags.'
89 echo 'If you mean the home directory, use $HOME instead.' 146 echo 'If you mean the home directory, use $HOME instead.'
90 echo 147 echo
91 fi 148 fi
92 case "$1" in 149 case "$key" in
93 --help) 150 --help)
94 show_help 151 show_help
95 exit 0 152 exit 0
96 ;; 153 ;;
97 --prefix=*) 154 --prefix)
155 [ -n "$value" ] || die "Missing value in flag $key."
98 PREFIX="$value" 156 PREFIX="$value"
99 PREFIX_SET=yes 157 PREFIX_SET=yes
100 ;; 158 ;;
101 --sysconfdir=*) 159 --sysconfdir)
160 [ -n "$value" ] || die "Missing value in flag $key."
102 SYSCONFDIR="$value" 161 SYSCONFDIR="$value"
103 SYSCONFDIR_SET=yes 162 SYSCONFDIR_SET=yes
104 ;; 163 ;;
105 --ostype=*) 164 --ostype)
165 # TODO make this a switch?
106 OSTYPE="$value" 166 OSTYPE="$value"
107 OSTYPE_SET=yes 167 OSTYPE_SET=yes
108 if [ "$OSTYPE" = "debian" ]; then 168 if [ "$OSTYPE" = "debian" ]; then
109 if [ "$LUA_SUFFIX_SET" != "yes" ]; then 169 if [ "$LUA_SUFFIX_SET" != "yes" ]; then
110 LUA_SUFFIX="5.1"; 170 LUA_SUFFIX="5.1";
168 LUA_INCDIR_SET=yes 228 LUA_INCDIR_SET=yes
169 fi 229 fi
170 CFLAGS="$CFLAGS" 230 CFLAGS="$CFLAGS"
171 fi 231 fi
172 ;; 232 ;;
173 --libdir=*) 233 --libdir)
174 LIBDIR="$value" 234 LIBDIR="$value"
175 LIBDIR_SET=yes 235 LIBDIR_SET=yes
176 ;; 236 ;;
177 --datadir=*) 237 --datadir)
178 DATADIR="$value" 238 DATADIR="$value"
179 DATADIR_SET=yes 239 DATADIR_SET=yes
180 ;; 240 ;;
181 --require-config) 241 --require-config)
182 REQUIRE_CONFIG=yes 242 REQUIRE_CONFIG=yes
183 ;; 243 ;;
184 --lua-suffix=*) 244 --lua-suffix)
245 [ -n "$value" ] || die "Missing value in flag $key."
185 LUA_SUFFIX="$value" 246 LUA_SUFFIX="$value"
186 LUA_SUFFIX_SET=yes 247 LUA_SUFFIX_SET=yes
187 ;; 248 ;;
188 --with-lua=*) 249 --lua-version|--with-lua-version)
250 [ -n "$value" ] || die "Missing value in flag $key."
251 LUA_VERSION="$value"
252 [ "$LUA_VERSION" = "5.1" -o "$LUA_VERSION" = "5.2" -o "$LUA_VERSION" = "5.3" ] || die "Invalid Lua version in flag $key."
253 LUA_VERSION_SET=yes
254 ;;
255 --with-lua)
256 [ -n "$value" ] || die "Missing value in flag $key."
189 LUA_DIR="$value" 257 LUA_DIR="$value"
190 LUA_DIR_SET=yes 258 LUA_DIR_SET=yes
191 ;; 259 ;;
192 --with-lua-include=*) 260 --with-lua-bin)
261 [ -n "$value" ] || die "Missing value in flag $key."
262 LUA_BINDIR="$value"
263 LUA_BINDIR_SET=yes
264 ;;
265 --with-lua-include)
266 [ -n "$value" ] || die "Missing value in flag $key."
193 LUA_INCDIR="$value" 267 LUA_INCDIR="$value"
194 LUA_INCDIR_SET=yes 268 LUA_INCDIR_SET=yes
195 ;; 269 ;;
196 --with-lua-lib=*) 270 --with-lua-lib)
197 LUA_LIBDIR="$value" LUA_LIBDIR_SET=yes 271 [ -n "$value" ] || die "Missing value in flag $key."
198 ;; 272 LUA_LIBDIR="$value"
199 --with-idn=*) 273 LUA_LIBDIR_SET=yes
274 ;;
275 --with-idn)
200 IDN_LIB="$value" 276 IDN_LIB="$value"
201 ;; 277 ;;
202 --idn-library=*) 278 --idn-library)
203 IDN_LIBRARY="$value" 279 IDN_LIBRARY="$value"
204 ;; 280 ;;
205 --with-ssl=*) 281 --with-ssl)
206 OPENSSL_LIB="$value" 282 OPENSSL_LIB="$value"
207 ;; 283 ;;
208 --with-random=getrandom) 284 --with-random)
209 PRNG=GETRANDOM 285 case "$value" in
210 ;; 286 getrandom)
211 --with-random=openssl) 287 PRNG=GETRANDOM
212 PRNG=OPENSSL 288 ;;
213 PRNGLIBS=-lcrypto 289 openssl)
214 ;; 290 PRNG=OPENSSL
215 --with-random=arc4random) 291 ;;
216 PRNG=ARC4RANDOM 292 arc4random)
217 ;; 293 PRNG=ARC4RANDOM
218 --cflags=*) 294 ;;
295 esac
296 ;;
297 --cflags)
219 CFLAGS="$value" 298 CFLAGS="$value"
220 ;; 299 ;;
221 --ldflags=*) 300 --ldflags)
222 LDFLAGS="$value" 301 LDFLAGS="$value"
223 ;; 302 ;;
224 --c-compiler=*) 303 --c-compiler)
225 CC="$value" 304 CC="$value"
226 ;; 305 ;;
227 --linker=*) 306 --linker)
228 LD="$value" 307 LD="$value"
229 ;; 308 ;;
230 --runwith=*) 309 --runwith)
231 RUNWITH="$value" 310 RUNWITH="$value"
232 ;; 311 ;;
233 --no-example-certs) 312 --no-example-certs)
234 EXCERTS= 313 EXCERTS=
235 ;; 314 ;;
236 --compiler-wrapper=*) 315 --compiler-wrapper)
237 CC="$value $CC" 316 CC="$value $CC"
238 LD="$value $LD" 317 LD="$value $LD"
239 ;; 318 ;;
240 *) 319 *)
241 echo "Error: Unknown flag: $1" 320 die "Error: Unknown flag: $1"
242 exit 1
243 ;; 321 ;;
244 esac 322 esac
245 shift 323 shift
246 done 324 done
247 325
259 then DATADIR=/var/lib/prosody 337 then DATADIR=/var/lib/prosody
260 else DATADIR=$PREFIX/var/lib/prosody 338 else DATADIR=$PREFIX/var/lib/prosody
261 fi 339 fi
262 fi 340 fi
263 341
264 if [ "$PREFIX_SET" = "yes" -a ! "$LIBDIR_SET" = "yes" ] 342 detect_lua_version() {
265 then 343 detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null`
266 LIBDIR=$PREFIX/lib 344 if [ "$detected_lua" != "nil" ]
267 fi 345 then
268 346 if [ "$LUA_VERSION_SET" != "yes" ]
269 find_program() { 347 then
270 path="$PATH" 348 echo "Lua version detected: $detected_lua"
271 item="$(echo "$path" | sed 's/\([^:]*\):.*/\1/')" 349 LUA_VERSION=$detected_lua
272 path="$(echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p')" 350 return 0
273 found="no" 351 elif [ "$LUA_VERSION" = "$detected_lua" ]
274 while [ "$item" ] 352 then
353 return 0
354 fi
355 fi
356 return 1
357 }
358
359 search_interpreter() {
360 suffix="$1"
361 if [ "$LUA_BINDIR_SET" = "yes" ]
362 then
363 find_lua="$LUA_BINDIR"
364 elif [ "$LUA_DIR_SET" = "yes" ]
365 then
366 LUA_BINDIR="$LUA_DIR/bin"
367 if [ -f "$LUA_BINDIR/lua$suffix" ]
368 then
369 find_lua="$LUA_BINDIR"
370 fi
371 else
372 find_lua=`find_program lua$suffix`
373 fi
374 if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ]
375 then
376 if detect_lua_version "$find_lua/lua$suffix"
377 then
378 echo "Lua interpreter found: $find_lua/lua$suffix..."
379 if [ "$LUA_BINDIR_SET" != "yes" ]
380 then
381 LUA_BINDIR="$find_lua"
382 fi
383 if [ "$LUA_DIR_SET" != "yes" ]
384 then
385 LUA_DIR=`dirname "$find_lua"`
386 fi
387 LUA_SUFFIX="$suffix"
388 return 0
389 fi
390 fi
391 return 1
392 }
393
394 lua_interp_found=no
395 if [ "$LUA_SUFFIX_SET" != "yes" ]
396 then
397 if [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.1" ]
398 then
399 suffixes="5.1 51 -5.1 -51"
400 elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.2" ]
401 then
402 suffixes="5.2 52 -5.2 -52"
403 elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.3" ]
404 then
405 suffixes="5.3 53 -5.3 -53"
406 else
407 suffixes="5.1 51 -5.1 -51 5.2 52 -5.2 -52 5.3 53 -5.3 -53"
408 fi
409 for suffix in "" `echo $suffixes`
275 do 410 do
276 if [ -f "$item/$1" ] 411 search_interpreter "$suffix" && {
277 then 412 lua_interp_found=yes
278 found="yes" 413 break
279 break 414 }
280 fi 415 done
281 item="$(echo "$path" | sed 's/\([^:]*\):.*/\1/')" 416 else
282 path="$(echo "$path" | sed -n 's/[^:]*::*\(.*\)/\1/p')" 417 search_interpreter "$LUA_SUFFIX" && {
283 done 418 lua_interp_found=yes
284 if [ "$found" = "yes" ] 419 }
285 then 420 fi
286 echo "$item" 421
422 if [ "$lua_interp_found" != "yes" ]
423 then
424 [ "$LUA_VERSION_SET" ] && { interp="Lua $LUA_VERSION" ;} || { interp="Lua" ;}
425 [ "$LUA_DIR_SET" -o "$LUA_BINDIR_SET" ] && { where="$LUA_BINDIR" ;} || { interp="\$PATH" ;}
426 echo "$interp interpreter not found in $where"
427 die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help."
428 fi
429
430 if [ "$LUA_VERSION_SET" = "yes" ]
431 then
432 echo_n "Checking if $LUA_BINDIR/lua$LUA_SUFFIX is Lua version $LUA_VERSION... "
433 if detect_lua_version "$LUA_BINDIR/lua$LUA_SUFFIX"
434 then
435 echo "yes"
287 else 436 else
288 echo "" 437 echo "no"
289 fi 438 die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help."
290 } 439 fi
291 440 fi
292 if [ "$LUA_SUFFIX_SET" != "yes" ] 441
293 then 442 if [ "$LUA_INCDIR_SET" != "yes" ]
294 for suffix in "5.1" "51" "" 443 then
295 do 444 LUA_INCDIR="$LUA_DIR/include"
296 LUA_SUFFIX="$suffix" 445 fi
297 if [ "$LUA_DIR_SET" = "yes" ] 446
298 then 447 if [ "$LUA_LIBDIR_SET" != "yes" ]
299 if [ -f "$LUA_DIR/bin/lua$suffix" ] 448 then
300 then 449 LUA_LIBDIR="$LUA_DIR/lib"
301 find_lua="$LUA_DIR" 450 fi
302 fi 451
452 echo_n "Checking Lua includes... "
453 lua_h="$LUA_INCDIR/lua.h"
454 if [ -f "$lua_h" ]
455 then
456 echo "lua.h found in $lua_h"
457 else
458 v_dir="$LUA_INCDIR/lua/$LUA_VERSION"
459 lua_h="$v_dir/lua.h"
460 if [ -f "$lua_h" ]
461 then
462 echo "lua.h found in $lua_h"
463 LUA_INCDIR="$v_dir"
464 else
465 d_dir="$LUA_INCDIR/lua$LUA_VERSION"
466 lua_h="$d_dir/lua.h"
467 if [ -f "$lua_h" ]
468 then
469 echo "lua.h found in $lua_h (Debian/Ubuntu)"
470 LUA_INCDIR="$d_dir"
303 else 471 else
304 find_lua="$(find_program lua$suffix)" 472 echo "lua.h not found (looked in $LUA_INCDIR, $v_dir, $d_dir)"
305 fi 473 die "You may want to use the flag --with-lua or --with-lua-include. See --help."
306 if [ "$find_lua" ] 474 fi
307 then 475 fi
308 echo "Lua interpreter found: $find_lua/lua$suffix..." 476 fi
309 break 477
310 fi 478 echo_n "Checking if Lua header version matches that of the interpreter... "
311 done 479 header_version=$(sed -n 's/.*LUA_VERSION_NUM.*5.\(.\).*/5.\1/p' "$lua_h")
312 fi 480 if [ "$header_version" = "$LUA_VERSION" ]
313 481 then
314 if [ "$LUA_DIR_SET" != "yes" ] 482 echo "yes"
315 then 483 else
316 echo -n "Looking for Lua... " 484 echo "no"
317 if [ ! "$find_lua" ] 485 echo "lua.h version mismatch (interpreter: $LUA_VERSION; lua.h: $header_version)."
318 then 486 die "You may want to use the flag --with-lua or --with-lua-include. See --help."
319 find_lua="$(find_program lua$LUA_SUFFIX)" 487 fi
320 echo "lua$LUA_SUFFIX found in \$PATH: $find_lua" 488
321 fi 489 echo_n "Configuring for system... "
322 if [ "$find_lua" ] 490 if uname -s
323 then 491 then
324 LUA_DIR="$(dirname $find_lua)" 492 UNAME_S=`uname -s`
325 LUA_BINDIR="$find_lua" 493 else
326 else 494 die "Could not determine operating system. 'uname -s' failed."
327 echo "lua$LUA_SUFFIX not found in \$PATH." 495 fi
328 echo "You may want to use the flags --with-lua and/or --lua-suffix. See --help." 496 echo_n "Configuring for architecture... "
329 exit 1 497 if uname -m
330 fi 498 then
331 fi 499 UNAME_M=`uname -m`
332 500 else
333 if [ "$LUA_INCDIR_SET" != "yes" ] 501 die "Could not determine processor architecture. 'uname -m' failed."
334 then 502 fi
335 LUA_INCDIR="$LUA_DIR/include" 503
336 fi 504 if [ "$UNAME_S" = Linux ]
337 505 then
338 if [ "$LUA_LIBDIR_SET" != "yes" ] 506 GCC_ARCH=`gcc -print-multiarch 2>/dev/null`
339 then 507 if [ -n "$GCC_ARCH" -a -d "/usr/lib/$GCC_ARCH" ]
340 LUA_LIBDIR="$LUA_DIR/lib" 508 then
341 fi 509 MULTIARCH_SUBDIR="lib/$GCC_ARCH"
342 510 elif [ -d "/usr/lib64" ]
343 if [ "$LUA_DIR_SET" = "yes" ] 511 then
344 then 512 # Useful for Fedora systems
345 LUA_BINDIR="$LUA_DIR/bin" 513 MULTIARCH_SUBDIR="lib64"
514 fi
346 fi 515 fi
347 516
348 if [ "$IDN_LIBRARY" = "icu" ] 517 if [ "$IDN_LIBRARY" = "icu" ]
349 then 518 then
350 IDNA_LIBS="$ICU_FLAGS" 519 IDNA_LIBS="$ICU_FLAGS"
353 if [ "$IDN_LIBRARY" = "idn" ] 522 if [ "$IDN_LIBRARY" = "idn" ]
354 then 523 then
355 IDNA_LIBS="-l$IDN_LIB" 524 IDNA_LIBS="-l$IDN_LIB"
356 fi 525 fi
357 526
527 if [ -f config.unix ]; then
528 rm -f config.unix
529 fi
530
358 OPENSSL_LIBS="-l$OPENSSL_LIB" 531 OPENSSL_LIBS="-l$OPENSSL_LIB"
359 532
360 echo -n "Checking Lua includes... " 533 if [ "$PRNG" = "OPENSSL" ]; then
361 lua_h="$LUA_INCDIR/lua.h" 534 PRNGLIBS=$OPENSSL_LIBS
362 if [ -f "$lua_h" ]
363 then
364 echo "lua.h found in $lua_h"
365 else
366 echo "lua.h not found (looked in $lua_h)"
367 echo "You may want to use the flag --with-lua-include. See --help."
368 exit 1
369 fi 535 fi
370 536
371 # Write config 537 # Write config
372 538
373 echo "Writing configuration..." 539 echo "Writing configuration..."
374 echo 540 echo
375 541
542 rm -f built
376 cat <<EOF > config.unix 543 cat <<EOF > config.unix
377 # This file was automatically generated by the configure script. 544 # This file was automatically generated by the configure script.
378 # Run "./configure --help" for details. 545 # Run "./configure --help" for details.
379 546
547 LUA_VERSION=$LUA_VERSION
380 PREFIX=$PREFIX 548 PREFIX=$PREFIX
381 SYSCONFDIR=$SYSCONFDIR 549 SYSCONFDIR=$SYSCONFDIR
382 LIBDIR=$LIBDIR 550 LIBDIR=$LIBDIR
383 DATADIR=$DATADIR 551 DATADIR=$DATADIR
384 LUA_SUFFIX=$LUA_SUFFIX 552 LUA_SUFFIX=$LUA_SUFFIX
385 LUA_DIR=$LUA_DIR 553 LUA_DIR=$LUA_DIR
554 LUA_DIR_SET=$LUA_DIR_SET
386 LUA_INCDIR=$LUA_INCDIR 555 LUA_INCDIR=$LUA_INCDIR
387 LUA_LIBDIR=$LUA_LIBDIR 556 LUA_LIBDIR=$LUA_LIBDIR
388 LUA_BINDIR=$LUA_BINDIR 557 LUA_BINDIR=$LUA_BINDIR
558 MULTIARCH_SUBDIR=$MULTIARCH_SUBDIR
389 REQUIRE_CONFIG=$REQUIRE_CONFIG 559 REQUIRE_CONFIG=$REQUIRE_CONFIG
390 IDN_LIB=$IDN_LIB 560 IDN_LIB=$IDN_LIB
391 IDNA_LIBS=$IDNA_LIBS 561 IDNA_LIBS=$IDNA_LIBS
392 OPENSSL_LIBS=$OPENSSL_LIBS 562 OPENSSL_LIBS=$OPENSSL_LIBS
393 CFLAGS=$CFLAGS 563 CFLAGS=$CFLAGS