From 6ec8f54e92d2ea241dd1b5c1cdc1075c3e045716 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Mon, 3 Aug 2026 14:36:03 +0200 Subject: [PATCH] Add support for linking against `zlib-rs` and `libbzip2-rs` --- Doc/using/configure.rst | 82 ++++- Doc/whatsnew/3.16.rst | 12 + ...-09-25-01-33-12.gh-issue-139314._m9BUl.rst | 9 + configure | 328 +++++++++++++----- configure.ac | 85 ++++- 5 files changed, 416 insertions(+), 100 deletions(-) create mode 100644 Misc/NEWS.d/next/Build/2025-09-25-01-33-12.gh-issue-139314._m9BUl.rst diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst index fd20ff2cb898107..dbf070058e7552c 100644 --- a/Doc/using/configure.rst +++ b/Doc/using/configure.rst @@ -71,7 +71,8 @@ Dependencies to build optional modules are: * - Dependency - Minimum version - Python module - * - `libbz2 `_ + * - `libbz2 `_ or + `libbzip2-rs `_ [1]_ - - :mod:`bz2` * - `libffi `_ @@ -82,47 +83,54 @@ Dependencies to build optional modules are: - :mod:`lzma` * - `libmpdec `_ - 2.5.0 - - :mod:`decimal` [1]_ + - :mod:`decimal` [2]_ * - `libreadline `_ or - `libedit `_ [2]_ + `libedit `_ [3]_ - - :mod:`readline` * - `libuuid `_ - - - ``_uuid`` [3]_ - * - `ncurses `_ [4]_ + - ``_uuid`` [4]_ + * - `ncurses `_ [5]_ - - :mod:`curses` * - `OpenSSL `_ - | 3.0.18 recommended | (1.1.1 minimum) - - :mod:`ssl`, :mod:`hashlib` [5]_ + - :mod:`ssl`, :mod:`hashlib` [6]_ * - `SQLite `_ - 3.15.2 - :mod:`sqlite3` * - `Tcl/Tk `_ - 8.5.12 - :mod:`tkinter`, :ref:`IDLE `, :mod:`turtle` - * - `zlib `_ - - 1.2.2.1 + * - `zlib `_, + `zlib-ng `_, or + `zlib-rs `_ [7]_ + - | 1.2.2.1 (zlib, zlib-ng) + | 0.6.0 (zlib-rs) - :mod:`zlib`, :mod:`gzip`, :mod:`ensurepip` * - `zstd `_ - 1.4.5 - :mod:`compression.zstd` -.. [1] If *libmpdec* is not available, the :mod:`decimal` module will use +.. [1] See :option:`--with-bzip2` for choosing the backend for the + :mod:`bz2` module. +.. [2] If *libmpdec* is not available, the :mod:`decimal` module will use a pure-Python implementation. -.. [2] See :option:`--with-readline` for choosing the backend for the +.. [3] See :option:`--with-readline` for choosing the backend for the :mod:`readline` module. -.. [3] The :mod:`uuid` module uses ``_uuid`` to generate "safe" UUIDs. +.. [4] The :mod:`uuid` module uses ``_uuid`` to generate "safe" UUIDs. See the module documentation for details. -.. [4] The :mod:`curses` module requires the ``libncurses`` or ``libncursesw`` +.. [5] The :mod:`curses` module requires the ``libncurses`` or ``libncursesw`` library. The :mod:`curses.panel` module additionally requires the ``libpanel`` or ``libpanelw`` library. -.. [5] If OpenSSL is not available, the :mod:`hashlib` module will use +.. [6] If OpenSSL is not available, the :mod:`hashlib` module will use bundled implementations of several hash functions. See :option:`--with-builtin-hashlib-hashes` for *forcing* usage of OpenSSL. +.. [7] See :option:`--with-zlib` for choosing the backend for the + :mod:`zlib` module. Note that the table does not include all optional modules; in particular, platform-specific modules like :mod:`winreg` are not listed here. @@ -1113,6 +1121,54 @@ Libraries options .. versionadded:: next +.. option:: --with-zlib=zlib|zlib-ng|zlib-rs + + Designate the zlib implementation to build the :mod:`zlib` module against. + + * ``zlib``: Use the system zlib library, found via ``pkg-config`` or as + ``libz``. + * ``zlib-ng``: Same detection as ``zlib``, but fail unless the detected + library is `zlib-ng `__. + * ``zlib-rs``: Use `zlib-rs + `__, found via + ``pkg-config`` as ``libz_rs``. + + Without this option (or with ``--with-zlib=auto``, the default), the system + zlib is used when found; configure only fails when an implementation was + requested explicitly but cannot be found. + + .. versionadded:: next + +.. option:: --without-zlib + + Don't build the :mod:`zlib` module, even when a zlib library is present + (built by default when one is found). + + .. versionadded:: next + +.. option:: --with-bzip2=bzip2|bzip2-rs + + Designate the bzip2 implementation to build the :mod:`bz2` module against. + + * ``bzip2``: Use the system bzip2 library, found via ``pkg-config`` or as + ``libbz2``. + * ``bzip2-rs``: Use `libbzip2-rs + `__, found via + ``pkg-config`` as ``libbz2_rs``. + + Without this option (or with ``--with-bzip2=auto``, the default), the + system bzip2 is used when found; configure only fails when an + implementation was requested explicitly but cannot be found. + + .. versionadded:: next + +.. option:: --without-bzip2 + + Don't build the :mod:`bz2` module, even when a bzip2 library is present + (built by default when one is found). + + .. versionadded:: next + .. option:: --with-libm=STRING Override ``libm`` math library to *STRING* (default is system-dependent). diff --git a/Doc/whatsnew/3.16.rst b/Doc/whatsnew/3.16.rst index 6e69737768d5e15..a0ab20085f27bea 100644 --- a/Doc/whatsnew/3.16.rst +++ b/Doc/whatsnew/3.16.rst @@ -823,6 +823,18 @@ Build changes (Contributed by Serhiy Storchaka in :gh:`136687`.) +* Add the :option:`--with-zlib` and :option:`--with-bzip2` :program:`configure` + options to select the zlib and bzip2 implementations used to build the + :mod:`zlib` and :mod:`bz2` modules. In addition to the default system + libraries, they can build against `zlib-rs + `__ and `libbzip2-rs + `__, and + ``--with-zlib=zlib-ng`` verifies that the detected zlib is `zlib-ng + `__. :option:`--without-zlib` and + :option:`--without-bzip2` exclude the modules from the build. + + (Contributed by Stan Ulbrych in :gh:`139314`.) + C API changes ============= diff --git a/Misc/NEWS.d/next/Build/2025-09-25-01-33-12.gh-issue-139314._m9BUl.rst b/Misc/NEWS.d/next/Build/2025-09-25-01-33-12.gh-issue-139314._m9BUl.rst new file mode 100644 index 000000000000000..afc78af0d28fc7a --- /dev/null +++ b/Misc/NEWS.d/next/Build/2025-09-25-01-33-12.gh-issue-139314._m9BUl.rst @@ -0,0 +1,9 @@ +Add the :option:`--with-zlib` and :option:`--with-bzip2` :program:`configure` +options to select the zlib and bzip2 implementations used to build the +:mod:`zlib` and :mod:`bz2` modules. In addition to the default system +libraries, they can build against `zlib-rs +`__ and `libbzip2-rs +`__, and +``--with-zlib=zlib-ng`` verifies that the detected zlib is `zlib-ng +`__. :option:`--without-zlib` and +:option:`--without-bzip2` exclude the modules from the build. diff --git a/configure b/configure index 836eb88e4cdb6e5..e005b047eac0998 100755 --- a/configure +++ b/configure @@ -1142,6 +1142,8 @@ with_c_locale_coercion with_valgrind with_dtrace enable_epoll +with_zlib +with_bzip2 with_libm with_libc enable_big_digits @@ -1964,6 +1966,12 @@ Optional Packages: (default is yes) --with-valgrind enable Valgrind support (default is no) --with-dtrace enable DTrace support (default is no) + --with(out)-zlib[=zlib|zlib-ng|zlib-rs|no] + select the zlib implementation to link against, or + disable zlib support (default: auto) + --with(out)-bzip2[=bzip2|bzip2-rs|no] + select the bzip2 implementation to link against, or + disable bzip2 support (default: auto) --with-libm=STRING override libm math library to STRING (default is system-dependent) --with-libc=STRING override libc C library to STRING (default is @@ -22805,6 +22813,30 @@ fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-zlib" >&5 +printf %s "checking for --with-zlib... " >&6; } + +# Check whether --with-zlib was given. +if test ${with_zlib+y} +then : + withval=$with_zlib; case $with_zlib in #( + yes|auto) : + with_zlib=auto ;; #( + zlib|zlib-ng|zlib-rs|no) : + ;; #( + *) : + as_fn_error $? "proper usage is --with(out)-zlib[=zlib|zlib-ng|zlib-rs|no]" "$LINENO" 5 ;; +esac +else case e in #( + e) with_zlib=auto ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_zlib" >&5 +printf "%s\n" "$with_zlib" >&6; } + +case $with_zlib in #( + auto|zlib) : @@ -22817,23 +22849,47 @@ then : fi + ;; #( + *) : + ;; +esac + +if test "x$with_zlib" = xzlib-rs +then : + + zlib_name="libz_rs" + zlib_version="0.6.0" + zlib_libname="z_rs" +else case e in #( + e) + zlib_name="zlib" + zlib_version="1.2.2.1" + zlib_libname="z" + ;; +esac +fi +if test "x$with_zlib" = xno +then : + have_zlib=no +else case e in #( + e) pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for zlib >= 1.2.2.1" >&5 -printf %s "checking for zlib >= 1.2.2.1... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $zlib_name >= $zlib_version" >&5 +printf %s "checking for $zlib_name >= $zlib_version... " >&6; } if test -n "$ZLIB_CFLAGS"; then pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.2.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.2.1") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$zlib_name >= \$zlib_version\""; } >&5 + ($PKG_CONFIG --exists --print-errors "$zlib_name >= $zlib_version") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "zlib >= 1.2.2.1" 2>/dev/null` + pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags "$zlib_name >= $zlib_version" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -22845,12 +22901,12 @@ if test -n "$ZLIB_LIBS"; then pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"zlib >= 1.2.2.1\""; } >&5 - ($PKG_CONFIG --exists --print-errors "zlib >= 1.2.2.1") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$zlib_name >= \$zlib_version\""; } >&5 + ($PKG_CONFIG --exists --print-errors "$zlib_name >= $zlib_version") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "zlib >= 1.2.2.1" 2>/dev/null` + pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs "$zlib_name >= $zlib_version" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -22871,9 +22927,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "zlib >= 1.2.2.1" 2>&1` + ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$zlib_name >= $zlib_version" 2>&1` else - ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "zlib >= 1.2.2.1" 2>&1` + ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$zlib_name >= $zlib_version" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$ZLIB_PKG_ERRORS" >&5 @@ -22895,14 +22951,15 @@ then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 -printf %s "checking for gzread in -lz... " >&6; } -if test ${ac_cv_lib_z_gzread+y} +as_ac_Lib=`printf "%s\n" "ac_cv_lib_$zlib_libname""_gzread" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -l$zlib_libname" >&5 +printf %s "checking for gzread in -l$zlib_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-l$zlib_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22926,9 +22983,9 @@ return gzread (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_z_gzread=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_z_gzread=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -22936,9 +22993,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 -printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } -if test "x$ac_cv_lib_z_gzread" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : have_zlib=yes else case e in #( @@ -22959,16 +23017,17 @@ done then : ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + ZLIB_LIBS=${ZLIB_LIBS-"-l$zlib_libname"} py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 -printf %s "checking for inflateCopy in -lz... " >&6; } -if test ${ac_cv_lib_z_inflateCopy+y} +as_ac_Lib=`printf "%s\n" "ac_cv_lib_$zlib_libname""_inflateCopy" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -l$zlib_libname" >&5 +printf %s "checking for inflateCopy in -l$zlib_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-l$zlib_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -22992,9 +23051,9 @@ return inflateCopy (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_z_inflateCopy=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_z_inflateCopy=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -23002,9 +23061,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 -printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } -if test "x$ac_cv_lib_z_inflateCopy" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h @@ -23042,14 +23102,15 @@ then : printf "%s\n" "#define HAVE_ZLIB_H 1" >>confdefs.h py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -lz" >&5 -printf %s "checking for gzread in -lz... " >&6; } -if test ${ac_cv_lib_z_gzread+y} +as_ac_Lib=`printf "%s\n" "ac_cv_lib_$zlib_libname""_gzread" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gzread in -l$zlib_libname" >&5 +printf %s "checking for gzread in -l$zlib_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-l$zlib_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -23073,9 +23134,9 @@ return gzread (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_z_gzread=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_z_gzread=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -23083,9 +23144,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_gzread" >&5 -printf "%s\n" "$ac_cv_lib_z_gzread" >&6; } -if test "x$ac_cv_lib_z_gzread" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : have_zlib=yes else case e in #( @@ -23106,16 +23168,17 @@ done then : ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} + ZLIB_LIBS=${ZLIB_LIBS-"-l$zlib_libname"} py_check_lib_save_LIBS=$LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -lz" >&5 -printf %s "checking for inflateCopy in -lz... " >&6; } -if test ${ac_cv_lib_z_inflateCopy+y} +as_ac_Lib=`printf "%s\n" "ac_cv_lib_$zlib_libname""_inflateCopy" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for inflateCopy in -l$zlib_libname" >&5 +printf %s "checking for inflateCopy in -l$zlib_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $LIBS" +LIBS="-l$zlib_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -23139,9 +23202,9 @@ return inflateCopy (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_z_inflateCopy=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_z_inflateCopy=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -23149,9 +23212,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_z_inflateCopy" >&5 -printf "%s\n" "$ac_cv_lib_z_inflateCopy" >&6; } -if test "x$ac_cv_lib_z_inflateCopy" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h @@ -23179,8 +23243,53 @@ printf "%s\n" "yes" >&6; } printf "%s\n" "#define HAVE_ZLIB_COPY 1" >>confdefs.h +fi + ;; +esac fi +if test "x$with_zlib" = xzlib-ng +then : + if test "x$have_zlib" = xyes +then : + + save_CFLAGS=$CFLAGS +save_CPPFLAGS=$CPPFLAGS +save_LDFLAGS=$LDFLAGS +save_LIBS=$LIBS + + + CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + ac_fn_check_decl "$LINENO" "ZLIBNG_VERSION" "ac_cv_have_decl_ZLIBNG_VERSION" "#include +" "$ac_c_undeclared_builtin_options" "CFLAGS" +if test "x$ac_cv_have_decl_ZLIBNG_VERSION" = xyes +then : + +else case e in #( + e) as_fn_error $? "--with-zlib=zlib-ng: the detected zlib library is not zlib-ng" "$LINENO" 5 ;; +esac +fi + +CFLAGS=$save_CFLAGS +CPPFLAGS=$save_CPPFLAGS +LDFLAGS=$save_LDFLAGS +LIBS=$save_LIBS + + + +fi +fi + +case $with_zlib in #( + auto|no) : + ;; #( + *) : + if test "x$have_zlib" = xno +then : + as_fn_error $? "--with-zlib=$with_zlib requested but $zlib_name was not found" "$LINENO" 5 +fi ;; +esac + if test "x$have_zlib" = xyes then : @@ -23189,6 +23298,30 @@ then : fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for --with-bzip2" >&5 +printf %s "checking for --with-bzip2... " >&6; } + +# Check whether --with-bzip2 was given. +if test ${with_bzip2+y} +then : + withval=$with_bzip2; case $with_bzip2 in #( + yes|auto) : + with_bzip2=auto ;; #( + bzip2|bzip2-rs|no) : + ;; #( + *) : + as_fn_error $? "proper usage is --with(out)-bzip2[=bzip2|bzip2-rs|no]" "$LINENO" 5 ;; +esac +else case e in #( + e) with_bzip2=auto ;; +esac +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_bzip2" >&5 +printf "%s\n" "$with_bzip2" >&6; } + +case $with_bzip2 in #( + auto|bzip2) : @@ -23201,23 +23334,45 @@ then : fi + ;; #( + *) : + ;; +esac + +if test "x$with_bzip2" = xbzip2-rs +then : + + bzip2_name="libbz2_rs" + bzip2_libname="bz2_rs" +else case e in #( + e) + bzip2_name="bzip2" + bzip2_libname="bz2" + ;; +esac +fi +if test "x$with_bzip2" = xno +then : + have_bzip2=no +else case e in #( + e) pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for bzip2" >&5 -printf %s "checking for bzip2... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $bzip2_name" >&5 +printf %s "checking for $bzip2_name... " >&6; } if test -n "$BZIP2_CFLAGS"; then pkg_cv_BZIP2_CFLAGS="$BZIP2_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bzip2\""; } >&5 - ($PKG_CONFIG --exists --print-errors "bzip2") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$bzip2_name\""; } >&5 + ($PKG_CONFIG --exists --print-errors "$bzip2_name") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_BZIP2_CFLAGS=`$PKG_CONFIG --cflags "bzip2" 2>/dev/null` + pkg_cv_BZIP2_CFLAGS=`$PKG_CONFIG --cflags "$bzip2_name" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -23229,12 +23384,12 @@ if test -n "$BZIP2_LIBS"; then pkg_cv_BZIP2_LIBS="$BZIP2_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bzip2\""; } >&5 - ($PKG_CONFIG --exists --print-errors "bzip2") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"\$bzip2_name\""; } >&5 + ($PKG_CONFIG --exists --print-errors "$bzip2_name") 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then - pkg_cv_BZIP2_LIBS=`$PKG_CONFIG --libs "bzip2" 2>/dev/null` + pkg_cv_BZIP2_LIBS=`$PKG_CONFIG --libs "$bzip2_name" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -23255,9 +23410,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - BZIP2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "bzip2" 2>&1` + BZIP2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$bzip2_name" 2>&1` else - BZIP2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "bzip2" 2>&1` + BZIP2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$bzip2_name" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$BZIP2_PKG_ERRORS" >&5 @@ -23278,14 +23433,15 @@ if test "x$ac_cv_header_bzlib_h" = xyes then : printf "%s\n" "#define HAVE_BZLIB_H 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 -printf %s "checking for BZ2_bzCompress in -lbz2... " >&6; } -if test ${ac_cv_lib_bz2_BZ2_bzCompress+y} + as_ac_Lib=`printf "%s\n" "ac_cv_lib_$bzip2_libname""_BZ2_bzCompress" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -l$bzip2_libname" >&5 +printf %s "checking for BZ2_bzCompress in -l$bzip2_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbz2 $LIBS" +LIBS="-l$bzip2_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -23309,9 +23465,9 @@ return BZ2_bzCompress (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_bz2_BZ2_bzCompress=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_bz2_BZ2_bzCompress=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -23319,9 +23475,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 -printf "%s\n" "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : have_bzip2=yes else case e in #( @@ -23340,7 +23497,7 @@ done then : BZIP2_CFLAGS=${BZIP2_CFLAGS-""} - BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} + BZIP2_LIBS=${BZIP2_LIBS-"-l$bzip2_libname"} fi @@ -23370,14 +23527,15 @@ if test "x$ac_cv_header_bzlib_h" = xyes then : printf "%s\n" "#define HAVE_BZLIB_H 1" >>confdefs.h - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -lbz2" >&5 -printf %s "checking for BZ2_bzCompress in -lbz2... " >&6; } -if test ${ac_cv_lib_bz2_BZ2_bzCompress+y} + as_ac_Lib=`printf "%s\n" "ac_cv_lib_$bzip2_libname""_BZ2_bzCompress" | sed "$as_sed_sh"` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BZ2_bzCompress in -l$bzip2_libname" >&5 +printf %s "checking for BZ2_bzCompress in -l$bzip2_libname... " >&6; } +if eval test \${$as_ac_Lib+y} then : printf %s "(cached) " >&6 else case e in #( e) ac_check_lib_save_LIBS=$LIBS -LIBS="-lbz2 $LIBS" +LIBS="-l$bzip2_libname $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -23401,9 +23559,9 @@ return BZ2_bzCompress (); _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_bz2_BZ2_bzCompress=yes + eval "$as_ac_Lib=yes" else case e in #( - e) ac_cv_lib_bz2_BZ2_bzCompress=no ;; + e) eval "$as_ac_Lib=no" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ @@ -23411,9 +23569,10 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ LIBS=$ac_check_lib_save_LIBS ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_bz2_BZ2_bzCompress" >&5 -printf "%s\n" "$ac_cv_lib_bz2_BZ2_bzCompress" >&6; } -if test "x$ac_cv_lib_bz2_BZ2_bzCompress" = xyes +eval ac_res=\$$as_ac_Lib + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Lib"\" = x"yes" then : have_bzip2=yes else case e in #( @@ -23432,7 +23591,7 @@ done then : BZIP2_CFLAGS=${BZIP2_CFLAGS-""} - BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} + BZIP2_LIBS=${BZIP2_LIBS-"-l$bzip2_libname"} fi @@ -23450,6 +23609,19 @@ else printf "%s\n" "yes" >&6; } have_bzip2=yes fi + ;; +esac +fi + +case $with_bzip2 in #( + auto|no) : + ;; #( + *) : + if test "x$have_bzip2" = xno +then : + as_fn_error $? "--with-bzip2=$with_bzip2 requested but $bzip2_name was not found" "$LINENO" 5 +fi ;; +esac pkg_failed=no diff --git a/configure.ac b/configure.ac index 3a9841b1e7d0747..bd4d806e39238e5 100644 --- a/configure.ac +++ b/configure.ac @@ -5704,10 +5704,34 @@ fi dnl Check for compression libraries AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy]) +AC_MSG_CHECKING([for --with-zlib]) +AC_ARG_WITH( + [zlib], + [AS_HELP_STRING([--with(out)-zlib@<:@=zlib|zlib-ng|zlib-rs|no@:>@], + [select the zlib implementation to link against, or disable + zlib support (default: auto)])], + [AS_CASE([$with_zlib], + [yes|auto], [with_zlib=auto], + [zlib|zlib-ng|zlib-rs|no], [], + [AC_MSG_ERROR([proper usage is --with(out)-zlib@<:@=zlib|zlib-ng|zlib-rs|no@:>@])])], + [with_zlib=auto]) +AC_MSG_RESULT([$with_zlib]) + dnl detect zlib from Emscripten emport -PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB]) +AS_CASE([$with_zlib], [auto|zlib], [PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB])]) + +AS_VAR_IF([with_zlib], [zlib-rs], [ + AS_VAR_SET([zlib_name], ["libz_rs"]) + AS_VAR_SET([zlib_version], ["0.6.0"]) + AS_VAR_SET([zlib_libname], ["z_rs"]) +], [ + AS_VAR_SET([zlib_name], ["zlib"]) + AS_VAR_SET([zlib_version], ["1.2.2.1"]) + AS_VAR_SET([zlib_libname], ["z"]) +]) -PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.2.1], [ +AS_VAR_IF([with_zlib], [no], [have_zlib=no], [ +PKG_CHECK_MODULES([ZLIB], [$zlib_name >= $zlib_version], [ have_zlib=yes dnl zlib 1.2.0 (2003) added inflateCopy AC_DEFINE([HAVE_ZLIB_COPY], [1]) @@ -5716,15 +5740,30 @@ PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.2.1], [ CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" LIBS="$LIBS $ZLIB_LIBS" AC_CHECK_HEADERS([zlib.h], [ - PY_CHECK_LIB([z], [gzread], [have_zlib=yes], [have_zlib=no]) + PY_CHECK_LIB([$zlib_libname], [gzread], [have_zlib=yes], [have_zlib=no]) ], [have_zlib=no]) AS_VAR_IF([have_zlib], [yes], [ ZLIB_CFLAGS=${ZLIB_CFLAGS-""} - ZLIB_LIBS=${ZLIB_LIBS-"-lz"} - PY_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) + ZLIB_LIBS=${ZLIB_LIBS-"-l$zlib_libname"} + PY_CHECK_LIB([$zlib_libname], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])]) ]) ]) ]) +]) + +AS_VAR_IF([with_zlib], [zlib-ng], [AS_VAR_IF([have_zlib], [yes], [ + WITH_SAVE_ENV([ + CPPFLAGS="$CPPFLAGS $ZLIB_CFLAGS" + AC_CHECK_DECL([ZLIBNG_VERSION], [], + [AC_MSG_ERROR([--with-zlib=zlib-ng: the detected zlib library is not zlib-ng])], + [@%:@include ]) + ]) +])]) + +AS_CASE([$with_zlib], + [auto|no], [], + [AS_VAR_IF([have_zlib], [no], + [AC_MSG_ERROR([--with-zlib=$with_zlib requested but $zlib_name was not found])])]) dnl binascii can use zlib for optimized crc32. AS_VAR_IF([have_zlib], [yes], [ @@ -5732,22 +5771,50 @@ AS_VAR_IF([have_zlib], [yes], [ BINASCII_LIBS="$ZLIB_LIBS" ]) +AC_MSG_CHECKING([for --with-bzip2]) +AC_ARG_WITH( + [bzip2], + [AS_HELP_STRING([--with(out)-bzip2@<:@=bzip2|bzip2-rs|no@:>@], + [select the bzip2 implementation to link against, or disable + bzip2 support (default: auto)])], + [AS_CASE([$with_bzip2], + [yes|auto], [with_bzip2=auto], + [bzip2|bzip2-rs|no], [], + [AC_MSG_ERROR([proper usage is --with(out)-bzip2@<:@=bzip2|bzip2-rs|no@:>@])])], + [with_bzip2=auto]) +AC_MSG_RESULT([$with_bzip2]) + dnl detect bzip2 from Emscripten emport -PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2]) +AS_CASE([$with_bzip2], [auto|bzip2], [PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2])]) -PKG_CHECK_MODULES([BZIP2], [bzip2], [have_bzip2=yes], [ +AS_VAR_IF([with_bzip2], [bzip2-rs], [ + AS_VAR_SET([bzip2_name], ["libbz2_rs"]) + AS_VAR_SET([bzip2_libname], ["bz2_rs"]) +], [ + AS_VAR_SET([bzip2_name], ["bzip2"]) + AS_VAR_SET([bzip2_libname], ["bz2"]) +]) + +AS_VAR_IF([with_bzip2], [no], [have_bzip2=no], [ +PKG_CHECK_MODULES([BZIP2], [$bzip2_name], [have_bzip2=yes], [ WITH_SAVE_ENV([ CPPFLAGS="$CPPFLAGS $BZIP2_CFLAGS" LIBS="$LIBS $BZIP2_LIBS" AC_CHECK_HEADERS([bzlib.h], [ - AC_CHECK_LIB([bz2], [BZ2_bzCompress], [have_bzip2=yes], [have_bzip2=no]) + AC_CHECK_LIB([$bzip2_libname], [BZ2_bzCompress], [have_bzip2=yes], [have_bzip2=no]) ], [have_bzip2=no]) AS_VAR_IF([have_bzip2], [yes], [ BZIP2_CFLAGS=${BZIP2_CFLAGS-""} - BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"} + BZIP2_LIBS=${BZIP2_LIBS-"-l$bzip2_libname"} ]) ]) ]) +]) + +AS_CASE([$with_bzip2], + [auto|no], [], + [AS_VAR_IF([have_bzip2], [no], + [AC_MSG_ERROR([--with-bzip2=$with_bzip2 requested but $bzip2_name was not found])])]) PKG_CHECK_MODULES([LIBLZMA], [liblzma], [have_liblzma=yes], [ WITH_SAVE_ENV([