1 # SCons build specification
9 pkg_name
="ffmpeg2theora"
13 BoolOption('static', 'Set to 1 for static linking', 0),
14 BoolOption('debug', 'Set to 1 to enable debugging', 0),
15 ('prefix', 'install architecture-independent files in', '/usr/local'),
16 ('bindir', 'user executables', 'PREFIX/bin'),
17 ('mandir', 'man documentation', 'PREFIX/man'),
18 ('destdir', 'extra install time prefix', ''),
19 ('APPEND_CCFLAGS', 'Additional C/C++ compiler flags'),
20 ('APPEND_LINKFLAGS', 'Additional linker flags')
22 env
= Environment(options
= opts
)
23 Help(opts
.GenerateHelpText(env
))
25 pkg_flags
="--cflags --libs"
27 pkg_flags
+=" --static"
28 env
.Append(LINKFLAGS
=["-static"])
30 prefix
= env
['prefix']
32 if prefix
.startswith('/'): prefix
= prefix
[1:]
33 prefix
= os
.path
.join(env
['destdir'], prefix
)
34 man_dir
= env
['mandir'].replace('PREFIX', prefix
)
35 bin_dir
= env
['bindir'].replace('PREFIX', prefix
)
37 env
.Append(CPPPATH
=['.'])
39 '-DPACKAGE_VERSION=\\"%s\\"' % pkg_version
,
40 '-DPACKAGE_STRING=\\"%s-%s\\"' % (pkg_name
, pkg_version
),
41 '-DPACKAGE=\\"%s\\"' % pkg_name
,
43 env
.Append(CCFLAGS
= Split('$APPEND_CCFLAGS'))
44 env
.Append(LINKFLAGS
= Split('$APPEND_LINKFLAGS'))
46 if env
['debug'] and env
['CC'] == 'gcc':
47 env
.Append(CCFLAGS
=["-g", "-O2", "-Wall"])
49 def CheckPKGConfig(context
, version
):
50 context
.Message( 'Checking for pkg-config... ' )
51 ret
= context
.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version
)[0]
55 def CheckPKG(context
, name
):
56 context
.Message( 'Checking for %s... ' % name
)
57 if os
.environ
.get('PKG_CONFIG_PATH', ''):
58 action
= 'PKG_CONFIG_PATH=%s pkg-config --exists "%s"' % (os
.environ
['PKG_CONFIG_PATH'], name
)
60 action
= 'pkg-config --exists "%s"' % name
61 ret
= context
.TryAction(action
)[0]
65 conf
= Configure(env
, custom_tests
= {
66 'CheckPKGConfig' : CheckPKGConfig
,
67 'CheckPKG' : CheckPKG
,
70 if not conf
.CheckPKGConfig('0.15.0'):
71 print 'pkg-config >= 0.15.0 not found.'
74 XIPH_LIBS
="ogg >= 1.1 vorbis vorbisenc theora >= 1.0beta1"
76 if not conf
.CheckPKG(XIPH_LIBS
):
77 print 'some xiph libs are missing, ffmpeg2theora depends on %s' % XIPH_LIBS
79 env
.ParseConfig('pkg-config %s "%s"' % (pkg_flags
, XIPH_LIBS
))
81 FFMPEG_LIBS
="libavformat libavcodec libavdevice libswscale libpostproc"
82 if os
.path
.exists("./ffmpeg"):
83 os
.environ
['PKG_CONFIG_PATH'] = "./ffmpeg/libavutil:./ffmpeg/libavformat:./ffmpeg/libavcodec:./ffmpeg/libavdevice:./ffmpeg/libswscale:./ffmpeg/libpostproc:" + os
.environ
.get('PKG_CONFIG_PATH', '')
84 if not conf
.CheckPKG(FFMPEG_LIBS
):
87 You can install it via
88 sudo apt-get install %s
89 or update PKG_CONFIG_PATH to point to ffmpeg's source folder
90 or run ./get_ffmpeg_svn.sh (for more information see INSTALL)
91 """ %(FFMPEG_LIBS
, " ".join(["%s-dev"%l
for l
in FFMPEG_LIBS
.split()]))
93 env
.ParseConfig('pkg-config %s "%s"' % (pkg_flags
, FFMPEG_LIBS
))
96 if os
.path
.exists("./libkate/misc/pkgconfig"):
97 os
.environ
['PKG_CONFIG_PATH'] = "./libkate/misc/pkgconfig:" + os
.environ
.get('PKG_CONFIG_PATH', '')
98 if os
.path
.exists("./libkate/pkg/pkgconfig"):
99 os
.environ
['PKG_CONFIG_PATH'] = "./libkate/pkg/pkgconfig:" + os
.environ
.get('PKG_CONFIG_PATH', '')
100 if conf
.CheckPKG(KATE_LIBS
):
101 env
.ParseConfig('pkg-config %s "%s"' % (pkg_flags
, KATE_LIBS
))
102 env
.Append(CCFLAGS
=['-DHAVE_KATE', '-DHAVE_OGGKATE'])
105 Could not find libkate. Subtitles support will be disabled.
106 You can also run ./get_libkate.sh (for more information see INSTALL)
107 or update PKG_CONFIG_PATH to point to libkate's source folder
112 ffmpeg2theora
= env
.Copy()
113 ffmpeg2theora_sources
= glob('src/*.c')
114 ffmpeg2theora
.Program('ffmpeg2theora', ffmpeg2theora_sources
)
116 ffmpeg2theora
.Install(bin_dir
, 'ffmpeg2theora')
117 ffmpeg2theora
.Install(man_dir
+ "/man1", 'ffmpeg2theora.1')
118 ffmpeg2theora
.Alias('install', prefix
)