include (CheckFunctionExists)
include (CheckSymbolExists)

CHECK_FUNCTION_EXISTS(asprintf     HAVE_ASPRINTF)
CHECK_FUNCTION_EXISTS(vasprintf    HAVE_VASPRINTF)
CHECK_FUNCTION_EXISTS(reallocarray HAVE_REALLOCARRAY)
CHECK_FUNCTION_EXISTS(strlcpy      HAVE_STRLCPY)
CHECK_FUNCTION_EXISTS(strlcat      HAVE_STRLCAT)
CHECK_FUNCTION_EXISTS(strtonum     HAVE_STRTONUM)

CHECK_SYMBOL_EXISTS(fork         "unistd.h" HAVE_FORK)
CHECK_SYMBOL_EXISTS(snprintf     "stdio.h"  HAVE_SNPRINTF)
CHECK_SYMBOL_EXISTS(strndup      "string.h" HAVE_STRNDUP)


if (HAVE_ASPRINTF)
    add_definitions(-DHAVE_ASPRINTF)
endif()
if (HAVE_FORK)
    add_definitions(-DHAVE_FORK)
endif()
if (HAVE_REALLOCARRAY)
    add_definitions(-DHAVE_REALLOCARRAY)
endif()
if (HAVE_SNPRINTF)
    add_definitions(-DHAVE_SNPRINTF)
endif()
if (HAVE_STRNDUP)
    add_definitions(-DHAVE_STRNDUP)
endif()
if (HAVE_STRLCPY)
    add_definitions(-DHAVE_STRLCPY)
endif()
if (HAVE_STRLCAT)
    add_definitions(-DHAVE_STRLCAT)
endif()
if (HAVE_STRTONUM)
    add_definitions(-DHAVE_STRTONUM)
endif()
if (HAVE_VASPRINTF)
    add_definitions(-DHAVE_VASPRINTF)
endif()
