Fix feature detections with CMake

* implement missing checks with CMake
* fixes and improve some detections
* remove missing but unused checks

Signed-off-by: OBATA Akio <obache@wizdas.com>
pull/148/head
OBATA Akio 3 years ago
parent 50a228fc2d
commit ad41084b8d

@ -31,6 +31,7 @@ include( CheckCXXSourceCompiles )
include( CheckTypeSize ) include( CheckTypeSize )
include( CheckCSourceRuns ) include( CheckCSourceRuns )
include( CheckLibraryExists ) include( CheckLibraryExists )
include( CheckStructHasMember )
##### include our cmake modules ################# ##### include our cmake modules #################
@ -346,7 +347,7 @@ check_function_exists( mkstemp HAVE_MKSTEMP )
check_symbol_exists( mkstemp "stdlib.h" HAVE_MKSTEMP_PROTO ) check_symbol_exists( mkstemp "stdlib.h" HAVE_MKSTEMP_PROTO )
check_function_exists( mkstemps HAVE_MKSTEMPS ) check_function_exists( mkstemps HAVE_MKSTEMPS )
check_symbol_exists( mkstemps "stdlib.h" HAVE_MKSTEMPS_PROTO ) check_symbol_exists( mkstemps "stdlib.h;unistd.h" HAVE_MKSTEMPS_PROTO )
check_function_exists( initgroups HAVE_INITGROUPS ) check_function_exists( initgroups HAVE_INITGROUPS )
check_symbol_exists( initgroups "grp.h;unistd.h" HAVE_INITGROUPS_PROTO ) check_symbol_exists( initgroups "grp.h;unistd.h" HAVE_INITGROUPS_PROTO )
@ -465,6 +466,7 @@ check_function_exists( putenv HAVE_PUTENV )
check_function_exists( poll HAVE_POLL ) check_function_exists( poll HAVE_POLL )
check_function_exists( madvise HAVE_MADVISE ) check_function_exists( madvise HAVE_MADVISE )
check_function_exists( getgroups HAVE_GETGROUPS ) check_function_exists( getgroups HAVE_GETGROUPS )
check_symbol_exists( posix_fadvise "fcntl.h" HAVE_FADVISE )
check_function_exists( getcwd HAVE_GETCWD ) check_function_exists( getcwd HAVE_GETCWD )
check_function_exists( dlerror HAVE_DLERROR ) check_function_exists( dlerror HAVE_DLERROR )
if( NOT HAVE_DLERROR ) if( NOT HAVE_DLERROR )
@ -502,7 +504,13 @@ check_type_size( "unsigned long" SIZEOF_UNSIGNED_LONG )
set( CMAKE_EXTRA_INCLUDE_FILES "netdb.h" ) set( CMAKE_EXTRA_INCLUDE_FILES "netdb.h" )
check_type_size( "struct addrinfo" STRUCT_ADDRINFO ) check_type_size( "struct addrinfo" STRUCT_ADDRINFO )
set( CMAKE_EXTRA_INCLUDE_FILES "netinet/in.h" ) set( CMAKE_EXTRA_INCLUDE_FILES "netinet/in.h" )
check_type_size( "struct sockaddr_in6" HAVE_STRUCT_SOCKADDR_IN6 ) check_type_size( "struct sockaddr_in6" STRUCT_SOCKADDR_IN6 )
check_struct_has_member( "struct sockaddr_in6" sin6_scope_id "sys/types.h;sys/socket.h;netinet/in.h" HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID )
check_struct_has_member( "struct sockaddr" sa_len "sys/types.h;sys/socket.h;netinet/in.h" HAVE_STRUCT_SOCKADDR_SA_LEN )
check_struct_has_member( "struct sockaddr_un" sun_len "sys/types.h;sys/un.h" HAVE_STRUCT_SOCKADDR_UN_SUN_LEN )
set( CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h" )
check_type_size( "struct ucred" STRUCT_UCRED )
check_struct_has_member( "struct sockaddr_in" sin_len "sys/types.h;sys/socket.h;netinet/in.h" HAVE_STRUCT_SOCKADDR_IN_SIN_LEN )
unset( CMAKE_EXTRA_INCLUDE_FILES ) unset( CMAKE_EXTRA_INCLUDE_FILES )
check_c_source_compiles(" check_c_source_compiles("
@ -548,6 +556,8 @@ endif( NOT HAVE_GOOD_GETADDRINFO )
# save CMAKE_REQUIRED_LIBRARIES # save CMAKE_REQUIRED_LIBRARIES
set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ) set( bak_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} )
check_symbol_exists( res_init "sys/types.h;netinet/in.h;arpa/nameser.h;resolv.h" HAVE_RES_INIT_PROTO )
set( CMAKE_REQUIRED_LIBRARIES resolv ) set( CMAKE_REQUIRED_LIBRARIES resolv )
check_c_source_compiles(" check_c_source_compiles("
#include <sys/types.h> #include <sys/types.h>
@ -634,6 +644,7 @@ if( NOT HAVE_LIBDL )
set( HAVE_LIBDL 1 ) set( HAVE_LIBDL 1 )
endif( HAVE_DLOPEN ) endif( HAVE_DLOPEN )
endif( NOT HAVE_LIBDL ) endif( NOT HAVE_LIBDL )
check_library_exists( dld, dld_link "" HAVE_DLD )
##### check for magic ########################### ##### check for magic ###########################

@ -13,20 +13,9 @@
#cmakedefine HAVE_DNSSD 1 #cmakedefine HAVE_DNSSD 1
#cmakedefine AVAHI_API_0_6 1 #cmakedefine AVAHI_API_0_6 1
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.
*/
#undef CRAY_STACKSEG_END
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Use su or sudo */ /* Use su or sudo */
#define DEFAULT_SUPER_USER_COMMAND "@DEFAULT_SUPER_USER_COMMAND@" #define DEFAULT_SUPER_USER_COMMAND "@DEFAULT_SUPER_USER_COMMAND@"
/* Define if getaddrinfo returns AF_UNIX sockets */
#undef GETADDRINFO_RETURNS_UNIX
/* getmntinfo() uses struct statvfs */ /* getmntinfo() uses struct statvfs */
#cmakedefine GETMNTINFO_USES_STATVFS #cmakedefine GETMNTINFO_USES_STATVFS
@ -119,9 +108,6 @@
/* Define to 1 if libbfd provides demangle.h header */ /* Define to 1 if libbfd provides demangle.h header */
#cmakedefine HAVE_DEMANGLE_H 1 #cmakedefine HAVE_DEMANGLE_H 1
/* You _must_ have bool */
#undef HAVE_BOOL
/* Define if getaddrinfo is broken and should be replaced */ /* Define if getaddrinfo is broken and should be replaced */
#cmakedefine HAVE_BROKEN_GETADDRINFO 1 #cmakedefine HAVE_BROKEN_GETADDRINFO 1
@ -174,7 +160,7 @@
#cmakedefine HAVE_DIRENT_H 1 #cmakedefine HAVE_DIRENT_H 1
/* Define if you have the GNU dld library. */ /* Define if you have the GNU dld library. */
#undef HAVE_DLD #cmakedefine HAVE_DLD
/* Define to 1 if you have the <dld.h> header file. */ /* Define to 1 if you have the <dld.h> header file. */
#cmakedefine HAVE_DLD_H 1 #cmakedefine HAVE_DLD_H 1
@ -201,7 +187,7 @@
#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1 #cmakedefine __KDE_HAVE_GCC_VISIBILITY 1
/* Define is posix_fadvise is supported */ /* Define is posix_fadvise is supported */
#undef HAVE_FADVISE #cmakedefine HAVE_FADVISE
/* Define if your system has libfam */ /* Define if your system has libfam */
#cmakedefine HAVE_FAM 1 #cmakedefine HAVE_FAM 1
@ -314,9 +300,6 @@
/* Define if you have jasper */ /* Define if you have jasper */
#cmakedefine HAVE_JASPER 1 #cmakedefine HAVE_JASPER 1
/* Define if your locale.h file contains LC_MESSAGES */
#undef HAVE_LC_MESSAGES
/* Defines if your system has the libart library */ /* Defines if your system has the libart library */
#cmakedefine HAVE_LIBART 1 #cmakedefine HAVE_LIBART 1
@ -341,12 +324,6 @@
/* Define if you have libpng */ /* Define if you have libpng */
#cmakedefine HAVE_LIBPNG 1 #cmakedefine HAVE_LIBPNG 1
/* Define if you have a working libpthread (will enable threaded code) */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the `qt-mt' library (-lqt-mt). */
#undef HAVE_LIBTQT_MT
/* Defined if you have libthai and want to have it compiled in */ /* Defined if you have libthai and want to have it compiled in */
#undef HAVE_LIBTHAI #undef HAVE_LIBTHAI
@ -422,9 +399,6 @@
/* Define to 1 if you have the <net/if.h> header file. */ /* Define to 1 if you have the <net/if.h> header file. */
#cmakedefine HAVE_NET_IF_H 1 #cmakedefine HAVE_NET_IF_H 1
/* Define to 1 if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define if system has non-POSIX extensions to the ACL support. */ /* Define if system has non-POSIX extensions to the ACL support. */
#cmakedefine HAVE_NON_POSIX_ACL_EXTENSIONS 1 #cmakedefine HAVE_NON_POSIX_ACL_EXTENSIONS 1
@ -480,7 +454,7 @@
#cmakedefine HAVE_RES_INIT 1 #cmakedefine HAVE_RES_INIT 1
/* Define if you have the res_init prototype */ /* Define if you have the res_init prototype */
#undef HAVE_RES_INIT_PROTO #cmakedefine HAVE_RES_INIT_PROTO
/* Define if revoke(tty) is present in unistd.h */ /* Define if revoke(tty) is present in unistd.h */
#cmakedefine HAVE_REVOKE 1 #cmakedefine HAVE_REVOKE 1
@ -603,13 +577,19 @@
#cmakedefine HAVE_STRUCT_SOCKADDR_IN6 1 #cmakedefine HAVE_STRUCT_SOCKADDR_IN6 1
/* Define to 1 if `sin6_scope_id' is member of `struct sockaddr_in6'. */ /* Define to 1 if `sin6_scope_id' is member of `struct sockaddr_in6'. */
#undef HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID #cmakedefine HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID 1
/* Define to 1 if `sa_len' is member of `struct sockaddr'. */ /* Define to 1 if `sa_len' is member of `struct sockaddr'. */
#undef HAVE_STRUCT_SOCKADDR_SA_LEN #cmakedefine HAVE_STRUCT_SOCKADDR_SA_LEN 1
/* Define to 1 if `sin_len' is member of `struct sockaddr_in'. */
#cmakedefine HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1
/* Define to 1 if `sun_len' is member of `struct sockaddr_un'. */
#cmakedefine HAVE_STRUCT_SOCKADDR_UN_SUN_LEN 1
/* Define if struct ucred is present from sys/socket.h */ /* Define if struct ucred is present from sys/socket.h */
#undef HAVE_STRUCT_UCRED #cmakedefine HAVE_STRUCT_UCRED 1
/* Define to 1 if you have the <sysent.h> header file. */ /* Define to 1 if you have the <sysent.h> header file. */
#cmakedefine HAVE_SYSENT_H 1 #cmakedefine HAVE_SYSENT_H 1

@ -47,6 +47,10 @@ from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
@ -873,7 +877,7 @@ TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port)
else else
sockname.sin_port = htons (0); sockname.sin_port = htons (0);
#ifdef BSD44SOCKETS #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
sockname.sin_len = sizeof (sockname); sockname.sin_len = sizeof (sockname);
#endif #endif
sockname.sin_family = AF_INET; sockname.sin_family = AF_INET;
@ -947,7 +951,7 @@ TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port)
} }
namelen = sizeof( sockname ) - sizeof( sockname.sun_path ) + strlen( sockname.sun_path ) + 1; namelen = sizeof( sockname ) - sizeof( sockname.sun_path ) + strlen( sockname.sun_path ) + 1;
#if defined(BSD44SOCKETS) #if defined(HAVE_STRUCT_SOCKADDR_UN_SUN_LEN)
sockname.sun_len = namelen; sockname.sun_len = namelen;
#endif #endif
@ -1278,7 +1282,7 @@ TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
* Build the socket name. * Build the socket name.
*/ */
#ifdef BSD44SOCKETS #ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
sockname.sin_len = sizeof (struct sockaddr_in); sockname.sin_len = sizeof (struct sockaddr_in);
#endif #endif
sockname.sin_family = AF_INET; sockname.sin_family = AF_INET;

Loading…
Cancel
Save