For the TLS examples and SWTPM interface that use POSIX sockets make sure `netdb.h` is included. Previously wolfSSL always included netdb.h, but now it requires `HAVE_NETDB_H`.

pull/332/head
David Garske 2024-02-29 09:21:14 -08:00
parent 35bf0b9649
commit 53bf0f4a0f
6 changed files with 98 additions and 0 deletions

View File

@ -47,6 +47,27 @@ target_compile_definitions(wolftpm PRIVATE
"BUILDING_WOLFTPM"
)
include(CheckIncludeFile)
check_include_file("fcntl.h" HAVE_FCNTL_H)
check_include_file("netdb.h" HAVE_NETDB_H)
check_include_file("time.h" HAVE_TIME_H)
check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H)
check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H)
check_include_file("sys/time.h" HAVE_SYS_TIME_H)
check_include_file("errno.h" HAVE_ERRNO_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
include(CheckFunctionExists)
check_function_exists("gethostbyname" HAVE_GETHOSTBYNAME)
check_function_exists("getaddrinfo" HAVE_GETADDRINFO)
check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
# TODO
# * wrapper
@ -245,6 +266,26 @@ file(APPEND ${OPTION_FILE} "#endif\n\n\n")
file(APPEND ${OPTION_FILE} "#endif /* WOLFTPM_OPTIONS_H */\n\n")
# generate config.h
message("Generating config header...")
set(WOLFTPM_CONFIG_H "yes" CACHE STRING
"Enable generation of config.h and define HAVE_CONFIG_H (default: enabled)")
set_property(CACHE WOLFTPM_DEBUG
PROPERTY STRINGS "yes;no")
if(WOLFTPM_CONFIG_H)
add_definitions("-DHAVE_CONFIG_H")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.in"
"${CMAKE_CURRENT_BINARY_DIR}/config.h" )
# If config.h exists, delete it to avoid a mixup with build/config.h
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/config.h")
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/config.h")
endif()
endif()
if (WOLFTPM_EXAMPLES)
add_tpm_example(activate_credential attestation/activate_credential.c)
add_tpm_example(make_credential attestation/make_credential.c)

View File

@ -41,6 +41,7 @@ include tests/include.am
include docs/include.am
include wrapper/include.am
include hal/include.am
include cmake/include.am
EXTRA_DIST+= README.md
EXTRA_DIST+= ChangeLog.md

5
cmake/README.md 100644
View File

@ -0,0 +1,5 @@
# wolfTPM CMake
This directory contains some supplementary files for the [CMakeLists.txt](../CMakeLists.txt) in the root.
See also cmake notes in the [INSTALL](../INSTALL) documentation file.

48
cmake/config.in 100644
View File

@ -0,0 +1,48 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#cmakedefine HAVE_FCNTL_H @HAVE_FCNTL_H@
/* Define to 1 if you have the <netdb.h> header file. */
#cmakedefine HAVE_NETDB_H @HAVE_NETDB_H@
/* Define to 1 if you have the <time.h> header file. */
#cmakedefine HAVE_TIME_H @HAVE_TIME_H@
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#cmakedefine HAVE_SYS_IOCTL_H @HAVE_SYS_IOCTL_H@
/* Define to 1 if you have the <sys/socket.h> header file. */
#cmakedefine HAVE_SYS_SOCKET_H @HAVE_SYS_SOCKET_H@
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H @HAVE_SYS_TIME_H@
/* Define to 1 if you have the <errno.h> header file. */
#cmakedefine HAVE_ERRNO_H @HAVE_ERRNO_H@
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H @HAVE_STRING_H@
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@
/* Define to 1 if you have the `getaddrinfo' function. */
#cmakedefine HAVE_GETADDRINFO @HAVE_GETADDRINFO@
/* Define to 1 if you have the `gethostbyname' function. */
#cmakedefine HAVE_GETHOSTBYNAME @HAVE_GETHOSTBYNAME@
/* Define to 1 if you have the `gettimeofday' function. */
#cmakedefine HAVE_GETTIMEOFDAY @HAVE_GETTIMEOFDAY@

2
cmake/include.am 100644
View File

@ -0,0 +1,2 @@
EXTRA_DIST += cmake/README.md
EXTRA_DIST += cmake/config.in

View File

@ -60,6 +60,7 @@ AC_CHECK_SIZEOF([long long], 8)
AC_CHECK_SIZEOF([long], 4)
# Check headers/libs
AC_CHECK_HEADERS([netdb.h])
AC_CHECK_FUNCS([gethostbyname getaddrinfo gettimeofday inet_ntoa memset socket])
AC_CHECK_LIB([network],[socket])