Improve and simplify function and header detection logic.
Simplify autoconf checks by using AC_CHECK_FUNCS/HEADERS. Clarify some ambiguous dependencies around strnlen/strndup. Unconditionally enable pidwraptest for all arc4random implementations. Remove HAVE_VASPRINTF conditional, since asprintf requires vasprintf. ok @doug
This commit is contained in:
parent
727bccd093
commit
a4cc953911
@ -10,6 +10,6 @@ openssl_LDADD += $(top_builddir)/crypto/libcrypto.la
|
||||
openssl_SOURCES =
|
||||
noinst_HEADERS =
|
||||
|
||||
if NO_STRTONUM
|
||||
if !HAVE_STRTONUM
|
||||
openssl_SOURCES += strtonum.c
|
||||
endif
|
||||
|
95
configure.ac
95
configure.ac
@ -58,75 +58,26 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
|
||||
)
|
||||
CFLAGS="$save_cflags $AM_CFLAGS"
|
||||
|
||||
AC_CHECK_FUNC(strlcpy,
|
||||
AM_CONDITIONAL(NO_STRLCPY, false),
|
||||
AC_DEFINE(NO_STRLCPY)
|
||||
AM_CONDITIONAL(NO_STRLCPY, true))
|
||||
AC_CHECK_FUNCS([arc4random_buf asprintf explicit_bzero funopen getauxval])
|
||||
AC_CHECK_FUNCS([getentropy issetugid memmem reallocarray])
|
||||
AC_CHECK_FUNCS([strlcat strlcpy strndup strnlen strtonum])
|
||||
AC_CHECK_FUNCS([timingsafe_bcmp timingsafe_memcmp])
|
||||
|
||||
AC_CHECK_FUNC(strlcat,
|
||||
AM_CONDITIONAL(NO_STRLCAT, false),
|
||||
AC_DEFINE(NO_STRLCAT)
|
||||
AM_CONDITIONAL(NO_STRLCAT, true))
|
||||
|
||||
AC_CHECK_FUNC(strndup,
|
||||
AM_CONDITIONAL(NO_STRNDUP, false),
|
||||
AC_DEFINE(NO_STRNDUP)
|
||||
AM_CONDITIONAL(NO_STRNDUP, true))
|
||||
|
||||
AC_CHECK_FUNC(strnlen,
|
||||
AM_CONDITIONAL(NO_STRNLEN, false),
|
||||
AC_DEFINE(NO_STRNLEN)
|
||||
AM_CONDITIONAL(NO_STRNLEN, true))
|
||||
|
||||
AC_CHECK_FUNC(asprintf,
|
||||
AM_CONDITIONAL(NO_ASPRINTF, false),
|
||||
AC_DEFINE(NO_ASPRINTF)
|
||||
AM_CONDITIONAL(NO_ASPRINTF, true))
|
||||
|
||||
AC_CHECK_FUNC(reallocarray,
|
||||
AM_CONDITIONAL(NO_REALLOCARRAY, false),
|
||||
AC_DEFINE(NO_REALLOCARRAY)
|
||||
AM_CONDITIONAL(NO_REALLOCARRAY, true))
|
||||
|
||||
AC_CHECK_FUNC(timingsafe_bcmp,
|
||||
AM_CONDITIONAL(NO_TIMINGSAFE_BCMP, false),
|
||||
AC_DEFINE(NO_TIMINGSAFE_BCMP)
|
||||
AM_CONDITIONAL(NO_TIMINGSAFE_BCMP, true))
|
||||
|
||||
AC_CHECK_FUNC(timingsafe_memcmp,
|
||||
AM_CONDITIONAL(NO_TIMINGSAFE_MEMCMP, false),
|
||||
AC_DEFINE(NO_TIMINGSAFE_MEMCMP)
|
||||
AM_CONDITIONAL(NO_TIMINGSAFE_MEMCMP, true))
|
||||
|
||||
AC_CHECK_FUNC(arc4random_buf,
|
||||
AM_CONDITIONAL(NO_ARC4RANDOM_BUF, false),
|
||||
AC_DEFINE(NO_ARC4RANDOM_BUF)
|
||||
AM_CONDITIONAL(NO_ARC4RANDOM_BUF, true))
|
||||
|
||||
AC_CHECK_FUNC(getentropy,
|
||||
AM_CONDITIONAL(NO_GETENTROPY, false),
|
||||
AC_DEFINE(NO_GETENTROPY)
|
||||
AM_CONDITIONAL(NO_GETENTROPY, true))
|
||||
|
||||
AC_CHECK_FUNC(issetugid,
|
||||
AM_CONDITIONAL(NO_ISSETUGID, false),
|
||||
AC_DEFINE(NO_ISSETUGID)
|
||||
AM_CONDITIONAL(NO_ISSETUGID, true))
|
||||
|
||||
AC_CHECK_FUNC(strtonum,
|
||||
AM_CONDITIONAL(NO_STRTONUM, false),
|
||||
AC_DEFINE(NO_STRTONUM)
|
||||
AM_CONDITIONAL(NO_STRTONUM, true))
|
||||
|
||||
AC_CHECK_FUNC(memmem,
|
||||
AM_CONDITIONAL(NO_MEMMEM, false),
|
||||
AC_DEFINE(NO_MEMMEM)
|
||||
AM_CONDITIONAL(NO_MEMMEM, true))
|
||||
|
||||
AC_CHECK_FUNC(explicit_bzero,
|
||||
AM_CONDITIONAL(NO_EXPLICIT_BZERO, false),
|
||||
AC_DEFINE(NO_EXPLICIT_BZERO)
|
||||
AM_CONDITIONAL(NO_EXPLICIT_BZERO, true))
|
||||
# Share test results with automake
|
||||
AM_CONDITIONAL([HAVE_ARC4RANDOM_BUF], [test "x$ac_cv_func_arc4random_buf" = xyes])
|
||||
AM_CONDITIONAL([HAVE_ASPRINTF], [test "x$ac_cv_func_asprintf" = xyes])
|
||||
AM_CONDITIONAL([HAVE_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" = xyes])
|
||||
AM_CONDITIONAL([HAVE_GETENTROPY], [test "x$ac_cv_func_getentropy" = xyes])
|
||||
AM_CONDITIONAL([HAVE_ISSETUGID], [test "x$ac_cv_func_issetugid" = xyes])
|
||||
AM_CONDITIONAL([HAVE_MEMMEM], [test "x$ac_cv_func_memmem" = xyes])
|
||||
AM_CONDITIONAL([HAVE_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" = xyes])
|
||||
AM_CONDITIONAL([HAVE_STRLCAT], [test "x$ac_cv_func_strlcat" = xyes])
|
||||
AM_CONDITIONAL([HAVE_STRLCPY], [test "x$ac_cv_func_strlcpy" = xyes])
|
||||
AM_CONDITIONAL([HAVE_STRNDUP], [test "x$ac_cv_func_strndup" = xyes])
|
||||
AM_CONDITIONAL([HAVE_STRNLEN], [test "x$ac_cv_func_strnlen" = xyes])
|
||||
AM_CONDITIONAL([HAVE_STRTONUM], [test "x$ac_cv_func_strtonum" = xyes])
|
||||
AM_CONDITIONAL([HAVE_TIMINGSAFE_BCMP], [test "x$ac_cv_func_timingsafe_bcmp" = xyes])
|
||||
AM_CONDITIONAL([HAVE_TIMINGSAFE_MEMCMP], [test "x$ac_cv_func_timingsafe_memcmp" = xyes])
|
||||
|
||||
AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
||||
@ -153,13 +104,7 @@ if test "x$ac_cv_have___va_copy" = "xyes" ; then
|
||||
AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNC(getauxval, AC_DEFINE(HAVE_GETAUXVAL))
|
||||
|
||||
AC_CHECK_FUNC(funopen, AC_DEFINE(HAVE_FUNOPEN))
|
||||
|
||||
AC_CHECK_HEADER(sys/sysctl.h, AC_DEFINE(HAVE_SYS_SYSCTL_H))
|
||||
|
||||
AC_CHECK_HEADER(err.h, AC_DEFINE(HAVE_ERR_H))
|
||||
AC_CHECK_HEADERS([sys/sysctl.h err.h])
|
||||
|
||||
AC_ARG_WITH([openssldir],
|
||||
AS_HELP_STRING([--with-openssldir], [Set the default openssl directory]),
|
||||
|
@ -16,7 +16,7 @@ noinst_LTLIBRARIES = libcompat.la libcompatnoopt.la
|
||||
libcompatnoopt_la_CFLAGS = -O0
|
||||
libcompatnoopt_la_SOURCES =
|
||||
|
||||
if NO_EXPLICIT_BZERO
|
||||
if !HAVE_EXPLICIT_BZERO
|
||||
libcompatnoopt_la_SOURCES += compat/explicit_bzero.c
|
||||
endif
|
||||
|
||||
@ -25,41 +25,42 @@ libcompat_la_CFLAGS = $(CFLAGS) $(USER_CFLAGS)
|
||||
libcompat_la_SOURCES =
|
||||
libcompat_la_LIBADD = $(PLATFORM_LDADD)
|
||||
|
||||
if NO_STRLCAT
|
||||
if !HAVE_STRLCAT
|
||||
libcompat_la_SOURCES += compat/strlcat.c
|
||||
endif
|
||||
|
||||
if NO_STRLCPY
|
||||
if !HAVE_STRLCPY
|
||||
libcompat_la_SOURCES += compat/strlcpy.c
|
||||
endif
|
||||
|
||||
if NO_STRNDUP
|
||||
if !HAVE_STRNDUP
|
||||
libcompat_la_SOURCES += compat/strndup.c
|
||||
if NO_STRNLEN
|
||||
# the only user of strnlen is strndup, so only build it if needed
|
||||
if !HAVE_STRNLEN
|
||||
libcompat_la_SOURCES += compat/strnlen.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if NO_ASPRINTF
|
||||
if !HAVE_ASPRINTF
|
||||
libcompat_la_SOURCES += compat/bsd-asprintf.c
|
||||
endif
|
||||
|
||||
if NO_REALLOCARRAY
|
||||
if !HAVE_REALLOCARRAY
|
||||
libcompat_la_SOURCES += compat/reallocarray.c
|
||||
endif
|
||||
|
||||
if NO_TIMINGSAFE_MEMCMP
|
||||
if !HAVE_TIMINGSAFE_MEMCMP
|
||||
libcompat_la_SOURCES += compat/timingsafe_memcmp.c
|
||||
endif
|
||||
|
||||
if NO_TIMINGSAFE_BCMP
|
||||
if !HAVE_TIMINGSAFE_BCMP
|
||||
libcompat_la_SOURCES += compat/timingsafe_bcmp.c
|
||||
endif
|
||||
|
||||
if NO_ARC4RANDOM_BUF
|
||||
if !HAVE_ARC4RANDOM_BUF
|
||||
libcompat_la_SOURCES += compat/arc4random.c
|
||||
|
||||
if NO_GETENTROPY
|
||||
if !HAVE_GETENTROPY
|
||||
if HOST_LINUX
|
||||
libcompat_la_SOURCES += compat/getentropy_linux.c
|
||||
endif
|
||||
@ -76,7 +77,7 @@ endif
|
||||
|
||||
endif
|
||||
|
||||
if NO_ISSETUGID
|
||||
if !HAVE_ISSETUGID
|
||||
if HOST_LINUX
|
||||
libcompat_la_SOURCES += compat/issetugid_linux.c
|
||||
endif
|
||||
|
@ -17,7 +17,7 @@
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef HAVE_VASPRINTF
|
||||
#ifndef HAVE_ASPRINTF
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h> /* for INT_MAX */
|
||||
@ -80,9 +80,7 @@ fail:
|
||||
errno = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_ASPRINTF
|
||||
int asprintf(char **str, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#ifndef LIBCRYPTOCOMPAT_STDIO_H
|
||||
#define LIBCRYPTOCOMPAT_STDIO_H
|
||||
|
||||
#ifdef NO_ASPRINTF
|
||||
#ifndef HAVE_ASPRINTF
|
||||
#include <stdarg.h>
|
||||
int vasprintf(char **str, const char *fmt, va_list ap);
|
||||
int asprintf(char **str, const char *fmt, ...);
|
||||
|
@ -7,16 +7,16 @@
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef NO_ARC4RANDOM_BUF
|
||||
#ifndef HAVE_ARC4RANDOM_BUF
|
||||
uint32_t arc4random(void);
|
||||
void arc4random_buf(void *_buf, size_t n);
|
||||
#endif
|
||||
|
||||
#ifdef NO_REALLOCARRAY
|
||||
#ifndef HAVE_REALLOCARRAY
|
||||
void *reallocarray(void *, size_t, size_t);
|
||||
#endif
|
||||
|
||||
#ifdef NO_STRTONUM
|
||||
#ifndef HAVE_STRTONUM
|
||||
long long strtonum(const char *nptr, long long minval,
|
||||
long long maxval, const char **errstr);
|
||||
#endif
|
||||
|
@ -12,34 +12,35 @@
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
#ifdef NO_STRLCPY
|
||||
#ifndef HAVE_STRLCPY
|
||||
size_t strlcpy(char *dst, const char *src, size_t siz);
|
||||
#endif
|
||||
|
||||
#ifdef NO_STRLCAT
|
||||
#ifndef HAVE_STRLCAT
|
||||
size_t strlcat(char *dst, const char *src, size_t siz);
|
||||
#endif
|
||||
|
||||
#ifdef NO_STRNDUP
|
||||
#ifndef HAVE_STRNDUP
|
||||
char * strndup(const char *str, size_t maxlen);
|
||||
#ifdef NO_STRNLEN
|
||||
/* the only user of strnlen is strndup, so only build it if needed */
|
||||
#ifndef HAVE_STRNLEN
|
||||
size_t strnlen(const char *str, size_t maxlen);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NO_EXPLICIT_BZERO
|
||||
#ifndef HAVE_EXPLICIT_BZERO
|
||||
void explicit_bzero(void *, size_t);
|
||||
#endif
|
||||
|
||||
#ifdef NO_TIMINGSAFE_BCMP
|
||||
#ifndef HAVE_TIMINGSAFE_BCMP
|
||||
int timingsafe_bcmp(const void *b1, const void *b2, size_t n);
|
||||
#endif
|
||||
|
||||
#ifdef NO_TIMINGSAFE_MEMCMP
|
||||
#ifndef HAVE_TIMINGSAFE_MEMCMP
|
||||
int timingsafe_memcmp(const void *b1, const void *b2, size_t len);
|
||||
#endif
|
||||
|
||||
#ifdef NO_MEMMEM
|
||||
#ifndef HAVE_MEMMEM
|
||||
void * memmem(const void *big, size_t big_len, const void *little,
|
||||
size_t little_len);
|
||||
#endif
|
||||
|
@ -3,11 +3,11 @@
|
||||
#ifndef LIBCRYPTOCOMPAT_UNISTD_H
|
||||
#define LIBCRYPTOCOMPAT_UNISTD_H
|
||||
|
||||
#ifdef NO_GETENTROPY
|
||||
#ifndef HAVE_GETENTROPY
|
||||
int getentropy(void *buf, size_t buflen);
|
||||
#endif
|
||||
|
||||
#ifdef NO_ISSETUGID
|
||||
#ifndef HAVE_ISSETUGID
|
||||
int issetugid(void);
|
||||
#endif
|
||||
|
||||
|
@ -9,7 +9,3 @@ LDADD += $(top_builddir)/crypto/libcrypto.la
|
||||
TESTS =
|
||||
check_PROGRAMS =
|
||||
EXTRA_DIST =
|
||||
|
||||
if !NO_ARC4RANDOM_BUF
|
||||
TESTS += pidwraptest.sh
|
||||
endif
|
||||
|
@ -305,7 +305,6 @@ test_drivers=(
|
||||
# disabled by-default tests
|
||||
tests_disabled=(
|
||||
biotest
|
||||
pidwraptest
|
||||
)
|
||||
$CP $libc_src/string/memmem.c tests/
|
||||
(cd tests
|
||||
@ -319,7 +318,7 @@ $CP $libc_src/string/memmem.c tests/
|
||||
echo "check_PROGRAMS += $TEST" >> Makefile.am
|
||||
echo "${TEST}_SOURCES = $i" >> Makefile.am
|
||||
done
|
||||
echo "if NO_MEMMEM" >> Makefile.am
|
||||
echo "if !HAVE_MEMMEM" >> Makefile.am
|
||||
echo "explicit_bzero_SOURCES += memmem.c" >> Makefile.am
|
||||
echo "endif" >> Makefile.am
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user