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')
12 opt.add_option('--static-openjpeg', action='store_true', default = False, help = 'link statically to openjpeg')
13 opt.add_option('--static-libdcp', action='store_true', default = False, help = 'build libdcp and in-tree dependencies statically')
16 conf.load('compiler_cxx')
17 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-Wno-unused-result', '-O2', '-D_FILE_OFFSET_BITS=64'])
18 conf.env.append_value('CXXFLAGS', ['-DLIBDCP_VERSION="%s"' % VERSION])
20 conf.env.TARGET_WINDOWS = conf.options.target_windows
21 conf.env.STATIC_OPENJPEG = conf.options.static_openjpeg
22 conf.env.STATIC_LIBDCP = conf.options.static_libdcp
24 if conf.options.target_windows:
25 conf.env.append_value('CXXFLAGS', '-DLIBDCP_WINDOWS')
27 conf.env.append_value('CXXFLAGS', '-DLIBDCP_POSIX')
29 conf.check_cfg(package = 'openssl', args = '--cflags --libs', uselib_store = 'OPENSSL', mandatory = True)
30 conf.check_cfg(package = 'libxml++-2.6', args = '--cflags --libs', uselib_store = 'LIBXML++', mandatory = True)
32 openjpeg_fragment = """
34 #include <openjpeg.h>\n
36 void* p = (void *) opj_image_create;\n
40 if conf.options.static_openjpeg:
41 conf.check_cc(fragment = openjpeg_fragment, msg = 'Checking for library openjpeg', stlib = 'openjpeg', uselib_store = 'OPENJPEG')
43 conf.check_cc(fragment = openjpeg_fragment, msg = 'Checking for library openjpeg', lib = 'openjpeg', uselib_store = 'OPENJPEG')
45 if conf.options.target_windows:
46 boost_lib_suffix = '-mt'
50 if conf.options.enable_debug:
51 conf.env.append_value('CXXFLAGS', '-g')
53 conf.env.append_value('CXXFLAGS', '-O3')
55 conf.check_cxx(fragment = """
56 #include <boost/filesystem.hpp>\n
57 int main() { boost::filesystem::copy_file ("a", "b"); }\n
59 msg = 'Checking for boost filesystem library',
60 libpath = '/usr/local/lib',
61 lib = ['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
62 uselib_store = 'BOOST_FILESYSTEM')
64 conf.check_cxx(fragment = """
65 #include <boost/signals2.hpp>\n
66 int main() { boost::signals2::signal<void (int)> x; }\n
68 msg = 'Checking for boost signals2 library',
69 uselib_store = 'BOOST_SIGNALS2')
74 conf.recurse('asdcplib')
77 create_version_cc(VERSION)
79 if bld.env.TARGET_WINDOWS:
80 boost_lib_suffix = '-mt'
84 bld(source = 'libdcp.pc.in',
86 includedir = '%s/include' % bld.env.PREFIX,
87 libs = "-L${libdir} -ldcp -lasdcp-libdcp -lkumu-libdcp -lboost_system%s" % boost_lib_suffix,
88 install_path = '${LIBDIR}/pkgconfig')
93 bld.recurse('asdcplib')
94 bld.recurse('examples')
96 bld.add_post_fun(post)
99 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~'
101 def create_version_cc(version):
102 if os.path.exists('.git'):
103 cmd = "LANG= git log --abbrev HEAD^..HEAD ."
104 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
105 o = output[0].decode('utf-8')
106 commit = o.replace ("commit ", "")[0:10]
111 text = '#include "version.h"\n'
112 text += 'char const * libdcp::git_commit = \"%s\";\n' % commit
113 text += 'char const * libdcp::version = \"%s\";\n' % version
114 print('Writing version information to src/version.cc')
115 o = open('src/version.cc', 'w')
119 print('Could not open src/version.cc for writing\n')
123 if ctx.cmd == 'install':
124 ctx.exec_command('/sbin/ldconfig')