diff options
author | Christian Heimes <christian@python.org> | 2021-11-23 21:26:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 21:26:50 (GMT) |
commit | 095bc8f0d6845dded8f67fbc6eca20dfac8b3929 (patch) | |
tree | 2fc5b7e663019beefe3be19b6c127f79bd22ed18 /configure.ac | |
parent | f840398a5fd8741653c26eb8641c48656c9800d4 (diff) | |
download | cpython-095bc8f0d6845dded8f67fbc6eca20dfac8b3929.zip cpython-095bc8f0d6845dded8f67fbc6eca20dfac8b3929.tar.gz cpython-095bc8f0d6845dded8f67fbc6eca20dfac8b3929.tar.bz2 |
bpo-45847: Port _crypt to PY_STDLIB_MOD (GH-29725)
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/configure.ac b/configure.ac index e539d3b..0008e8a 100644 --- a/configure.ac +++ b/configure.ac @@ -4190,25 +4190,46 @@ AC_CHECK_FUNCS(setpgrp, []) ) -# We search for both crypt and crypt_r as one or the other may be defined -# This gets us our -lcrypt in LIBS when required on the target platform. -# Save/restore LIBS to avoid linking libpython with libcrypt. -LIBS_SAVE=$LIBS -AC_SEARCH_LIBS(crypt_r, crypt) -LIBS="$LIBS_SAVE" -AC_SEARCH_LIBS(crypt, crypt) +dnl We search for both crypt and crypt_r as one or the other may be defined +dnl libxcrypt provides <crypt.h> and libcrypt with crypt_r() since +dnl at least 3.1.1 from 2015. +dnl FreeBSD defines crypt_r() in <unistd.h> +AH_TEMPLATE([HAVE_CRYPT_R], [Define if you have the crypt_r() function.]) + +PKG_CHECK_MODULES([LIBCRYPT], [libxcrypt >= 3.1.1], [ + AC_DEFINE([HAVE_CRYPT_R], [1]) +], [ + WITH_SAVE_ENV([ + AC_SEARCH_LIBS([crypt_r], [crypt], [ + AC_DEFINE([HAVE_CRYPT_R], [1]) + if test "$ac_cv_search_crypt_r" = "none required"; then + LIBCRYPT_LIBS= + else + LIBCRYPT_LIBS="$ac_cv_search_crypt_r" + fi + ]) + ]) +]) -AC_CHECK_FUNC(crypt_r, - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include <crypt.h> -]], [[ -struct crypt_data d; -char *r = crypt_r("", "", &d); -]])], - [AC_DEFINE(HAVE_CRYPT_R, 1, [Define if you have the crypt_r() function.])], - []) -) -LIBS=$LIBS_SAVE +WITH_SAVE_ENV([ + CPPFLAGS="$LIBCRYPT_CFLAGS $CFLAGS" + LDFLAGS="$LIBCRYPT_LIBS $LDFLAGS" + AC_CACHE_CHECK([for crypt or crypt_r], [ac_cv_crypt_crypt], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + #ifdef HAVE_CRYPT_H + #include <crypt.h> + #endif + #include <unistd.h> + ], [ + #ifdef HAVE_CRYPT_R + void *x = crypt_r; + #else + void *x = crypt; + #endif + ]) + ], [ac_cv_crypt_crypt=yes], [ac_cv_crypt_crypt=no]) + ]) +]) AC_CHECK_FUNCS(clock_gettime, [], [ AC_CHECK_LIB(rt, clock_gettime, [ @@ -6202,6 +6223,9 @@ PY_STDLIB_MOD([_sha512], [test "$with_builtin_sha512" = yes]) PY_STDLIB_MOD([_sha3], [test "$with_builtin_sha3" = yes]) PY_STDLIB_MOD([_blake2], [test "$with_builtin_blake2" = yes]) +PY_STDLIB_MOD([_crypt], + [], [test "$ac_cv_crypt_crypt" = yes], + [$LIBCRYPT_CFLAGS], [$LIBCRYPT_LIBS]) PY_STDLIB_MOD([_decimal], [], [], [$LIBMPDEC_CFLAGS], [$LIBMPDEC_LDFLAGS]) PY_STDLIB_MOD([nis], [], [test "$have_nis" = yes -a "$ac_cv_header_rpc_rpc_h" = yes], |