Skip to content

Commit

Permalink
Support for libpcre2posix
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
graygnuorg committed May 8, 2023
1 parent 11e05de commit a797374
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -7,6 +7,8 @@ on 2022-09-19. See the README.md file for details.

Please send pound bug reports to <gray@gnu.org>

* Support for libpcre2-posix

Version 4.7, 2023-04-17

* Default include directory
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
File renamed without changes.
73 changes: 73 additions & 0 deletions am/pcreposix.m4
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.

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
])
28 changes: 9 additions & 19 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#
# You should have received a copy of the GNU General Public License
# along with pound. If not, see <http://www.gnu.org/licenses/>.
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.
Expand Down Expand Up @@ -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}],
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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=\
Expand Down
4 changes: 3 additions & 1 deletion src/pound.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@
# include <openssl/engine.h>
#endif

#if HAVE_LIBPCREPOSIX
#if HAVE_LIBPCREPOSIX == 2
# include <pcre2posix.h>
#elif HAVE_LIBPCREPOSIX == 1
# if HAVE_PCREPOSIX_H
# include <pcreposix.h>
# elif HAVE_PCRE_PCREPOSIX_H
Expand Down

0 comments on commit a797374

Please sign in to comment.