2009-01-08 09:48:42 +00:00
|
|
|
CheckVersion("0.2")
|
2008-10-21 12:34:33 +00:00
|
|
|
|
2009-01-08 09:48:42 +00:00
|
|
|
Import("other/sdl/sdl.bam")
|
2008-11-29 10:19:00 +00:00
|
|
|
|
2008-05-10 17:18:56 +00:00
|
|
|
--- Setup Config --------
|
|
|
|
config = NewConfig()
|
2009-01-08 09:48:42 +00:00
|
|
|
config:Add(OptFindCompiler())
|
|
|
|
config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all"))
|
|
|
|
config:Add(OptFindLibrary("zlib", "zlib.h", false))
|
|
|
|
config:Add(SDL.OptFind("sdl", true))
|
|
|
|
config:Finalize("config.bam")
|
2007-05-22 15:05:28 +00:00
|
|
|
|
2007-08-02 08:20:53 +00:00
|
|
|
-- data compiler
|
2008-06-12 10:51:48 +00:00
|
|
|
function Script(name)
|
|
|
|
if family == "windows" then
|
|
|
|
return str_replace(name, "/", "\\")
|
2008-04-20 22:30:59 +00:00
|
|
|
end
|
2008-06-12 10:51:48 +00:00
|
|
|
return "python " .. name
|
2008-02-24 16:03:58 +00:00
|
|
|
end
|
2007-08-22 21:13:33 +00:00
|
|
|
|
|
|
|
function CHash(output, ...)
|
2009-01-08 09:48:42 +00:00
|
|
|
local inputs = FlatternTable({...})
|
2007-08-22 21:13:33 +00:00
|
|
|
|
|
|
|
output = Path(output)
|
|
|
|
|
|
|
|
-- compile all the files
|
2009-01-08 09:48:42 +00:00
|
|
|
local cmd = Script("scripts/cmd5.py") .. " "
|
|
|
|
for index, inname in ipairs(inputs) do
|
2008-06-12 10:51:48 +00:00
|
|
|
cmd = cmd .. Path(inname) .. " "
|
2007-08-22 21:13:33 +00:00
|
|
|
end
|
|
|
|
|
2008-06-12 10:51:48 +00:00
|
|
|
cmd = cmd .. " > " .. output
|
|
|
|
|
2009-01-08 09:48:42 +00:00
|
|
|
AddJob(output, "cmd5 " .. output, cmd)
|
|
|
|
for index, inname in ipairs(inputs) do
|
|
|
|
AddDependency(output, inname)
|
2007-08-22 21:13:33 +00:00
|
|
|
end
|
|
|
|
return output
|
|
|
|
end
|
|
|
|
|
2007-08-07 17:46:04 +00:00
|
|
|
function ResCompile(scriptfile)
|
|
|
|
scriptfile = Path(scriptfile)
|
|
|
|
output = PathBase(scriptfile) .. ".res"
|
2009-01-08 09:48:42 +00:00
|
|
|
AddJob(output, "rc " .. scriptfile, "rc /fo " .. output .. " " .. scriptfile)
|
|
|
|
AddDependency(output, scriptfile)
|
2007-08-07 17:46:04 +00:00
|
|
|
return output
|
|
|
|
end
|
|
|
|
|
2007-07-24 22:53:43 +00:00
|
|
|
function Dat2c(datafile, sourcefile, arrayname)
|
2007-07-13 13:40:04 +00:00
|
|
|
datafile = Path(datafile)
|
2007-07-24 22:53:43 +00:00
|
|
|
sourcefile = Path(sourcefile)
|
2008-06-12 10:51:48 +00:00
|
|
|
|
2009-01-08 09:48:42 +00:00
|
|
|
AddJob(
|
2008-06-12 10:51:48 +00:00
|
|
|
sourcefile,
|
|
|
|
"dat2c " .. PathFilename(sourcefile) .. " = " .. PathFilename(datafile),
|
2009-01-08 09:48:42 +00:00
|
|
|
Script("scripts/dat2c.py") .. " " .. datafile .. " " .. arrayname .. " > " .. sourcefile
|
2008-06-12 10:51:48 +00:00
|
|
|
)
|
2009-01-08 09:48:42 +00:00
|
|
|
AddDependency(sourcefile, datafile)
|
2007-07-24 22:53:43 +00:00
|
|
|
return sourcefile
|
2007-07-13 13:40:04 +00:00
|
|
|
end
|
|
|
|
|
2008-06-12 10:51:48 +00:00
|
|
|
function ContentCompile(action, output)
|
|
|
|
output = Path(output)
|
2009-01-08 09:48:42 +00:00
|
|
|
AddJob(
|
2008-06-12 10:51:48 +00:00
|
|
|
output,
|
|
|
|
action .. " > " .. output,
|
|
|
|
Script("datasrc/compile.py") .. " " .. action .. " > " .. Path(output)
|
|
|
|
)
|
2009-01-08 09:48:42 +00:00
|
|
|
AddDependency(output, Path("datasrc/content.py")) -- do this more proper
|
|
|
|
AddDependency(output, Path("datasrc/network.py"))
|
|
|
|
AddDependency(output, Path("datasrc/compile.py"))
|
|
|
|
AddDependency(output, Path("datasrc/datatypes.py"))
|
2008-06-12 10:51:48 +00:00
|
|
|
return output
|
2007-07-13 13:40:04 +00:00
|
|
|
end
|
2007-05-22 15:05:28 +00:00
|
|
|
|
2008-06-12 10:51:48 +00:00
|
|
|
-- Content Compile
|
|
|
|
network_source = ContentCompile("network_source", "src/game/generated/g_protocol.cpp")
|
2008-06-12 12:09:34 +00:00
|
|
|
network_header = ContentCompile("network_header", "src/game/generated/g_protocol.hpp")
|
2008-06-12 10:51:48 +00:00
|
|
|
client_content_source = ContentCompile("client_content_source", "src/game/generated/gc_data.cpp")
|
2008-06-12 12:09:34 +00:00
|
|
|
client_content_header = ContentCompile("client_content_header", "src/game/generated/gc_data.hpp")
|
2008-06-12 10:51:48 +00:00
|
|
|
server_content_source = ContentCompile("server_content_source", "src/game/generated/gs_data.cpp")
|
2008-06-12 12:09:34 +00:00
|
|
|
server_content_header = ContentCompile("server_content_header", "src/game/generated/gs_data.hpp")
|
2007-07-24 23:46:29 +00:00
|
|
|
|
2009-01-08 09:48:42 +00:00
|
|
|
AddDependency(network_source, network_header)
|
|
|
|
AddDependency(client_content_source, client_content_header)
|
|
|
|
AddDependency(server_content_source, server_content_header)
|
2007-08-22 21:13:33 +00:00
|
|
|
|
2009-01-08 09:48:42 +00:00
|
|
|
nethash = CHash("src/game/generated/nethash.c", "src/engine/e_protocol.h", "src/game/generated/g_protocol.hpp", "src/game/tuning.hpp", "src/game/gamecore.cpp", network_header)
|
2007-08-22 21:13:33 +00:00
|
|
|
|
2007-08-07 17:46:04 +00:00
|
|
|
client_link_other = {}
|
2009-01-11 12:57:29 +00:00
|
|
|
client_depends = {}
|
|
|
|
|
|
|
|
if family == "windows" then
|
|
|
|
table.insert(client_depends, Copy(".", "other\\sdl\\vc2005libs\\SDL.dll"))
|
|
|
|
end
|
|
|
|
|
2009-01-08 09:48:42 +00:00
|
|
|
|
2008-05-10 17:18:56 +00:00
|
|
|
if config.compiler.value == "cl" then
|
2008-03-22 18:40:27 +00:00
|
|
|
client_link_other = {ResCompile("other/icons/teeworlds.rc")}
|
2007-08-07 17:46:04 +00:00
|
|
|
end
|
|
|
|
|
2009-01-08 09:48:42 +00:00
|
|
|
function Intermediate_Output(settings, input)
|
|
|
|
return Path("objs/" .. PathBase(PathFilename(input)) .. settings.config_ext)
|
2007-12-15 10:24:49 +00:00
|
|
|
end
|
|
|
|
|
2007-08-02 08:20:53 +00:00
|
|
|
function build(settings)
|
2009-01-08 09:48:42 +00:00
|
|
|
--settings.objdir = Path("objs")
|
|
|
|
settings.cc.Output = Intermediate_Output
|
|
|
|
|
2008-05-10 17:18:56 +00:00
|
|
|
if config.compiler.value == "cl" then
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.cc.flags:Add("/wd4244")
|
2007-08-02 08:20:53 +00:00
|
|
|
else
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.cc.flags:Add("-Wall", "-fno-exceptions")
|
2008-10-20 16:18:02 +00:00
|
|
|
if platform == "macosx" then
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.cc.flags:Add("-mmacosx-version-min=10.4", "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
|
|
|
settings.link.flags:Add("-mmacosx-version-min=10.4", "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
2008-10-20 16:18:02 +00:00
|
|
|
elseif config.stackprotector.value == 1 then
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.cc.flags:Add("-fstack-protector", "-fstack-protector-all")
|
|
|
|
settings.link.flags:Add("-fstack-protector", "-fstack-protector-all")
|
2008-10-20 16:18:02 +00:00
|
|
|
end
|
2007-08-02 08:20:53 +00:00
|
|
|
end
|
2007-07-24 23:46:29 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
-- set some platform specific settings
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.cc.includes:Add("src")
|
2007-08-22 07:52:33 +00:00
|
|
|
|
|
|
|
if family == "unix" then
|
|
|
|
if platform == "macosx" then
|
|
|
|
glfw_platform = "macosx"
|
2008-03-05 19:38:47 +00:00
|
|
|
pa_platform = "mac_osx"
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.link.frameworks:Add("Carbon")
|
|
|
|
settings.link.frameworks:Add("AppKit")
|
2007-08-22 07:52:33 +00:00
|
|
|
else
|
|
|
|
glfw_platform = "x11"
|
2008-03-05 19:38:47 +00:00
|
|
|
pa_platform = "unix"
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.link.libs:Add("pthread")
|
2007-08-22 07:52:33 +00:00
|
|
|
end
|
|
|
|
elseif family == "windows" then
|
|
|
|
glfw_platform = "win32"
|
2008-03-05 19:38:47 +00:00
|
|
|
pa_platform = "win"
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.link.libs:Add("gdi32")
|
|
|
|
settings.link.libs:Add("user32")
|
|
|
|
settings.link.libs:Add("ws2_32")
|
|
|
|
settings.link.libs:Add("ole32")
|
|
|
|
settings.link.libs:Add("shell32")
|
2007-08-22 07:52:33 +00:00
|
|
|
end
|
|
|
|
|
2008-05-10 17:18:56 +00:00
|
|
|
-- compile zlib if needed
|
|
|
|
if config.zlib.value == 1 then
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.link.libs:Add("z")
|
2008-05-10 17:18:56 +00:00
|
|
|
if config.zlib.include_path then
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.cc.includes:Add(config.zlib.include_path)
|
2008-05-10 17:18:56 +00:00
|
|
|
end
|
|
|
|
zlib = {}
|
|
|
|
else
|
|
|
|
zlib = Compile(settings, Collect("src/engine/external/zlib/*.c"))
|
2009-01-08 09:48:42 +00:00
|
|
|
settings.cc.includes:Add("src/engine/external/zlib")
|
2008-05-10 17:18:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- build the small libraries
|
|
|
|
wavpack = Compile(settings, Collect("src/engine/external/wavpack/*.c"))
|
|
|
|
pnglite = Compile(settings, Collect("src/engine/external/pnglite/*.c"))
|
2008-03-05 19:38:47 +00:00
|
|
|
|
2008-03-22 18:40:27 +00:00
|
|
|
-- build game components
|
2009-01-08 09:48:42 +00:00
|
|
|
engine_settings = settings:Copy()
|
|
|
|
server_settings = engine_settings:Copy()
|
|
|
|
client_settings = engine_settings:Copy()
|
2007-10-02 08:26:08 +00:00
|
|
|
|
|
|
|
if family == "unix" then
|
|
|
|
if platform == "macosx" then
|
2009-01-08 09:48:42 +00:00
|
|
|
client_settings.link.frameworks:Add("OpenGL")
|
|
|
|
client_settings.link.frameworks:Add("AGL")
|
|
|
|
client_settings.link.frameworks:Add("Carbon")
|
|
|
|
client_settings.link.frameworks:Add("Cocoa")
|
2007-10-02 08:26:08 +00:00
|
|
|
else
|
2009-01-08 09:48:42 +00:00
|
|
|
client_settings.link.libs:Add("X11")
|
|
|
|
client_settings.link.libs:Add("GL")
|
|
|
|
client_settings.link.libs:Add("GLU")
|
2007-10-02 08:26:08 +00:00
|
|
|
end
|
|
|
|
elseif family == "windows" then
|
2009-01-08 09:48:42 +00:00
|
|
|
client_settings.link.libs:Add("opengl32")
|
|
|
|
client_settings.link.libs:Add("glu32")
|
|
|
|
client_settings.link.libs:Add("winmm")
|
2008-05-10 17:18:56 +00:00
|
|
|
end
|
2008-10-21 16:31:19 +00:00
|
|
|
|
|
|
|
-- apply sdl settings
|
2009-01-08 09:48:42 +00:00
|
|
|
config.sdl:Apply(client_settings)
|
2008-10-21 15:34:42 +00:00
|
|
|
|
2008-08-14 17:19:13 +00:00
|
|
|
engine = Compile(engine_settings, Collect("src/engine/*.c", "src/base/*.c"))
|
2007-10-02 08:26:08 +00:00
|
|
|
client = Compile(client_settings, Collect("src/engine/client/*.c"))
|
|
|
|
server = Compile(server_settings, Collect("src/engine/server/*.c"))
|
2007-08-22 07:52:33 +00:00
|
|
|
|
2008-09-03 18:09:06 +00:00
|
|
|
versionserver = Compile(settings, Collect("src/versionsrv/*.cpp"))
|
2007-07-21 18:07:27 +00:00
|
|
|
masterserver = Compile(settings, Collect("src/mastersrv/*.cpp"))
|
2008-06-12 10:51:48 +00:00
|
|
|
game_shared = Compile(settings, Collect("src/game/*.cpp"), nethash, network_source)
|
2009-01-08 09:48:42 +00:00
|
|
|
game_client = Compile(settings, CollectRecursive("src/game/client/*.cpp"), client_content_source)
|
|
|
|
game_server = Compile(settings, CollectRecursive("src/game/server/*.cpp"), server_content_source)
|
2008-01-12 15:07:57 +00:00
|
|
|
game_editor = Compile(settings, Collect("src/game/editor/*.cpp"))
|
2007-07-21 18:07:27 +00:00
|
|
|
|
2007-09-23 18:27:04 +00:00
|
|
|
-- build tools (TODO: fix this so we don't get double _d_d stuff)
|
2007-07-24 22:53:43 +00:00
|
|
|
tools_src = Collect("src/tools/*.cpp", "src/tools/*.c")
|
2008-10-08 16:33:08 +00:00
|
|
|
|
2008-10-21 15:59:32 +00:00
|
|
|
osxlaunch = {}
|
2008-10-23 16:18:33 +00:00
|
|
|
if platform == "macosx" then
|
2008-10-21 15:59:32 +00:00
|
|
|
osxlaunch = Compile(client_settings, Collect("src/osxlaunch/*.m"))
|
|
|
|
end
|
2007-07-24 22:53:43 +00:00
|
|
|
|
|
|
|
tools = {}
|
2009-01-08 09:48:42 +00:00
|
|
|
for i,v in ipairs(tools_src) do
|
2007-09-09 18:21:14 +00:00
|
|
|
toolname = PathFilename(PathBase(v))
|
2009-01-08 09:48:42 +00:00
|
|
|
tools[i] = Link(settings, toolname, Compile(settings, v), engine, zlib)
|
2007-07-24 22:53:43 +00:00
|
|
|
end
|
|
|
|
|
2008-09-03 18:09:06 +00:00
|
|
|
-- build client, server, version server and master server
|
2008-03-22 18:40:27 +00:00
|
|
|
client_exe = Link(client_settings, "teeworlds", game_shared, game_client,
|
2008-10-23 16:18:33 +00:00
|
|
|
engine, client, game_editor, zlib, pnglite, wavpack,
|
2008-10-21 15:59:32 +00:00
|
|
|
client_link_other, osxlaunch)
|
2007-10-02 08:26:08 +00:00
|
|
|
|
2008-03-22 18:40:27 +00:00
|
|
|
server_exe = Link(server_settings, "teeworlds_srv", engine, server,
|
2007-10-02 08:26:08 +00:00
|
|
|
game_shared, game_server, zlib)
|
2008-09-03 18:09:06 +00:00
|
|
|
|
|
|
|
versionserver_exe = Link(server_settings, "versionsrv", versionserver,
|
|
|
|
engine, zlib)
|
2007-10-02 08:26:08 +00:00
|
|
|
|
|
|
|
masterserver_exe = Link(server_settings, "mastersrv", masterserver,
|
|
|
|
engine, zlib)
|
2007-08-02 08:20:53 +00:00
|
|
|
|
|
|
|
-- make targets
|
2009-01-11 12:57:29 +00:00
|
|
|
c = PseudoTarget("client".."_"..settings.config_name, client_exe, client_depends)
|
2007-08-02 08:20:53 +00:00
|
|
|
s = PseudoTarget("server".."_"..settings.config_name, server_exe)
|
2009-01-08 09:48:42 +00:00
|
|
|
g = PseudoTarget("game".."_"..settings.config_name, client_exe, server_exe)
|
|
|
|
|
2008-09-03 18:09:06 +00:00
|
|
|
v = PseudoTarget("versionserver".."_"..settings.config_name, versionserver_exe)
|
2007-08-02 08:20:53 +00:00
|
|
|
m = PseudoTarget("masterserver".."_"..settings.config_name, masterserver_exe)
|
|
|
|
t = PseudoTarget("tools".."_"..settings.config_name, tools)
|
2007-12-19 18:47:47 +00:00
|
|
|
|
2007-12-19 19:45:30 +00:00
|
|
|
Target(c)
|
|
|
|
Target(s)
|
2008-09-03 18:09:06 +00:00
|
|
|
Target(v)
|
2007-12-19 19:45:30 +00:00
|
|
|
Target(m)
|
|
|
|
Target(t)
|
|
|
|
|
2008-10-21 15:59:32 +00:00
|
|
|
all = PseudoTarget(settings.config_name, c, s, v, m, t)
|
2007-12-19 18:47:47 +00:00
|
|
|
|
2007-08-02 08:20:53 +00:00
|
|
|
Target(all)
|
|
|
|
return all
|
2007-07-21 18:07:27 +00:00
|
|
|
end
|
2007-05-22 15:05:28 +00:00
|
|
|
|
2009-01-11 12:10:30 +00:00
|
|
|
if platform == "macosx" and arch == "ia32" then
|
|
|
|
debug_settings_ppc = NewSettings()
|
|
|
|
debug_settings_ppc.config_name = "debug_ppc"
|
|
|
|
debug_settings_ppc.config_ext = "_ppc_d"
|
|
|
|
debug_settings_ppc.debug = 1
|
|
|
|
debug_settings_ppc.cc.optimize = 0
|
|
|
|
debug_settings_ppc.cc.flags:Add("-arch ppc")
|
|
|
|
debug_settings_ppc.link.flags:Add("-arch ppc")
|
|
|
|
|
|
|
|
release_settings_ppc = NewSettings()
|
|
|
|
release_settings_ppc.config_name = "release_ppc"
|
|
|
|
release_settings_ppc.config_ext = "_ppc"
|
|
|
|
release_settings_ppc.debug = 0
|
|
|
|
release_settings_ppc.cc.optimize = 1
|
|
|
|
release_settings_ppc.cc.flags:Add("-arch ppc")
|
|
|
|
release_settings_ppc.link.flags:Add("-arch ppc")
|
|
|
|
|
|
|
|
debug_settings_x86 = NewSettings()
|
|
|
|
debug_settings_x86.config_name = "debug_x86"
|
|
|
|
debug_settings_x86.config_ext = "_x86_d"
|
|
|
|
debug_settings_x86.debug = 1
|
|
|
|
debug_settings_x86.cc.optimize = 0
|
|
|
|
|
|
|
|
release_settings_x86 = NewSettings()
|
|
|
|
release_settings_x86.config_name = "release_x86"
|
|
|
|
release_settings_x86.config_ext = "_x86"
|
|
|
|
release_settings_x86.debug = 0
|
|
|
|
release_settings_x86.cc.optimize = 1
|
|
|
|
|
|
|
|
ppc_d = build(debug_settings_ppc)
|
|
|
|
x86_d = build(debug_settings_x86)
|
|
|
|
ppc_r = build(release_settings_ppc)
|
|
|
|
x86_r = build(release_settings_x86)
|
|
|
|
DefaultTarget("game_debug_x86")
|
|
|
|
PseudoTarget("release", ppc_r, x86_r)
|
|
|
|
PseudoTarget("debug", ppc_d, x86_d)
|
|
|
|
|
|
|
|
PseudoTarget("server_release", "server_release_x86", "server_release_ppc")
|
|
|
|
PseudoTarget("server_debug", "server_debug_x86", "server_debug_ppc")
|
|
|
|
PseudoTarget("client_release", "client_release_x86", "client_release_ppc")
|
|
|
|
PseudoTarget("client_debug", "client_debug_x86", "client_debug_ppc")
|
|
|
|
else
|
|
|
|
debug_settings = NewSettings()
|
|
|
|
debug_settings.config_name = "debug"
|
|
|
|
debug_settings.config_ext = "_d"
|
|
|
|
debug_settings.debug = 1
|
|
|
|
debug_settings.cc.optimize = 0
|
|
|
|
|
|
|
|
release_settings = NewSettings()
|
|
|
|
release_settings.config_name = "release"
|
|
|
|
release_settings.config_ext = ""
|
|
|
|
release_settings.debug = 0
|
|
|
|
release_settings.cc.optimize = 1
|
|
|
|
|
|
|
|
build(debug_settings)
|
|
|
|
build(release_settings)
|
|
|
|
DefaultTarget("game_debug")
|
|
|
|
end
|
2007-08-02 08:20:53 +00:00
|
|
|
|