Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD compile fixes #6

Merged
merged 12 commits into from Sep 4, 2019
47 changes: 30 additions & 17 deletions telldus-core/CMakeLists.txt
Expand Up @@ -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)
Expand All @@ -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)
25 changes: 21 additions & 4 deletions telldus-core/common/CMakeLists.txt
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion telldus-core/common/Socket_unix.cpp
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion telldus-core/common/Strings.cpp
Expand Up @@ -19,7 +19,7 @@
#include <string>


#ifdef _MACOSX
#if defined(_MACOSX) || defined(_FREEBSD)
#define WCHAR_T_ENCODING "UCS-4-INTERNAL"
#else
#define WCHAR_T_ENCODING "WCHAR_T"
Expand Down
3 changes: 3 additions & 0 deletions telldus-core/common/Thread.h
Expand Up @@ -12,6 +12,9 @@
#ifndef TELLDUS_CORE_COMMON_THREAD_H_
#define TELLDUS_CORE_COMMON_THREAD_H_

#ifdef __FreeBSD__
#include <pthread.h>
#endif
#include <string>
#include "common/Mutex.h"

Expand Down
2 changes: 1 addition & 1 deletion telldus-core/service/CMakeLists.txt
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion telldus-core/service/ConnectionListener_unix.cpp
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions telldus-core/service/EventUpdateManager.cpp
Expand Up @@ -33,6 +33,10 @@
#include "service/ConnectionListener.h"
#include "service/Log.h"

#ifdef __FreeBSD__
extern char **environ;
#endif

typedef std::list<TelldusCore::Socket *> SocketList;
typedef std::list<std::string> StringList;

Expand Down
3 changes: 3 additions & 0 deletions telldus-core/service/Sensor.h
Expand Up @@ -7,6 +7,9 @@
#ifndef TELLDUS_CORE_SERVICE_SENSOR_H_
#define TELLDUS_CORE_SERVICE_SENSOR_H_

#ifdef __FreeBSD__
#include <ctime>
#endif
#include <string>
#include "common/Mutex.h"

Expand Down
2 changes: 2 additions & 0 deletions telldus-core/service/SettingsConfuse.cpp
Expand Up @@ -17,6 +17,8 @@

class Settings::PrivateData {
public:
PrivateData()
: cfg(NULL), var_cfg(NULL) {}
cfg_t *cfg;
cfg_t *var_cfg;
};
Expand Down
16 changes: 13 additions & 3 deletions telldus-core/tdadmin/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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 ()
20 changes: 20 additions & 0 deletions 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";
};
2 changes: 1 addition & 1 deletion telldus-core/tdtool/CMakeLists.txt
Expand Up @@ -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)

Expand Down