notmuch_compat_srcs = [ ] config = configuration_data() config.set_quoted('NOTMUCH_SRCDIR', meson.source_root()) # FIXME: this differs from the legacy build config.set('PLATFORM', build_machine.system()) cc = meson.get_compiler('c') cxx = meson.get_compiler('cpp') have_canonicalize_file_name = cc.has_function('canonicalize_file_name', prefix: '#include ', args: '-D_GNU_SOURCE') config.set10('HAVE_CANONICALIZE_FILE_NAME', have_canonicalize_file_name) if not have_canonicalize_file_name notmuch_compat_srcs += 'canonicalize_file_name.c' endif have_getline = cc.has_function('getline', prefix: '''#include #include ''') config.set10('HAVE_GETLINE', have_getline) if not have_getline notmuch_compat_srcs += [ 'getline.c', 'getdelim.c' ] endif have_strcasestr = cc.has_function('strcasestr', prefix: '#include ', args: '-D_GNU_SOURCE') config.set10('HAVE_STRCASESTR', have_strcasestr) if not have_strcasestr notmuch_compat_srcs += 'strcasestr.c' endif have_strsep = cc.has_function('strsep', prefix: '#include ') config.set10('HAVE_STRSEP', have_strsep) if not have_strsep notmuch_compat_srcs += 'strsep.c' endif have_timegm = cc.has_function('timegm', prefix: '#include ') config.set10('HAVE_TIMEGM', have_timegm) if not have_timegm notmuch_compat_srcs += 'timegm.c' endif have_d_type = cc.has_member('struct dirent', 'd_type', prefix: '#include ') config.set10('HAVE_D_TYPE', have_d_type) getpwuid_code = ''' #include #include int main() { struct passwd passwd, *ignored; getpwuid_r (0, &passwd, NULL, 0, &ignored); } ''' std_getpwuid = cc.compiles(getpwuid_code, name: 'standard getpwuid_r') config.set10('STD_GETPWUID', std_getpwuid) asctime_code = ''' #include #include int main() { struct tm tm; asctime_r (&tm, NULL); } ''' std_asctime = cc.compiles(asctime_code, name: 'standard asctime_r') config.set10('STD_ASCTIME', std_asctime) xapian_compact_code = ''' #include class TestCompactor : public Xapian::Compactor { }; ''' have_xapian_compact = cxx.compiles(xapian_compact_code, name: 'Xapian compact', dependencies: dep_xapian) config.set10('HAVE_XAPIAN_COMPACT', have_xapian_compact) xapian_field_processor_code = ''' #include class TitleFieldProcessor : public Xapian::FieldProcessor { }; ''' have_xapian_field_processor = cxx.compiles(xapian_field_processor_code, name: 'Xapian field processor', dependencies: dep_xapian) config.set10('HAVE_XAPIAN_FIELD_PROCESSOR', have_xapian_field_processor) xapian_db_retry_lock_code = ''' #include int flag = Xapian::DB_RETRY_LOCK; ''' have_xapian_db_retry_lock = cxx.compiles(xapian_db_retry_lock_code, name: 'Xapian retry lock', dependencies: dep_xapian) config.set10('HAVE_XAPIAN_DB_RETRY_LOCK', have_xapian_db_retry_lock) default_xapian_backend_code = ''' #include #include #include #define TESTDB "test.db" int main(void) { int i; struct { const char *file; const char *name; } backends[] = { { TESTDB "/iamglass", "glass" }, { TESTDB "/iamchert", "chert" }, { TESTDB "/iamflint", "flint" }, { NULL, "unknown" }, }; Xapian::WritableDatabase db("test.db", Xapian::DB_CREATE_OR_OPEN); for (i = 0; backends[i].file && access(backends[i].file, R_OK); i++) ; printf("%s", backends[i].name); } ''' default_xapian_backend = cxx.run(default_xapian_backend_code, name: 'Xapian default backend', dependencies: dep_xapian) message('Default Xapian backend: ' + default_xapian_backend.stdout()) config.set('DEFAULT_XAPIAN_BACKEND', default_xapian_backend.stdout()) configure_inc = include_directories('../lib') libnotmuch_version_major = cc.get_define('LIBNOTMUCH_MAJOR_VERSION', prefix: '#include ', include_directories: configure_inc) libnotmuch_version_minor = cc.get_define('LIBNOTMUCH_MINOR_VERSION', prefix: '#include ', include_directories: configure_inc) libnotmuch_version_micro = cc.get_define('LIBNOTMUCH_MICRO_VERSION', prefix: '#include ', include_directories: configure_inc) libnotmuch_version = libnotmuch_version_major + '.' + libnotmuch_version_minor + '.' + libnotmuch_version_micro config.set_quoted('PYTHON', cmd_python.path()) config.set('GMIME_MAJOR', dep_gmime.version().split('.')[0]) if cmd_ruby.found() ruby_dev = run_command(cmd_ruby.path(), ['-e', 'require \'mkmf\'']) have_ruby_dev = ruby_dev.returncode() == 0 else have_ruby_dev = false endif config.set10('HAVE_RUBY_DEV', have_ruby_dev) configure_file(input: 'config.h.in', output: 'config.h', configuration: config) inc_compat = include_directories('.') lib_compat = static_library('notmuch-compat', notmuch_compat_srcs)