You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
5.7 KiB

  1. # -------------------------------------------------------------
  2. # config.h
  3. # If we generate config.h by automake
  4. #include_directories(.)
  5. # Use cmake to generate config.h
  6. include(CheckIncludeFiles)
  7. include(CheckFunctionExists)
  8. include(CheckSymbolExists)
  9. include(CheckLibraryExists)
  10. include(CheckTypeSize)
  11. include(CheckCSourceCompiles)
  12. # Define if building universal (internal helper macro)
  13. # AC_APPLE_UNIVERSAL_BUILD
  14. set(CONNECT_IN_PROGRESS "EINPROGRESS")
  15. set(CONNECT_IN_PROGRESS "EINPROGRESS" CACHE STRING "")
  16. if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
  17. set(CMAKE_REQUIRED_INCLUDES "/usr/local/include" "/usr/include")
  18. endif ()
  19. check_include_files(dlfcn.h HAVE_DLFCN_H)
  20. check_include_files(ev.h HAVE_EV_H)
  21. check_include_files(fcntl.h HAVE_FCNTL_H)
  22. check_function_exists(fork HAVE_FORK)
  23. check_function_exists(getpwnam_r HAVE_GETPWNAM_R)
  24. check_function_exists(inet_ntop HAVE_INET_NTOP)
  25. check_include_files(inttypes.h HAVE_INTTYPES_H)
  26. set(HAVE_IPv6 1)
  27. check_include_files(langinfo.h HAVE_LANGINFO_H)
  28. set(HAVE_LIBPCRE 1)
  29. check_library_exists(socket socket "" HAVE_LIBSOCKET)
  30. check_include_files(limits.h HAVE_LIMITS_H)
  31. check_include_files(linux/if.h HAVE_LINUX_IF_H)
  32. check_include_files(linux/netfilter_ipv4.h HAVE_LINUX_NETFILTER_IPV4_H)
  33. check_include_files(linux/netfilter_ipv6/ip6_tables.h HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H)
  34. check_include_files(locale.h HAVE_LOCALE_H)
  35. check_function_exists(malloc HAVE_MALLOC)
  36. check_include_files(memory.h HAVE_MEMORY_H)
  37. check_function_exists(memset HAVE_MEMSET)
  38. check_include_files(netdb.h HAVE_NETDB_H)
  39. check_include_files(netinet/in.h HAVE_NETINET_IN_H)
  40. check_include_files(netinet/tcp.h HAVE_NETINET_TCP_H)
  41. check_include_files(linux/tcp.h HAVE_LINUX_TCP_H)
  42. check_include_files(net/if.h HAVE_NET_IF_H)
  43. check_include_files(pcre.h HAVE_PCRE_H)
  44. check_include_files(pcre/pcre.h HAVE_PCRE_PCRE_H)
  45. check_symbol_exists(PTHREAD_PRIO_INHERIT pthread.h HAVE_PTHREAD_PRIO_INHERIT)
  46. check_function_exists(select HAVE_SELECT)
  47. check_function_exists(setresuid HAVE_SETRESUID)
  48. check_function_exists(setreuid HAVE_SETREUID)
  49. check_function_exists(setrlimit HAVE_SETRLIMIT)
  50. check_function_exists(socket HAVE_SOCKET)
  51. check_include_files(stdint.h HAVE_STDINT_H)
  52. check_include_files(stdlib.h HAVE_STDLIB_H)
  53. check_function_exists(strerror HAVE_STRERROR)
  54. check_include_files(strings.h HAVE_STRINGS_H)
  55. check_include_files(string.h HAVE_STRING_H)
  56. check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H)
  57. check_include_files(sys/select.h HAVE_SYS_SELECT_H)
  58. check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
  59. check_include_files(sys/stat.h HAVE_SYS_STAT_H)
  60. check_include_files(sys/types.h HAVE_SYS_TYPES_H)
  61. check_include_files(sys/wait.h HAVE_SYS_WAIT_H)
  62. check_include_files(ares.h HAVE_ARES_H)
  63. check_include_files(unistd.h HAVE_UNISTD_H)
  64. check_function_exists(fork HAVE_FORK)
  65. check_function_exists(vfork HAVE_VFORK)
  66. check_include_files(vfork.h HAVE_VFORK_H)
  67. if (HAVE_VFORK)
  68. set(HAVE_WORKING_VFORK 1)
  69. endif ()
  70. if (HAVE_FORK)
  71. set(HAVE_WORKING_FORK 1)
  72. endif ()
  73. # Define to the sub-directory where libtool stores uninstalled libraries.
  74. set(LT_OBJDIR ".libs/")
  75. set(NDEBUG 1)
  76. set(PACKAGE ${PROJECT_NAME})
  77. set(PACKAGE_BUGREPORT max.c.lv@gmail.com)
  78. set(PACKAGE_NAME ${PROJECT_NAME})
  79. set(PACKAGE_VERSION ${PROJECT_VERSION})
  80. set(PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}")
  81. set(PACKAGE_TARNAME ${PROJECT_NAME})
  82. set(PACKAGE_URL "")
  83. #message(${PACKAGE_NAME} - v${PACKAGE_VERSION} - v${PROJECT_VERSION})
  84. # PTHREAD_CREATE_JOINABLE
  85. # Define as the return type of signal handlers (`int' or `void').
  86. set(RETSIGTYPE void)
  87. # Define to the type of arg 1 for `select'.
  88. set(SELECT_TYPE_ARG1 int)
  89. # Define to the type of args 2, 3 and 4 for `select'.
  90. set(SELECT_TYPE_ARG234 "(fd_set *)")
  91. # Define to the type of arg 5 for `select'.
  92. set(SELECT_TYPE_ARG5 "(struct timeval *)")
  93. # Define to 1 if you have the ANSI C header files.
  94. set(STDC_HEADERS 1)
  95. check_include_files("sys/time.h;time.h" TIME_WITH_SYS_TIME)
  96. # If the compiler supports a TLS storage class define it to that here
  97. check_c_source_compiles("
  98. __thread int tls;
  99. int main(void) { return 0; }"
  100. HAVE_GCC_THREAD_LOCAL_STORAGE)
  101. if (HAVE_GCC_THREAD_LOCAL_STORAGE)
  102. set(TLS __thread)
  103. endif ()
  104. set(_ALL_SOURCE 1)
  105. set(_GNU_SOURCE 1)
  106. set(_POSIX_PTHREAD_SEMANTICS 1)
  107. set(_TANDEM_SOURCE 1)
  108. set(__EXTENSIONS__ 1)
  109. # USE_SYSTEM_SHARED_LIB
  110. set(VERSION ${PACKAGE_VERSION})
  111. # TODO WORDS_BIGENDIAN
  112. # _MINIX
  113. # _POSIX_1_SOURCE
  114. # _POSIX_SOURCE
  115. # _UINT8_T
  116. # Define to empty if `const' does not conform to ANSI C.
  117. # undef const
  118. # Define to `__inline__' or `__inline' if that's what the C compiler
  119. # calls it, or to nothing if 'inline' is not supported under any name.
  120. #ifndef __cplusplus
  121. #undef inline
  122. #endif
  123. # TODO Assume we got inline support
  124. # https://cmake.org/Wiki/CMakeTestInline
  125. # Define to `int' if <sys/types.h> does not define.
  126. # undef pid_t
  127. # Define to the type of an unsigned integer type of width exactly 16 bits if
  128. # such a type exists and the standard includes do not define it.
  129. # undef uint16_t
  130. # Define to the type of an unsigned integer type of width exactly 8 bits if
  131. # such a type exists and the standard includes do not define it.
  132. # undef uint8_t
  133. set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
  134. check_type_size(pid_t PID_T)
  135. check_type_size(size_t SIZE_T)
  136. check_type_size(ssize_t SSIZE_T)
  137. set(CMAKE_EXTRA_INCLUDE_FILES)
  138. check_type_size(uint16_t UINT16_T)
  139. check_type_size(uint8_t UINT8_T)
  140. ## Inverse
  141. if (NOT HAVE_PID_T)
  142. set(pid_t int)
  143. endif ()
  144. if (NOT HAVE_SIZE_T)
  145. set(size_t "unsigned int")
  146. endif ()
  147. if (NOT HAVE_SSIZE_T)
  148. set(ssize_t int)
  149. endif ()
  150. if (NOT HAVE_UINT8_T)
  151. set(uint8_t "unsigned char")
  152. endif ()
  153. if (NOT HAVE_UINT16_T)
  154. set(uint16_t "unsigned short")
  155. endif ()
  156. # Define as `fork' if `vfork' does not work.
  157. if (NOT HAVE_WORKING_VFORK)
  158. set(vfork fork)
  159. endif ()