INCLUDE(CheckIncludeFile)
INCLUDE(CheckFunctionExists)

CHECK_INCLUDE_FILE("rpc/types.h" NNTI_HAVE_RPC_TYPES_H)
CHECK_INCLUDE_FILE("rpc/xdr.h"   NNTI_HAVE_RPC_XDR_H)

CHECK_FUNCTION_EXISTS(xdr_u_int8_t  NNTI_HAVE_XDR_U_INT8_T)
CHECK_FUNCTION_EXISTS(xdr_u_int16_t NNTI_HAVE_XDR_U_INT16_T)
CHECK_FUNCTION_EXISTS(xdr_u_int32_t NNTI_HAVE_XDR_U_INT32_T)
CHECK_FUNCTION_EXISTS(xdr_u_int64_t NNTI_HAVE_XDR_U_INT64_T)

# XDR_SIZEOF
check_c_source_compiles(
    "#include <rpc/xdr.h>\nint main(){xdr_sizeof(NULL,NULL);return 0;}"
    NNTI_HAVE_XDR_SIZEOF
)

SET( NNTI_HAVE_XDR 1 )

if( NOT NNTI_HAVE_RPC_TYPES_H  OR  NOT NNTI_HAVE_RPC_XDR_H )
  SET( NNTI_HAVE_XDR 0 )
endif()

if( NOT NNTI_HAVE_XDR_SIZEOF )
  SET( NNTI_HAVE_XDR 0 )
endif()

SET( NNTI_HAVE_XDR ${NNTI_HAVE_XDR} CACHE BOOL "Does XDR exist on this system?" )

