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