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')
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 conf.check_cxx(fragment="""
26 #include <boost/version.hpp>\n
27 #if BOOST_VERSION < 104500\n
28 #error boost too old\n
30 int main(void) { return 0; }\n
33 msg='Checking for boost library >= 1.45',
35 errmsg='too old\nPlease install boost version 1.45 or higher.')
40 create_version_cc(bld, VERSION)
42 bld(source='libsub.pc.in',
44 includedir='%s/include' % bld.env.PREFIX,
45 libs="-L${libdir} -lsub -lboost_system",
46 install_path='${LIBDIR}/pkgconfig')
51 bld.add_post_fun(post)
54 ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~ __pycache__ GPATH GRTAGS GSYMS GTAGS'
56 def create_version_cc(bld, version):
57 if os.path.exists('.git'):
58 cmd = "LANG= git log --abbrev HEAD^..HEAD ."
59 output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
60 o = output[0].decode('utf-8')
61 commit = o.replace ("commit ", "")[0:10]
66 text = '#include "version.h"\n'
67 text += 'char const * sub::git_commit = \"%s\";\n' % commit
68 text += 'char const * sub::version = \"%s\";\n' % version
69 if bld.env.ENABLE_DEBUG:
72 debug_string = 'false'
73 text += 'bool const built_with_debug = %s;\n' % debug_string
74 print('Writing version information to src/version.cc')
75 o = open('src/version.cc', 'w')
79 print('Could not open src/version.cc for writing\n')
83 if ctx.cmd == 'install':
84 ctx.exec_command('/sbin/ldconfig')