merge with trunk at r27259 and commit of a patch by anthony jones to fix msvc (though...
[blender-staging.git] / source / blender / makesdna / intern / SConscript
1 #!/usr/bin/python
2 import sys
3 import os
4
5 def normpath(path):
6         return os.path.abspath(os.path.normpath(path))
7
8 Import ('env')
9 cflags = ''
10 defines = []
11 root_build_dir=normpath(env['BF_BUILDDIR'])
12
13 source_files = ['makesdna.c']
14 header_files = env.Glob('../*.h')
15
16 makesdna_tool = env.Clone()
17 dna = env.Clone()
18 makesdna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesdna/\\"" ')
19
20 makesdna_tool.Append (CPPPATH = ['#/intern/guardedalloc',
21                                                                  '../../makesdna', '../', '../../bmesh'])
22
23 if env['OURPLATFORM'] == 'linuxcross':
24         USE_WINE = True # when cross compiling on linux 64bit this is useful
25 else:
26         USE_WINE = False
27
28 if not USE_WINE:
29         if env['OURPLATFORM'] == 'linuxcross':
30                 makesdna_tool.Replace(CC='gcc')
31                 makesdna_tool.Replace(AR='ar')
32                 makesdna_tool.Replace(LINK='gcc')
33
34 if sys.platform != 'cygwin':
35         makesdna_tool.Append (CCFLAGS = cflags)
36 makesdna_tool.Append (CPPDEFINES = defines)
37 makesdna_tool.Append( CFLAGS = env['CFLAGS'])
38 makesdna_tool.Append( CCFLAGS = env['CCFLAGS'])
39 makesdna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
40 targetdir = normpath(root_build_dir+'/lib')
41
42 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
43         targetdir = '#'+targetdir
44 makesdna_tool.Append (LIBPATH = targetdir)
45 if env['BF_PROFILE']:
46         makesdna_tool.Append (LINKFLAGS = env['BF_PROFILE_LINKFLAGS'])
47
48 targetdir = normpath(root_build_dir + '/makesdna')
49
50 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
51         targetdir = '#' + targetdir
52         #root_build_dir = "#"
53
54 makesdna = makesdna_tool.Program (target = targetdir, source = source_files, LIBS=['bf_guardedalloc', 'bf_blenlib'])
55
56 dna_dict = dna.Dictionary()
57 dna.Depends ('dna.c', makesdna)
58 dna.Depends ('dna.c', header_files)
59
60 ap = os.path.abspath
61
62 if env['OURPLATFORM'] != 'linuxcross':
63         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
64                 dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET")
65         else:
66                 dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna $TARGET")
67 else:
68         if USE_WINE:
69                 dna.Command ('dna.c', '', 'wine ' + ap(root_build_dir+os.sep+"makesdna $TARGET"))
70         else:
71                 if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
72                         dna.Command ('dna.c', '', "\"" + root_build_dir+os.sep+"makesdna\" $TARGET")
73                 else:
74                         dna.Command ('dna.c', '', root_build_dir+os.sep+"makesdna $TARGET")
75
76 obj = ['intern/dna.c', 'intern/dna_genfile.c']
77 Return ('obj')