|
|
|
@ -23,9 +23,74 @@ package("libsdl") |
|
|
|
|
elseif is_plat("windows", "mingw") then |
|
|
|
|
add_syslinks("gdi32", "user32", "winmm", "shell32") |
|
|
|
|
end |
|
|
|
|
add_links("SDL2main", "SDL2") |
|
|
|
|
add_includedirs("include", "include/SDL2") |
|
|
|
|
|
|
|
|
|
add_configs("use_sdlmain", {description = "Use SDL_main entry", default = true, type = "boolean"}) |
|
|
|
|
|
|
|
|
|
on_load(function (package) |
|
|
|
|
if package:config("use_sdlmain") then |
|
|
|
|
package:add("links", "SDL2main", "SDL2") |
|
|
|
|
else |
|
|
|
|
package:add("links", "SDL2") |
|
|
|
|
package:add("defines", "SDL_MAIN_HANDLED") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if package:is_plat("macosx") and package:version():ge("2.0.14") then |
|
|
|
|
package:add("frameworks", "CoreHaptics", "GameController") |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
on_fetch("linux", "macosx", function (package, opt) |
|
|
|
|
if opt.system then |
|
|
|
|
-- use sdl2-config |
|
|
|
|
local sdl2conf = try {function() return os.iorunv("sdl2-config", {"--version", "--cflags", "--libs"}) end} |
|
|
|
|
if sdl2conf then |
|
|
|
|
sdl2conf = os.argv(sdl2conf) |
|
|
|
|
local sdl2ver = table.remove(sdl2conf, 1) |
|
|
|
|
|
|
|
|
|
local result = {} |
|
|
|
|
result.version = sdl2ver |
|
|
|
|
|
|
|
|
|
for _, flag in ipairs(sdl2conf) do |
|
|
|
|
if flag:startswith("-L") and #flag > 2 then |
|
|
|
|
-- get linkdirs |
|
|
|
|
local linkdir = flag:sub(3) |
|
|
|
|
if linkdir and os.isdir(linkdir) then |
|
|
|
|
result.linkdirs = result.linkdirs or {} |
|
|
|
|
table.insert(result.linkdirs, linkdir) |
|
|
|
|
end |
|
|
|
|
elseif flag:startswith("-I") and #flag > 2 then |
|
|
|
|
-- get includedirs |
|
|
|
|
local includedir = flag:sub(3) |
|
|
|
|
if includedir and os.isdir(includedir) then |
|
|
|
|
result.includedirs = result.includedirs or {} |
|
|
|
|
table.insert(result.includedirs, includedir) |
|
|
|
|
end |
|
|
|
|
elseif flag:startswith("-l") and #flag > 2 then |
|
|
|
|
-- get links |
|
|
|
|
local link = flag:sub(3) |
|
|
|
|
result.links = result.links or {} |
|
|
|
|
table.insert(result.links, link) |
|
|
|
|
elseif flag:startswith("-D") and #flag > 2 then |
|
|
|
|
-- get defines |
|
|
|
|
local define = flag:sub(3) |
|
|
|
|
result.defines = result.defines or {} |
|
|
|
|
table.insert(result.defines, define) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return result |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- finding using sdl2-config didn't work, fallback on pkgconfig |
|
|
|
|
if package.find_package then |
|
|
|
|
return package:find_package("pkgconfig::sdl2", opt) |
|
|
|
|
else |
|
|
|
|
return find_package("pkgconfig::sdl2", opt) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
on_install("windows", "mingw", function (package) |
|
|
|
|
local arch = package:arch() |
|
|
|
|
if package:is_plat("mingw") then |
|
|
|
@ -43,13 +108,10 @@ package("libsdl") |
|
|
|
|
else |
|
|
|
|
table.insert(configs, "--enable-shared=no") |
|
|
|
|
end |
|
|
|
|
import("package.tools.autoconf").install(package, configs) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
on_load(function (package) |
|
|
|
|
if package:is_plat("macosx") and package:version():ge("2.0.14") then |
|
|
|
|
package:add("frameworks", "CoreHaptics", "GameController") |
|
|
|
|
if package:is_plat("linux") and package:config("pic") ~= false then |
|
|
|
|
table.insert(configs, "--with-pic") |
|
|
|
|
end |
|
|
|
|
import("package.tools.autoconf").install(package, configs) |
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
on_test(function (package) |
|
|
|
|