ddnet/other/sdl/sdl.bam

77 lines
2 KiB
Plaintext
Raw Normal View History

2008-11-29 10:19:00 +00:00
SDL = {
2009-01-08 09:48:42 +00:00
basepath = PathPath(ModuleFilename()),
2008-11-29 10:19:00 +00:00
OptFind = function (name, required)
2009-01-08 09:48:42 +00:00
local check = function(option, settings)
2008-11-29 10:19:00 +00:00
option.value = nil
option.use_sdlconfig = nil
option.use_win32sdl = nil
option.use_osxframework = nil
option.lib_path = nil
if ExecuteSilent("sdl-config") > 0 and ExecuteSilent("sdl-config --cflags") == 0 then
option.value = 1
option.use_sdlconfig = 1
end
if platform == "win32" then
option.value = 1
option.use_win32sdl = 1
end
if platform == "macosx" then
option.value = 1
option.use_osxframework = 1
end
end
local apply = function(option, settings)
if option.use_sdlconfig then
2009-01-08 09:48:42 +00:00
settings.cc.flags:Add("`sdl-config --cflags`")
settings.link.flags:Add("`sdl-config --libs`")
2008-11-29 10:19:00 +00:00
end
if option.use_osxframework then
2009-01-08 09:48:42 +00:00
client_settings.link.frameworks:Add("SDL")
client_settings.cc.includes:Add("/Library/Frameworks/SDL.framework/Headers")
2008-11-29 10:19:00 +00:00
end
if option.use_win32sdl then
2009-01-08 09:48:42 +00:00
settings.cc.includes:Add(SDL.basepath .. "/include")
settings.link.libpath:Add(SDL.basepath .. "/vc2005libs")
settings.link.libs:Add("SDL")
settings.link.libs:Add("SDLmain")
2008-11-29 10:19:00 +00:00
end
end
local save = function(option, output)
output:option(option, "value")
output:option(option, "use_sdlconfig")
output:option(option, "use_win32sdl")
output:option(option, "use_osxframework")
end
local display = function(option)
if option.value then
if option.use_sdlconfig then return "using sdl-config" end
if option.use_win32sdl then return "using supplied win32 libraries" end
if option.use_osxframework then return "using osx framework" end
return "using unknown method"
else
if option.required then
return "not found (required)"
else
return "not found (optional)"
end
end
end
local o = MakeOption(name, 0, check, save, display)
2009-01-08 09:48:42 +00:00
o.Apply = apply
2008-11-29 10:19:00 +00:00
o.include_path = nil
o.lib_path = nil
o.required = required
return o
end
}