Skip to content

Commit

Permalink
simplify some dir/file defines
Browse files Browse the repository at this point in the history
  • Loading branch information
john30 committed Sep 24, 2023
1 parent 087209f commit 26102d0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 28 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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.])
Expand Down
4 changes: 1 addition & 3 deletions src/ebusd/Makefile.am
Original file line number Diff line number Diff line change
@@ -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

Expand Down
18 changes: 2 additions & 16 deletions src/ebusd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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/"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 26102d0

Please sign in to comment.