8 opt.load('compiler_cxx')
9 opt.add_option('--target-windows', action='store_true', default = False, help = 'set up to do a cross-compile to Windows')
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 libdcp and in-tree dependencies statically, and link statically to openjpeg and cxml')
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
19 conf.env.STATIC = conf.options.static
20 conf.env.ENABLE_DEBUG = conf.options.enable_debug
22 if conf.options.target_windows:
23 conf.env.append_value('CXXFLAGS', '-DLIBDCP_WINDOWS')
25 conf.env.append_value('CXXFLAGS', '-DLIBDCP_POSIX')
27 conf.check_cfg(package = 'openssl', args = '--cflags --libs', uselib_store = 'OPENSSL', mandatory = True)
28 conf.check_cfg(package = 'libxml++-2.6', args = '--cflags --libs', uselib_store = 'LIBXML++', mandatory = True)
29 if conf.options.static:
30 conf.check_cc(fragment = """
32 #include <openjpeg.h>\n
34 void* p = (void *) opj_image_create;\n
38 msg = 'Checking for library openjpeg', stlib = 'openjpeg', uselib_store = 'OPENJPEG', mandatory = True)
40 conf.env.HAVE_CXML = 1
41 conf.env.STLIB_CXML = ['cxml']
43 conf.check_cfg(package = 'libopenjpeg', args = '--cflags --libs', uselib_store = 'OPENJPEG', mandatory = True)
44 conf.check_cfg(package = 'libcxml', args = '--cflags --libs', uselib_store = 'CXML', mandatory = True)
46 if conf.options.target_windows:
47 boost_lib_suffix = '-mt'
51 if conf.options.enable_debug:
52 conf.env.append_value('CXXFLAGS', '-g')
54 # Somewhat experimental use of -O2 rather than -O3 to see if
55 # Windows builds are any more reliable
56 conf.env.append_value('CXXFLAGS', '-O2')
58 conf.check_cxx(fragment = """
59 #include <boost/version.hpp>\n
60 #if BOOST_VERSION < 104500\n
61 #error boost too old\n
63 int main(void) { return 0; }\n
66 msg = 'Checking for boost library >= 1.45',
68 errmsg = 'too old\nPlease install boost version 1.45 or higher.')
70 conf.check_cxx(fragment = """
71 #include <boost/filesystem.hpp>\n
72 int main() { boost::filesystem::copy_file ("a", "b"); }\n
74 msg = 'Checking for boost filesystem library',
75 libpath = '/usr/local/lib',
76 lib = ['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
77 uselib_store = 'BOOST_FILESYSTEM')
79 conf.check_cxx(fragment = """
80 #include <boost/signals2.hpp>\n
81 int main() { boost::signals2::signal<void (int)> x; }\n
83 msg = 'Checking for boost signals2 library',
84 uselib_store = 'BOOST_SIGNALS2')
87 conf.recurse('asdcplib')
90 create_version_cc(bld, VERSION)
92 if bld.env.TARGET_WINDOWS:
93 boost_lib_suffix = '-mt'
97 bld(source = 'libdcp.pc.in',
99 includedir = '%s/include' % bld.env.PREFIX,
100 libs = "-L${libdir} -ldcp -lasdcp-libdcp -lkumu-libdcp -lboost_system%s" % boost_lib_suffix,
101 install_path = '${LIBDIR}/pkgconfig')
106 bld.recurse('asdcplib')
107 bld.recurse('examples')
109 bld.add_post_fun(post)
112 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~ __pycache__ GPATH GRTAGS GSYMS GTAGS'
114 def create_version_cc(bld, version):
115 if os.path.exists('.git'):
116 cmd = "LANG= git log --abbrev HEAD^..HEAD ."
117 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
118 o = output[0].decode('utf-8')
119 commit = o.replace ("commit ", "")[0:10]
124 text = '#include "version.h"\n'
125 text += 'char const * libdcp::git_commit = \"%s\";\n' % commit
126 text += 'char const * libdcp::version = \"%s\";\n' % version
127 if bld.env.ENABLE_DEBUG:
128 debug_string = 'true'
130 debug_string = 'false'
131 text += 'bool const built_with_debug = %s;\n' % debug_string
132 print('Writing version information to src/version.cc')
133 o = open('src/version.cc', 'w')
137 print('Could not open src/version.cc for writing\n')
141 if ctx.cmd == 'install':
142 ctx.exec_command('/sbin/ldconfig')