From a797374f220c5958f20a4f630083294dae4165b8 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Mon, 8 May 2023 12:25:59 +0300 Subject: [PATCH] Support for libpcre2posix * Makefile.am (ACLOCAL_AMFLAGS): New variable. * NEWS: Document changes. * README.md: Likewise. * acinclude.m4: Rename to am/ax_pthread.m4 * am/pcreposix.m4: New file. * configure.ac: Use PND_PCREPOSIX macro. * src/Makefile.am: Update. * src/pound.h: Include pcre2posix.h if available. --- Makefile.am | 2 + NEWS | 4 +- README.md | 10 +++-- acinclude.m4 => am/ax_pthread.m4 | 0 am/pcreposix.m4 | 73 ++++++++++++++++++++++++++++++++ configure.ac | 28 ++++-------- src/Makefile.am | 4 +- src/pound.h | 4 +- 8 files changed, 98 insertions(+), 27 deletions(-) rename acinclude.m4 => am/ax_pthread.m4 (100%) create mode 100644 am/pcreposix.m4 diff --git a/Makefile.am b/Makefile.am index 5f45434..bef14ae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,6 +18,8 @@ SUBDIRS = src tests doc EXTRA_DIST = ChangeLog.apsis +ACLOCAL_AMFLAGS = -I am + if FROM_GIT README: README.md perl md2txt.pl -o README -l 4 README.md diff --git a/NEWS b/NEWS index 5f51c39..8387634 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -Pound -- history of user-visible changes. 2023-04-19 +Pound -- history of user-visible changes. 2023-05-08 See the end of file for copying conditions. Pound is a continuation of the software originally developed by @@ -7,6 +7,8 @@ on 2022-09-19. See the README.md file for details. Please send pound bug reports to +* Support for libpcre2-posix + Version 4.7, 2023-04-17 * Default include directory diff --git a/README.md b/README.md index 0b24c90..fea6dc6 100644 --- a/README.md +++ b/README.md @@ -120,12 +120,14 @@ configuration options: * `--enable-pcreposix` or `--disable-pcreposix` - Enable or disable the use of the `pcreposix` library. This is a - library that makes it possible to use both POSIX extended and - Perl-compatible regular expressions in __pound__ configuration + Enable or disable the use of the `libpcreposix2` or `libpcreposix` + library. This is a library that makes it possible to use both POSIX + extended and Perl-compatible regular expressions in __pound__ configuration file. - By default, its presence is determined automatically. + By default, its presence is determined automatically; `libpcreposix2` + is preferred over `libpcreposix`. To force compiling with the older + `libpcreposix`, use `--enable-pcreposix=pcre1`. * `--enable-pthread-cancel-probe` or `--disable-pthread-cancel-probe` diff --git a/acinclude.m4 b/am/ax_pthread.m4 similarity index 100% rename from acinclude.m4 rename to am/ax_pthread.m4 diff --git a/am/pcreposix.m4 b/am/pcreposix.m4 new file mode 100644 index 0000000..2e5f38d --- /dev/null +++ b/am/pcreposix.m4 @@ -0,0 +1,73 @@ +# SYNOPSIS +# +# PND_PCREPOSIX +# +# DESCRIPTION +# +# Checks whether the pcreposix library and its headers are available. +# Prefers libpcre2 over libpcre. The --enable-pcreposix option can +# be used to enable, disable, or force the use of libpcre verison 1 +# (--enable-pcreposix=pcre1). Upon return, the status_pcreposix shell +# variable is set to indicate the result: +# +# . no - neither library has been found +# . 1 - libpcre is found +# . 2 - libpcre2 is found +# +# On success, the HAVE_LIBPCREPOSIX m4 macro is defined to the version +# of the library used (1 or 2). +# +# Substitution variables PCREPOSIX_CFLAGS and PCREPOSIX_LIBS are defined +# to compiler and loader flags needed in order to build with the version +# of the library located. +# +# LICENSE +# +# Copyright (C) 2023 Sergey Poznyakoff +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +AC_DEFUN([PND_PCREPOSIX], +[AC_ARG_ENABLE([pcreposix], + [AS_HELP_STRING([--enable-pcreposix],[enable or disable using the pcreposix library (default: enabled if available)])], + [status_pcreposix=${enableval}], + [status_pcreposix=yes]) + + AH_TEMPLATE([HAVE_LIBPCREPOSIX],[Define to the version of libpcreposix to use]) + + AC_SUBST([PCREPOSIX_CFLAGS]) + AC_SUBST([PCREPOSIX_LIBS]) + if test "$status_pcreposix" != no; then + AC_PATH_PROG([PCRE2_CONFIG],[pcre2-config],[]) + if test "$status_pcreposix" != pcre1 && test -n "$PCRE2_CONFIG"; then + PCREPOSIX_CFLAGS=$($PCRE2_CONFIG --cflags-posix) + PCREPOSIX_LIBS=$($PCRE2_CONFIG --libs-posix) + status_pcreposix=2 + else + AC_CHECK_HEADERS([pcreposix.h pcre/pcreposix.h]) + AC_CHECK_LIB([pcre],[pcre_compile], + [PCREPOSIX_LIBS=-lpcre + AC_CHECK_LIB([pcreposix],[regcomp], + [PCREPOSIX_LIBS="$PCREPOSIX_LIBS -lpcreposix" + status_pcreposix=1], + [status_pcreposix=no], + [$PCREPOSIX_LIBS])], + [status_pcreposix=no]) + fi + + case "$status_pcreposix" in + 1|2) AC_DEFINE_UNQUOTED([HAVE_LIBPCREPOSIX],[$status_pcreposix]) + esac + fi +]) diff --git a/configure.ac b/configure.ac index b57d83d..0eec280 100644 --- a/configure.ac +++ b/configure.ac @@ -14,13 +14,13 @@ # # You should have received a copy of the GNU General Public License # along with pound. If not, see . -AC_PREREQ([2.69]) +AC_PREREQ([2.71]) AC_INIT([pound],[4.7],[gray@gnu.org], [pound],[https://github.com/graygnuorg/pound]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_SRCDIR([src/pound.c]) AC_CONFIG_HEADERS([config.h]) -AM_INIT_AUTOMAKE([1.15 gnu tar-ustar]) +AM_INIT_AUTOMAKE([1.16.5 gnu tar-ustar]) AC_CANONICAL_HOST # Checks for programs. @@ -93,11 +93,6 @@ AC_ARG_WITH([group], [AS_HELP_STRING([--with-group=name],[The group that will own the files installed by Pound])], [I_GRP="${with_group}"]) -AC_ARG_ENABLE([pcreposix], - [AS_HELP_STRING([--enable-pcreposix],[enable or disable using the pcreposix library (default: enabled if available)])], - [status_pcreposix=${enableval}], - [status_pcreposix=yes]) - AC_ARG_ENABLE([tcmalloc], [AS_HELP_STRING([--enable-tcmalloc],[enable or disable using the tcmalloc library (default: enabled if available)])], [status_tcmalloc=${enableval}], @@ -158,18 +153,9 @@ AM_CONDITIONAL([SET_DH_AUTO],[test "$SET_DH_AUTO" = 1]) AC_DEFINE_UNQUOTED([SET_DH_AUTO],[$SET_DH_AUTO], [Define to 1 of *set_dh_auto macros are available]) -if test "$status_pcreposix" != no; then - AC_CHECK_LIB([pcre],[pcre_compile]) - AC_CHECK_LIB([pcreposix],[regcomp]) - if test $ac_cv_lib_pcreposix_regcomp = yes; then - status_pcreposix=yes - AC_DEFINE([HAVE_LIBPCREPOSIX],[1],[Define if compiling with libpcreposix]) - else - status_pcreposix=no - fi -fi +PND_PCREPOSIX -AC_CHECK_HEADERS([getopt.h pthread.h openssl/ssl.h openssl/engine.h pcreposix.h pcre/pcreposix.h]) +AC_CHECK_HEADERS([getopt.h pthread.h openssl/ssl.h openssl/engine.h]) AC_TYPE_UID_T AC_TYPE_PID_T @@ -231,7 +217,11 @@ EOF [bufsize=$MAXBUF owner_user=$I_OWNER owner_group=$I_GRP -status_pcreposix=$status_pcreposix +if test $status_pcreposix != no; then + status_pcreposix=pcre$status_pcreposix +else + status_pcreposix=$status_pcreposix +fi memory_allocator=$memory_allocator if test "$early_pthread_cancel_probe" = 1; then status_pthread_cancel_probe=yes diff --git a/src/Makefile.am b/src/Makefile.am index b69a171..bdac686 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,12 +17,12 @@ AM_CFLAGS = @PTHREAD_CFLAGS@ -AM_CPPFLAGS = @SSL_CPPFLAGS@ \ +AM_CPPFLAGS = @SSL_CPPFLAGS@ @PCREPOSIX_CFLAGS@ \ -DSYSCONFDIR=\"$(sysconfdir)\"\ -DLOCALSTATEDIR=\"$(localstatedir)\"\ -DPKGDATADIR=\"$(pkgdatadir)\" AM_LDFLAGS = @SSL_LDFLAGS@ -LDADD = libpound.a @PTHREAD_LIBS@ +LDADD = libpound.a @PCREPOSIX_LIBS@ @PTHREAD_LIBS@ sbin_PROGRAMS=pound pound_SOURCES=\ diff --git a/src/pound.h b/src/pound.h index bf2d7ae..9226854 100644 --- a/src/pound.h +++ b/src/pound.h @@ -90,7 +90,9 @@ # include #endif -#if HAVE_LIBPCREPOSIX +#if HAVE_LIBPCREPOSIX == 2 +# include +#elif HAVE_LIBPCREPOSIX == 1 # if HAVE_PCREPOSIX_H # include # elif HAVE_PCRE_PCREPOSIX_H