* Minimum SCons version is now 1.0.0
[blender-staging.git] / extern / verse / dist / SConstruct
1 #!/usr/bin/env python
2 #
3 # I think it is quite straight-forward to add new platforms,
4 # just look at the old makefile and at the existing platforms.
5 #
6 # This SConstruct creates a configuration file which can be
7 # used for tweaking a build.
8 #
9 # For more about SConstruct, see <http://www.scons.org/>.
10 #
11
12 import os
13 import os.path
14 import sys
15 import re
16 import time
17 import string
18 from distutils import sysconfig
19
20 Import('env')
21
22 defines = []
23 cflags = []
24 debug_flags = []
25 extra_flags = []
26 release_flags = []
27 warn_flags = []
28 platform_libs = []
29 platform_libpath = []
30 platform_linkflags = []
31
32 ourplatform = env['OURPLATFORM']
33 if ourplatform == 'win32-vc':
34     print "Building on win32"
35     defines += ['_WIN32']
36     warn_flags = ['/Wall']
37     platform_libs = ['ws2_32']
38 elif ourplatform == 'win32-mingw':
39     defines += ['_WIN32', 'WIN32']
40     platform_libs = ['shell32', 'kernel32', 'gdi32', 'user32', 'ws2_32']
41 elif ourplatform == 'linux2':
42     print "Building on linux2"
43 elif ourplatform == 'openbsd3':
44     print "Building on openbsd3"
45
46 root_build_dir = env['BF_BUILDDIR']
47
48 if env['VERSE_BUILD_BINARY'] == 'release':
49     cflags = extra_flags + release_flags + warn_flags
50     if ourplatform == 'win32-vc':
51         defines += ['NDEBUG']
52 else:
53     cflags = extra_flags + debug_flags + warn_flags
54     if ourplatform == 'win32-vc':
55         #defines += ['_DEBUG'] specifying this makes msvc want to link to python22_d.lib??
56         platform_linkflags += ['/DEBUG','/PDB:verse.pdb']
57
58
59 verse_env = env.Clone()
60
61 cmd_gen_files = (['v_cmd_gen.c',
62                   'v_cmd_def_a.c',
63                   'v_cmd_def_b.c',
64                   'v_cmd_def_c.c',
65                   'v_cmd_def_g.c',
66                   'v_cmd_def_m.c',
67                   'v_cmd_def_o.c',
68                   'v_cmd_def_s.c',
69                   'v_cmd_def_t.c'
70                   ])
71
72 cmd_gen_deps = (['v_gen_pack_init.c'])
73
74 proto_env = env.Clone()
75 proto_env.Append(CPPDEFINES=['V_GENERATE_FUNC_MODE'])
76 mkprot_tool = proto_env.Program(target = 'mkprot', source = cmd_gen_files)
77
78 mkprot_re = re.compile('v_cmd_def_([a-z]{1}).c')
79 def mkprot_emitter(target = None, source = None, env = None):
80     newtargets = list()
81     for s in source:
82         p, f = os.path.split(str(s))
83         m = mkprot_re.match(f)
84         if m:
85             newtargets.append("v_gen_pack_"+m.group(1)+"_node.c")
86     newtargets.extend(['verse.h'])
87     env.Depends(newtargets, mkprot_tool)
88     return (newtargets, source)
89
90 mkprot_bld = Builder(action = "\"" + mkprot_tool[0].abspath + "\" -src=\""+os.getcwd()+os.sep+"extern"+os.sep+"verse"+os.sep+"dist"+os.sep+os.sep+"\" -dst=\""+os.path.abspath(env['BF_BUILDDIR'])+os.sep+"extern"+os.sep+"verse"+os.sep+"dist"+os.sep+os.sep+"\"",
91             emitter = mkprot_emitter)
92
93 verse_env['BUILDERS']['Protocol'] = mkprot_bld
94
95 cmd_gen_deps.extend(verse_env.Protocol('do_mkprot', cmd_gen_files))
96
97 cmd_gen_deps.pop()
98
99 lib_source_files = (['v_cmd_buf.c',
100                      'v_connect.c',
101                      'v_connection.c',
102                      'v_encryption.c',
103                      'v_func_storage.c',
104                      'v_man_pack_node.c',
105                      'v_network.c',
106                      'v_network_in_que.c',
107                      'v_network_out_que.c',
108                      'v_pack.c',
109                      'v_pack_method.c',
110                      'v_prime.c',
111                      'v_randgen.c',
112                      'v_util.c',
113                      'v_bignum.c',
114                      'verse_ms.c'
115                      ])
116 lib_source_files.extend(cmd_gen_deps)
117
118 server_source_files = (['vs_connection.c',
119                         'vs_main.c',
120                         'vs_master.c',
121                         'vs_node_audio.c',
122                         'vs_node_bitmap.c',
123                         'vs_node_curve.c',
124                         'vs_node_geometry.c',
125                         'vs_node_head.c',
126                         'vs_node_material.c',
127                         'vs_node_object.c',
128                         'vs_node_particle.c',
129                         'vs_node_storage.c',
130                         'vs_node_text.c'
131                         ])
132
133 verselib_env = verse_env.Clone()
134 verselib_env.Append(CPPDEFINES = defines)
135
136 verseserver_env = verse_env.Clone()
137 verseserver_env.Append(CPPDEFINES = defines)
138 verseserver_env.Append (LIBPATH = ['.'])
139 verseserver_env.Append (LIBS= ['verse'])
140 verseserver_env.Append (LIBS= platform_libs)
141
142 verselib_env.BlenderLib(libname='verse', sources=lib_source_files, includes=["."], defines = defines, libtype=['core', 'intern', 'player'], priority = [5, 5, 100])
143 verseserver_env.BlenderProg(builddir="#"+root_build_dir+os.sep, progname='verse', sources=server_source_files, libs=[],
144 libpath='#'+env['BF_BUILDDIR']+'/lib')
145
146