2014-01-31 06:39:15 -07:00
|
|
|
include(CheckTypeSize)
|
2014-04-03 01:27:36 -07:00
|
|
|
include(CheckSymbolExists)
|
2014-06-05 02:41:27 -07:00
|
|
|
include(CheckFunctionExists)
|
|
|
|
include(CheckIncludeFiles)
|
2015-08-15 06:16:29 -07:00
|
|
|
include(CheckCSourceRuns)
|
2015-08-15 07:41:28 -07:00
|
|
|
include(CheckCSourceCompiles)
|
2014-01-31 11:10:18 -07:00
|
|
|
|
2014-01-31 06:39:15 -07:00
|
|
|
check_type_size("int" SIZEOF_INT)
|
|
|
|
check_type_size("long" SIZEOF_LONG)
|
2015-01-12 03:46:19 -07:00
|
|
|
check_type_size("intmax_t" SIZEOF_INTMAX_T)
|
2014-01-31 06:39:15 -07:00
|
|
|
check_type_size("off_t" SIZEOF_OFF_T)
|
2015-01-27 09:02:57 -07:00
|
|
|
check_type_size("size_t" SIZEOF_SIZE_T)
|
|
|
|
check_type_size("long long" SIZEOF_LONG_LONG)
|
2014-05-12 17:44:33 -07:00
|
|
|
check_type_size("void *" SIZEOF_VOID_PTR)
|
2014-01-31 06:39:15 -07:00
|
|
|
|
2014-04-03 01:27:36 -07:00
|
|
|
check_symbol_exists(_NSGetEnviron crt_externs.h HAVE__NSGETENVIRON)
|
2014-02-28 03:33:31 -07:00
|
|
|
|
2014-06-05 02:41:27 -07:00
|
|
|
# Headers
|
|
|
|
check_include_files(dirent.h HAVE_DIRENT_H)
|
|
|
|
check_include_files(fcntl.h HAVE_FCNTL_H)
|
|
|
|
check_include_files(iconv.h HAVE_ICONV_H)
|
|
|
|
check_include_files(langinfo.h HAVE_LANGINFO_H)
|
|
|
|
check_include_files(libgen.h HAVE_LIBGEN_H)
|
|
|
|
check_include_files(locale.h HAVE_LOCALE_H)
|
|
|
|
check_include_files(pwd.h HAVE_PWD_H)
|
|
|
|
check_include_files(strings.h HAVE_STRINGS_H)
|
|
|
|
check_include_files(stropts.h HAVE_STROPTS_H)
|
|
|
|
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
|
|
|
|
check_include_files(sys/wait.h HAVE_SYS_WAIT_H)
|
|
|
|
if(NOT HAVE_SYS_WAIT_H AND UNIX)
|
|
|
|
# See if_cscope.c
|
|
|
|
message(SEND_ERROR "header sys/wait.h is required for UNIX")
|
|
|
|
endif()
|
|
|
|
check_include_files(sys/utsname.h HAVE_SYS_UTSNAME_H)
|
|
|
|
check_include_files(utime.h HAVE_UTIME_H)
|
|
|
|
check_include_files(unistd.h HAVE_UNISTD_H)
|
|
|
|
check_include_files(utime.h HAVE_UTIME_H)
|
|
|
|
|
|
|
|
# Functions
|
|
|
|
check_function_exists(fseeko HAVE_FSEEKO)
|
|
|
|
check_function_exists(fsync HAVE_FSYNC)
|
|
|
|
check_function_exists(getpwent HAVE_GETPWENT)
|
|
|
|
check_function_exists(getpwnam HAVE_GETPWNAM)
|
|
|
|
check_function_exists(getpwuid HAVE_GETPWUID)
|
2014-11-01 10:34:42 -07:00
|
|
|
|
2014-11-08 14:18:04 -07:00
|
|
|
if(Iconv_FOUND)
|
|
|
|
set(HAVE_ICONV 1)
|
2014-11-01 10:34:42 -07:00
|
|
|
endif()
|
|
|
|
|
2015-04-19 14:49:39 -07:00
|
|
|
if(JEMALLOC_FOUND)
|
|
|
|
set(HAVE_JEMALLOC 1)
|
|
|
|
endif()
|
|
|
|
|
2014-06-05 02:41:27 -07:00
|
|
|
check_function_exists(putenv HAVE_PUTENV)
|
|
|
|
check_function_exists(opendir HAVE_OPENDIR)
|
|
|
|
check_function_exists(readlink HAVE_READLINK)
|
|
|
|
check_function_exists(setenv HAVE_SETENV)
|
2014-07-01 02:25:51 -07:00
|
|
|
if(UNIX AND NOT HAVE_SETENV)
|
2014-06-05 02:41:27 -07:00
|
|
|
message(SEND_ERROR "setenv() function not found on your system.")
|
|
|
|
endif()
|
2015-02-25 03:33:04 -07:00
|
|
|
check_function_exists(unsetenv HAVE_UNSETENV)
|
2014-06-05 02:41:27 -07:00
|
|
|
check_function_exists(setpgid HAVE_SETPGID)
|
|
|
|
check_function_exists(setsid HAVE_SETSID)
|
|
|
|
check_function_exists(sigaction HAVE_SIGACTION)
|
|
|
|
check_function_exists(strcasecmp HAVE_STRCASECMP)
|
|
|
|
check_function_exists(strncasecmp HAVE_STRNCASECMP)
|
|
|
|
check_function_exists(utime HAVE_UTIME)
|
|
|
|
check_function_exists(utimes HAVE_UTIMES)
|
|
|
|
|
|
|
|
# Symbols
|
|
|
|
check_symbol_exists(FD_CLOEXEC "fcntl.h" HAVE_FD_CLOEXEC)
|
|
|
|
if(HAVE_LANGINFO_H)
|
|
|
|
check_symbol_exists(CODESET "langinfo.h" HAVE_NL_LANGINFO_CODESET)
|
|
|
|
endif()
|
|
|
|
|
2015-08-15 06:16:29 -07:00
|
|
|
set(SI "#include <stdint.h>\n")
|
|
|
|
set(MS "int main(int argc,char**argv)\n{\n uint64_t i=0x0102030405060708ULL;")
|
|
|
|
set(ME "}")
|
2015-08-15 07:41:28 -07:00
|
|
|
check_c_source_compiles("
|
2015-08-15 06:16:29 -07:00
|
|
|
#define _BSD_SOURCE 1
|
|
|
|
#define _DEFAULT_SOURCE 1
|
|
|
|
${SI}
|
|
|
|
#include <endian.h>
|
2015-08-15 07:41:28 -07:00
|
|
|
#ifndef be64toh
|
|
|
|
# error No be64toh macros
|
|
|
|
#endif
|
2015-08-15 06:16:29 -07:00
|
|
|
${MS}
|
|
|
|
uint64_t j = be64toh(i);
|
2015-08-15 07:41:28 -07:00
|
|
|
return (j == 0); // j must not be zero
|
2015-08-15 06:16:29 -07:00
|
|
|
${ME}"
|
2015-08-15 07:41:28 -07:00
|
|
|
HAVE_BE64TOH_MACROS)
|
|
|
|
if(NOT "${HAVE_BE64TOH_MACROS}")
|
|
|
|
check_function_exists(be64toh HAVE_BE64TOH_FUNC)
|
|
|
|
endif()
|
|
|
|
if("${HAVE_BE64TOH_MACROS}" OR "${HAVE_BE64TOH_FUNC}")
|
|
|
|
set(HAVE_BE64TOH 1)
|
|
|
|
endif()
|
|
|
|
if (NOT "${HAVE_BE64TOH}")
|
|
|
|
if (NOT "${CMAKE_CROSSCOMPILING}")
|
|
|
|
# It is safe to make ORDER_BIG_ENDIAN not defined if
|
|
|
|
# - HAVE_BE64TOH is true. In this case be64toh will be used unconditionally in
|
|
|
|
# any case and ORDER_BIG_ENDIAN will not be examined.
|
|
|
|
# - CMAKE_CROSSCOMPILING *and* HAVE_BE64TOH are both false. In this case
|
|
|
|
# be64toh function which uses cycle and arithmetic operations is used which
|
|
|
|
# will work regardless of endianess. Function is sub-optimal though.
|
|
|
|
check_c_source_runs("
|
|
|
|
${SI}
|
|
|
|
${MS}
|
|
|
|
char *s = (char *) &i;
|
|
|
|
return (
|
|
|
|
s[0] == 0x01
|
|
|
|
&& s[1] == 0x02
|
|
|
|
&& s[2] == 0x03
|
|
|
|
&& s[3] == 0x04
|
|
|
|
&& s[4] == 0x05
|
|
|
|
&& s[5] == 0x06
|
|
|
|
&& s[6] == 0x07
|
|
|
|
&& s[7] == 0x08) ? 0 : 1;
|
|
|
|
${ME}"
|
|
|
|
ORDER_BIG_ENDIAN)
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-08-15 06:16:29 -07:00
|
|
|
|
2014-01-31 06:39:15 -07:00
|
|
|
# generate configuration header and update include directories
|
|
|
|
configure_file (
|
|
|
|
"${PROJECT_SOURCE_DIR}/config/config.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/config/auto/config.h"
|
|
|
|
)
|
2014-06-05 02:41:27 -07:00
|
|
|
|
2015-03-01 08:36:10 -07:00
|
|
|
# generate version definitions
|
|
|
|
configure_file (
|
|
|
|
"${PROJECT_SOURCE_DIR}/config/versiondef.h.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/config/auto/versiondef.h"
|
|
|
|
)
|
|
|
|
|
2014-01-31 06:39:15 -07:00
|
|
|
# generate pathdef.c
|
|
|
|
find_program(WHOAMI_PROG whoami)
|
|
|
|
find_program(HOSTNAME_PROG hostname)
|
|
|
|
|
2014-04-21 05:28:38 -07:00
|
|
|
if (NOT DEFINED USERNAME AND EXISTS ${WHOAMI_PROG})
|
2014-01-31 06:39:15 -07:00
|
|
|
execute_process(COMMAND ${WHOAMI_PROG}
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
OUTPUT_VARIABLE USERNAME)
|
|
|
|
endif()
|
|
|
|
if (EXISTS ${HOSTNAME_PROG})
|
|
|
|
execute_process(COMMAND ${HOSTNAME_PROG}
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
OUTPUT_VARIABLE HOSTNAME)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
configure_file (
|
|
|
|
"${PROJECT_SOURCE_DIR}/config/pathdef.c.in"
|
|
|
|
"${PROJECT_BINARY_DIR}/config/auto/pathdef.c"
|
|
|
|
ESCAPE_QUOTES)
|