aboutsummaryrefslogtreecommitdiff
path: root/install.bat
diff options
context:
space:
mode:
Diffstat (limited to 'install.bat')
-rw-r--r--install.bat59
1 files changed, 11 insertions, 48 deletions
diff --git a/install.bat b/install.bat
index e28734dc..cfa080e5 100644
--- a/install.bat
+++ b/install.bat
@@ -24,10 +24,6 @@ vars.LUA_LIBDIR = nil
24vars.LUA_LIBNAME = nil 24vars.LUA_LIBNAME = nil
25vars.LUA_VERSION = "5.1" 25vars.LUA_VERSION = "5.1"
26vars.LUA_SHORTV = nil -- "51" 26vars.LUA_SHORTV = nil -- "51"
27-- MinGW does not generate .lib, nor needs it to link, but MSVC does
28-- so .lib must be listed first to ensure they are found first if present.
29-- To prevent MSVC trying to link to a .dll, which won't work.
30vars.LUA_LIB_NAMES = "lua5.1.lib lua51.lib lua5.1.dll lua51.dll liblua.dll.a"
31vars.LUA_RUNTIME = nil 27vars.LUA_RUNTIME = nil
32vars.UNAME_M = nil 28vars.UNAME_M = nil
33vars.COMPILER_ENV_CMD = nil 29vars.COMPILER_ENV_CMD = nil
@@ -57,32 +53,6 @@ local function die(message)
57 os.exit(1) 53 os.exit(1)
58end 54end
59 55
60local function split_string(str, delim, maxNb)
61 -- Eliminate bad cases...
62 if string.find(str, delim) == nil then
63 return { str }
64 end
65 if maxNb == nil or maxNb < 1 then
66 maxNb = 0 -- No limit
67 end
68 local result = {}
69 local pat = "(.-)" .. delim .. "()"
70 local nb = 0
71 local lastPos
72 for part, pos in string.gmatch(str, pat) do
73 nb = nb + 1
74 result[nb] = part
75 lastPos = pos
76 if nb == maxNb then break end
77 end
78 -- Handle the last field
79 if nb ~= maxNb then
80 result[nb + 1] = string.sub(str, lastPos)
81 end
82 return result
83end
84
85
86local function exec(cmd) 56local function exec(cmd)
87 --print(cmd) 57 --print(cmd)
88 local status = os.execute("type NUL && "..cmd) 58 local status = os.execute("type NUL && "..cmd)
@@ -273,14 +243,8 @@ local function check_flags()
273 die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION) 243 die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION)
274 end 244 end
275 end 245 end
276 if vars.LUA_VERSION ~= "5.1" then 246 if not vars.LUA_VERSION:match("^5%.[123]$") then
277 if vars.LUA_VERSION == "5.2" then 247 die("Bad argument: /LV must either be 5.1, 5.2, or 5.3")
278 vars.LUA_LIB_NAMES = vars.LUA_LIB_NAMES:gsub("5([%.]?)1", "5%12")
279 elseif vars.LUA_VERSION == "5.3" then
280 vars.LUA_LIB_NAMES = vars.LUA_LIB_NAMES:gsub("5([%.]?)1", "5%13")
281 else
282 die("Bad argument: /LV must either be 5.1, 5.2, or 5.3")
283 end
284 end 248 end
285 if USE_MSVC_MANUAL and USE_MINGW then 249 if USE_MSVC_MANUAL and USE_MINGW then
286 die("Cannot combine option /MSVC and /MW") 250 die("Cannot combine option /MSVC and /MW")
@@ -339,7 +303,6 @@ local function look_for_interpreter(directory)
339 else 303 else
340 vars.LUA_VERSION = version 304 vars.LUA_VERSION = version
341 vars.LUA_SHORTV = version:gsub("%.", "") 305 vars.LUA_SHORTV = version:gsub("%.", "")
342 vars.LUA_LIB_NAMES = vars.LUA_LIB_NAMES:gsub("5([%.]?)[123]", "5%1" .. version:sub(-1))
343 end 306 end
344 end 307 end
345 308
@@ -358,6 +321,10 @@ local function look_for_interpreter(directory)
358end 321end
359 322
360local function look_for_link_libraries(directory) 323local function look_for_link_libraries(directory)
324 -- MinGW does not generate .lib, nor needs it to link, but MSVC does,
325 -- so .lib must be listed first to ensure they are found first if present,
326 -- to prevent MSVC trying to link to a .dll, which won't work.
327 local names = {S"lua$LUA_VERSION.lib", S"lua$LUA_SHORTV.lib", S"lua$LUA_VERSION.dll", S"lua$LUA_SHORTV.dll", "liblua.dll.a"}
361 local directories 328 local directories
362 if vars.LUA_LIBDIR then 329 if vars.LUA_LIBDIR then
363 directories = {vars.LUA_LIBDIR} 330 directories = {vars.LUA_LIBDIR}
@@ -366,7 +333,7 @@ local function look_for_link_libraries(directory)
366 end 333 end
367 334
368 for _, dir in ipairs(directories) do 335 for _, dir in ipairs(directories) do
369 for name in vars.LUA_LIB_NAMES:gmatch("[^%s]+") do 336 for _, name in ipairs(names) do
370 local full_name = dir .. "\\" .. name 337 local full_name = dir .. "\\" .. name
371 print(" checking for " .. full_name) 338 print(" checking for " .. full_name)
372 if exists(full_name) then 339 if exists(full_name) then
@@ -379,7 +346,7 @@ local function look_for_link_libraries(directory)
379 end 346 end
380 347
381 if vars.LUA_LIBDIR then 348 if vars.LUA_LIBDIR then
382 die(S"link library (one of; $LUA_LIB_NAMES) not found in $LUA_LIBDIR") 349 die(("Link library (one of %s) not found in %s"):format(table.concat(names, ", "), vars.LUA_LIBDIR))
383 end 350 end
384 return false 351 return false
385end 352end
@@ -574,16 +541,15 @@ local function get_possible_lua_directories()
574 541
575 -- No prefix given, so use PATH. 542 -- No prefix given, so use PATH.
576 local path = os.getenv("PATH") or "" 543 local path = os.getenv("PATH") or ""
577 path = path:gsub(";+", ";") -- Remove duplicates. 544 local directories = {}
578 local directories = split_string(path, ";") 545 for dir in path:gmatch("[^;]+") do
579 for i, dir in ipairs(directories) do
580 -- Remove trailing backslashes, but not from a drive letter like `C:\`. 546 -- Remove trailing backslashes, but not from a drive letter like `C:\`.
581 dir = dir:gsub("([^:])\\+$", "%1") 547 dir = dir:gsub("([^:])\\+$", "%1")
582 -- Remove trailing `bin` subdirectory, the searcher will check there anyway. 548 -- Remove trailing `bin` subdirectory, the searcher will check there anyway.
583 if dir:upper():match("[:\\]BIN$") then 549 if dir:upper():match("[:\\]BIN$") then
584 dir = dir:sub(1, -5) 550 dir = dir:sub(1, -5)
585 end 551 end
586 directories[i] = dir 552 table.insert(directories, dir)
587 end 553 end
588 -- Finally add some other default paths. 554 -- Finally add some other default paths.
589 table.insert(directories, [[c:\lua5.1.2]]) 555 table.insert(directories, [[c:\lua5.1.2]])
@@ -763,9 +729,6 @@ vars.INCDIR = S"$PREFIX\\include"
763vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "") 729vars.LUA_SHORTV = vars.LUA_VERSION:gsub("%.", "")
764 730
765if INSTALL_LUA then 731if INSTALL_LUA then
766 if vars.LUA_VERSION ~= "5.1" then
767 die("Cannot install own copy of Lua because only 5.1 is bundled")
768 end
769 vars.LUA_INTERPRETER = "lua5.1" 732 vars.LUA_INTERPRETER = "lua5.1"
770 vars.LUA_BINDIR = vars.BINDIR 733 vars.LUA_BINDIR = vars.BINDIR
771 vars.LUA_LIBDIR = vars.LIBDIR 734 vars.LUA_LIBDIR = vars.LIBDIR