Update libav submodule
[mplayer-build.git] / script / libav-config
blobe2f1292a26d1aeed3c49a53e5bd769e292b9be01
1 #!/usr/bin/env python3
3 import sys
4 import os
5 from os import path
6 from helpers import parse_configfile, run_command
7 from subprocess import check_call
9 def main():
10     try:
11         os.mkdir('libav_build')
12     except:
13         pass
14     mydir = os.getcwd()
15     extra_args = parse_configfile('common_options')
16     for arg in parse_configfile('libav_options'):
17         if arg == b'librtmp_magic':
18             try:
19                 check_call('pkg-config --exists librtmp'.split())
20             except:
21                 sys.exit('You have specified "librtmp_magic" in libav_options,'
22                          'but running "pkg-config --exists librtmp" failed - '
23                          "can't enable librtmp! Aborting.")
24             extra_args.append('--enable-librtmp')
25             cflags = run_command('pkg-config --cflags librtmp').strip()
26             libs = run_command('pkg-config --libs librtmp').strip()
27             extra_args.append(b'--extra-cflags=' + cflags)
28             extra_args.append(b'--extra-libs=' + libs)
29         else:
30             extra_args.append(arg)
32     args = ['--prefix=%s/build_libs' % mydir,
33             '--enable-gpl',
34             '--cpu=host',
35             '--disable-debug',
36             '--enable-pthreads',
37             '--disable-shared', '--enable-static',
38             '--disable-avdevice', '--disable-avfilter', '--disable-vaapi']
39     executables = 'avconv ffmpeg avplay ffplay avserver ffserver ' \
40                   'avprobe ffprobe'.split()
41     for name in executables:
42         if path.exists(path.join('libav', name + '.c')):
43             args.append('--disable-' + name)
45     executable = path.join(mydir, 'libav', 'configure')
47     os.chdir('libav_build')
48     check_call([executable] + args + extra_args)
50 main()