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
23 conf.env.ENABLE_DEBUG = conf.options.enable_debug
25 if conf.options.target_windows:
26 conf.env.append_value('CXXFLAGS', '-DLIBDCP_WINDOWS')
28 conf.env.append_value('CXXFLAGS', '-DLIBDCP_POSIX')
30 conf.check_cfg(package = 'openssl', args = '--cflags --libs', uselib_store = 'OPENSSL', mandatory = True)
31 conf.check_cfg(package = 'libxml++-2.6', args = '--cflags --libs', uselib_store = 'LIBXML++', mandatory = True)
32 conf.check_cfg(package = 'xmlsec1', args = '--cflags --libs', uselib_store = 'XMLSEC1', mandatory = True)
33 # Remove erroneous escaping of quotes from xmlsec1 defines
34 conf.env.DEFINES_XMLSEC1 = [f.replace('\\', '') for f in conf.env.DEFINES_XMLSEC1]
36 openjpeg_fragment = """
38 #include <openjpeg.h>\n
40 void* p = (void *) opj_image_create;\n
44 if conf.options.static_openjpeg:
45 conf.check_cc(fragment = openjpeg_fragment, msg = 'Checking for library openjpeg', stlib = 'openjpeg', uselib_store = 'OPENJPEG')
47 conf.check_cc(fragment = openjpeg_fragment, msg = 'Checking for library openjpeg', lib = 'openjpeg', uselib_store = 'OPENJPEG')
49 if conf.options.target_windows:
50 boost_lib_suffix = '-mt'
54 if conf.options.enable_debug:
55 conf.env.append_value('CXXFLAGS', '-g')
57 # Somewhat experimental use of -O2 rather than -O3 to see if
58 # Windows builds are any more reliable
59 conf.env.append_value('CXXFLAGS', '-O2')
61 conf.check_cxx(fragment = """
62 #include <boost/filesystem.hpp>\n
63 int main() { boost::filesystem::copy_file ("a", "b"); }\n
65 msg = 'Checking for boost filesystem library',
66 libpath = '/usr/local/lib',
67 lib = ['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
68 uselib_store = 'BOOST_FILESYSTEM')
70 conf.check_cxx(fragment = """
71 #include <boost/signals2.hpp>\n
72 int main() { boost::signals2::signal<void (int)> x; }\n
74 msg = 'Checking for boost signals2 library',
75 uselib_store = 'BOOST_SIGNALS2')
77 conf.check_cxx(fragment = """
78 #include <boost/date_time.hpp>\n
79 int main() { boost::gregorian::day_clock::local_day(); }\n
81 msg = 'Checking for boost datetime library',
82 libpath = '/usr/local/lib',
83 lib = ['boost_date_time%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
84 uselib_store = 'BOOST_DATETIME')
89 conf.recurse('asdcplib')
92 create_version_cc(bld, VERSION)
94 if bld.env.TARGET_WINDOWS:
95 boost_lib_suffix = '-mt'
99 bld(source = 'libdcp.pc.in',
101 includedir = '%s/include' % bld.env.PREFIX,
102 libs = "-L${libdir} -ldcp -lasdcp-libdcp -lkumu-libdcp -lboost_system%s" % boost_lib_suffix,
103 install_path = '${LIBDIR}/pkgconfig')
108 bld.recurse('asdcplib')
109 bld.recurse('examples')
111 bld.add_post_fun(post)
114 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~ __pycache__'
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 * libdcp::git_commit = \"%s\";\n' % commit
128 text += 'char const * libdcp::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')