#####################################################################
-if not cc.has_header('sys/capability.h')
- error('POSIX caps headers not found')
-endif
-foreach header : ['crypt.h',
- 'sys/sdt.h',
- 'threads.h',
- 'valgrind/memcheck.h',
- 'valgrind/valgrind.h',
- ]
+foreach header : [
+ 'crypt.h',
+ 'sys/capability.h',
+]
+
+ if not cc.has_header(header)
+ error('Header file @0@ not found.'.format(header))
+ endif
+endforeach
+
+foreach header : [
+ 'sys/sdt.h',
+ 'threads.h',
+ 'valgrind/memcheck.h',
+ 'valgrind/valgrind.h',
+]
conf.set10('HAVE_' + header.underscorify().to_upper(),
cc.has_header(header))
librt = cc.find_library('rt')
libm = cc.find_library('m')
libdl = cc.find_library('dl')
-libcrypt = dependency('libcrypt', 'libxcrypt', required : false)
-if not libcrypt.found()
- # fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC.
- libcrypt = cc.find_library('crypt')
-endif
libcap = dependency('libcap')
# On some architectures, libatomic is required. But on some installations,
libatomic = []
endif
-crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
-foreach ident : [
- ['crypt_ra', crypt_header],
- ['crypt_preferred_method', crypt_header],
- ['crypt_gensalt_ra', crypt_header]]
+libcrypt = dependency('libcrypt', 'libxcrypt', required : false)
+if not libcrypt.found()
+ # fallback to use find_library() if libcrypt is provided by glibc, e.g. for LibreELEC.
+ libcrypt = cc.find_library('crypt')
+endif
- have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
+foreach func : [
+ 'crypt_ra', # since libxcrypt-4.0.0
+ 'crypt_gensalt_ra', # since libxcrypt-4.0.0
+ 'crypt_preferred_method', # since libxcrypt-4.4.0
+]
+
+ have = cc.has_function(func, prefix : '''#include <crypt.h>''', args : '-D_GNU_SOURCE',
dependencies : libcrypt)
- conf.set10('HAVE_' + ident[0].to_upper(), have)
+ conf.set10('HAVE_' + func.to_upper(), have)
endforeach
bpf_framework = get_option('bpf-framework')
/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#if HAVE_CRYPT_H
-/* libxcrypt is a replacement for glibc's libcrypt, and libcrypt might be
- * removed from glibc at some point. As part of the removal, defines for
- * crypt(3) are dropped from unistd.h, and we must include crypt.h instead.
- *
- * Newer versions of glibc (v2.0+) already ship crypt.h with a definition
- * of crypt(3) as well, so we simply include it if it is present. MariaDB,
- * MySQL, PostgreSQL, Perl and some other wide-spread packages do it the
- * same way since ages without any problems.
- */
-# include <crypt.h>
-#else
-# include <unistd.h>
-#endif
-
+#include <crypt.h>
#include <stdlib.h>
#include "alloc-util.h"