summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2021-11-09 15:42:53 (GMT)
committerGitHub <noreply@github.com>2021-11-09 15:42:53 (GMT)
commit5b7c7cb104163a178e9d70cb3c80cbfa6af8fbfc (patch)
tree6a4539f3ca532d6664d57857497994137bad2ba1
parent185533639d6eddd42a28f9e3517067bd877e34c5 (diff)
downloadcpython-5b7c7cb104163a178e9d70cb3c80cbfa6af8fbfc.zip
cpython-5b7c7cb104163a178e9d70cb3c80cbfa6af8fbfc.tar.gz
cpython-5b7c7cb104163a178e9d70cb3c80cbfa6af8fbfc.tar.bz2
bpo-45763: Detect compression build deps in configure (GH-29483)
-rw-r--r--Doc/whatsnew/3.11.rst3
-rw-r--r--Misc/NEWS.d/next/Build/2021-11-09-10-15-33.bpo-45763.gP-vrX.rst2
-rwxr-xr-xconfigure186
-rw-r--r--configure.ac23
-rw-r--r--pyconfig.h.in18
-rw-r--r--setup.py9
6 files changed, 230 insertions, 11 deletions
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 7b15ace..27062f6 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -524,6 +524,9 @@ Build Changes
(Contributed by Brett Cannon and Christian Heimes in :issue:`45548`,
:issue:`45570`, :issue:`45571`, and :issue:`43974`.)
+* The build dependencies for :mod:`zlib`, :mod:`bz2`, and :mod:`lzma` are now
+ detected by :program:`configure`.
+ (Contributed by Christian Heimes in :issue:`45763`.)
C API Changes
=============
diff --git a/Misc/NEWS.d/next/Build/2021-11-09-10-15-33.bpo-45763.gP-vrX.rst b/Misc/NEWS.d/next/Build/2021-11-09-10-15-33.bpo-45763.gP-vrX.rst
new file mode 100644
index 0000000..1d09ae7
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2021-11-09-10-15-33.bpo-45763.gP-vrX.rst
@@ -0,0 +1,2 @@
+The build dependencies for :mod:`zlib`, :mod:`bz2`, and :mod:`lzma` are now
+detected by ``configure``.
diff --git a/configure b/configure
index 45ac189..a1f5e53 100755
--- a/configure
+++ b/configure
@@ -12884,8 +12884,62 @@ $as_echo "#define HAVE_LCHFLAGS 1" >>confdefs.h
fi
-# Check for compression libraries
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5
+for ac_header in zlib.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_zlib_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_ZLIB_H 1
+_ACEOF
+
+ save_LIBS="$LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5
+$as_echo_n "checking for gzread in -lz... " >&6; }
+if ${ac_cv_lib_z_gzread+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lz $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gzread ();
+int
+main ()
+{
+return gzread ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_z_gzread=yes
+else
+ ac_cv_lib_z_gzread=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5
+$as_echo "$ac_cv_lib_z_gzread" >&6; }
+if test "x$ac_cv_lib_z_gzread" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBZ 1
+_ACEOF
+
+ LIBS="-lz $LIBS"
+
+fi
+
+ LIBS="$save_LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5
$as_echo_n "checking for inflateCopy in -lz... " >&6; }
if ${ac_cv_lib_z_inflateCopy+:} false; then :
$as_echo_n "(cached) " >&6
@@ -12927,6 +12981,134 @@ $as_echo "#define HAVE_ZLIB_COPY 1" >>confdefs.h
fi
+ LIBS="$save_LIBS"
+
+fi
+
+done
+
+
+for ac_header in bzlib.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "bzlib.h" "ac_cv_header_bzlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_bzlib_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_BZLIB_H 1
+_ACEOF
+
+ save_LIBS="$LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5
+$as_echo_n "checking for BZ2_bzCompress in -lbz2... " >&6; }
+if ${ac_cv_lib_bz2_BZ2_bzCompress+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbz2 $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char BZ2_bzCompress ();
+int
+main ()
+{
+return BZ2_bzCompress ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_bz2_BZ2_bzCompress=yes
+else
+ ac_cv_lib_bz2_BZ2_bzCompress=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5
+$as_echo "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; }
+if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBBZ2 1
+_ACEOF
+
+ LIBS="-lbz2 $LIBS"
+
+fi
+
+ LIBS="$save_LIBS"
+
+fi
+
+done
+
+
+for ac_header in lzma.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "lzma.h" "ac_cv_header_lzma_h" "$ac_includes_default"
+if test "x$ac_cv_header_lzma_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LZMA_H 1
+_ACEOF
+
+ save_LIBS="$LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzma_easy_encoder in -llzma" >&5
+$as_echo_n "checking for lzma_easy_encoder in -llzma... " >&6; }
+if ${ac_cv_lib_lzma_lzma_easy_encoder+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-llzma $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char lzma_easy_encoder ();
+int
+main ()
+{
+return lzma_easy_encoder ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_lzma_lzma_easy_encoder=yes
+else
+ ac_cv_lib_lzma_lzma_easy_encoder=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzma_lzma_easy_encoder" >&5
+$as_echo "$ac_cv_lib_lzma_lzma_easy_encoder" >&6; }
+if test "x$ac_cv_lib_lzma_lzma_easy_encoder" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBLZMA 1
+_ACEOF
+
+ LIBS="-llzma $LIBS"
+
+fi
+
+ LIBS="$save_LIBS"
+
+fi
+
+done
+
diff --git a/configure.ac b/configure.ac
index 7361d89..a7e5f2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3830,9 +3830,26 @@ if test "$ac_cv_have_lchflags" = yes ; then
AC_DEFINE(HAVE_LCHFLAGS, 1, [Define to 1 if you have the 'lchflags' function.])
fi
-# Check for compression libraries
-dnl Check if system zlib has *Copy() functions
-AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy]))
+dnl Check for compression libraries
+AC_CHECK_HEADERS([zlib.h], [
+ save_LIBS="$LIBS"
+ AC_CHECK_LIB([z], [gzread])
+ LIBS="$save_LIBS"
+ AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE(HAVE_ZLIB_COPY, 1, [Define if the zlib library has inflateCopy])])
+ LIBS="$save_LIBS"
+])
+
+AC_CHECK_HEADERS([bzlib.h], [
+ save_LIBS="$LIBS"
+ AC_CHECK_LIB([bz2], [BZ2_bzCompress])
+ LIBS="$save_LIBS"
+])
+
+AC_CHECK_HEADERS([lzma.h], [
+ save_LIBS="$LIBS"
+ AC_CHECK_LIB([lzma], [lzma_easy_encoder])
+ LIBS="$save_LIBS"
+])
PY_CHECK_FUNC([hstrerror], [#include <netdb.h>])
diff --git a/pyconfig.h.in b/pyconfig.h.in
index 45617f2..2f71dd1 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -124,6 +124,9 @@
/* Has builtin __atomic_load_n() and __atomic_store_n() functions */
#undef HAVE_BUILTIN_ATOMIC
+/* Define to 1 if you have the <bzlib.h> header file. */
+#undef HAVE_BZLIB_H
+
/* Define to 1 if you have the 'chflags' function. */
#undef HAVE_CHFLAGS
@@ -580,6 +583,9 @@
/* Define to 1 if you have the `lchown' function. */
#undef HAVE_LCHOWN
+/* Define to 1 if you have the `bz2' library (-lbz2). */
+#undef HAVE_LIBBZ2
+
/* Define to 1 if you have the `dl' library (-ldl). */
#undef HAVE_LIBDL
@@ -592,6 +598,9 @@
/* Define to 1 if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
+/* Define to 1 if you have the `lzma' library (-llzma). */
+#undef HAVE_LIBLZMA
+
/* Define to build the readline module. */
#undef HAVE_LIBREADLINE
@@ -607,6 +616,9 @@
/* Define to 1 if you have the `uuid' library (-luuid). */
#undef HAVE_LIBUUID
+/* Define to 1 if you have the `z' library (-lz). */
+#undef HAVE_LIBZ
+
/* Define if you have the 'link' function. */
#undef HAVE_LINK
@@ -670,6 +682,9 @@
/* Define to 1 if you have the `lutimes' function. */
#undef HAVE_LUTIMES
+/* Define to 1 if you have the <lzma.h> header file. */
+#undef HAVE_LZMA_H
+
/* Define to 1 if you have the `madvise' function. */
#undef HAVE_MADVISE
@@ -1342,6 +1357,9 @@
/* Define if the zlib library has inflateCopy */
#undef HAVE_ZLIB_COPY
+/* Define to 1 if you have the <zlib.h> header file. */
+#undef HAVE_ZLIB_H
+
/* Define to 1 if you have the `_getpty' function. */
#undef HAVE__GETPTY
diff --git a/setup.py b/setup.py
index b125c51..7fe7d27 100644
--- a/setup.py
+++ b/setup.py
@@ -1634,10 +1634,7 @@ class PyBuildExt(build_ext):
def detect_compress_exts(self):
# Andrew Kuchling's zlib module.
- have_zlib = (
- find_file('zlib.h', self.inc_dirs, []) is not None and
- self.compiler.find_library_file(self.lib_dirs, 'z')
- )
+ have_zlib = sysconfig.get_config_var("HAVE_LIBZ")
if have_zlib:
self.add(Extension('zlib', ['zlibmodule.c'],
libraries=['z']))
@@ -1657,14 +1654,14 @@ class PyBuildExt(build_ext):
libraries=libraries))
# Gustavo Niemeyer's bz2 module.
- if (self.compiler.find_library_file(self.lib_dirs, 'bz2')):
+ if sysconfig.get_config_var("HAVE_LIBBZ2"):
self.add(Extension('_bz2', ['_bz2module.c'],
libraries=['bz2']))
else:
self.missing.append('_bz2')
# LZMA compression support.
- if self.compiler.find_library_file(self.lib_dirs, 'lzma'):
+ if sysconfig.get_config_var("HAVE_LIBLZMA"):
self.add(Extension('_lzma', ['_lzmamodule.c'],
libraries=['lzma']))
else: