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.

199 lines
5.8 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. if (CYGWIN)
  41. check_include_files("sys/types.h;netinet/tcp.h" HAVE_NETINET_TCP_H)
  42. else ()
  43. check_include_files(netinet/tcp.h HAVE_NETINET_TCP_H)
  44. endif ()
  45. check_include_files(linux/tcp.h HAVE_LINUX_TCP_H)
  46. check_include_files(net/if.h HAVE_NET_IF_H)
  47. check_include_files(pcre.h HAVE_PCRE_H)
  48. check_include_files(pcre/pcre.h HAVE_PCRE_PCRE_H)
  49. check_symbol_exists(PTHREAD_PRIO_INHERIT pthread.h HAVE_PTHREAD_PRIO_INHERIT)
  50. check_function_exists(select HAVE_SELECT)
  51. check_function_exists(setresuid HAVE_SETRESUID)
  52. check_function_exists(setreuid HAVE_SETREUID)
  53. check_function_exists(setrlimit HAVE_SETRLIMIT)
  54. check_function_exists(socket HAVE_SOCKET)
  55. check_include_files(stdint.h HAVE_STDINT_H)
  56. check_include_files(stdlib.h HAVE_STDLIB_H)
  57. check_function_exists(strerror HAVE_STRERROR)
  58. check_include_files(strings.h HAVE_STRINGS_H)
  59. check_include_files(string.h HAVE_STRING_H)
  60. check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H)
  61. check_include_files(sys/select.h HAVE_SYS_SELECT_H)
  62. check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
  63. check_include_files(sys/stat.h HAVE_SYS_STAT_H)
  64. check_include_files(sys/types.h HAVE_SYS_TYPES_H)
  65. check_include_files(sys/wait.h HAVE_SYS_WAIT_H)
  66. check_include_files(ares.h HAVE_ARES_H)
  67. check_include_files(unistd.h HAVE_UNISTD_H)
  68. check_function_exists(fork HAVE_FORK)
  69. check_function_exists(vfork HAVE_VFORK)
  70. check_include_files(vfork.h HAVE_VFORK_H)
  71. if (HAVE_VFORK)
  72. set(HAVE_WORKING_VFORK 1)
  73. endif ()
  74. if (HAVE_FORK)
  75. set(HAVE_WORKING_FORK 1)
  76. endif ()
  77. # Define to the sub-directory where libtool stores uninstalled libraries.
  78. set(LT_OBJDIR ".libs/")
  79. set(NDEBUG 1)
  80. set(PACKAGE ${PROJECT_NAME})
  81. set(PACKAGE_BUGREPORT max.c.lv@gmail.com)
  82. set(PACKAGE_NAME ${PROJECT_NAME})
  83. set(PACKAGE_VERSION ${PROJECT_VERSION})
  84. set(PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}")
  85. set(PACKAGE_TARNAME ${PROJECT_NAME})
  86. set(PACKAGE_URL "")
  87. #message(${PACKAGE_NAME} - v${PACKAGE_VERSION} - v${PROJECT_VERSION})
  88. # PTHREAD_CREATE_JOINABLE
  89. # Define as the return type of signal handlers (`int' or `void').
  90. set(RETSIGTYPE void)
  91. # Define to the type of arg 1 for `select'.
  92. set(SELECT_TYPE_ARG1 int)
  93. # Define to the type of args 2, 3 and 4 for `select'.
  94. set(SELECT_TYPE_ARG234 "(fd_set *)")
  95. # Define to the type of arg 5 for `select'.
  96. set(SELECT_TYPE_ARG5 "(struct timeval *)")
  97. # Define to 1 if you have the ANSI C header files.
  98. set(STDC_HEADERS 1)
  99. check_include_files("sys/time.h;time.h" TIME_WITH_SYS_TIME)
  100. # If the compiler supports a TLS storage class define it to that here
  101. check_c_source_compiles("
  102. __thread int tls;
  103. int main(void) { return 0; }"
  104. HAVE_GCC_THREAD_LOCAL_STORAGE)
  105. if (HAVE_GCC_THREAD_LOCAL_STORAGE)
  106. set(TLS __thread)
  107. endif ()
  108. set(_ALL_SOURCE 1)
  109. set(_GNU_SOURCE 1)
  110. set(_POSIX_PTHREAD_SEMANTICS 1)
  111. set(_TANDEM_SOURCE 1)
  112. set(__EXTENSIONS__ 1)
  113. # USE_SYSTEM_SHARED_LIB
  114. set(VERSION ${PACKAGE_VERSION})
  115. # TODO WORDS_BIGENDIAN
  116. # _MINIX
  117. # _POSIX_1_SOURCE
  118. # _POSIX_SOURCE
  119. # _UINT8_T
  120. # Define to empty if `const' does not conform to ANSI C.
  121. # undef const
  122. # Define to `__inline__' or `__inline' if that's what the C compiler
  123. # calls it, or to nothing if 'inline' is not supported under any name.
  124. #ifndef __cplusplus
  125. #undef inline
  126. #endif
  127. # TODO Assume we got inline support
  128. # https://cmake.org/Wiki/CMakeTestInline
  129. # Define to `int' if <sys/types.h> does not define.
  130. # undef pid_t
  131. # Define to the type of an unsigned integer type of width exactly 16 bits if
  132. # such a type exists and the standard includes do not define it.
  133. # undef uint16_t
  134. # Define to the type of an unsigned integer type of width exactly 8 bits if
  135. # such a type exists and the standard includes do not define it.
  136. # undef uint8_t
  137. set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
  138. check_type_size(pid_t PID_T)
  139. check_type_size(size_t SIZE_T)
  140. check_type_size(ssize_t SSIZE_T)
  141. set(CMAKE_EXTRA_INCLUDE_FILES)
  142. check_type_size(uint16_t UINT16_T)
  143. check_type_size(uint8_t UINT8_T)
  144. ## Inverse
  145. if (NOT HAVE_PID_T)
  146. set(pid_t int)
  147. endif ()
  148. if (NOT HAVE_SIZE_T)
  149. set(size_t "unsigned int")
  150. endif ()
  151. if (NOT HAVE_SSIZE_T)
  152. set(ssize_t int)
  153. endif ()
  154. if (NOT HAVE_UINT8_T)
  155. set(uint8_t "unsigned char")
  156. endif ()
  157. if (NOT HAVE_UINT16_T)
  158. set(uint16_t "unsigned short")
  159. endif ()
  160. # Define as `fork' if `vfork' does not work.
  161. if (NOT HAVE_WORKING_VFORK)
  162. set(vfork fork)
  163. endif ()