Bump version
[asdcplib-cth.git] / wscript
1 import subprocess
2 import os
3 import sys
4 import distutils.spawn
5 from waflib import Logs
6
7 APPNAME = 'libasdcp-cth'
8 VERSION = '0.1.1'
9
10 def options(opt):
11     opt.load('compiler_cxx')
12     opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to Windows')
13     opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
14     opt.add_option('--static', action='store_true', default=False, help='build statically')
15
16 def configure(conf):
17     conf.load('compiler_cxx')
18     conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
19
20     conf.env.TARGET_WINDOWS = conf.options.target_windows
21     conf.env.TARGET_OSX = sys.platform == 'darwin'
22     conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS and not conf.env.TARGET_OSX
23     conf.env.STATIC = conf.options.static
24     conf.env.VERSION = VERSION
25
26     if conf.env.TARGET_OSX:
27         conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter', '-Wno-unused-local-typedef'])
28
29     if conf.env.TARGET_LINUX:
30         conf.env.append_value('CXXFLAGS', ['-Wno-unused-result'])
31
32     conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
33
34     if conf.options.target_windows:
35         boost_lib_suffix = '-mt'
36     else:
37         boost_lib_suffix = ''
38
39     if conf.options.enable_debug:
40         conf.env.append_value('CXXFLAGS', '-g')
41     else:
42         conf.env.append_value('CXXFLAGS', '-O2')
43
44     conf.check_cxx(fragment="""
45                             #include <boost/version.hpp>\n
46                             #if BOOST_VERSION < 104500\n
47                             #error boost too old\n
48                             #endif\n
49                             int main(void) { return 0; }\n
50                             """,
51                    mandatory=True,
52                    msg='Checking for boost library >= 1.45',
53                    okmsg='yes',
54                    errmsg='too old\nPlease install boost version 1.45 or higher.')
55
56     conf.check_cxx(fragment="""
57                             #include <boost/filesystem.hpp>\n
58                             int main() { boost::filesystem::copy_file ("a", "b"); }\n
59                             """,
60                    msg='Checking for boost filesystem library',
61                    libpath='/usr/local/lib',
62                    lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
63                    uselib_store='BOOST_FILESYSTEM')
64
65     conf.recurse('src')
66
67 def build(bld):
68     if bld.env.TARGET_WINDOWS:
69         boost_lib_suffix = '-mt'
70         flags = '-DKM_WIN32'
71     else:
72         boost_lib_suffix = ''
73         flags = ''
74
75     bld(source='libasdcp-cth.pc.in',
76         version=VERSION,
77         includedir='%s/include/libasdcp-cth' % bld.env.PREFIX,
78         libs="-L${libdir} -lasdcp-cth -lkumu-cth -lboost_system%s" % boost_lib_suffix,
79         cflags=flags,
80         install_path='${LIBDIR}/pkgconfig')
81
82     bld.recurse('src')
83
84     bld.add_post_fun(post)
85
86 def post(ctx):
87     if ctx.cmd == 'install':
88         ctx.exec_command('/sbin/ldconfig')
89
90 def tags(bld):
91     os.system('etags src/*.cc src/*.h')