Merge pull request #1 from erijo/confuse-paths

Make settings paths set in cmake be used by telldusd
This commit is contained in:
Micke Prag 2012-03-30 04:59:52 -07:00
commit 748d19c58c
3 changed files with 20 additions and 7 deletions

View file

@ -240,8 +240,17 @@ ENDIF (UNIX)
IF (UNIX AND NOT APPLE)
INSTALL(TARGETS ${telldus-service_TARGET} RUNTIME DESTINATION sbin)
SET(SYSCONF_INSTALL_DIR "/etc" CACHE PATH "The sysconfig install dir (default prefix/etc)" )
SET(STATE_INSTALL_DIR "/var/state" CACHE PATH "The directory to store state information of the devices" )
IF (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
SET(STATE_INSTALL_DIR "/var/spool" CACHE PATH "The directory to store state information of the devices")
ELSE (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
SET(STATE_INSTALL_DIR "/var/state" CACHE PATH "The directory to store state information of the devices")
ENDIF (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/SettingsConfusePaths.h.in
${CMAKE_CURRENT_BINARY_DIR}/SettingsConfusePaths.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
INSTALL(FILES tellstick.conf
DESTINATION ${SYSCONF_INSTALL_DIR}
)

View file

@ -10,6 +10,7 @@
//
//
#include "Settings.h"
#include "SettingsConfusePaths.h"
#include "../client/telldus-core.h"
#include "Strings.h"
#include <confuse.h>
@ -28,12 +29,8 @@ public:
bool readConfig(cfg_t **cfg);
bool readVarConfig(cfg_t **cfg);
const char* CONFIG_FILE = "/etc/tellstick.conf";
#ifdef __FreeBSD__
const char* VAR_CONFIG_FILE = "/var/spool/telldus-core.conf";
#else
const char* VAR_CONFIG_FILE = "/var/state/telldus-core.conf";
#endif
const char* CONFIG_FILE = CONFIG_PATH "/tellstick.conf";
const char* VAR_CONFIG_FILE = VAR_CONFIG_PATH "/telldus-core.conf";
/*
* Constructor

View file

@ -0,0 +1,7 @@
#ifndef SETTINGSCONFUSEPATHS_H
#define SETTINGSCONFUSEPATHS_H
#define CONFIG_PATH "@SYSCONF_INSTALL_DIR@"
#define VAR_CONFIG_PATH "@STATE_INSTALL_DIR@"
#endif