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. check_include_files(dlfcn.h HAVE_DLFCN_H)
  17. check_include_files(ev.h HAVE_EV_H)
  18. check_include_files(fcntl.h HAVE_FCNTL_H)
  19. check_function_exists(fork HAVE_FORK)
  20. check_function_exists(getpwnam_r HAVE_GETPWNAM_R)
  21. check_function_exists(inet_ntop HAVE_INET_NTOP)
  22. check_include_files(inttypes.h HAVE_INTTYPES_H)
  23. set(HAVE_IPv6 1)
  24. check_include_files(langinfo.h HAVE_LANGINFO_H)
  25. set(HAVE_LIBPCRE 1)
  26. check_library_exists(socket socket "" HAVE_LIBSOCKET)
  27. check_include_files(limits.h HAVE_LIMITS_H)
  28. check_include_files(linux/if.h HAVE_LINUX_IF_H)
  29. check_include_files(linux/netfilter_ipv4.h HAVE_LINUX_NETFILTER_IPV4_H)
  30. check_include_files(linux/netfilter_ipv6/ip6_tables.h HAVE_LINUX_NETFILTER_IPV6_IP6_TABLES_H)
  31. check_include_files(locale.h HAVE_LOCALE_H)
  32. check_function_exists(malloc HAVE_MALLOC)
  33. check_include_files(memory.h HAVE_MEMORY_H)
  34. check_function_exists(memset HAVE_MEMSET)
  35. check_include_files(netdb.h HAVE_NETDB_H)
  36. check_include_files(netinet/in.h HAVE_NETINET_IN_H)
  37. check_include_files(net/if.h HAVE_NET_IF_H)
  38. check_include_files(pcre.h HAVE_PCRE_H)
  39. check_include_files(pcre/pcre.h HAVE_PCRE_PCRE_H)
  40. check_symbol_exists(PTHREAD_PRIO_INHERIT pthread.h HAVE_PTHREAD_PRIO_INHERIT)
  41. check_function_exists(select HAVE_SELECT)
  42. check_function_exists(setresuid HAVE_SETRESUID)
  43. check_function_exists(setreuid HAVE_SETREUID)
  44. check_function_exists(setrlimit HAVE_SETRLIMIT)
  45. check_function_exists(socket HAVE_SOCKET)
  46. check_include_files(stdint.h HAVE_STDINT_H)
  47. check_include_files(stdlib.h HAVE_STDLIB_H)
  48. check_function_exists(strerror HAVE_STRERROR)
  49. check_include_files(strings.h HAVE_STRINGS_H)
  50. check_include_files(string.h HAVE_STRING_H)
  51. check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H)
  52. check_include_files(sys/select.h HAVE_SYS_SELECT_H)
  53. check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
  54. check_include_files(sys/stat.h HAVE_SYS_STAT_H)
  55. check_include_files(sys/types.h HAVE_SYS_TYPES_H)
  56. check_include_files(sys/wait.h HAVE_SYS_WAIT_H)
  57. check_include_files(udns.h HAVE_UDNS_H)
  58. check_include_files(unistd.h HAVE_UNISTD_H)
  59. check_function_exists(fork HAVE_FORK)
  60. check_function_exists(vfork HAVE_VFORK)
  61. check_include_files(vfork.h HAVE_VFORK_H)
  62. if (HAVE_VFORK)
  63. set(HAVE_WORKING_VFORK 1)
  64. endif ()
  65. if (HAVE_FORK)
  66. set(HAVE_WORKING_FORK 1)
  67. endif ()
  68. # Define to the sub-directory where libtool stores uninstalled libraries.
  69. set(LT_OBJDIR ".libs/")
  70. set(NDEBUG 1)
  71. set(PACKAGE ${PROJECT_NAME})
  72. set(PACKAGE_BUGREPORT max.c.lv@gmail.com)
  73. set(PACKAGE_NAME ${PROJECT_NAME})
  74. #set(PACKAGE_VERSION ${PROJECT_VERSION})
  75. set(PACKAGE_VERSION 3.0.2)
  76. set(PACKAGE_STRING "${PROJECT_NAME} ${PACKAGE_VERSION}")
  77. set(PACKAGE_TARNAME ${PROJECT_NAME})
  78. set(PACKAGE_URL "")
  79. #message(${PACKAGE_NAME} - v${PACKAGE_VERSION} - v${PROJECT_VERSION})
  80. # PTHREAD_CREATE_JOINABLE
  81. # Define as the return type of signal handlers (`int' or `void').
  82. set(RETSIGTYPE void)
  83. # Define to the type of arg 1 for `select'.
  84. set(SELECT_TYPE_ARG1 int)
  85. # Define to the type of args 2, 3 and 4 for `select'.
  86. set(SELECT_TYPE_ARG234 "(fd_set *)")
  87. # Define to the type of arg 5 for `select'.
  88. set(SELECT_TYPE_ARG5 "(struct timeval *)")
  89. # Define to 1 if you have the ANSI C header files.
  90. set(STDC_HEADERS 1)
  91. check_include_files(sys/time.h time.h TIME_WITH_SYS_TIME)
  92. # If the compiler supports a TLS storage class define it to that here
  93. check_c_source_compiles("
  94. __thread int tls;
  95. int main(void) { return 0; }"
  96. HAVE_GCC_THREAD_LOCAL_STORAGE)
  97. if (HAVE_GCC_THREAD_LOCAL_STORAGE)
  98. set(TLS __thread)
  99. endif ()
  100. set(_ALL_SOURCE 1)
  101. set(_GNU_SOURCE 1)
  102. set(_POSIX_PTHREAD_SEMANTICS 1)
  103. set(_TANDEM_SOURCE 1)
  104. set(__EXTENSIONS__ 1)
  105. # USE_SYSTEM_SHARED_LIB
  106. set(VERSION ${PACKAGE_VERSION})
  107. # TODO WORDS_BIGENDIAN
  108. # _MINIX
  109. # _POSIX_1_SOURCE
  110. # _POSIX_SOURCE
  111. # _UINT8_T
  112. # Define to empty if `const' does not conform to ANSI C.
  113. # undef const
  114. # Define to `__inline__' or `__inline' if that's what the C compiler
  115. # calls it, or to nothing if 'inline' is not supported under any name.
  116. #ifndef __cplusplus
  117. #undef inline
  118. #endif
  119. # TODO Assume we got inline support
  120. # https://cmake.org/Wiki/CMakeTestInline
  121. # Define to the equivalent of the C99 'restrict' keyword, or to
  122. # nothing if this is not supported. Do not define if restrict is
  123. # supported directly.
  124. #define restrict __restrict
  125. if (NOT "c_restrict" IN_LIST CMAKE_C_COMPILE_FEATURES)
  126. message("No restrict")
  127. set(restrict __restrict)
  128. endif ()
  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 ()