[squid-dev] [PATCH] configure.ac cleanup of BerkleyDB related checks

Amos Jeffries squid3 at treenet.co.nz
Mon Mar 27 13:57:46 UTC 2017


While looking into the last remaining bits of bug 4610 I have found that
most of what we were doing for libdb / -ldb is not necessary any longer.

Most of the logic seems to be hangovers from when session helper was
using the BerkleyDB v1.85 compatibility interface. Some of it is
possibly still necessary for the time_quota helper, but that helper has
not been using it so far and needs an upgrade to match what happened to
session helper.

Changes:

* The helpers needing -ldb will not be built unless the library and
headers are available. So we can drop the Makefile LIB_DB substitutions
and always just link -ldb explicitly to these helpers.

NP: Anyone who needs small minimal binaries, can build with the
--as-needed linker flag, or without these helpers. This change has no
effect on other helpers or the main squid binary.

* Since we no longer need to check if -ldb is necessary, we can drop the
configure.ac and acinclude logic detecting that.

* Remove unused AC_CHECK_DECL(dbopen, ...)
 - resolves one "FIXME"

* Fix the time_quota helper check to only scan db.h header file contents
if that file is existing, and if the db_185.h file is not being used
instead.

* Fix the session helper check to only try compiling with the db.h
header if that header actually exists.

* De-duplicate the library header file detection shared by configure.ac
and the helpers required.m4 files (after the above two changes).

* Remove unused DBLIB variable from configure.ac.

Amos

-------------- next part --------------
=== modified file 'acinclude/lib-checks.m4'
--- acinclude/lib-checks.m4	2017-01-01 00:12:22 +0000
+++ acinclude/lib-checks.m4	2017-03-27 12:39:53 +0000
@@ -1,54 +1,27 @@
 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
 ##
 ## Squid software is distributed under GPLv2+ license and includes
 ## contributions from numerous individuals and organizations.
 ## Please see the COPYING and CONTRIBUTORS files for details.
 ##
 
-dnl checks whether dbopen needs -ldb to be added to libs
-dnl sets ac_cv_dbopen_libdb to either "yes" or "no"
-
-AC_DEFUN([SQUID_CHECK_DBOPEN_NEEDS_LIBDB],[
-  AC_CACHE_CHECK(if dbopen needs -ldb,ac_cv_dbopen_libdb, [
-    SQUID_STATE_SAVE(dbopen_libdb)
-    LIBS="$LIBS -ldb"
-    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#if HAVE_DB_185_H
-#include <db_185.h>
-#elif HAVE_DB_H
-#include <db.h>
-#endif]], 
-[[dbopen("", 0, 0, DB_HASH, (void *)0L)]])],
-    [ac_cv_dbopen_libdb="yes"],
-    [ac_cv_dbopen_libdb="no"])
-    SQUID_STATE_ROLLBACK(dbopen_libdb)
-  ])
-])
-
-
 dnl check whether regex works by actually compiling one
 dnl sets squid_cv_regex_works to either yes or no
 
 AC_DEFUN([SQUID_CHECK_REGEX_WORKS],[
   AC_CACHE_CHECK([if the system-supplied regex lib actually works],squid_cv_regex_works,[
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #if HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #if HAVE_REGEX_H
 #include <regex.h> 
 #endif
 ]], [[
 regex_t t; regcomp(&t,"",0);]])],
     [ squid_cv_regex_works=yes ],
     [ squid_cv_regex_works=no ])
   ])
 ])
 
 

=== modified file 'configure.ac'
--- configure.ac	2017-01-13 05:14:03 +0000
+++ configure.ac	2017-03-27 12:16:04 +0000
@@ -2794,42 +2794,40 @@
   sys/shm.h \
   sys/socket.h \
   sys/stat.h \
   syscall.h \
   sys/syscall.h \
   sys/time.h \
   sys/types.h \
   sys/uio.h \
   sys/un.h \
   sys/vfs.h \
   sys/wait.h \
   syslog.h \
   time.h \
   unistd.h \
   utime.h \
   varargs.h \
   byteswap.h \
   glib.h \
   stdint.h \
   inttypes.h \
-  db.h \
-  db_185.h \
   wchar.h
 )
 
 AC_CHECK_HEADERS( \
   linux/netfilter_ipv4.h \
   linux/netfilter_ipv6/ip6_tables.h \
 ,,,
 SQUID_DEFAULT_INCLUDES
 #if HAVE_LIMITS_H
 #include <limits.h>
 #endif
 /* Netfilter ip(6)tables v1.4.0 has broken headers */
 #if HAVE_NETINET_IN_H
 #include <netinet/in.h>
 #endif
 )
 
 dnl *BSD dont include the dependencies for all their net/ and netinet/ files
 dnl We must include a few basic type headers for them to work.
 AC_CHECK_HEADERS( \
@@ -3129,66 +3127,40 @@
   SQUID_CHECK_SIN6_LEN_IN_SAI
 fi
 SQUID_CHECK_SS_LEN_IN_SOCKADDR_STORAGE
 SQUID_CHECK_SIN_LEN_IN_SOCKADDR_IN
 
 
 dnl Check for libdl, used by auth_modules/PAM
 if test "x$with_dl" = "xyes"; then
     AC_CHECK_LIB(dl, dlopen)
 fi
 
 dnl -lintl is needed on SCO version 3.2v4.2 for strftime()
 dnl Robert Side <rside at aiinc.bc.ca>
 dnl Mon, 18 Jan 1999 17:48:00 GMT
 case "$host" in
 	*-pc-sco3.2*)
 		AC_CHECK_LIB(intl, strftime)
 		;;
 esac
 
-dnl Check for libdb
-dnl this is not fully functional if db.h is for a differend db version
-DBLIB=
-
-dnl check that dbopen is actually defined in the header
-dnl FIXME: in case of failure undef db-related includes etc.
-AC_CHECK_DECL(dbopen,,,[
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#if HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#if HAVE_DB_185_H
-#include <db_185.h>
-#elif HAVE_DB_H
-#include <db.h>
-#endif])
-
-dnl 1.85
-SQUID_CHECK_DBOPEN_NEEDS_LIBDB
-if test "x$ac_cv_dbopen_libdb" = "xyes"; then
-    LIB_DB="-ldb"
-fi
-AC_SUBST(LIB_DB)
-
 dnl System-specific library modifications
 dnl
 case "$host" in
   i386-*-solaris2.*)
     if test "x$GCC" = "xyes"; then
       AC_MSG_NOTICE([Removing -O for gcc on $host])
       CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9g]]*//'`"
     fi
   ;;
 
   *-sgi-irix*)
     AC_MSG_NOTICE([Removing -lsocket for IRIX...])
     LIBS=`echo $LIBS | sed -e s/-lsocket//`
     AC_MSG_NOTICE([Removing -lnsl for IRIX...])
     LIBS=`echo $LIBS | sed -e s/-lnsl//`
     ac_cv_lib_nsl_main=no
     AC_MSG_NOTICE([Removing -lbsd for IRIX...])
     LIBS=`echo $LIBS | sed -e s/-lbsd//`
   ;;
 dnl From: c0032033 at ws.rz.tu-bs.de (Joerg Schumacher)

=== modified file 'src/acl/external/session/Makefile.am'
--- src/acl/external/session/Makefile.am	2017-01-01 00:12:22 +0000
+++ src/acl/external/session/Makefile.am	2017-03-27 12:38:33 +0000
@@ -1,19 +1,19 @@
 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
 ##
 ## Squid software is distributed under GPLv2+ license and includes
 ## contributions from numerous individuals and organizations.
 ## Please see the COPYING and CONTRIBUTORS files for details.
 ##
 
 include $(top_srcdir)/src/Common.am
 
 libexec_PROGRAMS= ext_session_acl
 man_MANS= ext_session_acl.8
 
 ext_session_acl_SOURCES= \
 	ext_session_acl.cc
 ext_session_acl_LDADD = \
 	$(COMPAT_LIB) \
-	$(LIB_DB)
+	-ldb
 
 EXTRA_DIST= ext_session_acl.8 required.m4

=== modified file 'src/acl/external/session/required.m4'
--- src/acl/external/session/required.m4	2017-01-01 00:12:22 +0000
+++ src/acl/external/session/required.m4	2017-03-27 12:41:08 +0000
@@ -1,8 +1,15 @@
 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
 ##
 ## Squid software is distributed under GPLv2+ license and includes
 ## contributions from numerous individuals and organizations.
 ## Please see the COPYING and CONTRIBUTORS files for details.
 ##
 
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <db.h>]],[[DB_ENV *db_env = NULL; db_env_create(&db_env, 0);]])],[BUILD_HELPER="session"],[])
+AC_CHECK_HEADERS(db.h,[
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <db.h>]],[[
+    DB_ENV *db_env = nullptr;
+    db_env_create(&db_env, 0);
+  ]])],[
+    BUILD_HELPER="session"
+  ],[])
+])

=== modified file 'src/acl/external/time_quota/Makefile.am'
--- src/acl/external/time_quota/Makefile.am	2017-01-01 00:12:22 +0000
+++ src/acl/external/time_quota/Makefile.am	2017-03-27 12:40:40 +0000
@@ -1,21 +1,21 @@
 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
 ##
 ## Squid software is distributed under GPLv2+ license and includes
 ## contributions from numerous individuals and organizations.
 ## Please see the COPYING and CONTRIBUTORS files for details.
 ##
 
 include $(top_srcdir)/src/Common.am
 
 libexec_PROGRAMS= ext_time_quota_acl
 man_MANS= ext_time_quota_acl.8
 
 DEFS += -DDEFAULT_QUOTA_DB=\"$(localstatedir)/ext_time_quota.db\"
 
 ext_time_quota_acl_SOURCES= \
 	ext_time_quota_acl.cc
 ext_time_quota_acl_LDADD = \
 	$(COMPAT_LIB) \
-	$(LIB_DB)
+	-ldb
 
 EXTRA_DIST= ext_time_quota_acl.8 required.m4

=== modified file 'src/acl/external/time_quota/required.m4'
--- src/acl/external/time_quota/required.m4	2017-01-01 00:12:22 +0000
+++ src/acl/external/time_quota/required.m4	2017-03-27 12:39:29 +0000
@@ -1,9 +1,12 @@
 ## Copyright (C) 1996-2017 The Squid Software Foundation and contributors
 ##
 ## Squid software is distributed under GPLv2+ license and includes
 ## contributions from numerous individuals and organizations.
 ## Please see the COPYING and CONTRIBUTORS files for details.
 ##
 
-AC_CHECK_HEADERS([db_185.h],[BUILD_HELPER="time_quota"])
-AC_EGREP_HEADER([dbopen],[/usr/include/db.h],[BUILD_HELPER="time_quota"])
+AC_CHECK_HEADERS(db_185.h,[BUILD_HELPER="time_quota"],[
+  AC_CHECK_HEADERS(db.h,[
+    AC_EGREP_HEADER([dbopen],[/usr/include/db.h],[BUILD_HELPER="time_quota"])
+  ])
+])



More information about the squid-dev mailing list