add option WITH_BUILTIN_GLEW, so linux packagers can disable to use their own glew...
[blender.git] / source / blender / makesrna / 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 = [] #['-Wall']
10 defines = []
11 root_build_dir=normpath(env['BF_BUILDDIR'])
12
13 source_files = env.Glob('*.c')
14 source_files.remove('rna_access.c')
15
16 generated_files = source_files[:]
17 generated_files.remove('rna_define.c')
18 generated_files.remove('makesrna.c')
19
20 api_files = env.Glob('*_api.c')
21 for api_file in api_files:
22     generated_files.remove(api_file)
23
24 generated_files = [filename[:-2] + '_gen.c' for filename in generated_files]
25
26 makesrna_tool = env.Clone()
27 rna = env.Clone()
28 makesrna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesrna/\\"" ')
29
30 defs = []
31
32 incs = '#/intern/guardedalloc ../../blenlib ../../blenkernel ../../blenloader'
33 incs += ' ../../imbuf ../../makesdna ../../makesrna ../../ikplugin'
34 incs += ' ../../windowmanager ../../editors/include ../../blenfont'
35 incs += ' ../../render/extern/include'
36 incs += ' #/intern/audaspace/intern '
37 incs += ' #/extern/glew/include '
38
39 if env['WITH_BF_OPENEXR']:
40     defs.append('WITH_OPENEXR')
41
42 if env['WITH_BF_TIFF']:
43     defs.append('WITH_TIFF')
44
45 if env['WITH_BF_OPENJPEG']:
46     defs.append('WITH_OPENJPEG')
47
48 if env['WITH_BF_DDS']:
49     defs.append('WITH_DDS')
50
51 if env['WITH_BF_CINEON']:
52     defs.append('WITH_CINEON')
53
54 if env['WITH_BF_HDR']:
55     defs.append('WITH_HDR')
56
57 if env['WITH_BF_FFMPEG']:
58     defs.append('WITH_FFMPEG')
59     incs += ' ' + env['BF_FFMPEG_INC']
60
61 if env['WITH_BF_OGG']:
62     defs.append('WITH_OGG')
63
64 if env['WITH_BF_QUICKTIME']:
65     defs.append('WITH_QUICKTIME')
66     incs += ' ../../quicktime'
67
68 if env['WITH_BF_LCMS']:
69     defs.append('WITH_LCMS')
70
71 if env['WITH_BF_GAMEENGINE']:
72     defs.append('WITH_GAMEENGINE')
73     
74 if env['WITH_BF_FFTW3']:
75     defs.append('FFTW3=1')
76
77 if env['WITH_BF_SDL']:
78     defs.append('WITH_SDL')
79
80 if env['WITH_BF_OPENAL']:
81     defs.append('WITH_OPENAL')
82
83 if env['WITH_BF_JACK']:
84     defs.append('WITH_JACK')
85
86 if env['BF_UNIT_TEST']:
87     defs.append('UNIT_TEST')
88
89 if env['WITH_BF_PYTHON']:
90     defs.append('WITH_PYTHON')
91
92 if env['WITH_BF_COLLADA']:
93     defs.append('WITH_COLLADA')
94
95 if env['OURPLATFORM'] == 'linux2':
96     cflags='-pthread'
97     incs += ' ../../../extern/binreloc/include'
98
99 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
100     incs += ' ' + env['BF_PTHREADS_INC']
101
102 makesrna_tool.Append(CPPDEFINES=defs)
103
104 makesrna_tool.Append (CPPPATH = Split(incs))
105
106 if env['OURPLATFORM'] == 'linuxcross':
107     USE_WINE = True # when cross compiling on linux 64bit this is useful
108 else:
109     USE_WINE = False
110
111 if not USE_WINE:
112     if env['OURPLATFORM'] == 'linuxcross':
113         makesdna_tool.Replace(CC='gcc')
114         makesdna_tool.Replace(AR='ar')
115         makesdna_tool.Replace(LINK='gcc')
116
117 if sys.platform != 'cygwin':
118     makesrna_tool.Append (CCFLAGS = cflags)
119 makesrna_tool.Append (CPPDEFINES = defines)
120
121 libdir = root_build_dir+'/lib'
122 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
123     libdir = '#' + libdir
124
125 makesrna_tool.Append (LIBPATH = libdir)
126
127 makesrna_tool.Append( CFLAGS = env['CFLAGS'])
128 makesrna_tool.Append( CCFLAGS = env['CCFLAGS'])
129 makesrna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
130
131 if env['BF_PROFILE']:
132     makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
133
134 if env['BF_DEBUG']:
135     makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
136     makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
137     if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
138         makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
139
140 targetpath = root_build_dir+'/makesrna'
141 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
142     targetpath = '#' + targetpath
143
144 if env['OURPLATFORM'] == 'linux2' and root_build_dir[0]==os.sep:
145     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
146 else:
147     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
148
149 rna_dict = rna.Dictionary()
150 rna.Depends (generated_files, makesrna)
151
152 # this seems bad, how to retrieve it from scons?
153 build_dir = root_build_dir + os.sep +'source' + os.sep + 'blender' + os.sep + 'makesrna' + os.sep + 'intern' + os.sep
154     
155 if env['OURPLATFORM'] != 'linuxcross':
156     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
157         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
158     else:
159         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna\" \""  + build_dir + '"' )
160 else:
161     rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
162     
163     if USE_WINE:
164         rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
165     else:
166         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
167
168
169 obj = ['intern/rna_access.c']
170 for generated_file in generated_files:
171     obj += ['intern/' + generated_file]
172
173 Return ('obj')
174