5 VERSION = '0.01.0devel'
8 opt.load('compiler_cxx')
9 opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
10 opt.add_option('--static', action='store_true', default=False, help='build libsub statically and link statically to cxml')
13 conf.load('compiler_cxx')
14 conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
15 conf.env.append_value('CXXFLAGS', ['-DLIBSUB_VERSION="%s"' % VERSION])
17 conf.env.ENABLE_DEBUG = conf.options.enable_debug
18 conf.env.STATIC = conf.options.static
20 if conf.options.enable_debug:
21 conf.env.append_value('CXXFLAGS', '-g')
23 conf.env.append_value('CXXFLAGS', '-O3')
25 if conf.options.static:
26 conf.env.HAVE_CXML = 1
27 conf.env.STLIB_CXML = ['cxml']
29 conf.check_cfg(package='libcxml', atleast_version='0.08', args='--cflags --libs', uselib_store='CXML', mandatory=True)
31 conf.check_cxx(fragment="""
32 #include <boost/version.hpp>\n
33 #if BOOST_VERSION < 104500\n
34 #error boost too old\n
36 int main(void) { return 0; }\n
39 msg='Checking for boost library >= 1.45',
41 errmsg='too old\nPlease install boost version 1.45 or higher.')
43 conf.check_cxx(fragment = """
44 #include <boost/filesystem.hpp>\n
45 int main() { boost::filesystem::copy_file ("a", "b"); }\n
47 msg = 'Checking for boost filesystem library',
48 libpath = '/usr/local/lib',
49 lib = ['boost_filesystem', 'boost_system'],
50 uselib_store = 'BOOST_FILESYSTEM')
55 create_version_cc(bld, VERSION)
57 bld(source='libsub.pc.in',
59 includedir='%s/include' % bld.env.PREFIX,
60 libs="-L${libdir} -lsub -lboost_system",
61 install_path='${LIBDIR}/pkgconfig')
67 bld.add_post_fun(post)
70 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~ __pycache__ GPATH GRTAGS GSYMS GTAGS'
72 def create_version_cc(bld, version):
73 if os.path.exists('.git'):
74 cmd = "LANG= git log --abbrev HEAD^..HEAD ."
75 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
76 o = output[0].decode('utf-8')
77 commit = o.replace ("commit ", "")[0:10]
82 text = '#include "version.h"\n'
83 text += 'char const * sub::git_commit = \"%s\";\n' % commit
84 text += 'char const * sub::version = \"%s\";\n' % version
85 if bld.env.ENABLE_DEBUG:
88 debug_string = 'false'
89 text += 'bool const built_with_debug = %s;\n' % debug_string
90 print('Writing version information to src/version.cc')
91 o = open('src/version.cc', 'w')
95 print('Could not open src/version.cc for writing\n')
99 if ctx.cmd == 'install':
100 ctx.exec_command('/sbin/ldconfig')