diff --git a/telldus-core/CMakeLists.txt b/telldus-core/CMakeLists.txt index 3f6ae5a1..38eac5bc 100644 --- a/telldus-core/CMakeLists.txt +++ b/telldus-core/CMakeLists.txt @@ -42,8 +42,18 @@ ENDIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") SET(BUILD_TDTOOL TRUE CACHE BOOL "Build tdtool") SET(BUILD_TDADMIN ${TDADMIN_DEFAULT} CACHE BOOL "Build tdadmin") +SET(GENERATE_DOXYGEN FALSE CACHE BOOL "Enable generation of doxygen") SET(GENERATE_MAN FALSE CACHE BOOL "Enable generation of man-files") + +IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + SET(MAN_DIR_DEFAULT "man") +ELSE() + SET(MAN_DIR_DEFAULT "share/man") +ENDIF() +SET(MAN_DIR ${MAN_DIR_DEFAULT} CACHE PATH "The directory where man pages are located (related to ${CMAKE_INSTALL_PREFIX})") + + ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(service) ADD_SUBDIRECTORY(client) @@ -61,20 +71,23 @@ ENDIF(BUILD_TDADMIN) ENABLE_TESTING() ADD_SUBDIRECTORY(tests) -FIND_PACKAGE(Doxygen) - -IF(DOXYGEN_FOUND) - SET(DOXY_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - - CONFIGURE_FILE( - "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in" - ${DOXY_CONFIG} @ONLY - ) - - ADD_CUSTOM_TARGET(docs - ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG} - DEPENDS ${DOXY_CONFIG} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Generating doxygen documentation" VERBATIM - ) -ENDIF() +IF (GENERATE_DOXYGEN) + FIND_PACKAGE(Doxygen) + IF(DOXYGEN_FOUND) + SET(DOXY_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + + CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in" + ${DOXY_CONFIG} @ONLY + ) + + ADD_CUSTOM_TARGET(docs + ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG} + DEPENDS ${DOXY_CONFIG} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Generating doxygen documentation" VERBATIM + ) + ELSE() + MESSAGE("Warn: doxygen not found, wont build") + ENDIF() +ENDIF(GENERATE_DOXYGEN) diff --git a/telldus-core/common/CMakeLists.txt b/telldus-core/common/CMakeLists.txt index 13aafa87..1b931f5d 100644 --- a/telldus-core/common/CMakeLists.txt +++ b/telldus-core/common/CMakeLists.txt @@ -54,16 +54,33 @@ ELSEIF (WIN32) ) ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") #### FreeBSD #### - FIND_LIBRARY(ICONV_LIBRARY iconv) + string(REGEX MATCH "(([0-9]+)\\.([0-9]+))-([A-Z0-9])+" FREEBSD "${CMAKE_SYSTEM_VERSION}") + set( FREEBSD_RELEASE "${CMAKE_MATCH_1}" ) ADD_DEFINITIONS( -D_FREEBSD ) LIST(APPEND telldus-common_SRCS Event_unix.cpp EventHandler_unix.cpp Socket_unix.cpp ) - LIST(APPEND telldus-common_LIBRARIES - ${ICONV_LIBRARY} - ) + + # FreeBSD 10 has iconv built in to libc + # However, if user has libiconv package installed, clang will find that header first, + # and we'd get a link error. This fix will at least let it build; we cannot + # force the user to NOT have libiconv installed. + # + # "proper" fix would be to force clang/gcc to use system header. How? + IF( (FREEBSD_RELEASE LESS 10) OR (EXISTS "/usr/local/include/iconv.h")) + IF(NOT (FREEBSD_RELEASE LESS 10)) + # Note that building the freebsd port with this may or may not fail, + # as the port does not define a dependency on libiconv package. + # When building with poudriere, this is not an issue since it will not be installed. + MESSAGE(WARNING "building with libiconv from package instead of base") + ENDIF() + FIND_LIBRARY(ICONV_LIBRARY iconv) + LIST(APPEND telldus-common_LIBRARIES + ${ICONV_LIBRARY} + ) + ENDIF () ELSE (APPLE) #### Linux #### ADD_DEFINITIONS( -D_LINUX ) diff --git a/telldus-core/common/Socket_unix.cpp b/telldus-core/common/Socket_unix.cpp index 79dc086f..42842dcd 100644 --- a/telldus-core/common/Socket_unix.cpp +++ b/telldus-core/common/Socket_unix.cpp @@ -18,7 +18,7 @@ #include "common/Strings.h" #define BUFSIZE 512 -#if defined(_MACOSX) && !defined(SOCK_CLOEXEC) +#if (defined(_MACOSX) || defined (__FreeBSD__)) && !defined(SOCK_CLOEXEC) #define SOCK_CLOEXEC 0 #endif diff --git a/telldus-core/common/Strings.cpp b/telldus-core/common/Strings.cpp index dc15f81f..e583f46f 100644 --- a/telldus-core/common/Strings.cpp +++ b/telldus-core/common/Strings.cpp @@ -19,7 +19,7 @@ #include -#ifdef _MACOSX +#if defined(_MACOSX) || defined(_FREEBSD) #define WCHAR_T_ENCODING "UCS-4-INTERNAL" #else #define WCHAR_T_ENCODING "WCHAR_T" diff --git a/telldus-core/common/Thread.h b/telldus-core/common/Thread.h index c5724eb8..b0306cad 100644 --- a/telldus-core/common/Thread.h +++ b/telldus-core/common/Thread.h @@ -12,6 +12,9 @@ #ifndef TELLDUS_CORE_COMMON_THREAD_H_ #define TELLDUS_CORE_COMMON_THREAD_H_ +#ifdef __FreeBSD__ +#include +#endif #include #include "common/Mutex.h" diff --git a/telldus-core/service/CMakeLists.txt b/telldus-core/service/CMakeLists.txt index 595d551c..b2c8999f 100644 --- a/telldus-core/service/CMakeLists.txt +++ b/telldus-core/service/CMakeLists.txt @@ -249,7 +249,7 @@ IF (UNIX) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating man file telldusd.1" ) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/telldusd.1 DESTINATION share/man/man1) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/telldusd.1 DESTINATION ${MAN_DIR}/man1) ENDIF (GENERATE_MAN) ENDIF (UNIX) diff --git a/telldus-core/service/ConnectionListener_unix.cpp b/telldus-core/service/ConnectionListener_unix.cpp index d3b238f9..33a6b00f 100644 --- a/telldus-core/service/ConnectionListener_unix.cpp +++ b/telldus-core/service/ConnectionListener_unix.cpp @@ -17,7 +17,7 @@ #include "service/ConnectionListener.h" #include "common/Socket.h" -#if defined(_MACOSX) && !defined(SOCK_CLOEXEC) +#if (defined(_MACOSX) || defined (__FreeBSD__)) && !defined(SOCK_CLOEXEC) #define SOCK_CLOEXEC 0 #endif diff --git a/telldus-core/service/EventUpdateManager.cpp b/telldus-core/service/EventUpdateManager.cpp index a76d5ca1..3299baee 100644 --- a/telldus-core/service/EventUpdateManager.cpp +++ b/telldus-core/service/EventUpdateManager.cpp @@ -33,6 +33,10 @@ #include "service/ConnectionListener.h" #include "service/Log.h" +#ifdef __FreeBSD__ +extern char **environ; +#endif + typedef std::list SocketList; typedef std::list StringList; diff --git a/telldus-core/service/Sensor.h b/telldus-core/service/Sensor.h index 0ebd6332..2070a3c4 100644 --- a/telldus-core/service/Sensor.h +++ b/telldus-core/service/Sensor.h @@ -7,6 +7,9 @@ #ifndef TELLDUS_CORE_SERVICE_SENSOR_H_ #define TELLDUS_CORE_SERVICE_SENSOR_H_ +#ifdef __FreeBSD__ +#include +#endif #include #include "common/Mutex.h" diff --git a/telldus-core/service/SettingsConfuse.cpp b/telldus-core/service/SettingsConfuse.cpp index 05030417..911d6880 100644 --- a/telldus-core/service/SettingsConfuse.cpp +++ b/telldus-core/service/SettingsConfuse.cpp @@ -17,6 +17,8 @@ class Settings::PrivateData { public: + PrivateData() + : cfg(NULL), var_cfg(NULL) {} cfg_t *cfg; cfg_t *var_cfg; }; diff --git a/telldus-core/tdadmin/CMakeLists.txt b/telldus-core/tdadmin/CMakeLists.txt index 7c72b26b..16c2bc76 100644 --- a/telldus-core/tdadmin/CMakeLists.txt +++ b/telldus-core/tdadmin/CMakeLists.txt @@ -52,13 +52,13 @@ IF (UNIX) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating man file tdadmin.1" ) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdadmin.1 DESTINATION share/man/man1) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdadmin.1 DESTINATION ${MAN_DIR}/man1) ENDIF (GENERATE_MAN) ENDIF (UNIX) INSTALL(TARGETS tdadmin RUNTIME DESTINATION sbin) -IF (UNIX AND NOT APPLE) +IF (UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") SET(UDEV_RULES_DIR "/etc/udev/rules.d" CACHE PATH "The directory where udev store its rules" ) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/05-tellstick.rules @@ -76,4 +76,14 @@ IF (UNIX AND NOT APPLE) INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/parsed/udev.sh DESTINATION share/telldus-core/helpers/ ) -ENDIF (UNIX AND NOT APPLE) +ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + SET(UDEV_RULES_DIR "/usr/local/etc/devd/" CACHE PATH "The directory where devd store its rules" ) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/freebsd-devd-tellstick.conf + ${CMAKE_BINARY_DIR}/parsed/tellstick.conf + @ONLY + ) + INSTALL(FILES ${CMAKE_BINARY_DIR}/parsed/tellstick.conf + DESTINATION ${UDEV_RULES_DIR} + ) +ENDIF () diff --git a/telldus-core/tdadmin/freebsd-devd-tellstick.conf b/telldus-core/tdadmin/freebsd-devd-tellstick.conf new file mode 100644 index 00000000..fd5b490c --- /dev/null +++ b/telldus-core/tdadmin/freebsd-devd-tellstick.conf @@ -0,0 +1,20 @@ +notify 50 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x1781"; + match "product" "0x0c30"; + + action "chgrp dialer /dev/$cdev; chmod 660 /dev/$cdev; + @CMAKE_INSTALL_PREFIX@/sbin/tdadmin --pid $product --vid $vendor --serial $sernum controller connect"; +}; + +notify 50 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "DETACH"; + match "vendor" "0x1781"; + match "product" "0x0c30"; + + action "@CMAKE_INSTALL_PREFIX@/sbin/tdadmin --pid $product --vid $vendor --serial $sernum controller disconnect"; +}; diff --git a/telldus-core/tdtool/CMakeLists.txt b/telldus-core/tdtool/CMakeLists.txt index c9aeb07b..f96fafc3 100644 --- a/telldus-core/tdtool/CMakeLists.txt +++ b/telldus-core/tdtool/CMakeLists.txt @@ -49,7 +49,7 @@ IF (UNIX) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating man file tdtool.1" ) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdtool.1 DESTINATION share/man/man1) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tdtool.1 DESTINATION ${MAN_DIR}/man1) ENDIF (GENERATE_MAN) ENDIF (UNIX)