SCons build system files added.
[blender.git] / SConstruct
1 import string
2 import os
3 import sys
4 from distutils import sysconfig
5
6 # Setting up default environment variables for all platforms
7
8 sdl_cenv = Environment ()
9 sdl_lenv = Environment ()
10 link_env = Environment ()
11
12 if sys.platform == 'linux2':
13     use_international = 'false'
14     use_gameengine = 'false'
15     use_openal = 'false'
16     use_fmod = 'false'
17     use_quicktime = 'false'
18     release_flags = ['-O2']
19     debug_flags = ['-O2', '-g']
20     extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
21     cxxflags = []
22     defines = []
23     warn_flags = ['-Wall', '-W']
24     window_system = 'X11'
25     platform_libs = ['m', 'z', 'GL', 'GLU', 'png', 'jpeg', 'util']
26     platform_libpath = []
27     platform_linkflags = []
28     extra_includes = []
29     # SDL specific stuff.
30     sdl_cenv.ParseConfig ('sdl-config --cflags')
31     sdl_lenv.ParseConfig ('sdl-config --libs')
32     sdl_cdict = sdl_cenv.Dictionary()
33     sdl_ldict = sdl_lenv.Dictionary()
34     sdl_cflags = string.join(sdl_cdict['CCFLAGS'])
35     sdl_include = sdl_cdict['CPPPATH'][0]
36     link_env.Append (LIBS=sdl_ldict['LIBS'])
37     link_env.Append (LIBPATH=sdl_ldict['LIBPATH'])
38     # Python variables.
39     python_include = sysconfig.get_python_inc ()
40     python_libpath = sysconfig.get_python_lib (0, 1) + '/config'
41     python_lib = 'python%d.%d' % sys.version_info[0:2]
42
43 elif sys.platform == 'darwin':
44     use_international = 'false'
45     use_gameengine = 'false'
46     use_openal = 'false'
47     use_fmod = 'false'
48     use_quicktime = 'true'
49     # TODO: replace darwin-6.8-powerpc with the actual directiory on the
50     #       build machine
51     darwin_precomp = '#../lib/darwin-6.8-powerpc'
52     extra_flags = ['-pipe', '-fPIC', '-funsigned-char']
53     cxxflags = []
54     defines = ['_THREAD_SAFE']
55     warn_flags = ['-Wall', '-W']
56     release_flags = []
57     debug_flags = ['-g']
58     window_system = 'CARBON'
59     # SDL specific stuff.
60     sdl_cdict = sdl_cenv.Dictionary()
61     sdl_ldict = sdl_lenv.Dictionary()
62     sdl_cflags = string.join(sdl_cdict['CCFLAGS'])
63     sdl_include = darwin_precomp + '/sdl/include'
64     link_env.Append (LIBS=['libSDL.a'])
65     link_env.Append (LIBPATH=[darwin_precomp + '/sdl/lib'])
66     platform_libs = ['z', 'GL', 'GLU', 'png', 'jpeg', 'stdc++'] 
67     extra_includes = ['/sw/include']
68     platform_libpath = ['/System/Library/Frameworks/OpenGL.framework/Libraries']
69     platform_linkflags = []
70     # Python variables.
71     python_lib = 'python%d.%d' % sys.version_info[0:2]
72     python_libpath = sysconfig.get_python_lib (0, 1) + '/config'
73     python_include = sysconfig.get_python_inc ()
74
75 elif sys.platform == 'cygwin':
76     use_international = 'false'
77     use_gameengine = 'false'
78     use_openal = 'false'
79     use_fmod = 'false'
80     use_quicktime = 'false'
81     release_flags = ['-O2']
82     debug_flags = ['-O2', '-g']
83     extra_flags = ['-pipe', '-mno-cygwin', '-mwindows', '-funsigned-char']
84     defines = ['FREE_WINDOWS', 'NDEBUG']
85     cxxflags = []
86     warn_flags = ['-Wall', '-Wno-char-subscripts']
87     platform_libs = ['png', 'jpeg', 'netapi32',
88                      'opengl32', 'glu32', 'winmm',
89                      'mingw32', 'z']
90     platform_libpath = ['/usr/lib/w32api', '/lib/w32api']
91     platform_linkflags = ['-mwindows', '-mno-cygwin', '-mconsole']
92     window_system = 'WIN32'
93     extra_includes = ['/usr/include']
94     # SDL specific stuff.
95     sdl_cenv.ParseConfig ('sdl-config --cflags')
96     sdl_lenv.ParseConfig ('sdl-config --libs')
97     sdl_cdict = sdl_cenv.Dictionary()
98     sdl_ldict = sdl_lenv.Dictionary()
99     sdl_cflags = '-DWIN32'
100     sdl_include = sdl_cdict['CPPPATH'][0]
101     link_env.Append (LIBS=sdl_ldict['LIBS'])
102     link_env.Append (LIBPATH=sdl_ldict['LIBPATH'])
103     # We need to force the Cygwin environment to use the g++ linker.
104     link_env.Replace (CC='g++')
105     # Python variables.
106     python_include = sysconfig.get_python_inc ()
107     python_libpath = sysconfig.get_python_lib (0, 1) + '/config'
108     python_lib = 'python%d.%d' % sys.version_info[0:2]
109
110 elif sys.platform == 'win32':
111     use_international = 'true'
112     use_gameengine = 'false'
113     use_openal = 'true'
114     use_fmod = 'false'
115     use_quicktime = 'true'
116     release_flags = ['/G6', '/GF']
117     debug_flags = []
118     extra_flags = ['/EHsc', '/J', '/W3', '/Gd', '/MT']
119     cxxflags = []
120     defines = ['WIN32', 'NDEBUG', '_CONSOLE', 'FTGL_STATIC_LIBRARY']
121     defines += ['GAME_BLENDER=0', 'INTERNATIONAL', 'WITH_QUICKTIME']
122     warn_flags = []
123     platform_libs = ['SDL', 'freetype2ST', 'ftgl_static_ST', 'gnu_gettext',
124                      'qtmlClient', 'odelib', 'openal_static', 'soundsystem',
125                      'ws2_32', 'dxguid', 'opengl32', 'libjpeg', 'glu32',
126                      'vfw32', 'winmm', 'libpng_st', 'libz_st', 'solid',
127                      'qhull', 'iconv', 'kernel32', 'user32', 'gdi32',
128                      'winspool', 'comdlg32', 'advapi32', 'shell32',
129                      'ole32', 'oleaut32', 'uuid', 'odbc32', 'odbccp32',
130                      'libcmt', 'libc']
131     platform_libpath = ['#../lib/windows/ftgl/lib',
132                         '#../lib/windows/freetype/lib',
133                         '#../lib/windows/gettext/lib',
134                         '#../lib/windows/iconv/lib',
135                         '#../lib/windows/jpeg/lib',
136                         '#../lib/windows/QTDevWin/Libraries',
137                         '#../lib/windows/ode/lib',
138                         '#../lib/windows/openal/lib',
139                         '#../lib/windows/png/lib',
140                         '#../lib/windows/zlib/lib',
141                         '#../lib/windows/solid/lib',
142                         '#../lib/windows/qhull/lib',
143                         '#../lib/windows/sdl/lib']
144     platform_linkflags = [
145                         '/SUBSYSTEM:CONSOLE',
146                         '/MACHINE:IX86',
147                         '/ENTRY:mainCRTStartup',
148                         '/INCREMENTAL:NO',
149                         '/NODEFAULTLIB:"msvcprt.lib"',
150                         '/NODEFAULTLIB:"glut32.lib"',
151                         '/NODEFAULTLIB:"libcd.lib"',
152                         #'/NODEFAULTLIB:"libc.lib"',
153                         '/NODEFAULTLIB:"libcpd.lib"',
154                         '/NODEFAULTLIB:"libcp.lib"',
155                         '/NODEFAULTLIB:"libcmtd.lib"',
156                         ]
157     window_system = 'WIN32'
158     extra_includes = ['#../lib/windows/zlib/include',
159                       '#../lib/windows/jpeg/include',
160                       '#../lib/windows/png/include']
161     if use_international == 'true':
162         extra_includes += ['#../lib/windows/ftgl/include',
163                            '#../lib/windows/freetype/include',
164                            '#../lib/windows/gettext/include']
165     if use_quicktime == 'true':
166         extra_includes += ['#../lib/windows/QTDevWin/CIncludes']
167     if use_openal == 'true':
168         extra_includes += ['#../lib/windows/openal/include']
169     sdl_include = '#../lib/windows/sdl/include'
170     sdl_cflags = ''
171     window_system = 'WIN32'
172     # Python lib name
173     python_libpath = '#../lib/windows/python/include'
174     python_libpath = '#../lib/windows/python/lib'
175     python_lib = 'python22'
176
177 elif string.find (sys.platform, 'sunos') != -1:
178     window_system = 'X11'
179
180 elif string.find (sys.platform, 'irix') != -1:
181     use_international = 'false'
182     use_gameengine = 'false'
183     use_openal = 'false'
184     use_fmod = 'false'
185     use_quicktime = 'false'
186     irix_precomp = '#../lib/irix-6.5-mips'
187     extra_flags = ['-n32', '-mips3', '-Xcpluscomm']
188     cxxflags = ['-n32', '-mips3', '-Xcpluscomm', '-LANG:std']
189     cxxflags += ['-LANG:libc_in_namespace_std=off']
190     
191     window_system = 'X11'
192     release_flags = ['-O2', '-OPT:Olimit=0']
193     debug_flags = ['-O2', '-g']
194     defines = []
195     warn_flags = ['-fullwarn', '-woff', '1001,1110,1201,1209,1355,1424,1681,3201']
196     sdl_cflags = ''
197     sdl_include = irix_precomp + '/sdl/include/SDL'
198     link_env.Append (LIBS=['libSDL.a'])
199     link_env.Append (LIBPATH=[irix_precomp + '/sdl/lib'])
200     python_libpath = irix_precomp + '/python/lib/python2.2/config'
201     python_include = irix_precomp + '/python/include/python2.2'
202     python_lib = 'python2.2'
203
204     platform_libs = ['SDL', 'movieGL', 'GLU', 'GL', 'Xmu', 'Xext', 'X11',
205                      'c', 'm', 'dmedia', 'cl', 'audio',
206                      'Cio', 'png', 'jpeg', 'z', 'pthread']
207     platform_libpath = [irix_precomp + '/png/lib',
208                         irix_precomp + '/jpeg/lib',
209                         '/usr/lib32', '/lib/freeware/lib32']
210     platform_linkflags = ['-mips3']
211     extra_includes = [irix_precomp + '/jpeg/include',
212                       irix_precomp + '/png/include',
213                       '/usr/freeware/include',
214                       '/usr/include']
215
216 elif string.find (sys.platform, 'hp-ux') != -1:
217     window_system = 'X11'
218
219 else:
220     print "Unknown platform"
221
222 #-----------------------------------------------------------------------------
223 # End of platform specific section
224 #-----------------------------------------------------------------------------
225 cflags = extra_flags + release_flags + warn_flags
226
227 Export ('use_international')
228 Export ('use_gameengine')
229 Export ('use_openal')
230 Export ('use_fmod')
231 Export ('use_quicktime')
232 Export ('python_include')
233 Export ('cflags')
234 Export ('defines')
235 Export ('cxxflags')
236 Export ('window_system')
237 Export ('sdl_cflags')
238 Export ('sdl_include')
239 Export ('extra_includes')
240 Export ('platform_libs')
241 Export ('platform_libpath')
242 Export ('platform_linkflags')
243
244 SConscript(['intern/SConscript',
245             'source/SConscript'])
246
247 libpath = (['lib'])
248
249 libraries = (['blender_render',
250               'blender_blendersrc',
251               'blender_renderconverter',
252               'blender_blenloader',
253               'blender_writestreamglue',
254               'blender_deflate',
255               'blender_writeblenfile',
256               'blender_readblenfile',
257               'blender_readstreamglue',
258               'blender_inflate',
259               'blender_img',
260               'blender_radiosity',
261               'blender_blenkernel',
262               'blender_blenpluginapi',
263               'blender_imbuf',
264               'blender_avi',
265               'blender_blenlib',
266               'blender_python',
267               'blender_makesdna',
268               'blender_kernel',
269               'blender_BSP',
270               'blender_LOD',
271               'blender_GHOST',
272               'blender_STR',
273               'blender_guardedalloc',
274               'blender_BMF',
275               'blender_CTR',
276               'blender_MEM',
277               'blender_IK',
278               'blender_MT',
279               'soundsystem'])
280
281 link_env.Append (LIBS=libraries)
282 link_env.Append (LIBPATH=libpath)
283
284 if use_international == 'true':
285     link_env.Append (LIBS=['blender_FTF'])
286 if use_quicktime == 'true':
287     link_env.Append (LIBS=['blender_quicktime'])
288
289 link_env.Append (LIBS=python_lib)
290 link_env.Append (LIBPATH=python_libpath)
291 link_env.Append (LIBS=platform_libs)
292 link_env.Append (LIBPATH=platform_libpath)
293 if sys.platform == 'darwin':
294     link_env.Append (LINKFLAGS=' -framework Carbon')
295     link_env.Append (LINKFLAGS=' -framework AGL')
296     if use_quicktime == 'true':
297         link_env.Append (LINKFLAGS=' -framework QuickTime')
298 else:
299     link_env.Append (LINKFLAGS=platform_linkflags)
300
301 source_files = ['source/creator/buildinfo.c',
302                 'source/creator/creator.c']
303
304 include_paths = ['#/intern/guardedalloc',
305                  '#/source/blender/makesdna',
306                  '#/source/blender/blenkernel',
307                  '#/source/blender/blenloader',
308                  '#/source/blender/python',
309                  '#/source/blender/blenlib',
310                  '#/source/blender/renderconverter',
311                  '#/source/blender/render/extern/include',
312                  '#/source/kernel/gen_messaging',
313                  '#/source/kernel/gen_system',
314                  '#/source/blender/include',
315                  '#/source/blender/imbuf']
316
317 link_env.Append (CPPPATH=include_paths)
318 link_env.Program (target='blender', source=source_files, CCFLAGS=cflags)
319
320 if sys.platform == 'darwin':
321     bundle = Environment ()
322     blender_app = 'blender'
323     bundle.Depends ('#/blender.app/Contents/MacOS/' + blender_app, blender_app)
324     bundle.Command ('dummy1', '#/blender.app', 'rm -rf $SOURCE')
325     bundle.Command ('dummy2', '#/source/darwin/blender.app', 'cp -R $SOURCE .')
326     bundle.Command ('#/blender.app/Contents/Info.plist',
327                     '#/source/darwin/blender.app/Contents/Info.plist',
328                     "cat $SOURCE | sed s/VERSION/`cat release/VERSION`/ | \
329                                    sed s/DATE/`date +'%Y-%b-%d'`/ \
330                                    > $TARGET")
331     bundle.Command ('dummy3', blender_app,
332                     'cp $SOURCE blender.app/Contents/MacOS')
333     bundle.Command ('dummy4', '#/blender.app/Contents/MacOS/' + blender_app,
334                     'chmod +x $SOURCE')
335     bundle.Command ('dummy5', 'blender.app',
336                     'find $SOURCE -name CVS -prune -exec rm -rf {} \;')
337     bundle.Command ('dummy6', 'blender.app',
338                     'find $SOURCE -name .DS_Store -exec rm -rf {} \;')