mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Enable support to use pkg-config for curl, opusfile, opus and ogg
instead of the bundled libs. This should enable support for building on more platforms again. To disable pkg-config detection and use the bundled libraries instead, you can manually set it like this: bam config curl.use_pkgconfig=false opus.use_pkgconfig=false opusfile.use_pkgconfig=false ogg.use_pkgconfig=false Fixes #172
This commit is contained in:
parent
73229fbb62
commit
0df6866036
50
bam.lua
50
bam.lua
|
@ -3,6 +3,10 @@ CheckVersion("0.4")
|
|||
Import("configure.lua")
|
||||
Import("other/sdl/sdl.lua")
|
||||
Import("other/freetype/freetype.lua")
|
||||
Import("other/curl/curl.lua")
|
||||
Import("other/opus/opusfile.lua")
|
||||
Import("other/opus/opus.lua")
|
||||
Import("other/opus/ogg.lua")
|
||||
|
||||
--- Setup Config -------
|
||||
config = NewConfig()
|
||||
|
@ -13,6 +17,10 @@ config:Add(OptTestCompileC("macosxppc", "int main(){return 0;}", "-arch ppc"))
|
|||
config:Add(OptLibrary("zlib", "zlib.h", false))
|
||||
config:Add(SDL.OptFind("sdl", true))
|
||||
config:Add(FreeType.OptFind("freetype", true))
|
||||
config:Add(Curl.OptFind("curl", true))
|
||||
config:Add(Opusfile.OptFind("opusfile", true))
|
||||
config:Add(Opus.OptFind("opus", true))
|
||||
config:Add(Ogg.OptFind("ogg", true))
|
||||
config:Add(OptString("websockets", false))
|
||||
config:Finalize("config.lua")
|
||||
|
||||
|
@ -212,10 +220,6 @@ function build(settings)
|
|||
|
||||
settings.cc.includes:Add("src")
|
||||
settings.cc.includes:Add("src/engine/external")
|
||||
settings.cc.includes:Add("src/engine/external/ogg")
|
||||
settings.cc.includes:Add("other/opus/include")
|
||||
settings.cc.includes:Add("other/opus/include/opus")
|
||||
settings.cc.includes:Add("other/curl/include")
|
||||
settings.cc.includes:Add("other/mysql/include")
|
||||
|
||||
-- set some platform specific settings
|
||||
|
@ -286,22 +290,6 @@ function build(settings)
|
|||
client_settings.link.frameworks:Add("Cocoa")
|
||||
launcher_settings.link.frameworks:Add("Cocoa")
|
||||
|
||||
client_settings.link.libs:Add("crypto")
|
||||
client_settings.link.libs:Add("ssl")
|
||||
|
||||
client_settings.link.libs:Add("opusfile")
|
||||
client_settings.link.libs:Add("opus")
|
||||
client_settings.link.libs:Add("ogg")
|
||||
client_settings.link.libs:Add("curl")
|
||||
|
||||
if string.find(settings.config_name, "64") then
|
||||
client_settings.link.libpath:Add("other/opus/mac/lib64")
|
||||
client_settings.link.libpath:Add("other/curl/mac/lib64")
|
||||
else
|
||||
client_settings.link.libpath:Add("other/opus/mac/lib32")
|
||||
client_settings.link.libpath:Add("other/curl/mac/lib32")
|
||||
end
|
||||
|
||||
if string.find(settings.config_name, "sql") then
|
||||
if arch == "amd64" then
|
||||
server_settings.link.libpath:Add("other/mysql/mac/lib64")
|
||||
|
@ -313,22 +301,8 @@ function build(settings)
|
|||
client_settings.link.libs:Add("X11")
|
||||
client_settings.link.libs:Add("GL")
|
||||
client_settings.link.libs:Add("GLU")
|
||||
client_settings.link.libs:Add("opusfile")
|
||||
client_settings.link.libs:Add("opus")
|
||||
client_settings.link.libs:Add("ogg")
|
||||
client_settings.link.libs:Add("curl")
|
||||
client_settings.link.libs:Add("ssl")
|
||||
client_settings.link.libs:Add("crypto")
|
||||
client_settings.link.libs:Add("dl")
|
||||
|
||||
if arch == "amd64" then
|
||||
client_settings.link.libpath:Add("other/opus/linux/lib64")
|
||||
client_settings.link.libpath:Add("other/curl/linux/lib64")
|
||||
else
|
||||
client_settings.link.libpath:Add("other/opus/linux/lib32")
|
||||
client_settings.link.libpath:Add("other/curl/linux/lib32")
|
||||
end
|
||||
|
||||
if string.find(settings.config_name, "sql") then
|
||||
if arch == "amd64" then
|
||||
server_settings.link.libpath:Add("other/mysql/linux/lib64")
|
||||
|
@ -340,10 +314,8 @@ function build(settings)
|
|||
|
||||
elseif family == "windows" then
|
||||
if arch == "amd64" then
|
||||
client_settings.link.libpath:Add("other/opus/windows/lib64")
|
||||
client_settings.link.libpath:Add("other/curl/windows/lib64")
|
||||
else
|
||||
client_settings.link.libpath:Add("other/opus/windows/lib32")
|
||||
client_settings.link.libpath:Add("other/curl/windows/lib32")
|
||||
end
|
||||
client_settings.link.libs:Add("opengl32")
|
||||
|
@ -357,10 +329,12 @@ function build(settings)
|
|||
end
|
||||
end
|
||||
|
||||
-- apply sdl settings
|
||||
config.sdl:Apply(client_settings)
|
||||
-- apply freetype settings
|
||||
config.freetype:Apply(client_settings)
|
||||
config.curl:Apply(client_settings)
|
||||
config.opusfile:Apply(client_settings)
|
||||
config.opus:Apply(client_settings)
|
||||
config.ogg:Apply(client_settings)
|
||||
|
||||
engine = Compile(engine_settings, Collect("src/engine/shared/*.cpp", "src/base/*.c"))
|
||||
client = Compile(client_settings, Collect("src/engine/client/*.cpp"))
|
||||
|
|
95
other/curl/curl.lua
Normal file
95
other/curl/curl.lua
Normal file
|
@ -0,0 +1,95 @@
|
|||
Curl = {
|
||||
basepath = PathDir(ModuleFilename()),
|
||||
|
||||
OptFind = function (name, required)
|
||||
local check = function(option, settings)
|
||||
option.value = false
|
||||
option.lib_path = nil
|
||||
|
||||
if IsNegativeTerm(ScriptArgs[name .. ".use_pkgconfig"]) then
|
||||
option.use_pkgconfig = false
|
||||
elseif IsPositiveTerm(ScriptArgs[name .. ".use_pkgconfig"]) then
|
||||
option.use_pkgconfig = true
|
||||
end
|
||||
|
||||
if ExecuteSilent("pkg-config libcurl") == 0 then
|
||||
option.value = true
|
||||
if option.use_pkgconfig == nil then
|
||||
option.use_pkgconfig = true
|
||||
end
|
||||
end
|
||||
|
||||
if option.use_pkgconfig == nil then
|
||||
option.use_pkgconfig = false
|
||||
end
|
||||
|
||||
if platform == "win32" then
|
||||
option.value = true
|
||||
elseif platform == "win64" then
|
||||
option.value = true
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||
option.value = true
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||
option.value = true
|
||||
elseif platform == "linux" and arch == "x86" then
|
||||
option.value = true
|
||||
elseif platform == "linux" and arch == "amd64" then
|
||||
option.value = true
|
||||
end
|
||||
end
|
||||
|
||||
local apply = function(option, settings)
|
||||
if option.use_pkgconfig == true then
|
||||
settings.cc.flags:Add("`pkg-config --cflags libcurl`")
|
||||
settings.link.flags:Add("`pkg-config --libs libcurl`")
|
||||
else
|
||||
settings.cc.includes:Add(Curl.basepath .. "/include")
|
||||
|
||||
if family ~= "windows" then
|
||||
settings.link.libs:Add("curl")
|
||||
settings.link.libs:Add("ssl")
|
||||
settings.link.libs:Add("crypto")
|
||||
end
|
||||
|
||||
if platform == "win32" then
|
||||
settings.link.libpath:Add("other/curl/windows/lib32")
|
||||
elseif platform == "win64" then
|
||||
settings.link.libpath:Add("other/curl/windows/lib64")
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||
settings.link.libpath:Add("other/curl/mac/lib32")
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||
settings.link.libpath:Add("other/curl/mac/lib64")
|
||||
elseif platform == "linux" and arch == "x86" then
|
||||
settings.link.libpath:Add("other/curl/linux/lib32")
|
||||
elseif platform == "linux" and arch == "amd64" then
|
||||
settings.link.libpath:Add("other/curl/linux/lib64")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local save = function(option, output)
|
||||
output:option(option, "value")
|
||||
output:option(option, "use_pkgconfig")
|
||||
end
|
||||
|
||||
local display = function(option)
|
||||
if option.value == true then
|
||||
if option.use_pkgconfig == true then return "using pkg-config" end
|
||||
return "using bundled libs"
|
||||
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)
|
||||
o.Apply = apply
|
||||
o.include_path = nil
|
||||
o.lib_path = nil
|
||||
o.required = required
|
||||
return o
|
||||
end
|
||||
}
|
94
other/opus/ogg.lua
Normal file
94
other/opus/ogg.lua
Normal file
|
@ -0,0 +1,94 @@
|
|||
Ogg = {
|
||||
basepath = PathDir(ModuleFilename()),
|
||||
|
||||
OptFind = function (name, required)
|
||||
local check = function(option, settings)
|
||||
option.value = false
|
||||
option.lib_path = nil
|
||||
|
||||
if IsNegativeTerm(ScriptArgs[name .. ".use_pkgconfig"]) then
|
||||
option.use_pkgconfig = false
|
||||
elseif IsPositiveTerm(ScriptArgs[name .. ".use_pkgconfig"]) then
|
||||
option.use_pkgconfig = true
|
||||
end
|
||||
|
||||
if ExecuteSilent("pkg-config ogg") == 0 then
|
||||
option.value = true
|
||||
if option.use_pkgconfig == nil then
|
||||
option.use_pkgconfig = true
|
||||
end
|
||||
end
|
||||
|
||||
if option.use_pkgconfig == nil then
|
||||
option.use_pkgconfig = false
|
||||
end
|
||||
|
||||
if platform == "win32" then
|
||||
option.value = true
|
||||
elseif platform == "win64" then
|
||||
option.value = true
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||
option.value = true
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||
option.value = true
|
||||
elseif platform == "linux" and arch == "x86" then
|
||||
option.value = true
|
||||
elseif platform == "linux" and arch == "amd64" then
|
||||
option.value = true
|
||||
end
|
||||
end
|
||||
|
||||
local apply = function(option, settings)
|
||||
if option.use_pkgconfig == true then
|
||||
settings.cc.flags:Add("`pkg-config --cflags ogg`")
|
||||
settings.link.flags:Add("`pkg-config --libs ogg`")
|
||||
else
|
||||
settings.cc.includes:Add(Ogg.basepath .. "/include")
|
||||
settings.cc.includes:Add(Ogg.basepath .. "/include/ogg")
|
||||
|
||||
if family ~= "windows" then
|
||||
settings.link.libs:Add("ogg")
|
||||
end
|
||||
|
||||
if platform == "win32" then
|
||||
client_settings.link.libpath:Add("other/opus/windows/lib32")
|
||||
elseif platform == "win64" then
|
||||
client_settings.link.libpath:Add("other/opus/windows/lib64")
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||
client_settings.link.libpath:Add("other/opus/mac/lib32")
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||
client_settings.link.libpath:Add("other/opus/mac/lib64")
|
||||
elseif platform == "linux" and arch == "x86" then
|
||||
client_settings.link.libpath:Add("other/opus/linux/lib32")
|
||||
elseif platform == "linux" and arch == "amd64" then
|
||||
client_settings.link.libpath:Add("other/opus/linux/lib64")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local save = function(option, output)
|
||||
output:option(option, "value")
|
||||
output:option(option, "use_pkgconfig")
|
||||
end
|
||||
|
||||
local display = function(option)
|
||||
if option.value == true then
|
||||
if option.use_pkgconfig == true then return "using pkg-config" end
|
||||
return "using bundled libs"
|
||||
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)
|
||||
o.Apply = apply
|
||||
o.include_path = nil
|
||||
o.lib_path = nil
|
||||
o.required = required
|
||||
return o
|
||||
end
|
||||
}
|
94
other/opus/opus.lua
Normal file
94
other/opus/opus.lua
Normal file
|
@ -0,0 +1,94 @@
|
|||
Opus = {
|
||||
basepath = PathDir(ModuleFilename()),
|
||||
|
||||
OptFind = function (name, required)
|
||||
local check = function(option, settings)
|
||||
option.value = false
|
||||
option.lib_path = nil
|
||||
|
||||
if IsNegativeTerm(ScriptArgs[name .. ".use_pkgconfig"]) then
|
||||
option.use_pkgconfig = false
|
||||
elseif IsPositiveTerm(ScriptArgs[name .. ".use_pkgconfig"]) then
|
||||
option.use_pkgconfig = true
|
||||
end
|
||||
|
||||
if ExecuteSilent("pkg-config opus") == 0 then
|
||||
option.value = true
|
||||
if option.use_pkgconfig == nil then
|
||||
option.use_pkgconfig = true
|
||||
end
|
||||
end
|
||||
|
||||
if option.use_pkgconfig == nil then
|
||||
option.use_pkgconfig = false
|
||||
end
|
||||
|
||||
if platform == "win32" then
|
||||
option.value = true
|
||||
elseif platform == "win64" then
|
||||
option.value = true
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||
option.value = true
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||
option.value = true
|
||||
elseif platform == "linux" and arch == "x86" then
|
||||
option.value = true
|
||||
elseif platform == "linux" and arch == "amd64" then
|
||||
option.value = true
|
||||
end
|
||||
end
|
||||
|
||||
local apply = function(option, settings)
|
||||
if option.use_pkgconfig == true then
|
||||
settings.cc.flags:Add("`pkg-config --cflags opus`")
|
||||
settings.link.flags:Add("`pkg-config --libs opus`")
|
||||
else
|
||||
settings.cc.includes:Add(Opus.basepath .. "/include")
|
||||
settings.cc.includes:Add(Opus.basepath .. "/include/opus")
|
||||
|
||||
if family ~= "windows" then
|
||||
settings.link.libs:Add("opus")
|
||||
end
|
||||
|
||||
if platform == "win32" then
|
||||
client_settings.link.libpath:Add("other/opus/windows/lib32")
|
||||
elseif platform == "win64" then
|
||||
client_settings.link.libpath:Add("other/opus/windows/lib64")
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||
client_settings.link.libpath:Add("other/opus/mac/lib32")
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||
client_settings.link.libpath:Add("other/opus/mac/lib64")
|
||||
elseif platform == "linux" and arch == "x86" then
|
||||
client_settings.link.libpath:Add("other/opus/linux/lib32")
|
||||
elseif platform == "linux" and arch == "amd64" then
|
||||
client_settings.link.libpath:Add("other/opus/linux/lib64")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local save = function(option, output)
|
||||
output:option(option, "value")
|
||||
output:option(option, "use_pkgconfig")
|
||||
end
|
||||
|
||||
local display = function(option)
|
||||
if option.value == true then
|
||||
if option.use_pkgconfig == true then return "using pkg-config" end
|
||||
return "using bundled libs"
|
||||
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)
|
||||
o.Apply = apply
|
||||
o.include_path = nil
|
||||
o.lib_path = nil
|
||||
o.required = required
|
||||
return o
|
||||
end
|
||||
}
|
94
other/opus/opusfile.lua
Normal file
94
other/opus/opusfile.lua
Normal file
|
@ -0,0 +1,94 @@
|
|||
Opusfile = {
|
||||
basepath = PathDir(ModuleFilename()),
|
||||
|
||||
OptFind = function (name, required)
|
||||
local check = function(option, settings)
|
||||
option.value = false
|
||||
option.lib_path = nil
|
||||
|
||||
if IsNegativeTerm(ScriptArgs[name .. ".use_pkgconfig"]) then
|
||||
option.use_pkgconfig = false
|
||||
elseif IsPositiveTerm(ScriptArgs[name .. ".use_pkgconfig"]) then
|
||||
option.use_pkgconfig = true
|
||||
end
|
||||
|
||||
if ExecuteSilent("pkg-config opusfile") == 0 then
|
||||
option.value = true
|
||||
if option.use_pkgconfig == nil then
|
||||
option.use_pkgconfig = true
|
||||
end
|
||||
end
|
||||
|
||||
if option.use_pkgconfig == nil then
|
||||
option.use_pkgconfig = false
|
||||
end
|
||||
|
||||
if platform == "win32" then
|
||||
option.value = true
|
||||
elseif platform == "win64" then
|
||||
option.value = true
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||
option.value = true
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||
option.value = true
|
||||
elseif platform == "linux" and arch == "x86" then
|
||||
option.value = true
|
||||
elseif platform == "linux" and arch == "amd64" then
|
||||
option.value = true
|
||||
end
|
||||
end
|
||||
|
||||
local apply = function(option, settings)
|
||||
if option.use_pkgconfig == true then
|
||||
settings.cc.flags:Add("`pkg-config --cflags opusfile`")
|
||||
settings.link.flags:Add("`pkg-config --libs opusfile`")
|
||||
else
|
||||
settings.cc.includes:Add(Opusfile.basepath .. "/include")
|
||||
settings.cc.includes:Add(Opusfile.basepath .. "/include/opus")
|
||||
|
||||
if family ~= "windows" then
|
||||
settings.link.libs:Add("opusfile")
|
||||
end
|
||||
|
||||
if platform == "win32" then
|
||||
client_settings.link.libpath:Add("other/opus/windows/lib32")
|
||||
elseif platform == "win64" then
|
||||
client_settings.link.libpath:Add("other/opus/windows/lib64")
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "32") then
|
||||
client_settings.link.libpath:Add("other/opus/mac/lib32")
|
||||
elseif platform == "macosx" and string.find(settings.config_name, "64") then
|
||||
client_settings.link.libpath:Add("other/opus/mac/lib64")
|
||||
elseif platform == "linux" and arch == "x86" then
|
||||
client_settings.link.libpath:Add("other/opus/linux/lib32")
|
||||
elseif platform == "linux" and arch == "amd64" then
|
||||
client_settings.link.libpath:Add("other/opus/linux/lib64")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local save = function(option, output)
|
||||
output:option(option, "value")
|
||||
output:option(option, "use_pkgconfig")
|
||||
end
|
||||
|
||||
local display = function(option)
|
||||
if option.value == true then
|
||||
if option.use_pkgconfig == true then return "using pkg-config" end
|
||||
return "using bundled libs"
|
||||
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)
|
||||
o.Apply = apply
|
||||
o.include_path = nil
|
||||
o.lib_path = nil
|
||||
o.required = required
|
||||
return o
|
||||
end
|
||||
}
|
Loading…
Reference in a new issue