9 opt.load('compiler_cxx')
10 opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
11 opt.add_option('--static', action='store_true', default=False, help='build libsub statically and link statically to cxml and dcp')
12 opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to make a Windows package')
13 opt.add_option('--disable-tests', action='store_true', default=False, help='disable building of tests')
16 conf.load('compiler_cxx')
17 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
18 conf.env.append_value('CXXFLAGS', ['-DLIBSUB_VERSION="%s"' % VERSION])
20 conf.env.ENABLE_DEBUG = conf.options.enable_debug
21 conf.env.STATIC = conf.options.static
22 conf.env.TARGET_WINDOWS = conf.options.target_windows
23 conf.env.DISABLE_TESTS = conf.options.disable_tests
24 conf.env.API_VERSION = API_VERSION
26 if conf.options.enable_debug:
27 conf.env.append_value('CXXFLAGS', '-g')
29 conf.env.append_value('CXXFLAGS', '-O3')
31 conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
33 if conf.options.static:
34 conf.env.HAVE_CXML = 1
35 conf.env.LIB_CXML = ['glibmm-2.4', 'glib-2.0', 'pcre', 'sigc-2.0', 'rt', 'xml++-2.6', 'xml2', 'pthread', 'lzma', 'dl', 'z']
36 conf.env.STLIB_CXML = ['cxml']
37 conf.check_cfg(package='libcxml', atleast_version='0.14.0', args='--cflags', uselib_store='CXML', mandatory=True)
38 conf.env.HAVE_ASDCPLIB_CTH = 1
39 conf.env.STLIB_ASDCPLIB_CTH = ['asdcp-cth', 'kumu-cth']
40 conf.env.LIB_ASDCPLIB_CTH = ['ssl', 'crypto']
41 conf.check_cfg(package='libasdcp-cth', atleast_version='0.0.1', args='--cflags', uselib_store='ASDCPLIB_CTH', mandatory=True)
43 conf.check_cfg(package='libcxml', atleast_version='0.14.0', args='--cflags --libs', uselib_store='CXML', mandatory=True)
44 conf.check_cfg(package='libasdcp-cth', atleast_version='0.0.1', args='--cflags --libs', uselib_store='ASDCPLIB_CTH', mandatory=True)
47 if conf.env.TARGET_WINDOWS:
48 boost_lib_suffix = '-mt'
50 conf.check_cxx(fragment="""
51 #include <boost/version.hpp>\n
52 #if BOOST_VERSION < 104500\n
53 #error boost too old\n
55 int main(void) { return 0; }\n
58 msg='Checking for boost library >= 1.45',
60 errmsg='too old\nPlease install boost version 1.45 or higher.')
62 conf.check_cxx(fragment="""
63 #include <boost/filesystem.hpp>\n
64 int main() { boost::filesystem::copy_file ("a", "b"); }\n
66 msg='Checking for boost filesystem library',
67 libpath='/usr/local/lib',
68 lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
69 uselib_store='BOOST_FILESYSTEM')
71 conf.check_cxx(fragment="""
72 #include <boost/locale.hpp>\n
73 int main() { boost::locale::conv::to_utf<char> ("a", "cp850"); }\n
75 msg='Checking for boost locale library',
76 libpath='/usr/local/lib',
77 lib=['boost_locale%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
78 uselib_store='BOOST_LOCALE')
80 conf.check_cxx(fragment="""
81 #include <boost/regex.hpp>\n
82 int main() { boost::regex re ("foo"); }\n
84 msg='Checking for boost regex library',
85 libpath='/usr/local/lib',
86 lib=['boost_regex%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
87 uselib_store='BOOST_REGEX')
89 if not conf.env.DISABLE_TESTS:
93 create_version_cc(bld, VERSION)
95 if bld.env.TARGET_WINDOWS:
96 boost_lib_suffix = '-mt'
100 bld(source='libsub%s.pc.in' % bld.env.API_VERSION,
102 includedir='%s/include/libsub%s' % (bld.env.PREFIX, bld.env.API_VERSION),
103 libs="-L${libdir} -lsub%s -lboost_system%s" % (bld.env.API_VERSION, boost_lib_suffix),
104 install_path='${LIBDIR}/pkgconfig')
107 if not bld.env.DISABLE_TESTS:
111 bld.add_post_fun(post)
114 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~ __pycache__ GPATH GRTAGS GSYMS GTAGS'
116 def create_version_cc(bld, version):
117 if os.path.exists('.git'):
118 cmd = "LANG= git log --abbrev HEAD^..HEAD ."
119 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
120 o = output[0].decode('utf-8')
121 commit = o.replace ("commit ", "")[0:10]
126 text = '#include "version.h"\n'
127 text += 'char const * sub::git_commit = \"%s\";\n' % commit
128 text += 'char const * sub::version = \"%s\";\n' % version
129 if bld.env.ENABLE_DEBUG:
130 debug_string = 'true'
132 debug_string = 'false'
133 text += 'bool const built_with_debug = %s;\n' % debug_string
134 print('Writing version information to src/version.cc')
135 o = open('src/version.cc', 'w')
139 print('Could not open src/version.cc for writing\n')
143 if ctx.cmd == 'install':
144 ctx.exec_command('/sbin/ldconfig')