summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-11-22 08:05:06 (GMT)
committerGitHub <noreply@github.com>2021-11-22 08:05:06 (GMT)
commitdb2277a114463d30a58d9066f2b47f7a53a1488c (patch)
treeea170cb169f303f82732b3b9e26b79c7a8268600 /configure.ac
parentd2b55b07d2b503dcd3b5c0e2753efa835cff8e8f (diff)
downloadcpython-db2277a114463d30a58d9066f2b47f7a53a1488c.zip
cpython-db2277a114463d30a58d9066f2b47f7a53a1488c.tar.gz
cpython-db2277a114463d30a58d9066f2b47f7a53a1488c.tar.bz2
bpo-45723: Add helpers for save/restore env (GH-29637)
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac78
1 files changed, 48 insertions, 30 deletions
diff --git a/configure.ac b/configure.ac
index e263993..63df518 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,6 +23,32 @@ m4_ifdef(
[AC_MSG_ERROR([Please install pkgconf's m4 macro package and re-run autoreconf])]
)dnl
+dnl Helpers for saving and restoring environment variables:
+dnl - _SAVE_VAR([VAR]) Helper for SAVE_ENV; stores VAR as save_VAR
+dnl - _RESTORE_VAR([VAR]) Helper for RESTORE_ENV; restores VAR from save_VAR
+dnl - SAVE_ENV Saves CFLAGS, LDFLAGS, LIBS, and CPPFLAGS
+dnl - RESTORE_ENV Restores CFLAGS, LDFLAGS, LIBS, and CPPFLAGS
+dnl - WITH_SAVE_ENV([SCRIPT]) Runs SCRIPT wrapped with SAVE_ENV/RESTORE_ENV
+AC_DEFUN([_SAVE_VAR], [AS_VAR_COPY([save_][$1], [$1])])dnl
+AC_DEFUN([_RESTORE_VAR], [AS_VAR_COPY([$1], [save_][$1])])dnl
+AC_DEFUN([SAVE_ENV],
+[_SAVE_VAR([CFLAGS])]
+[_SAVE_VAR([CPPFLAGS])]
+[_SAVE_VAR([LDFLAGS])]
+[_SAVE_VAR([LIBS])]
+)dnl
+AC_DEFUN([RESTORE_ENV],
+[_RESTORE_VAR([CFLAGS])]
+[_RESTORE_VAR([CPPFLAGS])]
+[_RESTORE_VAR([LDFLAGS])]
+[_RESTORE_VAR([LIBS])]
+)dnl
+AC_DEFUN([WITH_SAVE_ENV],
+[SAVE_ENV]
+[$1]
+[RESTORE_ENV]
+)dnl
+
AC_SUBST(BASECPPFLAGS)
if test "$srcdir" != . -a "$srcdir" != "$(pwd)"; then
# If we're building out-of-tree, we need to make sure the following
@@ -3174,37 +3200,29 @@ PKG_CHECK_MODULES(
)
AS_VAR_APPEND([LIBSQLITE3_CFLAGS], [' -I$(srcdir)/Modules/_sqlite'])
+WITH_SAVE_ENV(
dnl bpo-45774/GH-29507: The CPP check in AC_CHECK_HEADER can fail on FreeBSD,
-dnl hence CPPFLAGS instead of CFLAGS. We still need to save CFLAGS, because it
-dnl is touched by AC_CHECK_HEADER.
-AS_VAR_COPY([save_CFLAGS], [CFLAGS])
-AS_VAR_COPY([save_CPPFLAGS], [CPPFLAGS])
-AS_VAR_COPY([save_LDFLAGS], [LDFLAGS])
-AS_VAR_COPY([save_LIBS], [LIBS])
-CPPFLAGS="$LIBSQLITE3_CFLAGS $CFLAGS"
-LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS"
-
-AC_CHECK_HEADER([sqlite3.h], [
- AC_CHECK_LIB([sqlite3], [sqlite3_open_v2], [
- have_sqlite3=yes
- AC_COMPILE_IFELSE([
- AC_LANG_PROGRAM([
- #include <sqlite3.h>
- #if SQLITE_VERSION_NUMBER < 3007015
- # error "SQLite 3.7.15 or higher required"
- #endif
- ], [])
- ], [have_supported_sqlite3=yes], [have_supported_sqlite3=no])
- ], [have_sqlite3=no])
- AC_CHECK_LIB([sqlite3], [sqlite3_load_extension],
- [have_sqlite3_load_extension=yes],
- [have_sqlite3_load_extension=no])
-])
-
-AS_VAR_COPY([CFLAGS], [save_CFLAGS])
-AS_VAR_COPY([CPPFLAGS], [save_CPPFLAGS])
-AS_VAR_COPY([LDFLAGS], [save_LDFLAGS])
-AS_VAR_COPY([LIBS], [save_LIBS])
+dnl hence CPPFLAGS instead of CFLAGS.
+ CPPFLAGS="$LIBSQLITE3_CFLAGS $CFLAGS"
+ LDFLAGS="$LIBSQLITE3_LIBS $LDFLAGS"
+
+ AC_CHECK_HEADER([sqlite3.h], [
+ AC_CHECK_LIB([sqlite3], [sqlite3_open_v2], [
+ have_sqlite3=yes
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ #include <sqlite3.h>
+ #if SQLITE_VERSION_NUMBER < 3007015
+ # error "SQLite 3.7.15 or higher required"
+ #endif
+ ], [])
+ ], [have_supported_sqlite3=yes], [have_supported_sqlite3=no])
+ ], [have_sqlite3=no])
+ AC_CHECK_LIB([sqlite3], [sqlite3_load_extension],
+ [have_sqlite3_load_extension=yes],
+ [have_sqlite3_load_extension=no])
+ ])
+)
# Check for support for loadable sqlite extensions
AC_MSG_CHECKING(for --enable-loadable-sqlite-extensions)