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.LIB_CXML = ['glibmm-2.4', 'glib-2.0', 'pcre', 'sigc-2.0', 'rt', 'xml++-2.6', 'xml2', 'pthread', 'lzma', 'dl', 'z']
28 conf.env.STLIB_CXML = ['cxml']
29 conf.check_cfg(package='libcxml', atleast_version='0.08', args='--cflags', uselib_store='CXML', mandatory=True)
31 conf.check_cfg(package='libcxml', atleast_version='0.08', args='--cflags --libs', uselib_store='CXML', mandatory=True)
33 conf.check_cxx(fragment="""
34 #include <boost/version.hpp>\n
35 #if BOOST_VERSION < 104500\n
36 #error boost too old\n
38 int main(void) { return 0; }\n
41 msg='Checking for boost library >= 1.45',
43 errmsg='too old\nPlease install boost version 1.45 or higher.')
45 conf.check_cxx(fragment = """
46 #include <boost/filesystem.hpp>\n
47 int main() { boost::filesystem::copy_file ("a", "b"); }\n
49 msg = 'Checking for boost filesystem library',
50 libpath = '/usr/local/lib',
51 lib = ['boost_filesystem', 'boost_system'],
52 uselib_store = 'BOOST_FILESYSTEM')
54 conf.check_cxx(fragment = """
55 #include <boost/locale.hpp>\n
56 int main() { boost::locale::conv::to_utf<char> ("a", "cp850"); }\n
58 msg = 'Checking for boost locale library',
59 libpath = '/usr/local/lib',
60 lib = ['boost_locale', 'boost_system'],
61 uselib_store = 'BOOST_LOCALE')
66 create_version_cc(bld, VERSION)
68 bld(source='libsub.pc.in',
70 includedir='%s/include' % bld.env.PREFIX,
71 libs="-L${libdir} -lsub -lboost_system",
72 install_path='${LIBDIR}/pkgconfig')
78 bld.add_post_fun(post)
81 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~ __pycache__ GPATH GRTAGS GSYMS GTAGS'
83 def create_version_cc(bld, version):
84 if os.path.exists('.git'):
85 cmd = "LANG= git log --abbrev HEAD^..HEAD ."
86 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
87 o = output[0].decode('utf-8')
88 commit = o.replace ("commit ", "")[0:10]
93 text = '#include "version.h"\n'
94 text += 'char const * sub::git_commit = \"%s\";\n' % commit
95 text += 'char const * sub::version = \"%s\";\n' % version
96 if bld.env.ENABLE_DEBUG:
99 debug_string = 'false'
100 text += 'bool const built_with_debug = %s;\n' % debug_string
101 print('Writing version information to src/version.cc')
102 o = open('src/version.cc', 'w')
106 print('Could not open src/version.cc for writing\n')
110 if ctx.cmd == 'install':
111 ctx.exec_command('/sbin/ldconfig')