Fix two errors in the iDCT specification.
[xiph/unicode.git] / theora-old / SConstruct
blob59dcd166a509375a7dc22de5d5ec12924bd76762
1 # SCons build specification
2 # see http://www.scons.org if you do not have this tool
3 from os.path import join
4 import SCons
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
11 blockmap.c
12 comment.c
13 cpu.c
14 dct.c
15 dct_decode.c
16 decode.c
17 dsp.c
18 frarray.c
19 frinit.c
20 huffman.c
21 idct.c
22 mcomp.c
23 misc_common.c
24 pb.c
25 pp.c
26 quant.c
27 reconstruct.c
28 scan.c
29 toplevel.c
30 """)
32 env = Environment()
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]
40 context.Result( ret )
41 return ret
43 def CheckPKG(context, name):
44 context.Message( 'Checking for %s... ' % name )
45 ret = context.TryAction('pkg-config --exists %s' % name)[0]
46 context.Result( ret )
47 return ret
49 def CheckSDL(context):
50 name = "sdl-config"
51 context.Message( 'Checking for %s... ' % name )
52 ret = SCons.Util.WhereIs('sdl-config')
53 context.Result( ret )
54 return ret
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
61 #endif
62 return 0;
64 """
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)
69 return result
71 host_x86_64_test = """
72 int main(int argc, char **argv) {
73 #if !defined(__x86_64__)
74 #error __x86_64__ not defined
75 #endif
76 return 0;
78 """
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)
83 return 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.'
95 Exit(1)
97 if not conf.CheckPKG('ogg'):
98 print 'libogg not found.'
99 Exit(1)
101 if conf.CheckPKG('vorbis vorbisenc'):
102 have_vorbis=True
103 else:
104 have_vorbis=False
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("""
114 x86_32/dsp_mmx.c
115 x86_32/dsp_mmxext.c
116 x86_32/recon_mmx.c
117 x86_32/fdct_mmx.c
118 """)
119 elif conf.CheckHost_x86_64():
120 libtheora_Sources += Split("""
121 x86_64/dsp_mmx.c
122 x86_64/dsp_mmxext.c
123 x86_64/recon_mmx.c
124 x86_64/fdct_mmx.c
125 """)
126 env = conf.Finish()
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))
134 #installing
135 prefix='/usr'
136 lib_dir = prefix + '/lib'
137 env.Alias('install', prefix)
138 env.Install(lib_dir, [libtheora_a, libtheora_so])
140 # example programs
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))
146 if have_vorbis:
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:
153 plyex = encex.Copy()
154 plyex_Sources = Split("""player_example.c""")
155 plyex.ParseConfig('sdl-config --cflags --libs')
156 plyex.Program('examples/player_example', path('examples', plyex_Sources))