aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2016-10-26 15:18:58 -0200
committerHisham <hisham@gobolinux.org>2016-10-26 15:18:58 -0200
commit48e5329617f20e97262ca5510264fdb5d645ae6f (patch)
tree4979d09d913f7fa22d88010eed6808282db5c78c /configure
parent9ab9a8be410201c821fb72851067270e862fca12 (diff)
downloadluarocks-48e5329617f20e97262ca5510264fdb5d645ae6f.tar.gz
luarocks-48e5329617f20e97262ca5510264fdb5d645ae6f.tar.bz2
luarocks-48e5329617f20e97262ca5510264fdb5d645ae6f.zip
Improve check of Lua interpreter
(e.g. allow it to find `lua5.1` when lua is 5.3 and only `--lua-version=5.1` is given).
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure77
1 files changed, 39 insertions, 38 deletions
diff --git a/configure b/configure
index 3636aed3..15cc21f8 100755
--- a/configure
+++ b/configure
@@ -229,15 +229,17 @@ detect_lua_version() {
229 detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null` 229 detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null`
230 if [ "$detected_lua" != "nil" ] 230 if [ "$detected_lua" != "nil" ]
231 then 231 then
232 echo "Lua version detected: $detected_lua"
233 if [ "$LUA_VERSION_SET" != "yes" ] 232 if [ "$LUA_VERSION_SET" != "yes" ]
234 then 233 then
234 echo "Lua version detected: $detected_lua"
235 LUA_VERSION=$detected_lua 235 LUA_VERSION=$detected_lua
236 elif [ "$LUA_VERSION" != "$detected_lua" ] 236 return 0
237 elif [ "$LUA_VERSION" = "$detected_lua" ]
237 then 238 then
238 die "This clashes with the value of --lua-version. Please check your configuration." 239 return 0
239 fi 240 fi
240 fi 241 fi
242 return 1
241} 243}
242 244
243search_interpreter() { 245search_interpreter() {
@@ -247,23 +249,35 @@ search_interpreter() {
247 find_lua="$LUA_BINDIR" 249 find_lua="$LUA_BINDIR"
248 elif [ "$LUA_DIR_SET" = "yes" ] 250 elif [ "$LUA_DIR_SET" = "yes" ]
249 then 251 then
250 if [ -f "$LUA_DIR/bin/lua$suffix" ] 252 LUA_BINDIR="$LUA_DIR/bin"
253 if [ -f "$LUA_BINDIR/lua$suffix" ]
251 then 254 then
252 find_lua="$LUA_DIR/bin" 255 find_lua="$LUA_BINDIR"
253 fi 256 fi
254 else 257 else
255 find_lua=`find_program lua$suffix` 258 find_lua=`find_program lua$suffix`
256 fi 259 fi
257 if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ] 260 if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ]
258 then 261 then
259 echo "Lua interpreter found: $find_lua/lua$suffix..." 262 if detect_lua_version "$find_lua/lua$suffix"
260 LUA_SUFFIX=$suffix 263 then
261 detect_lua_version "$find_lua/lua$LUA_SUFFIX" 264 echo "Lua interpreter found: $find_lua/lua$suffix..."
262 return 0 265 if [ "$LUA_BINDIR_SET" != "yes" ]
266 then
267 LUA_BINDIR="$find_lua"
268 fi
269 if [ "$LUA_DIR_SET" != "yes" ]
270 then
271 LUA_DIR=`dirname "$find_lua"`
272 fi
273 LUA_SUFFIX="$suffix"
274 return 0
275 fi
263 fi 276 fi
264 return 1 277 return 1
265} 278}
266 279
280lua_interp_found=no
267if [ "$LUA_SUFFIX_SET" != "yes" ] 281if [ "$LUA_SUFFIX_SET" != "yes" ]
268then 282then
269 if [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.1" ] 283 if [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.1" ]
@@ -278,7 +292,6 @@ then
278 else 292 else
279 suffixes="5.3 53 -5.3 -53 5.2 52 -5.2 -52 5.1 51 -5.1 -51" 293 suffixes="5.3 53 -5.3 -53 5.2 52 -5.2 -52 5.1 51 -5.1 -51"
280 fi 294 fi
281 lua_interp_found=no
282 for suffix in "" `echo $suffixes` 295 for suffix in "" `echo $suffixes`
283 do 296 do
284 search_interpreter "$suffix" && { 297 search_interpreter "$suffix" && {
@@ -286,23 +299,28 @@ then
286 break 299 break
287 } 300 }
288 done 301 done
302else
303 search_interpreter "$LUA_SUFFIX" && {
304 lua_interp_found=yes
305 }
289fi 306fi
290 307
291if [ "$LUA_DIR_SET" != "yes" ] 308if [ "$lua_interp_found" != "yes" ]
292then 309then
293 if [ -z "$find_lua" ] 310 [ "$LUA_VERSION_SET" ] && { interp="Lua $LUA_VERSION" ;} || { interp="Lua" ;}
294 then 311 [ "$LUA_DIR_SET" -o "$LUA_BINDIR_SET" ] && { where="$LUA_BINDIR" ;} || { interp="\$PATH" ;}
295 echo_n "Looking for Lua... " 312 echo "$interp interpreter not found in $where"
296 find_lua=`find_program lua$LUA_SUFFIX` 313 die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help."
297 fi 314fi
298 315
299 if [ -n "$find_lua" ] 316if [ "$LUA_VERSION_SET" = "yes" ]
317then
318 echo_n "Checking if $LUA_BINDIR/lua$LUA_SUFFIX is Lua version $LUA_VERSION... "
319 if detect_lua_version "$LUA_BINDIR/lua$LUA_SUFFIX"
300 then 320 then
301 LUA_DIR=`dirname $find_lua` 321 echo "yes"
302 LUA_BINDIR="$find_lua"
303 echo "lua$LUA_SUFFIX found in \$PATH: $find_lua"
304 else 322 else
305 echo "lua$LUA_SUFFIX not found in \$PATH." 323 echo "no"
306 die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help." 324 die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help."
307 fi 325 fi
308fi 326fi
@@ -317,23 +335,6 @@ then
317 LUA_LIBDIR="$LUA_DIR/lib" 335 LUA_LIBDIR="$LUA_DIR/lib"
318fi 336fi
319 337
320if [ "$LUA_DIR_SET" = "yes" -a "$LUA_BINDIR_SET" != "yes" ]
321then
322 LUA_BINDIR="$LUA_DIR/bin"
323fi
324
325if [ "$lua_interp_found" != "yes" ]
326then
327 echo_n "Checking Lua interpreter... "
328 if [ -x "$LUA_BINDIR/lua$LUA_SUFFIX" ]
329 then
330 echo "lua$LUA_SUFFIX found in $LUA_BINDIR"
331 else
332 echo "lua$LUA_SUFFIX not found (looked in $LUA_BINDIR)"
333 die "You may want to use the flag --with-lua or --with-lua-bin. See --help."
334 fi
335fi
336
337echo_n "Checking Lua includes... " 338echo_n "Checking Lua includes... "
338lua_h="$LUA_INCDIR/lua.h" 339lua_h="$LUA_INCDIR/lua.h"
339if [ -f "$lua_h" ] 340if [ -f "$lua_h" ]