diff --git a/CMakeLists.txt b/CMakeLists.txt index b155ab69..ab42dca8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,11 @@ file(STRINGS "VERSION" VERSION) project(ebusd) +include(GNUInstallDirs) +include(CheckFunctionExists) +include(CheckCXXSourceRuns) +include(CheckIncludeFile) + set(PACKAGE ${CMAKE_PROJECT_NAME}) set(PACKAGE_NAME ${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) set(CMAKE_INSTALL_PREFIX "" CACHE PATH "..." FORCE) endif() -include(GNUInstallDirs) -include(CheckFunctionExists) -include(CheckCXXSourceRuns) -include(CheckIncludeFile) add_definitions(-fpic -Wall -Wno-unused-function -Wextra) @@ -172,7 +173,7 @@ int main() { endif(HAVE_DIRECT_FLOAT_FORMAT_REV) 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) include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${ebusd_SOURCE_DIR}/src) diff --git a/config.h.cmake b/config.h.cmake index 0c693a2f..f73c5a54 100755 --- a/config.h.cmake +++ b/config.h.cmake @@ -50,13 +50,13 @@ #cmakedefine PACKAGE_BUGREPORT "${PACKAGE_BUGREPORT}" /* 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. */ #cmakedefine PACKAGE_NAME "${PACKAGE_NAME}" /* 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. */ #cmakedefine PACKAGE_STRING "${PACKAGE_STRING}" diff --git a/configure.ac b/configure.ac index ad7453ed..c3fbd666 100755 --- a/configure.ac +++ b/configure.ac @@ -153,8 +153,8 @@ AM_COND_IF([KNX], [AC_CONFIG_FILES([ 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_LOGFILE, LOCALSTATEDIR "/log/" PACKAGE ".log", [The path and name of the log 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_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(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.]) diff --git a/src/ebusd/Makefile.am b/src/ebusd/Makefile.am index a557e5c5..673ef653 100644 --- a/src/ebusd/Makefile.am +++ b/src/ebusd/Makefile.am @@ -1,8 +1,6 @@ AM_CXXFLAGS = -I$(top_srcdir)/src \ -isystem$(top_srcdir) \ - -Wconversion -Wno-unused-parameter \ - -DSYSCONFDIR=\"$(sysconfdir)\" \ - -DLOCALSTATEDIR=\"$(localstatedir)\" + -Wconversion -Wno-unused-parameter bin_PROGRAMS = ebusd diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index 79deee4d..1cfcdd48 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -52,20 +52,6 @@ using std::setw; using std::nouppercase; 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 "://"). */ #define CONFIG_PATH_SUFFIX "://cfg.ebusd.eu/" @@ -117,7 +103,7 @@ static struct options s_opt = { false, // foreground false, // enableHex false, // enableDefine - PID_FILE_NAME, // pidFile + PACKAGE_PIDFILE, // pidFile 8888, // port false, // localOnly 0, // httpPort @@ -257,7 +243,7 @@ static const struct argp_option argpoptions[] = { {"foreground", 'f', nullptr, 0, "Run in foreground", 0 }, {"enablehex", O_HEXCMD, nullptr, 0, "Enable hex 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 }, {"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 },