simplify some dir/file defines

This commit is contained in:
John
2023-09-24 08:43:22 +02:00
parent 087209f2e7
commit 26102d0de3
5 changed files with 13 additions and 28 deletions
+6 -5
View File
@@ -10,6 +10,11 @@ file(STRINGS "VERSION" VERSION)
project(ebusd) project(ebusd)
include(GNUInstallDirs)
include(CheckFunctionExists)
include(CheckCXXSourceRuns)
include(CheckIncludeFile)
set(PACKAGE ${CMAKE_PROJECT_NAME}) set(PACKAGE ${CMAKE_PROJECT_NAME})
set(PACKAGE_NAME ${CMAKE_PROJECT_NAME}) set(PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(PACKAGE_TARNAME ${CMAKE_PROJECT_NAME}) set(PACKAGE_TARNAME ${CMAKE_PROJECT_NAME})
@@ -45,10 +50,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "" CACHE PATH "..." FORCE) set(CMAKE_INSTALL_PREFIX "" CACHE PATH "..." FORCE)
endif() endif()
include(GNUInstallDirs)
include(CheckFunctionExists)
include(CheckCXXSourceRuns)
include(CheckIncludeFile)
add_definitions(-fpic -Wall -Wno-unused-function -Wextra) add_definitions(-fpic -Wall -Wno-unused-function -Wextra)
@@ -172,7 +173,7 @@ int main() {
endif(HAVE_DIRECT_FLOAT_FORMAT_REV) endif(HAVE_DIRECT_FLOAT_FORMAT_REV)
endif(NOT HAVE_DIRECT_FLOAT_FORMAT) endif(NOT HAVE_DIRECT_FLOAT_FORMAT)
add_definitions(-D_GNU_SOURCE -DHAVE_CONFIG_H -DSYSCONFDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}" -DLOCALSTATEDIR="${CMAKE_INSTALL_FULL_LOCALSTATEDIR}") add_definitions(-D_GNU_SOURCE -DHAVE_CONFIG_H)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${ebusd_SOURCE_DIR}/src) include_directories(${ebusd_SOURCE_DIR}/src)
+2 -2
View File
@@ -50,13 +50,13 @@
#cmakedefine PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" #cmakedefine PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}"
/* The path and name of the log file. */ /* The path and name of the log file. */
#define PACKAGE_LOGFILE LOCALSTATEDIR "/log/" PACKAGE ".log" #cmakedefine PACKAGE_LOGFILE "${PACKAGE_LOGFILE}"
/* The full name of this package. */ /* The full name of this package. */
#cmakedefine PACKAGE_NAME "${PACKAGE_NAME}" #cmakedefine PACKAGE_NAME "${PACKAGE_NAME}"
/* The path and name of the PID file. */ /* The path and name of the PID file. */
#define PACKAGE_PIDFILE LOCALSTATEDIR "/run/" PACKAGE ".pid" #cmakedefine PACKAGE_PIDFILE "${PACKAGE_PIDFILE}"
/* The full name and version of this package. */ /* The full name and version of this package. */
#cmakedefine PACKAGE_STRING "${PACKAGE_STRING}" #cmakedefine PACKAGE_STRING "${PACKAGE_STRING}"
+2 -2
View File
@@ -153,8 +153,8 @@ AM_COND_IF([KNX], [AC_CONFIG_FILES([
src/lib/knx/Makefile src/lib/knx/Makefile
])]) ])])
AC_DEFINE_UNQUOTED(PACKAGE_PIDFILE, LOCALSTATEDIR "/run/" PACKAGE ".pid", [The path and name of the PID file.]) AC_DEFINE_UNQUOTED(PACKAGE_PIDFILE, "${localstatedir}/run/${PACKAGE_NAME}.pid", [The path and name of the PID file.])
AC_DEFINE_UNQUOTED(PACKAGE_LOGFILE, LOCALSTATEDIR "/log/" PACKAGE ".log", [The path and name of the log file.]) AC_DEFINE_UNQUOTED(PACKAGE_LOGFILE, "${localstatedir}/log/${PACKAGE_NAME}.log", [The path and name of the log file.])
AC_DEFINE(SCAN_VERSION, "[m4_esyscmd_s([sed -e 's#^\([0-9]*\.[0-9]*\).*#\1#' -e 's#\.\([0-9]\)$#0\1#' -e 's#\.##' VERSION])]", [The version of the package formatted for the scan result.]) AC_DEFINE(SCAN_VERSION, "[m4_esyscmd_s([sed -e 's#^\([0-9]*\.[0-9]*\).*#\1#' -e 's#\.\([0-9]\)$#0\1#' -e 's#\.##' VERSION])]", [The version of the package formatted for the scan result.])
AC_DEFINE(PACKAGE_VERSION_MAJOR, [m4_esyscmd_s([sed -e 's#^\([0-9]*\)\..*$#\1#' VERSION])], [The major version of the package.]) AC_DEFINE(PACKAGE_VERSION_MAJOR, [m4_esyscmd_s([sed -e 's#^\([0-9]*\)\..*$#\1#' VERSION])], [The major version of the package.])
AC_DEFINE(PACKAGE_VERSION_MINOR, [m4_esyscmd_s([sed -e 's#^.*\.\([0-9]*\)$#\1#' VERSION])], [The minor version of the package.]) AC_DEFINE(PACKAGE_VERSION_MINOR, [m4_esyscmd_s([sed -e 's#^.*\.\([0-9]*\)$#\1#' VERSION])], [The minor version of the package.])
+1 -3
View File
@@ -1,8 +1,6 @@
AM_CXXFLAGS = -I$(top_srcdir)/src \ AM_CXXFLAGS = -I$(top_srcdir)/src \
-isystem$(top_srcdir) \ -isystem$(top_srcdir) \
-Wconversion -Wno-unused-parameter \ -Wconversion -Wno-unused-parameter
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DLOCALSTATEDIR=\"$(localstatedir)\"
bin_PROGRAMS = ebusd bin_PROGRAMS = ebusd
+2 -16
View File
@@ -52,20 +52,6 @@ using std::setw;
using std::nouppercase; using std::nouppercase;
using std::cout; using std::cout;
/** the path and name of the PID file. */
#ifdef PACKAGE_PIDFILE
#define PID_FILE_NAME PACKAGE_PIDFILE
#else
#define PID_FILE_NAME "/var/run/ebusd.pid"
#endif
/** the path and name of the log file. */
#ifdef PACKAGE_LOGFILE
#define LOG_FILE_NAME PACKAGE_LOGFILE
#else
#define LOG_FILE_NAME "/var/log/ebusd.log"
#endif
/** the config path part behind the scheme (scheme without "://"). */ /** the config path part behind the scheme (scheme without "://"). */
#define CONFIG_PATH_SUFFIX "://cfg.ebusd.eu/" #define CONFIG_PATH_SUFFIX "://cfg.ebusd.eu/"
@@ -117,7 +103,7 @@ static struct options s_opt = {
false, // foreground false, // foreground
false, // enableHex false, // enableHex
false, // enableDefine false, // enableDefine
PID_FILE_NAME, // pidFile PACKAGE_PIDFILE, // pidFile
8888, // port 8888, // port
false, // localOnly false, // localOnly
0, // httpPort 0, // httpPort
@@ -257,7 +243,7 @@ static const struct argp_option argpoptions[] = {
{"foreground", 'f', nullptr, 0, "Run in foreground", 0 }, {"foreground", 'f', nullptr, 0, "Run in foreground", 0 },
{"enablehex", O_HEXCMD, nullptr, 0, "Enable hex command", 0 }, {"enablehex", O_HEXCMD, nullptr, 0, "Enable hex command", 0 },
{"enabledefine", O_DEFCMD, nullptr, 0, "Enable define command", 0 }, {"enabledefine", O_DEFCMD, nullptr, 0, "Enable define command", 0 },
{"pidfile", O_PIDFIL, "FILE", 0, "PID file name (only for daemon) [" PID_FILE_NAME "]", 0 }, {"pidfile", O_PIDFIL, "FILE", 0, "PID file name (only for daemon) [" PACKAGE_PIDFILE "]", 0 },
{"port", 'p', "PORT", 0, "Listen for command line connections on PORT [8888]", 0 }, {"port", 'p', "PORT", 0, "Listen for command line connections on PORT [8888]", 0 },
{"localhost", O_LOCAL, nullptr, 0, "Listen for command line connections on 127.0.0.1 interface only", 0 }, {"localhost", O_LOCAL, nullptr, 0, "Listen for command line connections on 127.0.0.1 interface only", 0 },
{"httpport", O_HTTPPT, "PORT", 0, "Listen for HTTP connections on PORT, 0 to disable [0]", 0 }, {"httpport", O_HTTPPT, "PORT", 0, "Listen for HTTP connections on PORT, 0 to disable [0]", 0 },