diff options
Diffstat (limited to 'src/luarocks/deps.lua')
-rw-r--r-- | src/luarocks/deps.lua | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 0eb80193..d935a5c8 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -649,6 +649,16 @@ function deps.scan_deps(results, manifest, name, version, deps_mode) | |||
649 | end | 649 | end |
650 | end | 650 | end |
651 | 651 | ||
652 | local function lua_h_exists(d) | ||
653 | local lua_h = dir.path(d, "lua.h") | ||
654 | local fd = io.open(lua_h) | ||
655 | if fd then | ||
656 | -- TODO check that LUA_VERSION_MAJOR and LUA_VERSION_MINOR match luaver | ||
657 | fd:close() | ||
658 | return d | ||
659 | end | ||
660 | end | ||
661 | |||
652 | local function find_lua_incdir(prefix, luaver, luajitver) | 662 | local function find_lua_incdir(prefix, luaver, luajitver) |
653 | luajitver = luajitver and luajitver:gsub("%-.*", "") | 663 | luajitver = luajitver and luajitver:gsub("%-.*", "") |
654 | local shortv = luaver:gsub("%.", "") | 664 | local shortv = luaver:gsub("%.", "") |
@@ -662,11 +672,7 @@ local function find_lua_incdir(prefix, luaver, luajitver) | |||
662 | luajitver and prefix .. "/include/luajit-" .. luajitver:match("^(%d+%.%d+)"), | 672 | luajitver and prefix .. "/include/luajit-" .. luajitver:match("^(%d+%.%d+)"), |
663 | } | 673 | } |
664 | for _, d in ipairs(incdirs) do | 674 | for _, d in ipairs(incdirs) do |
665 | local lua_h = dir.path(d, "lua.h") | 675 | if lua_h_exists(d) then |
666 | local fd = io.open(lua_h) | ||
667 | if fd then | ||
668 | -- TODO check that LUA_VERSION_MAJOR and LUA_VERSION_MINOR match luaver | ||
669 | fd:close() | ||
670 | return d | 676 | return d |
671 | end | 677 | end |
672 | end | 678 | end |
@@ -678,14 +684,18 @@ end | |||
678 | function deps.check_lua_incdir(vars) | 684 | function deps.check_lua_incdir(vars) |
679 | local ljv = util.get_luajit_version() | 685 | local ljv = util.get_luajit_version() |
680 | 686 | ||
681 | if (not vars.LUA_INCDIR) and vars.LUA_DIR then | 687 | if vars.LUA_INCDIR then |
688 | return lua_h_exists(vars.LUA_INCDIR) | ||
689 | end | ||
690 | |||
691 | if vars.LUA_DIR then | ||
682 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) | 692 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) |
683 | if vars.LUA_INCDIR == nil then | 693 | if vars.LUA_INCDIR then |
684 | return nil, "Failed finding Lua header files. You may need to install them or configure LUA_INCDIR.", "dependency" | 694 | return true |
685 | end | 695 | end |
686 | end | 696 | end |
687 | 697 | ||
688 | return true | 698 | return nil, "Failed finding Lua header files. You may need to install them or configure LUA_INCDIR.", "dependency" |
689 | end | 699 | end |
690 | 700 | ||
691 | function deps.check_lua_libdir(vars) | 701 | function deps.check_lua_libdir(vars) |