From cc147e7cae55a44aaa9ee97749d876f76d8676a1 Mon Sep 17 00:00:00 2001 From: Thomas von Dein Date: Thu, 20 Nov 2025 23:46:08 +0100 Subject: [PATCH] completed meson/ninja build --- meson.build | 85 ++++++++++++++++++++++++++++++++++----------- platform.h.in | 95 ++++++--------------------------------------------- 2 files changed, 76 insertions(+), 104 deletions(-) diff --git a/meson.build b/meson.build index 3a16e1e..7d90d37 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,8 @@ project( 'dbtool', 'cpp', - version: '1.9.1', license: 'GPL', + version: '1.9.1', meson_version: '>=1.3', default_options: [ 'warning_level=2', @@ -16,36 +16,73 @@ add_project_arguments( '-Wno-unused-result', '-Wno-missing-braces', '-Wno-format-zero-length', - '-Wundef', '-Wvla', + '-Wno-sign-compare', + '-Wno-narrowing' ], language: 'cpp', ) + cpp = meson.get_compiler('cpp') +conf = configuration_data() +dbtool_inc = include_directories('.') + +if host_machine.system().startswith('freebsd') + dbtool_inc = include_directories('.', '/usr/local/include') + add_project_link_arguments('LDFLAGS=/usr/local/lib') +endif + + +# check for funcs. +foreach func : ['getopt', 'fdopen', 'fgetc', 'getenv', 'getpass'] + conf.set('HAVE_'+func.to_upper(), cpp.has_function(func, prefix : '#include \n#include \n#include ')) +endforeach + + + +# check for libraries with CMAKE or pkg-config +pcre2 = dependency('libpcre2-8') + + +# manually check for libraries +lib_berkeley = cpp.find_library('db_cxx', + dirs : ['/usr', '/usr/local']) +inc_berkeley = include_directories('/usr', '/usr/local') + +lib_gdbm = cpp.find_library('gdbm', + dirs : ['/usr', '/usr/local']) +inc_gdbm = include_directories('/usr', '/usr/local') + + +# check commandline options prefix = get_option('prefix') -pcre2 = dependency('libpcre2-8') -#gdbm = dependency('libgdbm6t64') -#gdbm = dependency('libdb_cxx') +if get_option('buildtype') == 'debug' + conf.set('DEBUG', '1') +endif -lib_berkeley = cpp.find_library('db_cxx', - dirs : ['/usr']) -inc_berkeley = include_directories('/usr') -conf = configuration_data() -#conf.set10('HAVE_LIBGDBM', gdbm.found()) +# setup conf map +version = '@0@'.format(meson.project_version()) + conf.set10('HAVE_LIBPCRE', pcre2.found()) -conf.set10('DB_CXX_HEADER', lib_berkeley.found()) +conf.set10('HAVE_BERKELEY', lib_berkeley.found()) +conf.set10('HAVE_GDBM', lib_gdbm.found()) conf.set('prefix', prefix) +conf.set('VERSION', version) -platform_h = custom_target( - 'platform_h', - output : 'platform.h', - command : ['./platform.sh', conf.get('HAVE_LIBPCRE'), '@OUTPUT@'], + +# write out the config header +m = configure_file( + input : 'platform.h.in', + output : 'platform.h', + configuration : conf, ) + +# code dbtool_sources = files( 'cipher.cc', 'config.cc', @@ -55,17 +92,25 @@ dbtool_sources = files( 'rijndael.cc' ) +# add dependencies, manual libs are added directly below dbtool_deps = [ pcre2 ] -dbtool_inc = include_directories('.') executable( 'dbtool', - [dbtool_sources, platform_h], - include_directories: [dbtool_inc], - dependencies: [dbtool_deps, lib_berkeley], - include_directories : inc_berkeley, + [dbtool_sources], + include_directories: [dbtool_inc, inc_berkeley, inc_gdbm], + dependencies: [dbtool_deps, lib_berkeley, lib_gdbm], install: true ) + +# build manual page +pod2man = find_program('pod2man', native: true) +if pod2man.found() + res = run_command(pod2man.full_path(), 'dbtool.pod', 'dbtool.1', check:true) + if res.returncode() == 0 + install_man('dbtool.1') + endif +endif diff --git a/platform.h.in b/platform.h.in index 5327b5f..7df2252 100644 --- a/platform.h.in +++ b/platform.h.in @@ -1,92 +1,19 @@ /* platform.h.in. Generated from configure.ac by autoheader. */ -/* "Berkeley DB C++ Header File" */ -#undef DB_CXX_HEADER +#mesondefine HAVE_BERKELEY +#mesondefine HAVE_GDBM +#mesondefine HAVE_LIBPCRE +#mesondefine HAVE_GETPASS +#mesondefine HAVE_GETOPT +#mesondefine HAVE_FDOPEN +#mesondefine HAVE_FGETC +#mesondefine HAVE_GETENV -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H -/* Define to 1 if you have the `fdopen' function. */ -#undef HAVE_FDOPEN +#define PCRE2_CODE_UNIT_WIDTH 8 +#define PACKAGE "dbtool" -/* Define to 1 if you have the `fgetc' function. */ -#undef HAVE_FGETC - -/* Define to 1 if you have the `getenv' function. */ -#undef HAVE_GETENV - -/* Define to 1 if you have the `getopt' function. */ -#undef HAVE_GETOPT - -/* Define to 1 if you have the `getpass' function. */ -#undef HAVE_GETPASS - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `gdbm' library (-lgdbm). */ -#undef HAVE_LIBGDBM - -/* Define to 1 if you have the `pcre' library (-lpcre). */ -#undef HAVE_LIBPCRE - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -#undef LT_OBJDIR - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION +#define VERSION "@VERSION@" /* Define to empty if `const' does not conform to ANSI C. */ #undef const