aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure633
1 files changed, 303 insertions, 330 deletions
diff --git a/configure b/configure
index 7bc5bced..209f0c44 100755
--- a/configure
+++ b/configure
@@ -1,74 +1,44 @@
1#!/bin/sh 1#!/bin/sh
2 2
3# A basic configure script for LuaRocks.
4# Not doing any fancy shell stuff here to keep good compatibility.
5
6# Defaults 3# Defaults
7 4
8PREFIX="/usr/local" 5PREFIX="/usr/local"
9SYSCONFDIR="$PREFIX/etc/luarocks" 6SYSCONFDIR="$PREFIX/etc/luarocks"
10ROCKS_TREE="$PREFIX" 7ROCKS_TREE="$PREFIX"
11LUA_SUFFIX=""
12LUA_DIR="/usr"
13LUA_BINDIR="/usr/bin"
14LUA_INCDIR="/usr/include"
15LUA_LIBDIR="/usr/lib"
16LUA_VERSION="5.1"
17MULTIARCH_SUBDIR=""
18 8
19# ---------------------------------------------------------------------------- 9# ----------------------------------------------------------------------------
20# FUNCTION DEFINITIONS 10# FUNCTION DEFINITIONS
21# ---------------------------------------------------------------------------- 11# ----------------------------------------------------------------------------
22 12
23# Help 13# Utility functions
14# -----------------
24 15
25show_help() { 16# Resolves a full path
26cat <<EOF 17# - alternative to "readlink -f", which is not available on solaris
27Configure LuaRocks. 18# based on https://stackoverflow.com/a/6554854/1793220
28 19canonicalpath() {
29--help This help. 20 oldpwd="$PWD"
30--prefix=DIR Prefix where LuaRocks should be installed. 21 if [ -d "$1" ]
31 Default is $PREFIX 22 then
32--sysconfdir=DIR Location where the config file should be installed. 23 if cd "$1" >/dev/null 2>&1
33 Default is \$PREFIX/etc/luarocks 24 then
34 25 echo "$PWD"
35Where to install files installed by rocks, to make the accessible to Lua and 26 else
36your \$PATH. Beware of clashes between files installed by LuaRocks and by your 27 echo "$1"
37system's package manager. 28 fi
38 29 else
39--rocks-tree=DIR Root of the local tree of installed rocks. 30 if cd "$(dirname "$1")" >/dev/null 2>&1
40 Default is \$PREFIX 31 then
41 32 echo "$PWD/$(basename "$1")"
42--lua-version=VERSION Use specific Lua version: 5.1, 5.2, 5.3, or 5.4 33 else
43 Default is auto-detected. 34 echo "$1"
44--lua-suffix=SUFFIX Versioning suffix to use in Lua filenames. 35 fi
45 Default is "$LUA_SUFFIX" (lua$LUA_SUFFIX...) 36 fi
46--with-lua=PREFIX Use Lua from given prefix. 37 cd "$oldpwd" >/dev/null 2>&1 || return
47 Default is auto-detected (the parent directory of \$LUA_BINDIR).
48--with-lua-bin=DIR You can also specify Lua's bin dir.
49 Default is the directory of the auto-detected Lua interpreter,
50 or \$LUA_DIR/bin if --with-lua is used.
51--with-lua-include=DIR You can also specify Lua's includes dir.
52 Default is \$LUA_DIR/include
53--with-lua-lib=DIR You can also specify Lua's libraries dir.
54 Default is \$LUA_DIR/lib
55--with-downloader=TOOL Which tool to use as a downloader.
56 Valid options are: curl, wget.
57 Default is to auto-detect.
58--with-md5-checker=TOOL Which tool to use as a downloader.
59 Valid options are: md5sum, openssl
60 Default is to auto-detect.
61--force-config Use a single config location. Do not use the
62 \$LUAROCKS_CONFIG variable or the user's home
63 directory. Useful to avoid conflicts when LuaRocks
64 is embedded within an application.
65EOF
66} 38}
67 39
68# Helper functions
69
70find_program() { 40find_program() {
71 prog=`command -v "$1" 2>/dev/null` 41 prog=$(command -v "$1" 2>/dev/null)
72 if [ -n "$prog" ] 42 if [ -n "$prog" ]
73 then 43 then
74 dirname "$prog" 44 dirname "$prog"
@@ -78,37 +48,154 @@ find_program() {
78die() { 48die() {
79 echo "$*" 49 echo "$*"
80 echo 50 echo
81 echo "configure failed." 51 RED "configure failed."
52 echo
82 echo 53 echo
83 exit 1 54 exit 1
84} 55}
85 56
86find_helper() { 57echo_n() {
87 explanation="$1" 58 printf "%s" "$*"
88 shift 59}
89 tried="$*" 60
90 while [ -n "$1" ] 61bold='\033[1m'
91 do 62red='\033[1;31m'
92 found=`find_program "$1"` 63green='\033[1;32m'
93 if [ -n "$found" ] 64blue='\033[1;36m'
65reset='\033[0m'
66
67BOLD() {
68 printf "$bold%s$reset" "$*"
69}
70
71RED() {
72 printf "$red%s$reset" "$*"
73}
74
75GREEN() {
76 printf "$green%s$reset" "$*"
77}
78
79BLUE() {
80 printf "$blue%s$reset" "$*"
81}
82
83# Help
84# ----
85
86show_help() {
87cat <<EOF
88
89Configure the build process of LuaRocks.
90
91--help This help.
92
93Where to install LuaRocks:
94--------------------------
95
96--prefix=PREFIX Directory where LuaRocks should be installed.
97 - Default is $PREFIX
98--sysconfdir=SYSCONFDIR Where the config file should be installed.
99 - Default is $SYSCONFDIR
100 (PREFIX/etc/luarocks)
101
102Where to install files provided by rocks:
103-----------------------------------------
104
105--rocks-tree=ROCKS_DIR Root of the local tree of installed rocks.
106 To make files installed in this location
107 accessible to Lua and your \$PATH, see
108 "luarocks path --help" after installation.
109 Avoid using paths controlled by your
110 system's package manager, such as /usr.
111 - Default is $PREFIX
112 (PREFIX)
113
114Where is your Lua interpreter:
115------------------------------
116
117--lua-version=VERSION) Use specific Lua version: 5.1, 5.2, 5.3, or 5.4
118 - Default is auto-detected.
119--with-lua=LUA_DIR) Use Lua from given directory.
120 - Default is auto-detected from your \$PATH
121 (or the parent directory of LUA_BINDIR
122 if --with-lua-bin is used).
123--with-lua-bin=LUA_BINDIR) You can also specify Lua's bin dir.
124 - Default is the directory of the
125 auto-detected Lua interpreter,
126 (or LUA_DIR/bin if --with-lua is used)
127--with-lua-include=LUA_INCDIR) Lua's includes dir.
128 - Default is LUA_DIR/include
129--with-lua-lib=LUA_LIBDIR) Lua's libraries dir.
130 - Default is LUA_DIR/lib
131
132For specialized uses of LuaRocks:
133---------------------------------
134
135--force-config) Force using a single config location.
136 Do not honor the \$LUAROCKS_CONFIG_5_x
137 or \$LUAROCKS_CONFIG environment
138 variable or the user's local config.
139 Useful to avoid conflicts when LuaRocks
140 is embedded within an application.
141
142EOF
143}
144
145# Lua detection
146# -------------
147
148detect_lua_version() {
149 detected_lua=$($1 -e 'print(_VERSION:match(" (5%.[1234])$"))' 2> /dev/null)
150 if [ "$detected_lua" != "nil" ]
151 then
152 if [ "$LUA_VERSION_SET" != "yes" ]
94 then 153 then
95 echo "$1 found at $found" 154 echo "Lua version detected: $(GREEN "$detected_lua")"
96 HELPER=$1 155 LUA_VERSION=$detected_lua
97 return 156 return 0
157 elif [ "$LUA_VERSION" = "$detected_lua" ]
158 then
159 return 0
98 fi 160 fi
99 shift 161 fi
100 done 162 return 1
101 echo "Could not find $explanation. Tried: $tried."
102 die "Make sure one of them is installed and available in your PATH."
103} 163}
104 164
105case `echo -n x` in 165search_interpreter() {
106-n*) echo_n_flag='';; 166 suffix="$1"
107*) echo_n_flag='-n';; 167 lua_at=""
108esac 168 if [ "$LUA_BINDIR_SET" = "yes" ]
109 169 then
110echo_n() { 170 lua_at="$LUA_BINDIR"
111 echo $echo_n_flag "$*" 171 elif [ "$LUA_DIR_SET" = "yes" ]
172 then
173 LUA_BINDIR="$LUA_DIR/bin"
174 if [ -f "$LUA_BINDIR/lua$suffix" ]
175 then
176 lua_at="$LUA_BINDIR"
177 fi
178 else
179 lua_at=$(find_program "lua$suffix")
180 fi
181 if [ -n "$lua_at" ] && [ -x "$lua_at/lua$suffix" ]
182 then
183 if detect_lua_version "$lua_at/lua$suffix"
184 then
185 echo "Lua interpreter found: $(GREEN "$lua_at/lua$suffix")"
186 if [ "$LUA_BINDIR_SET" != "yes" ]
187 then
188 LUA_BINDIR="$lua_at"
189 fi
190 if [ "$LUA_DIR_SET" != "yes" ]
191 then
192 LUA_DIR=$(dirname "$lua_at")
193 fi
194 LUA_INTERPRETER="lua$suffix"
195 return 0
196 fi
197 fi
198 return 1
112} 199}
113 200
114# ---------------------------------------------------------------------------- 201# ----------------------------------------------------------------------------
@@ -119,89 +206,97 @@ echo_n() {
119 206
120while [ -n "$1" ] 207while [ -n "$1" ]
121do 208do
122 value="`echo $1 | sed 's/[^=]*.\(.*\)/\1/'`" 209 value="$(echo "$1" | sed 's/[^=]*.\(.*\)/\1/')"
123 key="`echo $1 | sed 's/=.*//'`" 210 key="$(echo "$1" | sed 's/=.*//')"
124 if `echo "$value" | grep "~" >/dev/null 2>/dev/null` 211 if echo "$value" | grep "~" >/dev/null 2>/dev/null
125 then 212 then
126 echo 213 echo
127 echo '*WARNING*: the "~" sign is not expanded in flags.' 214 echo "$(RED WARNING:) the '~' sign is not expanded in flags."
128 echo 'If you mean the home directory, use $HOME instead.' 215 echo "If you mean the home directory, use \$HOME instead."
129 echo 216 echo
130 fi 217 fi
131 case "$key" in 218 case "$key" in
219
220 # Help
221 # ----
132 --help) 222 --help)
133 show_help 223 show_help
134 exit 0 224 exit 0
135 ;; 225 ;;
226
227 # Where to install LuaRocks:
228 # --------------------------
136 --prefix) 229 --prefix)
137 [ -n "$value" ] || die "Missing value in flag $key." 230 [ -n "$value" ] || die "Missing value in flag $key."
138 PREFIX="$value" 231 PREFIX="$(canonicalpath "$value")"
139 PREFIX_SET=yes 232 PREFIX_SET=yes
140 ;; 233 ;;
141 --sysconfdir) 234 --sysconfdir)
142 [ -n "$value" ] || die "Missing value in flag $key." 235 [ -n "$value" ] || die "Missing value in flag $key."
143 SYSCONFDIR="$value" 236 SYSCONFDIR="$(canonicalpath "$value")"
144 SYSCONFDIR_SET=yes 237 SYSCONFDIR_SET=yes
145 ;; 238 ;;
239
240
241 # Where to install files provided by rocks:
242 # -----------------------------------------
146 --rocks-tree) 243 --rocks-tree)
147 [ -n "$value" ] || die "Missing value in flag $key." 244 [ -n "$value" ] || die "Missing value in flag $key."
148 ROCKS_TREE="$value" 245 ROCKS_TREE="$(canonicalpath "$value")"
149 ROCKS_TREE_SET=yes 246 ROCKS_TREE_SET=yes
150 ;; 247 ;;
151 --force-config) 248
152 FORCE_CONFIG=yes 249 # Where is your Lua interpreter:
153 ;; 250 # ------------------------------
154 --versioned-rocks-dir)
155 echo "--versioned-rocks-dir is no longer necessary."
156 echo "The rocks tree in LuaRocks 3.0 is always versioned."
157 ;;
158 --lua-suffix)
159 [ -n "$value" ] || die "Missing value in flag $key."
160 LUA_SUFFIX="$value"
161 LUA_SUFFIX_SET=yes
162 ;;
163 --lua-version|--with-lua-version) 251 --lua-version|--with-lua-version)
164 [ -n "$value" ] || die "Missing value in flag $key." 252 [ -n "$value" ] || die "Missing value in flag $key."
165 LUA_VERSION="$value" 253 LUA_VERSION="$value"
166 [ "$LUA_VERSION" = "5.1" -o "$LUA_VERSION" = "5.2" -o "$LUA_VERSION" = "5.3" -o "$LUA_VERSION" = "5.4" ] || die "Invalid Lua version in flag $key." 254 case "$LUA_VERSION" in
255 5.1|5.2|5.3|5.4) ;;
256 *) die "Invalid Lua version in flag $key."
257 esac
167 LUA_VERSION_SET=yes 258 LUA_VERSION_SET=yes
168 ;; 259 ;;
169 --with-lua) 260 --with-lua)
170 [ -n "$value" ] || die "Missing value in flag $key." 261 [ -n "$value" ] || die "Missing value in flag $key."
171 LUA_DIR="$value" 262 LUA_DIR="$(canonicalpath "$value")"
263 [ -d "$LUA_DIR" ] || die "Bad value for --with-lua: $LUA_DIR is not a valid directory."
172 LUA_DIR_SET=yes 264 LUA_DIR_SET=yes
173 ;; 265 ;;
174 --with-lua-bin) 266 --with-lua-bin)
175 [ -n "$value" ] || die "Missing value in flag $key." 267 [ -n "$value" ] || die "Missing value in flag $key."
176 LUA_BINDIR="$value" 268 LUA_BINDIR="$(canonicalpath "$value")"
269 [ -d "$LUA_BINDIR" ] || die "Bad value for --with-lua-bin: $LUA_BINDIR is not a valid directory."
177 LUA_BINDIR_SET=yes 270 LUA_BINDIR_SET=yes
178 ;; 271 ;;
179 --with-lua-include) 272 --with-lua-include)
180 [ -n "$value" ] || die "Missing value in flag $key." 273 [ -n "$value" ] || die "Missing value in flag $key."
181 LUA_INCDIR="$value" 274 LUA_INCDIR="$(canonicalpath "$value")"
182 LUA_INCDIR_SET=yes 275 [ -d "$LUA_INCDIR" ] || die "Bad value for --with-lua-include: $LUA_INCDIR is not a valid directory."
183 ;; 276 ;;
184 --with-lua-lib) 277 --with-lua-lib)
185 [ -n "$value" ] || die "Missing value in flag $key." 278 [ -n "$value" ] || die "Missing value in flag $key."
186 LUA_LIBDIR="$value" 279 LUA_LIBDIR="$(canonicalpath "$value")"
187 LUA_LIBDIR_SET=yes 280 [ -d "$LUA_LIBDIR" ] || die "Bad value for --with-lua-lib: $LUA_LIBDIR is not a valid directory."
188 ;; 281 ;;
189 --with-downloader) 282
190 [ -n "$value" ] || die "Missing value in flag $key." 283 # For specialized uses of LuaRocks:
191 case "$value" in 284 # ---------------------------------
192 wget|curl) LUAROCKS_DOWNLOADER="$value" ;; 285 --force-config)
193 *) die "Invalid option: $value. See --help." ;; 286 FORCE_CONFIG=yes
194 esac
195 LUAROCKS_DOWNLOADER_SET=yes
196 ;; 287 ;;
197 --with-md5-checker) 288
198 [ -n "$value" ] || die "Missing value in flag $key." 289 # Old options that no longer apply
199 case "$value" in 290 # --------------------------------
200 md5sum|openssl|md5) LUAROCKS_MD5CHECKER="$value" ;; 291 --versioned-rocks-dir)
201 *) die "Invalid option: $value. See --help." ;; 292 echo "--versioned-rocks-dir is no longer necessary."
202 esac 293 echo "The rocks tree in LuaRocks 3.0 is always versioned."
203 LUAROCKS_MD5CHECKER_SET=yes
204 ;; 294 ;;
295 --lua-suffix)
296 echo "--lua-suffix is no longer necessary."
297 echo "The suffix is automatically detected."
298 ;;
299
205 *) 300 *)
206 die "Error: Unknown flag: $1" 301 die "Error: Unknown flag: $1"
207 ;; 302 ;;
@@ -209,7 +304,16 @@ do
209 shift 304 shift
210done 305done
211 306
212if [ "$PREFIX_SET" = "yes" -a ! "$SYSCONFDIR_SET" = "yes" ] 307echo
308BLUE "Configuring LuaRocks..."
309echo
310echo
311
312# ----------------------------------------
313# Derive options from the ones given
314# ----------------------------------------
315
316if [ "$PREFIX_SET" = "yes" ] && [ ! "$SYSCONFDIR_SET" = "yes" ]
213then 317then
214 if [ "$PREFIX" = "/usr" ] 318 if [ "$PREFIX" = "/usr" ]
215 then SYSCONFDIR=/etc/luarocks 319 then SYSCONFDIR=/etc/luarocks
@@ -217,260 +321,129 @@ then
217 fi 321 fi
218fi 322fi
219 323
220 324if [ "$PREFIX_SET" = "yes" ] && [ ! "$ROCKS_TREE_SET" = "yes" ]
221if [ "$PREFIX_SET" = "yes" -a ! "$ROCKS_TREE_SET" = "yes" ]
222then 325then
223 ROCKS_TREE=$PREFIX 326 ROCKS_TREE=$PREFIX
224fi 327fi
225 328
226detect_lua_version() { 329# ----------------------------------------
227 detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[1234])$"))' 2> /dev/null` 330# Search for Lua
228 if [ "$detected_lua" != "nil" ] 331# ----------------------------------------
229 then
230 if [ "$LUA_VERSION_SET" != "yes" ]
231 then
232 echo "Lua version detected: $detected_lua"
233 LUA_VERSION=$detected_lua
234 return 0
235 elif [ "$LUA_VERSION" = "$detected_lua" ]
236 then
237 return 0
238 fi
239 fi
240 return 1
241}
242
243search_interpreter() {
244 suffix="$1"
245 if [ "$LUA_BINDIR_SET" = "yes" ]
246 then
247 find_lua="$LUA_BINDIR"
248 elif [ "$LUA_DIR_SET" = "yes" ]
249 then
250 LUA_BINDIR="$LUA_DIR/bin"
251 if [ -f "$LUA_BINDIR/lua$suffix" ]
252 then
253 find_lua="$LUA_BINDIR"
254 fi
255 else
256 find_lua=`find_program lua$suffix`
257 fi
258 if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ]
259 then
260 if detect_lua_version "$find_lua/lua$suffix"
261 then
262 echo "Lua interpreter found: $find_lua/lua$suffix..."
263 if [ "$LUA_BINDIR_SET" != "yes" ]
264 then
265 LUA_BINDIR="$find_lua"
266 fi
267 if [ "$LUA_DIR_SET" != "yes" ]
268 then
269 LUA_DIR=`dirname "$find_lua"`
270 fi
271 LUA_SUFFIX="$suffix"
272 return 0
273 fi
274 fi
275 return 1
276}
277 332
278lua_interp_found=no 333lua_interp_found=no
279if [ "$LUA_SUFFIX_SET" != "yes" ] 334
280then 335case "$LUA_VERSION" in
281 if [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.1" ] 3365.1)
282 then 337 suffixes="5.1 51 -5.1 -51 jit"
283 suffixes="5.1 51 -5.1 -51" 338 ;;
284 elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.2" ] 3395.2)
285 then 340 suffixes="5.2 52 -5.2 -52"
286 suffixes="5.2 52 -5.2 -52" 341 ;;
287 elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.3" ] 3425.3)
288 then 343 suffixes="5.3 53 -5.3 -53"
289 suffixes="5.4 54 -5.4 -54" 344 ;;
290 elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.4" ] 3455.4)
291 then 346 suffixes="5.4 54 -5.4 -54"
292 suffixes="5.3 53 -5.3 -53" 347 ;;
293 else 348*)
294 suffixes="5.4 54 -5.4 -54 5.3 53 -5.3 -53 5.2 52 -5.2 -52 5.1 51 -5.1 -51" 349 suffixes="5.4 54 -5.4 -54 5.3 53 -5.3 -53 5.2 52 -5.2 -52 5.1 51 -5.1 -51 jit"
295 fi 350 ;;
296 for suffix in `echo $suffixes` "" 351esac
297 do 352
298 search_interpreter "$suffix" && { 353for suffix in $suffixes ""
299 lua_interp_found=yes 354do
300 break 355 search_interpreter "$suffix" && {
301 }
302 done
303else
304 search_interpreter "$LUA_SUFFIX" && {
305 lua_interp_found=yes 356 lua_interp_found=yes
357 break
306 } 358 }
307fi 359done
308 360
309if [ "$lua_interp_found" != "yes" ] 361if [ "$lua_interp_found" != "yes" ]
310then 362then
311 [ "$LUA_VERSION_SET" ] && { interp="Lua $LUA_VERSION" ;} || { interp="Lua" ;} 363 if [ "$LUA_VERSION_SET" ]
312 [ "$LUA_DIR_SET" -o "$LUA_BINDIR_SET" ] && { where="$LUA_BINDIR" ;} || { where="\$PATH" ;}
313 echo "$interp interpreter not found in $where"
314 die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help."
315fi
316
317if [ "$LUA_VERSION_SET" = "yes" ]
318then
319 echo_n "Checking if $LUA_BINDIR/lua$LUA_SUFFIX is Lua version $LUA_VERSION... "
320 if detect_lua_version "$LUA_BINDIR/lua$LUA_SUFFIX"
321 then 364 then
322 echo "yes" 365 interp="Lua $LUA_VERSION"
323 else 366 else
324 echo "no" 367 interp="Lua"
325 die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-suffix. See --help."
326 fi 368 fi
327fi 369 if [ "$LUA_DIR_SET" ] || [ "$LUA_BINDIR_SET" ]
328
329if [ "$LUA_INCDIR_SET" != "yes" ]
330then
331 LUA_INCDIR="$LUA_DIR/include"
332fi
333
334if [ "$LUA_LIBDIR_SET" != "yes" ]
335then
336 LUA_LIBDIR="$LUA_DIR/lib"
337fi
338
339echo_n "Checking Lua includes... "
340lua_h="$LUA_INCDIR/lua.h"
341if [ -f "$lua_h" ]
342then
343 echo "lua.h found in $lua_h"
344else
345 v_dir="$LUA_INCDIR/lua/$LUA_VERSION"
346 lua_h="$v_dir/lua.h"
347 if [ -f "$lua_h" ]
348 then 370 then
349 echo "lua.h found in $lua_h" 371 where="$LUA_BINDIR"
350 LUA_INCDIR="$v_dir"
351 else 372 else
352 d_dir="$LUA_INCDIR/lua$LUA_VERSION" 373 where="\$PATH"
353 lua_h="$d_dir/lua.h"
354 if [ -f "$lua_h" ]
355 then
356 echo "lua.h found in $lua_h (Debian/Ubuntu)"
357 LUA_INCDIR="$d_dir"
358 else
359 echo "lua.h not found (looked in $LUA_INCDIR, $v_dir, $d_dir)"
360 die "You may want to use the flag --with-lua or --with-lua-include. See --help."
361 fi
362 fi 374 fi
375 echo "$(RED $interp interpreter not found) in $where"
376 echo "You may want to use the flags $(BOLD --with-lua), $(BOLD --with-lua-bin) and/or $(BOLD --lua-version)"
377 die "Run $(BOLD ./configure --help) for details."
363fi 378fi
364 379
365echo_n "Checking if Lua header version matches that of the interpreter... " 380if [ "$LUA_VERSION_SET" = "yes" ]
366header_version=$(sed -n 's/.*LUA_VERSION_NUM.*5.\(.\).*/5.\1/p' "$lua_h")
367if [ "$header_version" = "$LUA_VERSION" ]
368then
369 echo "yes"
370else
371 echo "no"
372 echo "lua.h version mismatch (interpreter: $LUA_VERSION; lua.h: $header_version)."
373 die "You may want to use the flag --with-lua or --with-lua-include. See --help."
374fi
375
376
377if [ "$LUAROCKS_DOWNLOADER_SET" != "yes" ]
378then
379 find_helper "a downloader helper program" curl wget fetch
380 LUAROCKS_DOWNLOADER=$HELPER
381fi
382
383if [ "$LUAROCKS_MD5CHECKER_SET" != "yes" ]
384then
385 find_helper "a MD5 checksum calculator" md5sum openssl md5
386 LUAROCKS_MD5CHECKER=$HELPER
387fi
388
389find_helper "an 'unzip' program" unzip
390
391echo_n "Configuring for system... "
392if uname -s
393then
394 LUAROCKS_UNAME_S=`uname -s`
395else
396 die "Could not determine operating system. 'uname -s' failed."
397fi
398echo_n "Configuring for architecture... "
399if uname -m
400then
401 LUAROCKS_UNAME_M=`uname -m`
402else
403 die "Could not determine processor architecture. 'uname -m' failed."
404fi
405
406for v in 5.1 5.2 5.3 5.4; do
407 if [ "$v" != "$LUA_VERSION" ]; then
408 if [ -e "$PREFIX/share/lua/$v/luarocks/site_config.lua" ]; then
409 LUA_OTHER_VERSION="$v"
410 break
411 fi
412 fi
413done
414
415if [ "$LUAROCKS_UNAME_S" = Linux ]
416then 381then
417 GCC_ARCH=`gcc -print-multiarch 2>/dev/null` 382 echo_n "Checking if $LUA_BINDIR/$LUA_INTERPRETER is Lua version $LUA_VERSION... "
418 if [ -n "$GCC_ARCH" -a -d "/usr/lib/$GCC_ARCH" ] 383 if detect_lua_version "$LUA_BINDIR/$LUA_INTERPRETER"
419 then
420 MULTIARCH_SUBDIR="lib/$GCC_ARCH"
421 elif [ -d "/usr/lib64" ]
422 then 384 then
423 # Useful for Fedora systems 385 echo "yes"
424 MULTIARCH_SUBDIR="lib64" 386 else
387 echo "no"
388 die "You may want to use the flags --with-lua, --with-lua-bin and/or --lua-version. See --help."
425 fi 389 fi
426fi 390fi
427 391
428if [ -f config.unix ]; then 392unzip_found=$(find_program "unzip")
429 rm -f config.unix 393if [ -n "$unzip_found" ]
394then
395 echo "unzip found in PATH: $(GREEN "$unzip_found")"
396else
397 RED "Could not find 'unzip'."
398 die "Make sure it is installed and available in your PATH."
430fi 399fi
431 400
432SITE_CONFIG=src/luarocks/core/site_config_$(echo "$LUA_VERSION" | sed 's,\.,_,').lua
433
434# Write config 401# Write config
435 402
436echo "Writing configuration..." 403make clean > /dev/null 2> /dev/null
437echo
438 404
439rm -f built 405rm -f built
440cat <<EOF > config.unix 406cat <<EOF > config.unix
441# This file was automatically generated by the configure script. 407# This file was automatically generated by the configure script.
442# Run "./configure --help" for details. 408# Run "./configure --help" for details.
443 409
444LUA_VERSION=$LUA_VERSION
445SITE_CONFIG=$SITE_CONFIG
446PREFIX=$PREFIX 410PREFIX=$PREFIX
447SYSCONFDIR=$SYSCONFDIR 411SYSCONFDIR=$SYSCONFDIR
448ROCKS_TREE=$ROCKS_TREE 412ROCKS_TREE=$ROCKS_TREE
449LUA_SUFFIX=$LUA_SUFFIX 413LUA_VERSION=$LUA_VERSION
414LUA_INTERPRETER=$LUA_INTERPRETER
450LUA_DIR=$LUA_DIR 415LUA_DIR=$LUA_DIR
451LUA_DIR_SET=$LUA_DIR_SET 416LUA_BINDIR=$LUA_BINDIR
452LUA_INCDIR=$LUA_INCDIR 417LUA_INCDIR=$LUA_INCDIR
453LUA_LIBDIR=$LUA_LIBDIR 418LUA_LIBDIR=$LUA_LIBDIR
454LUA_BINDIR=$LUA_BINDIR
455FORCE_CONFIG=$FORCE_CONFIG 419FORCE_CONFIG=$FORCE_CONFIG
456LUAROCKS_UNAME_M=$LUAROCKS_UNAME_M
457LUAROCKS_UNAME_S=$LUAROCKS_UNAME_S
458LUAROCKS_DOWNLOADER=$LUAROCKS_DOWNLOADER
459LUAROCKS_MD5CHECKER=$LUAROCKS_MD5CHECKER
460MULTIARCH_SUBDIR=$MULTIARCH_SUBDIR
461
462EOF 420EOF
463 421
464echo "Installation prefix: $PREFIX" 422{
465echo "LuaRocks configuration directory: $SYSCONFDIR" 423 echo '-- LuaRocks configuration'
466echo "Using Lua from: $LUA_DIR" 424 echo
467 425 echo 'rocks_trees = {'
468make clean > /dev/null 2> /dev/null 426 echo ' { name = "user", root = home .. "/.luarocks" },'
427 echo ' { name = "system", root = "'"$ROCKS_TREE"'" },'
428 echo '}'
429 if [ -n "$LUA_INTERPRETER" ]; then echo 'lua_interpreter = "'"$LUA_INTERPRETER"'"' ; fi
430 if [ -n "$LUA_DIR" ]; then echo 'variables.LUA_DIR = "'"$LUA_DIR"'"' ; fi
431 if [ -n "$LUA_INCDIR" ]; then echo 'variables.LUA_INCDIR = "'"$LUA_INCDIR"'"' ; fi
432 if [ -n "$LUA_BINDIR" ]; then echo 'variables.LUA_BINDIR = "'"$LUA_BINDIR"'"' ; fi
433 if [ -n "$LUA_LIBDIR" ]; then echo 'variables.LUA_LIBDIR = "'"$LUA_LIBDIR"'"' ; fi
434} > "config-$LUA_VERSION.lua.in"
469 435
470echo 436echo
471echo "Done configuring." 437BLUE "Done configuring."
472echo "- Type 'make build' and 'make install':" 438echo
439echo
440echo "LuaRocks will be installed at......: $(GREEN "$PREFIX")"
441echo "LuaRocks will install rocks at.....: $(GREEN "$ROCKS_TREE")"
442echo "LuaRocks configuration directory...: $(GREEN "$SYSCONFDIR")"
443echo "Using Lua from.....................: $(GREEN "$LUA_DIR")"
444echo
445echo "* Type $(BOLD make build) and $(BOLD make install):"
473echo " to install to $PREFIX as usual." 446echo " to install to $PREFIX as usual."
474echo "- Type 'make bootstrap':" 447echo "* Type $(BOLD make bootstrap):"
475echo " to install LuaRocks in $PREFIX as a rock." 448echo " to install LuaRocks into $ROCKS_TREE as a rock."
476echo 449echo