Set up MXF header value DisplayHeight. Otherwise mediainfo reports
[asdcplib.git] / wscript
1 from __future__ import print_function
2
3 import subprocess
4 import shlex
5 import os
6 import sys
7 import distutils.spawn
8 from waflib import Logs
9
10 APPNAME = 'libasdcp-dcpomatic'
11
12 if os.path.exists('.git'):
13     this_version = subprocess.Popen(shlex.split('git tag -l --points-at HEAD'), stdout=subprocess.PIPE).communicate()[0].decode('utf-8')
14     last_version = subprocess.Popen(shlex.split('git describe --tags --abbrev=0'), stdout=subprocess.PIPE).communicate()[0].decode('utf-8')
15     if this_version == '':
16         VERSION = '%sdevel' % last_version[1:].strip()
17     else:
18         VERSION = this_version[1:].strip()
19 else:
20     VERSION = open('VERSION').read().strip()
21
22 def options(opt):
23     opt.load('compiler_cxx')
24     opt.add_option('--target-windows-64', action='store_true', default=False, help='set up to do a cross-compile to Windows 64-bit')
25     opt.add_option('--target-windows-32', action='store_true', default=False, help='set up to do a cross-compile to Windows 32-bit')
26     opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
27     opt.add_option('--static', action='store_true', default=False, help='build statically')
28
29 def configure(conf):
30     conf.load('compiler_cxx')
31     conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
32
33     conf.env.TARGET_WINDOWS_64 = conf.options.target_windows_64
34     conf.env.TARGET_WINDOWS_32 = conf.options.target_windows_32
35     conf.env.TARGET_OSX = sys.platform == 'darwin'
36     conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS_64 and not conf.env.TARGET_WINDOWS_32 and not conf.env.TARGET_OSX
37     conf.env.STATIC = conf.options.static
38     conf.env.VERSION = VERSION
39
40     if conf.env.TARGET_OSX:
41         conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
42
43     if conf.env.TARGET_LINUX:
44         gcc = conf.env['CC_VERSION']
45         conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-deprecated-copy', '-Wno-class-memaccess'])
46
47     conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
48
49     if conf.options.enable_debug:
50         conf.env.append_value('CXXFLAGS', '-g')
51     else:
52         conf.env.append_value('CXXFLAGS', '-O2')
53
54     conf.check(header_name='valgrind/memcheck.h', mandatory=False)
55
56     conf.recurse('src')
57
58 def build(bld):
59     if bld.env.TARGET_WINDOWS_64:
60         flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN -DKM_WIN32_UTF8'
61     elif bld.env.TARGET_WINDOWS_32:
62         flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN -DKM_WIN32_UTF8'
63     else:
64         flags = ''
65
66     bld(source='libasdcp-dcpomatic.pc.in',
67         version=VERSION,
68         includedir='%s/include/libasdcp-dcpomatic' % bld.env.PREFIX,
69         libs="-L${libdir} -lasdcp-dcpomatic -lkumu-dcpomatic",
70         cflags=flags,
71         install_path='${LIBDIR}/pkgconfig')
72
73     bld.recurse('src')
74
75     bld.add_post_fun(post)
76
77 def post(ctx):
78     if ctx.cmd == 'install':
79         ctx.exec_command('/sbin/ldconfig')
80
81 def tags(bld):
82     os.system('etags src/*.cc src/*.h')
83
84 def dist(bld):
85     f = open('VERSION', 'w')
86     print(VERSION, file=f)
87     f.close()