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