summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2022-07-18 06:46:49 (GMT)
committerGitHub <noreply@github.com>2022-07-18 06:46:49 (GMT)
commit30412d91b6bfb4c973dbfd5cbe2c2e2f7d9e0563 (patch)
treedafc7f66881004539a6b126e08191f05614fa6c3 /configure.ac
parente747562345238cefd68ef6581feb17707a3a06ff (diff)
downloadcpython-30412d91b6bfb4c973dbfd5cbe2c2e2f7d9e0563.zip
cpython-30412d91b6bfb4c973dbfd5cbe2c2e2f7d9e0563.tar.gz
cpython-30412d91b6bfb4c973dbfd5cbe2c2e2f7d9e0563.tar.bz2
[3.11] gh-94801: Use custom flags to check for headers and libs (GH-94802) (GH-94881)
Co-authored-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac132
1 files changed, 88 insertions, 44 deletions
diff --git a/configure.ac b/configure.ac
index a12d143..695576a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,6 +49,48 @@ AC_DEFUN([WITH_SAVE_ENV],
[RESTORE_ENV]
)dnl
+dnl PY_CHECK_FUNC(FUNCTION, [INCLUDES], [AC_DEFINE-VAR])
+AC_DEFUN([PY_CHECK_FUNC],
+[ AS_VAR_PUSHDEF([py_var], [ac_cv_func_$1])
+ AS_VAR_PUSHDEF([py_define], m4_ifblank([$3], [[HAVE_]m4_toupper($1)], [$3]))
+ AC_CACHE_CHECK(
+ [for $1],
+ [py_var],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([$2], [void *x=$1])],
+ [AS_VAR_SET([py_var], [yes])],
+ [AS_VAR_SET([py_var], [no])])]
+ )
+ AS_VAR_IF(
+ [py_var],
+ [yes],
+ [AC_DEFINE([py_define], [1], [Define if you have the '$1' function.])])
+ AS_VAR_POPDEF([py_var])
+ AS_VAR_POPDEF([py_define])
+])
+
+dnl PY_CHECK_LIB(LIBRARY, FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], [OTHER-LIBRARIES])
+dnl Like AC_CHECK_LIB() but does not modify LIBS
+AC_DEFUN([PY_CHECK_LIB],
+[AS_VAR_COPY([py_check_lib_save_LIBS], [LIBS])]
+[AC_CHECK_LIB($1, $2, $3, $4, $5)]
+[AS_VAR_COPY([LIBS], [py_check_lib_save_LIBS])]
+)
+
+dnl PY_CHECK_EMSCRIPTEN_PORT(PKG_VAR, [EMPORT_ARGS])
+dnl Use Emscripten port unless user passes ${PKG_VAR}_CFLAGS
+dnl or ${PKG_VAR}_LIBS to configure.
+AC_DEFUN([PY_CHECK_EMSCRIPTEN_PORT], [
+ AS_VAR_PUSHDEF([py_cflags], [$1_CFLAGS])
+ AS_VAR_PUSHDEF([py_libs], [$1_LIBS])
+ AS_IF([test "$ac_sys_system" = "Emscripten" -a -z "$py_cflags" -a -z "$py_libs"], [
+ py_cflags="$2"
+ py_libs="$2"
+ ])
+ AS_VAR_POPDEF([py_cflags])
+ AS_VAR_POPDEF([py_libs])
+])
+
AC_SUBST(BASECPPFLAGS)
if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then
# If we're building out-of-tree, we need to make sure the following
@@ -3335,12 +3377,12 @@ AS_VAR_IF([have_uuid], [missing], [
AC_DEFINE([HAVE_UUID_H], [1])
AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE], [1])
], [
- AC_CHECK_HEADERS([uuid/uuid.h], [
- WITH_SAVE_ENV(
- [AC_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes])
- ])
- WITH_SAVE_ENV([
- AC_CHECK_LIB([uuid], [uuid_generate_time_safe], [
+ WITH_SAVE_ENV([
+ CPPFLAGS="$CFLAGS $LIBUUID_CFLAGS"
+ LDFLAGS="$LDFLAGS $LIBUUID_LIBS"
+ AC_CHECK_HEADERS([uuid/uuid.h], [
+ PY_CHECK_LIB([uuid], [uuid_generate_time], [have_uuid=yes])
+ PY_CHECK_LIB([uuid], [uuid_generate_time_safe], [
have_uuid=yes
AC_DEFINE([HAVE_UUID_GENERATE_TIME_SAFE], [1])
])
@@ -3694,6 +3736,9 @@ AS_CASE([$ac_sys_system],
[OSSAUDIODEV_LIBS=""]
)
+dnl detect sqlite3 from Emscripten emport
+PY_CHECK_EMSCRIPTEN_PORT([LIBSQLITE3], [-sUSE_SQLITE3])
+
dnl Check for SQLite library. Use pkg-config if available.
PKG_CHECK_MODULES(
[LIBSQLITE3], [sqlite3 >= 3.7.15], [], [
@@ -4675,64 +4720,63 @@ fi
dnl Check for compression libraries
AH_TEMPLATE([HAVE_ZLIB_COPY], [Define if the zlib library has inflateCopy])
+dnl detect zlib from Emscripten emport
+PY_CHECK_EMSCRIPTEN_PORT([ZLIB], [-sUSE_ZLIB])
+
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0], [
have_zlib=yes
dnl zlib 1.2.0 (2003) added inflateCopy
AC_DEFINE([HAVE_ZLIB_COPY], [1])
], [
- AC_CHECK_HEADERS([zlib.h], [
- WITH_SAVE_ENV([
- AC_CHECK_LIB([z], [gzread], [
- have_zlib=yes
- ZLIB_CFLAGS=${ZLIB_CFLAGS-""}
- ZLIB_LIBS=${ZLIB_LIBS-"-lz"}
- AC_CHECK_LIB([z], [inflateCopy], [AC_DEFINE([HAVE_ZLIB_COPY], [1])])
- ], [
- have_zlib=no
- ])
+ WITH_SAVE_ENV([
+ CPPFLAGS="$CFLAGS $ZLIB_CFLAGS"
+ LDFLAGS="$LDFLAGS $ZLIB_LIBS"
+ AC_CHECK_HEADERS([zlib.h], [
+ PY_CHECK_LIB([z], [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])])
])
- ], [have_zlib=no])
+ ])
])
-if test "$have_zlib" = "yes" -a "$ac_sys_system" = "Emscripten" -a "$ZLIB_LIBS" = "-lz"; then
- ZLIB_CFLAGS="-sUSE_ZLIB"
- ZLIB_LIBS="-sUSE_ZLIB"
-fi
-
dnl binascii can use zlib for optimized crc32.
AS_VAR_IF([have_zlib], [yes], [
BINASCII_CFLAGS="-DUSE_ZLIB_CRC32 $ZLIB_CFLAGS"
BINASCII_LIBS="$ZLIB_LIBS"
])
+dnl detect bzip2 from Emscripten emport
+PY_CHECK_EMSCRIPTEN_PORT([BZIP2], [-sUSE_BZIP2])
+
PKG_CHECK_MODULES([BZIP2], [bzip2], [have_bzip2=yes], [
- AC_CHECK_HEADERS([bzlib.h], [
- WITH_SAVE_ENV([
- AC_CHECK_LIB([bz2], [BZ2_bzCompress], [
- have_bzip2=yes
- BZIP2_CFLAGS=${BZIP2_CFLAGS-""}
- BZIP2_LIBS=${BZIP2_LIBS-"-lbz2"}
- ], [have_bzip2=no])
+ WITH_SAVE_ENV([
+ CPPFLAGS="$CFLAGS $BZIP2_CFLAGS"
+ LDFLAGS="$LDFLAGS $BZIP2_LIBS"
+ AC_CHECK_HEADERS([bzlib.h], [
+ AC_CHECK_LIB([bz2], [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"}
])
- ], [have_bzip2=no])
+ ])
])
-if test "$have_bzip2" = "yes" -a "$ac_sys_system" = "Emscripten" -a "$BZIP2_LIBS" = "-lbz2"; then
- BZIP2_CFLAGS="-sUSE_BZIP2"
- BZIP2_LIBS="-sUSE_BZIP2"
-fi
-
-
PKG_CHECK_MODULES([LIBLZMA], [liblzma], [have_liblzma=yes], [
- AC_CHECK_HEADERS([lzma.h], [
- WITH_SAVE_ENV([
- AC_CHECK_LIB([lzma], [lzma_easy_encoder], [
- have_liblzma=yes
- LIBLZMA_CFLAGS=${LIBLZMA_CFLAGS-""}
- LIBLZMA_LIBS=${LIBLZMA_LIBS-"-llzma"}
- ], [have_liblzma=no])
+ WITH_SAVE_ENV([
+ CPPFLAGS="$CFLAGS $LIBLZMA_CFLAGS"
+ LDFLAGS="$LDFLAGS $LIBLZMA_LIBS"
+ AC_CHECK_HEADERS([lzma.h], [
+ AC_CHECK_LIB([lzma], [lzma_easy_encoder], [have_liblzma=yes], [have_liblzma=no])
+ ], [have_liblzma=no])
+ AS_VAR_IF([have_liblzma], [yes], [
+ LIBLZMA_CFLAGS=${LIBLZMA_CFLAGS-""}
+ LIBLZMA_LIBS=${LIBLZMA_LIBS-"-llzma"}
])
- ], [have_liblzma=no])
+ ])
])
PY_CHECK_FUNC([hstrerror], [#include <netdb.h>])