1 from __future__ import print_function
8 from waflib import Logs
10 APPNAME = 'libasdcp-dcpomatic'
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()
18 VERSION = this_version[1:].strip()
20 VERSION = open('VERSION').read().strip()
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')
30 conf.load('compiler_cxx')
31 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
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
40 if conf.env.TARGET_OSX:
41 conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
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'])
47 conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
49 if conf.options.enable_debug:
50 conf.env.append_value('CXXFLAGS', '-g')
52 conf.env.append_value('CXXFLAGS', '-O2')
54 conf.check(header_name='valgrind/memcheck.h', mandatory=False)
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'
66 bld(source='libasdcp-dcpomatic.pc.in',
68 includedir='%s/include/libasdcp-dcpomatic' % bld.env.PREFIX,
69 libs="-L${libdir} -lasdcp-dcpomatic -lkumu-dcpomatic",
71 install_path='${LIBDIR}/pkgconfig')
75 bld.add_post_fun(post)
78 if ctx.cmd == 'install':
79 ctx.exec_command('/sbin/ldconfig')
82 os.system('etags src/*.cc src/*.h')
85 f = open('VERSION', 'w')
86 print(VERSION, file=f)