diff --git a/CMakeLists.txt b/CMakeLists.txt index 7207a04..596ceba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,9 +13,11 @@ SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") # config.h IF(WIN32) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_windows.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h) + SET(LIBNFC_SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/config" CACHE PATH "libnfc configuration directory") INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/contrib/win32) ELSE(WIN32) SET(_XOPEN_SOURCE 600) + SET(SYSCONFDIR "/etc" CACHE PATH "System configuration directory") CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config_posix.h.cmake ${CMAKE_CURRENT_SOURCE_DIR}/config.h) ENDIF(WIN32) diff --git a/cmake/config_posix.h.cmake b/cmake/config_posix.h.cmake index 4978aea..72d4a74 100644 --- a/cmake/config_posix.h.cmake +++ b/cmake/config_posix.h.cmake @@ -2,3 +2,4 @@ #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" #cmakedefine _XOPEN_SOURCE @_XOPEN_SOURCE@ +#cmakedefine SYSCONFDIR "@SYSCONFDIR@" diff --git a/cmake/config_windows.h.cmake b/cmake/config_windows.h.cmake index 5267ced..34fb2e6 100644 --- a/cmake/config_windows.h.cmake +++ b/cmake/config_windows.h.cmake @@ -3,3 +3,4 @@ #cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" #cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" +#cmakedefine LIBNFC_SYSCONFDIR "@LIBNFC_SYSCONFDIR@" diff --git a/libnfc/Makefile.am b/libnfc/Makefile.am index a214483..3a0e988 100644 --- a/libnfc/Makefile.am +++ b/libnfc/Makefile.am @@ -1,7 +1,7 @@ SUBDIRS = chips buses drivers . # set the include path found by configure -AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) +AM_CPPFLAGS = $(all_includes) $(LIBNFC_CFLAGS) -DSYSCONFDIR='"$(sysconfdir)"' noinst_HEADERS = \ conf.h \ diff --git a/libnfc/conf.c b/libnfc/conf.c index ab4ab0a..6e0c967 100644 --- a/libnfc/conf.c +++ b/libnfc/conf.c @@ -1,5 +1,5 @@ /*- - * Copyright (C) 2012 Romuald Conty + * Copyright (C) 2012, 2013 Romuald Conty * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the @@ -17,6 +17,10 @@ #include "conf.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif // HAVE_CONFIG_H + #include #include #include @@ -31,7 +35,14 @@ #define LOG_CATEGORY "libnfc.config" #define LOG_GROUP NFC_LOG_GROUP_CONFIG -#define LIBNFC_SYSCONFDIR "/etc/nfc" +#ifndef LIBNFC_SYSCONFDIR +// If this define does not already exists, we build it using SYSCONFDIR +#ifndef SYSCONFDIR +#error "SYSCONFDIR is not defined but required." +#endif // SYSCONFDIR +#define LIBNFC_SYSCONFDIR SYSCONFDIR"/nfc" +#endif // LIBNFC_SYSCONFDIR + #define LIBNFC_CONFFILE LIBNFC_SYSCONFDIR"/libnfc.conf" #define LIBNFC_DEVICECONFDIR LIBNFC_SYSCONFDIR"/devices.d"