Permalink
Browse files

Make cross-compilation for windows possible using mingw

  • Loading branch information...
def- committed Sep 3, 2015
1 parent 85f6e45 commit d4fe267c5842f567d8cd721df22c427b6dae9106
Showing with 67 additions and 38 deletions.
  1. +59 −30 bam.lua
  2. +2 −2 configure.lua
  3. +1 −1 other/curl/curl.lua
  4. +1 −1 other/freetype/freetype.lua
  5. +1 −1 other/opus/ogg.lua
  6. +1 −1 other/opus/opus.lua
  7. +1 −1 other/opus/opusfile.lua
  8. +1 −1 other/sdl/sdl.lua
View
89 bam.lua
@@ -1,5 +1,18 @@
CheckVersion("0.4")
target_family = os.getenv("TARGET_FAMILY")
if target_family then
family = target_family
end
target_platform = os.getenv("TARGET_PLATFORM")
if target_platform then
platform = target_platform
end
target_arch = os.getenv("TARGET_ARCH")
if target_arch then
arch = target_arch
end
Import("configure.lua")
Import("other/sdl/sdl.lua")
Import("other/freetype/freetype.lua")
@@ -28,7 +41,7 @@ config:Finalize("config.lua")
-- data compiler
function Script(name)
if family == "windows" then
if family == "windows" and target_family ~= "windows" then
return str_replace(name, "/", "\\")
end
return "python " .. name
@@ -67,14 +80,20 @@ DuplicateDirectoryStructure("src", "src", "objs")
]]
function ResCompile(scriptfile)
windres = os.getenv("WINDRES")
if not windres then
windres = "windres"
end
scriptfile = Path(scriptfile)
if config.compiler.driver == "cl" then
output = PathBase(scriptfile) .. ".res"
AddJob(output, "rc " .. scriptfile, "rc /fo " .. output .. " " .. scriptfile)
elseif config.compiler.driver == "gcc" then
output = PathBase(scriptfile) .. ".coff"
AddJob(output, "windres " .. scriptfile, "windres -i " .. scriptfile .. " -o " .. output)
AddJob(output, windres .. " " .. scriptfile, windres .. " -i " .. scriptfile .. " -o " .. output)
end
AddDependency(output, scriptfile)
return output
end
@@ -128,36 +147,36 @@ server_sql_depends = {}
if family == "windows" then
if platform == "win32" then
table.insert(client_depends, CopyToDirectory(".", "other\\freetype\\lib32\\freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\sdl\\lib32\\SDL.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\libcurl.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\libeay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\libidn-11.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\ssleay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib32\\zlib1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib32\\libgcc_s_sjlj-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib32\\libogg-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib32\\libopus-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib32\\libopusfile-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/freetype/lib32/freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/sdl/lib32/SDL.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/libcurl.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/libeay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/libidn-11.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/ssleay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib32/zlib1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libgcc_s_sjlj-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libogg-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libopus-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib32/libopusfile-0.dll"))
else
table.insert(client_depends, CopyToDirectory(".", "other\\freetype\\lib64\\freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\sdl\\lib64\\SDL.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib64\\libcurl.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib64\\libeay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib64\\ssleay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\curl\\windows\\lib64\\zlib1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libwinpthread-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libgcc_s_seh-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libogg-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libopus-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other\\opus\\windows\\lib64\\libopusfile-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/freetype/lib64/freetype.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/sdl/lib64/SDL.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib64/libcurl.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib64/libeay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib64/ssleay32.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/curl/windows/lib64/zlib1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libwinpthread-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libgcc_s_seh-1.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libogg-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libopus-0.dll"))
table.insert(client_depends, CopyToDirectory(".", "other/opus/windows/lib64/libopusfile-0.dll"))
end
table.insert(server_sql_depends, CopyToDirectory(".", "other\\mysql\\vc2005libs\\mysqlcppconn.dll"))
table.insert(server_sql_depends, CopyToDirectory(".", "other\\mysql\\vc2005libs\\libmysql.dll"))
table.insert(server_sql_depends, CopyToDirectory(".", "other/mysql/vc2005libs/mysqlcppconn.dll"))
table.insert(server_sql_depends, CopyToDirectory(".", "other/mysql/vc2005libs/libmysql.dll"))
if config.compiler.driver == "cl" then
client_link_other = {ResCompile("other/icons/teeworlds_cl.rc")}
@@ -179,6 +198,16 @@ function build(settings)
--settings.objdir = Path("objs")
settings.cc.Output = Intermediate_Output
cc = os.getenv("CC")
if cc then
settings.cc.exe_c = cc
end
cxx = os.getenv("CXX")
if cxx then
settings.cc.exe_cxx = cxx
settings.link.exe = cxx
settings.dll.exe = cxx
end
cflags = os.getenv("CFLAGS")
if cflags then
settings.cc.flags:Add(cflags)
View
@@ -382,8 +382,8 @@ function OptCCompiler(name, default_driver, default_c, default_cxx, desc)
error(option.driver.." is not a known c/c++ compile driver")
end
if option.c_compiler then settings.cc.c_compiler = option.c_compiler end
if option.cxx_compiler then settings.cc.cxx_compiler = option.cxx_compiler end
if option.c_compiler then settings.cc.exe_c = option.c_compiler end
if option.cxx_compiler then settings.cc.exe_cxx = option.cxx_compiler end
end
local save = function(option, output)
View
@@ -12,7 +12,7 @@ Curl = {
option.use_pkgconfig = true
end
if ExecuteSilent("pkg-config libcurl") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config libcurl") == 0 then
option.value = true
if option.use_pkgconfig == nil then
option.use_pkgconfig = true
@@ -8,7 +8,7 @@ FreeType = {
option.use_winlib = 0
option.lib_path = nil
if ExecuteSilent("pkg-config freetype2") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config freetype2") == 0 then
option.value = true
option.use_pkgconfig = true
end
View
@@ -12,7 +12,7 @@ Ogg = {
option.use_pkgconfig = true
end
if ExecuteSilent("pkg-config ogg") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config ogg") == 0 then
option.value = true
if option.use_pkgconfig == nil then
option.use_pkgconfig = true
View
@@ -12,7 +12,7 @@ Opus = {
option.use_pkgconfig = true
end
if ExecuteSilent("pkg-config opus") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config opus") == 0 then
option.value = true
if option.use_pkgconfig == nil then
option.use_pkgconfig = true
View
@@ -12,7 +12,7 @@ Opusfile = {
option.use_pkgconfig = true
end
if ExecuteSilent("pkg-config opusfile") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config opusfile") == 0 then
option.value = true
if option.use_pkgconfig == nil then
option.use_pkgconfig = true
View
@@ -9,7 +9,7 @@ SDL = {
option.use_osxframework = false
option.lib_path = nil
if ExecuteSilent("pkg-config sdl") == 0 then
if family ~= "windows" and ExecuteSilent("pkg-config sdl") == 0 then
option.value = true
option.use_pkgconfig = true
end

0 comments on commit d4fe267

Please sign in to comment.