From b05878f9a803f981604fda1efffa2ac1ae28329d Mon Sep 17 00:00:00 2001 From: Rich Mattes Date: Sun, 9 Dec 2018 12:52:56 -0500 Subject: [PATCH] Fix issues with xdr detection Add logic to detect and use the libtirpc xdr implementation on Linux. Addresses #11. Fall back to the system stdint.h to define size types in the bundled xdr types.h when stdint.h is available. --- cmake/internal/SearchForStuff.cmake | 10 +++++++++- config.h.in | 1 + libplayerinterface/CMakeLists.txt | 11 ++++++++++- replace/CMakeLists.txt | 14 +++++++------- replace/rpc/types.h | 7 ++++++- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/cmake/internal/SearchForStuff.cmake b/cmake/internal/SearchForStuff.cmake index 6dbe2d83..1a139f39 100644 --- a/cmake/internal/SearchForStuff.cmake +++ b/cmake/internal/SearchForStuff.cmake @@ -4,6 +4,7 @@ INCLUDE (CheckFunctionExists) INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) INCLUDE (CheckSymbolExists) +INCLUDE (FindPkgConfig) SET (PLAYER_EXTRA_LIB_DIRS "" CACHE STRING "List of extra library directories.") MARK_AS_ADVANCED (PLAYER_EXTRA_LIB_DIRS) @@ -11,6 +12,8 @@ SET (PLAYER_EXTRA_INCLUDE_DIRS "" CACHE STRING "List of extra include directorie MARK_AS_ADVANCED (PLAYER_EXTRA_INCLUDE_DIRS) SET (CMAKE_REQUIRED_INCLUDES ${PLAYER_EXTRA_INCLUDE_DIRS}) +CHECK_INCLUDE_FILES("stdint.h" HAVE_STDINT_H) + IF (PLAYER_OS_QNX) SET (CMAKE_REQUIRED_LIBRARIES socket) ELSEIF (PLAYER_OS_SOLARIS) @@ -19,10 +22,16 @@ ENDIF (PLAYER_OS_QNX) CHECK_FUNCTION_EXISTS (getaddrinfo HAVE_GETADDRINFO) SET (CMAKE_REQUIRED_LIBRARIES) +IF (PLAYER_OS_LINUX AND PKG_CONFIG_FOUND) + PKG_CHECK_MODULES(TIRPC libtirpc) +ENDIF(PLAYER_OS_LINUX AND PKG_CONFIG_FOUND) + IF (PLAYER_OS_QNX) SET (CMAKE_REQUIRED_LIBRARIES rpc) ELSEIF (PLAYER_OS_SOLARIS) SET (CMAKE_REQUIRED_LIBRARIES nsl) +ELSEIF (PLAYER_OS_LINUX AND TIRPC_FOUND) + SET (CMAKE_REQUIRED_LIBRARIES ${TIRPC_LIBRARIES}) ENDIF (PLAYER_OS_QNX) CHECK_FUNCTION_EXISTS (xdr_free HAVE_XDR) IF (HAVE_XDR) @@ -141,7 +150,6 @@ INCLUDE (TestBigEndian) TEST_BIG_ENDIAN (WORDS_BIGENDIAN) # GTK checks -INCLUDE (FindPkgConfig) IF (NOT PKG_CONFIG_FOUND) MESSAGE (STATUS "WARNING: Could not find pkg-config. This will prevent searching for GTK and building many drivers.") ELSE (NOT PKG_CONFIG_FOUND) diff --git a/config.h.in b/config.h.in index 63e60a23..b778a250 100644 --- a/config.h.in +++ b/config.h.in @@ -8,6 +8,7 @@ /* enable TCP_NODELAY */ #cmakedefine ENABLE_TCP_NODELAY 1 +#cmakedefine HAVE_STDINT_H 1 #cmakedefine HAVE_GETADDRINFO 1 #cmakedefine HAVE_I2C 1 #cmakedefine HAVE_JPEG 1 diff --git a/libplayerinterface/CMakeLists.txt b/libplayerinterface/CMakeLists.txt index 0e22b8fd..06f4b65d 100644 --- a/libplayerinterface/CMakeLists.txt +++ b/libplayerinterface/CMakeLists.txt @@ -95,6 +95,10 @@ SET (playerinterfaceSrcs ${playerxdr_h} IF (PLAYER_OS_QNX) SET (interfaceLibFlag -lrpc) +ELSEIF (PLAYER_OS_LINUX AND TIRPC_FOUND) + SET (interfaceLibFlag -ltirpc) + set (interfaceCflags ${TIRPC_CFLAGS}) + INCLUDE_DIRECTORIES(${TIRPC_INCLUDE_DIRS}) ELSE (PLAYER_OS_QNX) SET (interfaceLibFlag) ENDIF (PLAYER_OS_QNX) @@ -112,12 +116,17 @@ SET_SOURCE_FILES_PROPERTIES (${playerxdr_h} ${playerxdr_c} PROPERTIES GENERATED IF (PLAYER_OS_QNX) TARGET_LINK_LIBRARIES (playerinterface rpc) PLAYERCORE_ADD_INT_LINK_LIB (rpc) +ELSEIF (PLAYER_OS_LINUX AND TIRPC_FOUND) + TARGET_LINK_LIBRARIES (playerinterface ${TIRPC_LIBRARIES}) + PLAYERCORE_ADD_INT_LINK_LIB (tirpc) + TARGET_INCLUDE_DIRECTORIES (playerinterface PUBLIC ${TIRPC_INCLUDE_DIRS}) ENDIF (PLAYER_OS_QNX) IF (NOT HAVE_XDR) TARGET_LINK_LIBRARIES (playerinterface playerreplace) + TARGET_INCLUDE_DIRECTORIES(playerinterface PUBLIC "${PROJECT_SOURCE_DIR}/replace") ENDIF (NOT HAVE_XDR) PLAYER_MAKE_PKGCONFIG ("playerinterface" "Player Interface library - part of the Player Project" - "" "" "" "${interfaceLibFlag}") + "" "" "${interfaceCflags}" "${interfaceLibFlag}") PLAYER_INSTALL_HEADERS (playerinterface ${playerxdr_h} addr_util.h diff --git a/replace/CMakeLists.txt b/replace/CMakeLists.txt index 475ee218..5b811454 100644 --- a/replace/CMakeLists.txt +++ b/replace/CMakeLists.txt @@ -14,7 +14,7 @@ IF (NOT HAVE_XDR) xdr_mem.c xdr_sizeof.c) IF (PLAYER_OS_WIN) - SET (ws2_32lib ws2_32) + SET (ws2_32lib ws2_32) ENDIF (PLAYER_OS_WIN) ENDIF (NOT HAVE_XDR) @@ -57,7 +57,7 @@ ENDIF (NOT HAVE_NANOSLEEP) IF (NOT HAVE_POLL) SET (replaceSrcs ${replaceSrcs} poll.c) IF (PLAYER_OS_WIN) - SET (ws2_32lib ws2_32) + SET (ws2_32lib ws2_32) ENDIF (PLAYER_OS_WIN) ENDIF (NOT HAVE_POLL) @@ -69,12 +69,12 @@ IF (replaceSrcs) PLAYER_ADD_LIBRARY (playerreplace ${replaceSrcs}) TARGET_LINK_LIBRARIES (playerreplace playercommon) IF (PLAYER_OS_WIN) - IF (NOT HAVE_XDR OR NOT HAVE_POLL) - TARGET_LINK_LIBRARIES (playerreplace ws2_32) - ENDIF (NOT HAVE_XDR OR NOT HAVE_POLL) - PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "playercommon ${ws2_32Lib}" "" "" "") + IF (NOT HAVE_XDR OR NOT HAVE_POLL) + TARGET_LINK_LIBRARIES (playerreplace ws2_32) + ENDIF (NOT HAVE_XDR OR NOT HAVE_POLL) + PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "playercommon ${ws2_32Lib}" "" "" "") ELSE (PLAYER_OS_WIN) - PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "playercommon" "" "" "") + PLAYER_MAKE_PKGCONFIG ("playerreplace" "Player library of replacements for missing platform functionality - part of the Player Project" "playercommon" "" "" "") ENDIF (PLAYER_OS_WIN) ENDIF (replaceSrcs) diff --git a/replace/rpc/types.h b/replace/rpc/types.h index 0767c95a..12ff2032 100644 --- a/replace/rpc/types.h +++ b/replace/rpc/types.h @@ -35,6 +35,8 @@ #ifndef _RPC_TYPES_H #define _RPC_TYPES_H 1 +#include "config.h" + typedef int bool_t; typedef int enum_t; /* This needs to be changed to uint32_t in the future */ @@ -81,6 +83,9 @@ typedef unsigned long long int u_quad_t; #endif /* Fixed-size types, underlying types depend on word size and compiler. */ +#if HAVE_STDINT_H +#include +#else typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int int16_t; @@ -91,7 +96,7 @@ typedef unsigned int uint32_t; typedef signed long long int int64_t; typedef unsigned long long int uint64_t; //#endif - +#endif typedef char* caddr_t; //#include