zsh: backport PCRE2 patches and move to it
[feed/packages.git] / utils / zsh / patches / 005-51877-do-not-build-pcre-module-if-pcre2-config-is-no.patch
1 From 10bdbd8b5b0b43445aff23dcd412f25cf6aa328a Mon Sep 17 00:00:00 2001
2 From: Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
3 Date: Tue, 20 Jun 2023 18:14:27 +0900
4 Subject: [PATCH] 51877: do not build pcre module if pcre2-config is not found
5
6 ---
7 ChangeLog | 5 +++++
8 Src/Modules/pcre.mdd | 2 +-
9 configure.ac | 31 +++++++++++++++++++------------
10 3 files changed, 25 insertions(+), 13 deletions(-)
11
12 # diff --git a/ChangeLog b/ChangeLog
13 # index 14349dcf2..e89ffee1b 100644
14 # --- a/ChangeLog
15 # +++ b/ChangeLog
16 # @@ -1,3 +1,8 @@
17 # +2023-06-20 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
18 # +
19 # + * 51877: Src/Modules/pcre.mdd, configure.ac: do not build pcre
20 # + module if pcre2-config is not available.
21 # +
22 # 2023-06-19 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
23
24 # * 51862: Doc/Makefile.in, configure.ac: support texinfo-7.0
25 --- a/Src/Modules/pcre.mdd
26 +++ b/Src/Modules/pcre.mdd
27 @@ -1,5 +1,5 @@
28 name=zsh/pcre
29 -link=`if test x$enable_pcre = xyes && (pcre-config --version >/dev/null 2>/dev/null); then echo dynamic; else echo no; fi`
30 +link=`if test x$enable_pcre = xyes; then echo dynamic; else echo no; fi`
31 load=no
32
33 autofeatures="b:pcre_compile b:pcre_study b:pcre_match"
34 --- a/configure.ac
35 +++ b/configure.ac
36 @@ -440,6 +440,17 @@ dnl Do you want to look for pcre support
37 AC_ARG_ENABLE(pcre,
38 AS_HELP_STRING([--enable-pcre],[enable the search for the pcre2 library (may create run-time library dependencies)]))
39
40 +AC_ARG_VAR(PCRE_CONFIG, [pathname of pcre2-config if it is not in PATH])
41 +if test "x$enable_pcre" = xyes; then
42 + AC_CHECK_PROG([PCRE_CONFIG], pcre2-config, pcre2-config)
43 + if test "x$PCRE_CONFIG" = x; then
44 + enable_pcre=no
45 + AC_MSG_WARN([pcre2-config not found: pcre module is disabled.])
46 + AC_MSG_NOTICE(
47 + [Set PCRE_CONFIG to pathname of pcre2-config if it is not in PATH.])
48 + fi
49 +fi
50 +
51 dnl Do you want to look for capability support?
52 AC_ARG_ENABLE(cap,
53 AS_HELP_STRING([--enable-cap],[enable the search for POSIX capabilities (may require additional headers to be added by hand)]))
54 @@ -660,15 +671,12 @@ AC_HEADER_DIRENT
55 AC_HEADER_STAT
56 AC_HEADER_SYS_WAIT
57
58 -oldcflags="$CFLAGS"
59 -if test x$enable_pcre = xyes; then
60 -AC_CHECK_PROG([PCRECONF], pcre2-config, pcre2-config)
61 dnl pcre2-config --cflags may produce a -I output which needs to go into
62 dnl CPPFLAGS else configure's preprocessor tests don't pick it up,
63 dnl producing a warning.
64 -if test "x$ac_cv_prog_PCRECONF" = xpcre2-config; then
65 - CPPFLAGS="$CPPFLAGS `pcre2-config --cflags`"
66 -fi
67 +if test "x$enable_pcre" = xyes; then
68 + CPPFLAGS="`$PCRE_CONFIG --cflags` $CPPFLAGS"
69 + AC_CHECK_HEADERS([pcre2.h],,,[#define PCRE2_CODE_UNIT_WIDTH 8])
70 fi
71
72 AC_CHECK_HEADERS(sys/time.h sys/times.h sys/select.h termcap.h termio.h \
73 @@ -680,7 +688,6 @@ AC_CHECK_HEADERS(sys/time.h sys/times.h
74 netinet/in_systm.h langinfo.h wchar.h stddef.h \
75 sys/stropts.h iconv.h ncurses.h ncursesw/ncurses.h \
76 ncurses/ncurses.h)
77 -AC_CHECK_HEADERS([pcre2.h],,,[#define PCRE2_CODE_UNIT_WIDTH 8])
78 if test x$dynamic = xyes; then
79 AC_CHECK_HEADERS(dlfcn.h)
80 AC_CHECK_HEADERS(dl.h)
81 @@ -957,10 +964,6 @@ if test "x$ac_found_iconv" = "xyes"; the
82 [Define as const if the declaration of iconv() needs const.])
83 fi
84
85 -if test x$enable_pcre = xyes; then
86 - LIBS="`$ac_cv_prog_PCRECONF --libs8` $LIBS"
87 -fi
88 -
89 dnl ---------------------
90 dnl CHECK TERMCAP LIBRARY
91 dnl ---------------------
92 @@ -1321,7 +1324,6 @@ AC_CHECK_FUNCS(strftime strptime mktime
93 pathconf sysconf \
94 tgetent tigetflag tigetnum tigetstr setupterm initscr resize_term \
95 getcchar setcchar waddwstr wget_wch win_wch use_default_colors \
96 - pcre2_compile_8 \
97 nl_langinfo \
98 erand48 open_memstream \
99 posix_openpt \
100 @@ -1376,6 +1378,11 @@ if test x$zsh_cv_func_realpath_accepts_n
101 AC_DEFINE(REALPATH_ACCEPTS_NULL)
102 fi
103
104 +if test x$enable_pcre = xyes; then
105 + LIBS="`$PCRE_CONFIG --libs8` $LIBS"
106 + AC_CHECK_FUNCS(pcre2_compile_8)
107 +fi
108 +
109 if test x$enable_cap = xyes; then
110 AC_CHECK_FUNCS(cap_get_proc)
111 fi