[xiph-commits] r12674 - trunk/theora

j at svn.xiph.org j at svn.xiph.org
Wed Mar 7 13:09:22 PST 2007


Author: j
Date: 2007-03-07 13:09:20 -0800 (Wed, 07 Mar 2007)
New Revision: 12674

Modified:
   trunk/theora/SConstruct
Log:
- update SConstruct script to check for SDL / sys/soundcard.h
  and only build examples if all required eibs are present
- add install target
- remove tabs
- build shared and static lib



Modified: trunk/theora/SConstruct
===================================================================
--- trunk/theora/SConstruct	2007-03-07 21:01:16 UTC (rev 12673)
+++ trunk/theora/SConstruct	2007-03-07 21:09:20 UTC (rev 12674)
@@ -1,7 +1,7 @@
 # SCons build specification
 # see http://www.scons.org if you do not have this tool
-
 from os.path import join
+import SCons
 
 # TODO: should use lamda and map to work on python 1.5
 def path(prefix, list): return [join(prefix, x) for x in list]
@@ -34,39 +34,81 @@
   env.Append(CCFLAGS=["-g", "-O2", "-Wall"])
 #  env.Append(CCFLAGS=["-g", "-Wall"])
 
+def CheckPKGConfig(context, version): 
+  context.Message( 'Checking for pkg-config... ' ) 
+  ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0] 
+  context.Result( ret ) 
+  return ret 
+
+def CheckPKG(context, name): 
+  context.Message( 'Checking for %s... ' % name )
+  ret = context.TryAction('pkg-config --exists %s' % name)[0]
+  context.Result( ret ) 
+  return ret
+     
+def CheckSDL(context):
+  name = "sdl-config"
+  context.Message( 'Checking for %s... ' % name )
+  ret = SCons.Util.WhereIs('sdl-config')
+  context.Result( ret ) 
+  return ret
+
 # check for appropriate inline asm support
 host_x86_32_test = """
     int main(int argc, char **argv) {
 #if !defined(__i386__)
-	#error __i386__ not defined
+  #error __i386__ not defined
 #endif
-	return 0;
+  return 0;
     }
     """
 def CheckHost_x86_32(context):
-        context.Message('Checking for an x86_32 host...')
-        result = context.TryCompile(host_x86_32_test, '.c')
-        context.Result(result)
-        return result
+  context.Message('Checking for an x86_32 host...')
+  result = context.TryCompile(host_x86_32_test, '.c')
+  context.Result(result)
+  return result
 
 host_x86_64_test = """
     int main(int argc, char **argv) {
 #if !defined(__x86_64__)
-	#error __x86_64__ not defined
+  #error __x86_64__ not defined
 #endif
-	return 0;
+  return 0;
     }
     """
 def CheckHost_x86_64(context):
-        context.Message('Checking for an x86_64 host...')
-        result = context.TryCompile(host_x86_64_test, '.c')
-        context.Result(result)
-        return result
+  context.Message('Checking for an x86_64 host...')
+  result = context.TryCompile(host_x86_64_test, '.c')
+  context.Result(result)
+  return result
 
 conf = Configure(env, custom_tests = {
-	'CheckHost_x86_32' : CheckHost_x86_32,
-	'CheckHost_x86_64' : CheckHost_x86_64
-	})
+  'CheckPKGConfig' : CheckPKGConfig,
+  'CheckPKG' : CheckPKG,
+  'CheckSDL' : CheckSDL,
+  'CheckHost_x86_32' : CheckHost_x86_32,
+  'CheckHost_x86_64' : CheckHost_x86_64,
+  })
+  
+if not conf.CheckPKGConfig('0.15.0'): 
+   print 'pkg-config >= 0.15.0 not found.' 
+   Exit(1)
+
+if not conf.CheckPKG('ogg'): 
+  print 'libogg not found.' 
+  Exit(1) 
+
+if conf.CheckPKG('vorbis vorbisenc'):
+  have_vorbis=True
+else:
+  have_vorbis=False
+  
+build_player_example=True
+if not conf.CheckHeader('sys/soundcard.h'):
+  build_player_example=False
+if build_player_example and not conf.CheckSDL():
+  build_player_example=False
+
 if conf.CheckHost_x86_32():
   libtheora_Sources += Split("""
     x86_32/dsp_mmx.c
@@ -84,24 +126,31 @@
 env = conf.Finish()
 
 env.Append(CPPPATH=['lib', 'include'])
+env.ParseConfig('pkg-config --cflags --libs ogg')
 
-env.Library('theora', path('lib', libtheora_Sources))
+libtheora_a = env.Library('lib/theora', path('lib', libtheora_Sources))
+libtheora_so = env.SharedLibrary('lib/theora', path('lib', libtheora_Sources))
 
+#installing
+prefix='/usr'
+lib_dir = prefix + '/lib'
+env.Alias('install', prefix)
+env.Install(lib_dir, [libtheora_a, libtheora_so])
 
 # example programs
+dump_video = env.Copy()
+dump_video.Append(LIBS=['theora'], LIBPATH=['./lib'])
+dump_video_Sources = Split("""dump_video.c""")
+dump_video.Program('examples/dump_video', path('examples', dump_video_Sources))
 
-examples = env.Copy()
+if have_vorbis:
+  encex = dump_video.Copy()
+  encex.ParseConfig('pkg-config --cflags --libs vorbisenc vorbis')
+  encex_Sources = Split("""encoder_example.c""")
+  encex.Program('examples/encoder_example', path('examples', encex_Sources))
 
-examples.Append(LIBPATH=['.'])
-examples.Append(LIBS=['theora','vorbisenc','vorbis','ogg']);
-
-encex_Sources = Split("""encoder_example.c""")
-examples.Program('examples/encoder_example', 
-	path('examples', encex_Sources))
-
-plyex_Sources = Split("""player_example.c""")
-examples.Append(CPPFLAGS=[Split('-I/usr/include/SDL -D_REENTRANT')])
-examples.Append(LINKFLAGS=[Split('-L/usr/lib -lSDL -lpthread')])
-examples.Program('examples/player_example',
-	path('examples', plyex_Sources))
-
+  if build_player_example:
+    plyex = encex.Copy()
+    plyex_Sources = Split("""player_example.c""")
+    plyex.ParseConfig('sdl-config --cflags --libs')
+    plyex.Program('examples/player_example', path('examples', plyex_Sources))



More information about the commits mailing list