From a0e8d454c80bf39d935b95c5fd53611db7cbb0e9 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 13 Sep 2022 11:56:28 +0000 Subject: [PATCH] configure: Make the default database path configurable Signed-off-by: Michael Tremer --- configure.ac | 14 ++++++++++++++ src/python/locationmodule.c | 4 ++++ src/scripts/location.in | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 521194f..c469cbc 100644 --- a/configure.ac +++ b/configure.ac @@ -120,6 +120,19 @@ CC_CHECK_FLAGS_APPEND([my_LDFLAGS], [LDFLAGS], [-fno-semantic-interposition]) # ------------------------------------------------------------------------------ +AC_ARG_WITH([database-path], + AS_HELP_STRING([--with-database-path], [The default database path]), + [], [with_database_path=/var/lib/${PACKAGE_NAME}/database.db] +) + +if test -z "${with_database_path}"; then + AC_MSG_ERROR([The default database path is empty]) +fi + +AC_DEFINE_UNQUOTED([LIBLOC_DEFAULT_DATABASE_PATH], ["${with_database_path}"], + [The default path for the database]) +AC_SUBST([DEFAULT_DATABASE_PATH], [${with_database_path}]) + AC_ARG_WITH([systemd], AS_HELP_STRING([--with-systemd], [Enable systemd support.]) ) @@ -205,6 +218,7 @@ AC_MSG_RESULT([ cflags: ${CFLAGS} ldflags: ${LDFLAGS} + database path: ${with_database_path} debug: ${enable_debug} systemd support: ${have_systemd} diff --git a/src/python/locationmodule.c b/src/python/locationmodule.c index 46d9f83..45c7bd8 100644 --- a/src/python/locationmodule.c +++ b/src/python/locationmodule.c @@ -121,6 +121,10 @@ PyMODINIT_FUNC PyInit__location(void) { if (PyModule_AddStringConstant(m, "__version__", PACKAGE_VERSION)) return NULL; + // Default Database Path + if (PyModule_AddStringConstant(m, "DATABASE_PATH", LIBLOC_DEFAULT_DATABASE_PATH)) + return NULL; + // AS if (PyType_Ready(&ASType) < 0) return NULL; diff --git a/src/scripts/location.in b/src/scripts/location.in index 25119a8..be13156 100644 --- a/src/scripts/location.in +++ b/src/scripts/location.in @@ -59,7 +59,7 @@ class CLI(object): # database parser.add_argument("--database", "-d", - default="@databasedir@/database.db", help=_("Path to database"), + default=location.DATABASE_PATH, help=_("Path to database"), ) # public key -- 2.39.2