diff options
author | Christian Heimes <christian@python.org> | 2021-11-10 19:26:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-10 19:26:55 (GMT) |
commit | 0a9f69539be27acf1cddf1b58d02a88d02e5008d (patch) | |
tree | 45073f51d11b129bd88c0da801c0a23a61e7558f /configure.ac | |
parent | c1323d4b8cb010a06c11bace6e681bea7f895851 (diff) | |
download | cpython-0a9f69539be27acf1cddf1b58d02a88d02e5008d.zip cpython-0a9f69539be27acf1cddf1b58d02a88d02e5008d.tar.gz cpython-0a9f69539be27acf1cddf1b58d02a88d02e5008d.tar.bz2 |
bpo-45747: Detect gdbm/dbm dependencies in configure (GH-29467)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 73 |
1 files changed, 72 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index cfd7184..4817422 100644 --- a/configure.ac +++ b/configure.ac @@ -3094,6 +3094,74 @@ else TCLTK_LIBS="$with_tcltk_libs" fi +# check for _gdbmmodulec dependencies +AC_CHECK_HEADERS([gdbm.h], [ + LIBS_SAVE=$LIBS + AC_CHECK_LIB([gdbm], [gdbm_open]) + LIBS=$LIBS_SAVE +]) + +# check for _dbmmodule.c dependencies +AC_CHECK_HEADERS([ndbm.h], [ + LIBS_SAVE="$LIBS" + AC_CHECK_LIB([ndbm], [dbm_open]) + LIBS="$LIBS_SAVE" + AC_CHECK_LIB([gdbm_compat], [dbm_open]) + LIBS="$LIBS_SAVE" +]) + +# "gdbm-ndbm.h" and "gdbm/ndbm.h" are both normalized to "gdbm_ndbm_h" +# unset ac_cv_header_gdbm_ndbm_h to prevent false positive cache hits. +AS_UNSET([ac_cv_header_gdbm_ndbm_h]) +AC_CACHE_VAL([ac_cv_header_gdbm_slash_ndbm_h], [ + AC_CHECK_HEADER( + [gdbm/ndbm.h], + [ac_cv_header_gdbm_slash_ndbm_h=yes], [ac_cv_header_gdbm_slash_ndbm_h=no] + ) +]) +AS_VAR_IF([ac_cv_header_gdbm_slash_ndbm_h], [yes], [ + AC_DEFINE([HAVE_GDBM_NDBM_H], [1], [Define to 1 if you have the <gdbm/ndbm.h> header file.]) +]) + +AS_UNSET([ac_cv_header_gdbm_ndbm_h]) +AC_CACHE_VAL([ac_cv_header_gdbm_dash_ndbm_h], [ + AC_CHECK_HEADER( + [gdbm-ndbm.h], + [ac_cv_header_gdbm_dash_ndbm_h=yes], [ac_cv_header_gdbm_dash_ndbm_h=no] + ) +]) +AS_VAR_IF([ac_cv_header_gdbm_dash_ndbm_h], [yes], [ + AC_DEFINE([HAVE_GDBM_DASH_NDBM_H], [1], [Define to 1 if you have the <gdbm-ndbm.h> header file.]) +]) +AS_UNSET([ac_cv_header_gdbm_ndbm_h]) + +if test "$ac_cv_header_gdbm_slash_ndbm_h" = yes -o "$ac_cv_header_gdbm_dash_ndbm_h" = yes; then + LIBS_SAVE="$LIBS" + AC_CHECK_LIB([gdbm_compat], [dbm_open]) + LIBS="$LIBS_SAVE" +fi + +# Check for libdb >= 5 with dbm_open() +# db.h re-defines the name of the function +AC_CHECK_HEADERS([db.h], [ + AC_CACHE_CHECK([for libdb], [ac_cv_have_libdb], [ + LIBS_SAVE="$LIBS" + LIBS="$LIBS -ldb" + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + #define DB_DBM_HSEARCH 1 + #include <db.h> + #if DB_VERSION_MAJOR < 5 + #error "dh.h: DB_VERSION_MAJOR < 5 is not supported." + #endif + ], [DBM *dbm = dbm_open(NULL, 0, 0)]) + ], [ac_cv_have_libdb=yes], [ac_cv_have_libdb=no]) + LIBS="$LIBS_SAVE" + ]) + AS_VAR_IF([ac_cv_have_libdb], [yes], [ + AC_DEFINE([HAVE_LIBDB], [1], [Define to 1 if you have the `db' library (-ldb).]) + ]) +]) + # Check for --with-dbmliborder AC_MSG_CHECKING(for --with-dbmliborder) AC_ARG_WITH(dbmliborder, @@ -3103,12 +3171,15 @@ if test x$with_dbmliborder = xyes then AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) else - for db in `echo $with_dbmliborder | sed 's/:/ /g'`; do + as_save_IFS=$IFS + IFS=: + for db in $with_dbmliborder; do if test x$db != xndbm && test x$db != xgdbm && test x$db != xbdb then AC_MSG_ERROR([proper usage is --with-dbmliborder=db1:db2:...]) fi done + IFS=$as_save_IFS fi]) AC_MSG_RESULT($with_dbmliborder) |