refactor(build): remove unused stdlib function and include checks

In addition: merge some checks for the same feature into one
test_compile. This reduces the total number of test compiles
which speeds up the cmake configure stage.
This commit is contained in:
bfredl
2023-02-27 16:30:32 +01:00
committed by Björn Linse
parent fbaf5bde55
commit 166b149d5b
8 changed files with 43 additions and 53 deletions

View File

@ -28,9 +28,7 @@ int main(void)
check_type_size("int" SIZEOF_INT LANGUAGE C)
check_type_size("long" SIZEOF_LONG LANGUAGE C)
check_type_size("intmax_t" SIZEOF_INTMAX_T LANGUAGE C)
check_type_size("int32_t" SIZEOF_INT32_T LANGUAGE C)
check_type_size("size_t" SIZEOF_SIZE_T LANGUAGE C)
check_type_size("long long" SIZEOF_LONG_LONG LANGUAGE C)
check_type_size("void *" SIZEOF_VOID_PTR LANGUAGE C)
check_symbol_exists(_NSGetEnviron crt_externs.h HAVE__NSGETENVIRON)
@ -38,7 +36,6 @@ check_symbol_exists(_NSGetEnviron crt_externs.h HAVE__NSGETENVIRON)
# Headers
check_include_files(langinfo.h HAVE_LANGINFO_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(sys/utsname.h HAVE_SYS_UTSNAME_H)
check_include_files(termios.h HAVE_TERMIOS_H)
@ -47,15 +44,8 @@ check_include_files(sys/sdt.h HAVE_SYS_SDT_H)
# Functions
check_function_exists(fseeko HAVE_FSEEKO)
check_function_exists(getpwent HAVE_GETPWENT)
check_function_exists(getpwnam HAVE_GETPWNAM)
check_function_exists(getpwuid HAVE_GETPWUID)
check_function_exists(readv HAVE_READV)
check_function_exists(opendir HAVE_OPENDIR)
check_function_exists(readlink HAVE_READLINK)
check_function_exists(setpgid HAVE_SETPGID)
check_function_exists(setsid HAVE_SETSID)
check_function_exists(sigaction HAVE_SIGACTION)
check_function_exists(strnlen HAVE_STRNLEN)
check_function_exists(strcasecmp HAVE_STRCASECMP)
check_function_exists(strncasecmp HAVE_STRNCASECMP)
@ -64,22 +54,28 @@ check_function_exists(strptime HAVE_STRPTIME)
check_c_source_compiles("
#include <sys/types.h>
#include <dirent.h>
#include <sys/file.h>
int main(void)
{
DIR *dir = opendir(\"dirname\");
dirfd(dir);
return 0;
}
" HAVE_DIRFD)
check_c_source_compiles("
#include <sys/file.h>
int main(void)
{
flock(10, LOCK_SH);
return 0;
}
" HAVE_FLOCK)
" HAVE_DIRFD_AND_FLOCK)
check_c_source_compiles("
#include <pwd.h>
int main(void)
{
getpwent();
getpwuid(0);
getpwnam(\"root\");
return 0;
}
" HAVE_PWD_FUNCS)
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
check_c_source_compiles("
@ -101,11 +97,13 @@ if(HAVE_LANGINFO_H)
endif()
check_include_files("endian.h" HAVE_ENDIAN_H)
check_include_files("sys/endian.h" HAVE_SYS_ENDIAN_H)
set(ENDIAN_INCLUDE_FILE "endian.h")
if(HAVE_SYS_ENDIAN_H AND NOT HAVE_ENDIAN_H)
set(ENDIAN_INCLUDE_FILE "sys/endian.h")
if(NOT HAVE_ENDIAN_H)
check_include_files("sys/endian.h" HAVE_SYS_ENDIAN_H)
if (HAVE_SYS_ENDIAN_H)
set(ENDIAN_INCLUDE_FILE "sys/endian.h")
endif()
endif()
set(SI "#include <stdint.h>\n")

View File

@ -3,9 +3,7 @@
#cmakedefine SIZEOF_INT @SIZEOF_INT@
#cmakedefine SIZEOF_INTMAX_T @SIZEOF_INTMAX_T@
#cmakedefine SIZEOF_INT32_T @SIZEOF_INT32_T@
#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
#if @SIZEOF_VOID_PTR@ == 8
@ -19,18 +17,12 @@
#cmakedefine HAVE__NSGETENVIRON
#cmakedefine HAVE_FD_CLOEXEC
#cmakedefine HAVE_FSEEKO
#cmakedefine HAVE_GETPWENT
#cmakedefine HAVE_GETPWNAM
#cmakedefine HAVE_GETPWUID
#cmakedefine HAVE_LANGINFO_H
#cmakedefine HAVE_LOCALE_H
#cmakedefine HAVE_NL_LANGINFO_CODESET
#cmakedefine HAVE_NL_MSG_CAT_CNTR
#cmakedefine HAVE_PWD_H
#cmakedefine HAVE_PWD_FUNCS
#cmakedefine HAVE_READLINK
#cmakedefine HAVE_SETPGID
#cmakedefine HAVE_SETSID
#cmakedefine HAVE_SIGACTION
#cmakedefine HAVE_STRNLEN
#cmakedefine HAVE_STRCASECMP
#cmakedefine HAVE_STRINGS_H
@ -51,8 +43,7 @@
# undef HAVE_SYS_UIO_H
# endif
#endif
#cmakedefine HAVE_DIRFD
#cmakedefine HAVE_FLOCK
#cmakedefine HAVE_DIRFD_AND_FLOCK
#cmakedefine HAVE_FORKPTY
#ifndef UNIT_TESTING