15fbaa80bd0f670233cbcddd741b57ce12caad43
[blender.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.Copy()
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.Copy()
75 proto_env.Append(CPPDEFINES=['V_GENERATE_FUNC_MODE'])
76 mkprot_tool = proto_env.Program(target = 'mkprot', source = cmd_gen_files)
77
78 print os.getcwd()
79
80 mkprot_re = re.compile('v_cmd_def_([a-z]{1}).c')
81 def mkprot_emitter(target = None, source = None, env = None):
82         newtargets = list()
83         for s in source:
84                 p, f = os.path.split(str(s))
85                 m = mkprot_re.match(f)
86                 if m:
87                         newtargets.append("v_gen_pack_"+m.group(1)+"_node.c")
88         newtargets.extend(['verse.h'])
89         env.Depends(newtargets, mkprot_tool)
90         return (newtargets, source)
91
92 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+"\"",
93                         emitter = mkprot_emitter)
94
95 verse_env['BUILDERS']['Protocol'] = mkprot_bld
96
97 cmd_gen_deps.extend(verse_env.Protocol('do_mkprot', cmd_gen_files))
98
99
100 print "XXXXXXXXXXXXXXXXX"
101 for i in cmd_gen_deps:
102     print i
103 print "XXXXXXXXXXXXXXXXX"
104 cmd_gen_deps.pop()
105
106 lib_source_files = (['v_cmd_buf.c',
107                                          'v_connect.c',
108                                          'v_connection.c',
109                                          'v_encryption.c',
110                                          'v_func_storage.c',
111                                          'v_man_pack_node.c',
112                                          'v_network.c',
113                                          'v_network_in_que.c',
114                                          'v_network_out_que.c',
115                                          'v_pack.c',
116                                          'v_pack_method.c',
117                                          'v_prime.c',
118                                          'v_randgen.c',
119                                          'v_util.c',
120                                          'v_bignum.c'
121                                          ])
122 lib_source_files.extend(cmd_gen_deps)
123
124 server_source_files = (['vs_connection.c',
125                         'vs_main.c',
126                         'vs_master.c',
127                         'vs_node_audio.c',
128                         'vs_node_bitmap.c',
129                         'vs_node_curve.c',
130                         'vs_node_geometry.c',
131                         'vs_node_head.c',
132                         'vs_node_material.c',
133                         'vs_node_object.c',
134                         'vs_node_particle.c',
135                         'vs_node_storage.c',
136                         'vs_node_text.c'
137                         ])
138
139 verselib_env = verse_env.Copy()
140 verselib_env.Append(CPPDEFINES = defines)
141
142 verseserver_env = verse_env.Copy()
143 verseserver_env.Append(CPPDEFINES = defines)
144 verseserver_env.Append (LIBS=['libverse'])
145 verseserver_env.Append (LIBPATH = ['.'])
146 verseserver_env.Append (LIBS= platform_libs)
147
148 #verselib =
149 verselib_env.BlenderLib(libname='verse', sources=lib_source_files, includes=["."], defines = defines, libtype=['core', 'intern'], priority = [5, 5])
150 verseserver_env.BlenderProg(builddir="#"+root_build_dir, progname='verse', sources=server_source_files, libs=['verse'],
151 libpath='#'+env['BF_BUILDDIR']+'/lib')
152
153