9 opt.load('compiler_cxx')
10 opt.add_option('--target-windows', action='store_true', default = False, help = 'set up to do a cross-compile to Windows')
11 opt.add_option('--enable-debug', action='store_true', default = False, help = 'build with debugging information and without optimisation')
14 conf.load('compiler_cxx')
15 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-Wno-unused-result', '-O2', '-D_FILE_OFFSET_BITS=64'])
16 conf.env.append_value('CXXFLAGS', ['-DLIBDCP_VERSION="%s"' % VERSION])
18 conf.env.TARGET_WINDOWS = conf.options.target_windows
20 if conf.options.target_windows:
21 conf.env.append_value('CXXFLAGS', '-DLIBDCP_WINDOWS')
22 conf.env.append_value('LIB', 'msvcr100')
24 conf.env.append_value('CXXFLAGS', '-DLIBDCP_POSIX')
26 conf.check_cfg(package = 'openssl', args = '--cflags --libs', uselib_store = 'OPENSSL', mandatory = True)
27 conf.check_cfg(package = 'libxml++-2.6', args = '--cflags --libs', uselib_store = 'LIBXML++', mandatory = True)
29 conf.check_cc(fragment = """
31 #include <openjpeg.h>\n
33 void* p = (void *) opj_image_create;\n
36 """, msg = 'Checking for library openjpeg', lib = 'openjpeg', uselib_store = 'OPENJPEG')
38 if conf.options.target_windows:
39 boost_lib_suffix = '-mt'
43 if conf.options.enable_debug:
44 conf.env.append_value('CXXFLAGS', '-g')
46 conf.env.append_value('CXXFLAGS', '-O3')
48 conf.check_cxx(fragment = """
49 #include <boost/filesystem.hpp>\n
50 int main() { boost::filesystem::copy_file ("a", "b"); }\n
52 msg = 'Checking for boost filesystem library',
53 libpath = '/usr/local/lib',
54 lib = ['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
55 uselib_store = 'BOOST_FILESYSTEM')
57 conf.check_cxx(fragment = """
58 #include <boost/signals2.hpp>\n
59 int main() { boost::signals2::signal<void (int)> x; }\n
61 msg = 'Checking for boost signals2 library',
62 uselib_store = 'BOOST_SIGNALS2')
67 conf.recurse('asdcplib')
70 create_version_cc(VERSION)
72 if bld.env.TARGET_WINDOWS:
73 boost_lib_suffix = '-mt'
77 bld(source = 'libdcp.pc.in',
79 includedir = '%s/include' % bld.env.PREFIX,
80 libs = "-L${libdir} -ldcp -lkumu-libdcp -lasdcp-libdcp -lboost_system%s" % boost_lib_suffix,
81 install_path = '${LIBDIR}/pkgconfig')
86 bld.recurse('asdcplib')
87 bld.recurse('examples')
89 bld.add_post_fun(post)
92 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~'
94 def create_version_cc(version):
95 if os.path.exists('.git'):
96 cmd = "LANG= git log --abbrev HEAD^..HEAD ."
97 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
98 o = output[0].decode('utf-8')
99 commit = o.replace ("commit ", "")[0:10]
104 text = '#include "version.h"\n'
105 text += 'char const * libdcp::git_commit = \"%s\";\n' % commit
106 text += 'char const * libdcp::version = \"%s\";\n' % version
107 print('Writing version information to src/version.cc')
108 o = open('src/version.cc', 'w')
112 print('Could not open src/version.cc for writing\n')
116 if ctx.cmd == 'install':
117 ctx.exec_command('/sbin/ldconfig')