diff --git a/CMakeLists.txt b/CMakeLists.txt index 3960176..4424505 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Makefile.am b/Makefile.am index 6a316e3..90c1148 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/cmake/README.md b/cmake/README.md new file mode 100644 index 0000000..a138be5 --- /dev/null +++ b/cmake/README.md @@ -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. diff --git a/cmake/config.in b/cmake/config.in new file mode 100644 index 0000000..8a0bc31 --- /dev/null +++ b/cmake/config.in @@ -0,0 +1,48 @@ +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H @HAVE_FCNTL_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETDB_H @HAVE_NETDB_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TIME_H @HAVE_TIME_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_IOCTL_H @HAVE_SYS_IOCTL_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKET_H @HAVE_SYS_SOCKET_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H @HAVE_SYS_TIME_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERRNO_H @HAVE_ERRNO_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H @HAVE_STRING_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@ + +/* Define to 1 if you have the 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@ diff --git a/cmake/include.am b/cmake/include.am new file mode 100644 index 0000000..ceec20a --- /dev/null +++ b/cmake/include.am @@ -0,0 +1,2 @@ +EXTRA_DIST += cmake/README.md +EXTRA_DIST += cmake/config.in diff --git a/configure.ac b/configure.ac index 134e6b7..7d2101e 100644 --- a/configure.ac +++ b/configure.ac @@ -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])