1 # SCons build specification
2 # see http://www.scons.org if you do not have this tool
3 from os
.path
import join
6 # TODO: should use lamda and map to work on python 1.5
7 def path(prefix
, list): return [join(prefix
, x
) for x
in list]
9 libtheora_Sources
= Split("""
10 dct_encode.c encode.c encoder_toplevel.c
33 if env
['CC'] == 'gcc':
34 env
.Append(CCFLAGS
=["-g", "-O2", "-Wall"])
35 # env.Append(CCFLAGS=["-g", "-Wall"])
37 def CheckPKGConfig(context
, version
):
38 context
.Message( 'Checking for pkg-config... ' )
39 ret
= context
.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version
)[0]
43 def CheckPKG(context
, name
):
44 context
.Message( 'Checking for %s... ' % name
)
45 ret
= context
.TryAction('pkg-config --exists %s' % name
)[0]
49 def CheckSDL(context
):
51 context
.Message( 'Checking for %s... ' % name
)
52 ret
= SCons
.Util
.WhereIs('sdl-config')
56 # check for appropriate inline asm support
57 host_x86_32_test
= """
58 int main(int argc, char **argv) {
59 #if !defined(__i386__)
60 #error __i386__ not defined
65 def CheckHost_x86_32(context
):
66 context
.Message('Checking for an x86_32 host...')
67 result
= context
.TryCompile(host_x86_32_test
, '.c')
68 context
.Result(result
)
71 host_x86_64_test
= """
72 int main(int argc, char **argv) {
73 #if !defined(__x86_64__)
74 #error __x86_64__ not defined
79 def CheckHost_x86_64(context
):
80 context
.Message('Checking for an x86_64 host...')
81 result
= context
.TryCompile(host_x86_64_test
, '.c')
82 context
.Result(result
)
85 conf
= Configure(env
, custom_tests
= {
86 'CheckPKGConfig' : CheckPKGConfig
,
87 'CheckPKG' : CheckPKG
,
88 'CheckSDL' : CheckSDL
,
89 'CheckHost_x86_32' : CheckHost_x86_32
,
90 'CheckHost_x86_64' : CheckHost_x86_64
,
93 if not conf
.CheckPKGConfig('0.15.0'):
94 print 'pkg-config >= 0.15.0 not found.'
97 if not conf
.CheckPKG('ogg'):
98 print 'libogg not found.'
101 if conf
.CheckPKG('vorbis vorbisenc'):
106 build_player_example
=True
107 if not conf
.CheckHeader('sys/soundcard.h'):
108 build_player_example
=False
109 if build_player_example
and not conf
.CheckSDL():
110 build_player_example
=False
112 if conf
.CheckHost_x86_32():
113 libtheora_Sources
+= Split("""
119 elif conf
.CheckHost_x86_64():
120 libtheora_Sources
+= Split("""
128 env
.Append(CPPPATH
=['lib', 'include'])
129 env
.ParseConfig('pkg-config --cflags --libs ogg')
131 libtheora_a
= env
.Library('lib/theora', path('lib', libtheora_Sources
))
132 libtheora_so
= env
.SharedLibrary('lib/theora', path('lib', libtheora_Sources
))
136 lib_dir
= prefix
+ '/lib'
137 env
.Alias('install', prefix
)
138 env
.Install(lib_dir
, [libtheora_a
, libtheora_so
])
141 dump_video
= env
.Copy()
142 dump_video
.Append(LIBS
=['theora'], LIBPATH
=['./lib'])
143 dump_video_Sources
= Split("""dump_video.c""")
144 dump_video
.Program('examples/dump_video', path('examples', dump_video_Sources
))
147 encex
= dump_video
.Copy()
148 encex
.ParseConfig('pkg-config --cflags --libs vorbisenc vorbis')
149 encex_Sources
= Split("""encoder_example.c""")
150 encex
.Program('examples/encoder_example', path('examples', encex_Sources
))
152 if build_player_example
:
154 plyex_Sources
= Split("""player_example.c""")
155 plyex
.ParseConfig('sdl-config --cflags --libs')
156 plyex
.Program('examples/player_example', path('examples', plyex_Sources
))