6 # This wrapper for AC_PATH_PROGS behaves like that macro except when
7 # VARIABLE is already set; in that case we just accept the value verbatim.
8 # (AC_PATH_PROGS would accept it only if it looks like an absolute path.)
9 # A desirable future improvement would be to convert a non-absolute-path
10 # input into absolute form.
11 AC_DEFUN([PGAC_PATH_PROGS],
12 [if test -z "$$1"; then
15 # Report the value of $1 in configure's output in all cases.
16 AC_MSG_CHECKING([for $1])
24 # Look for Bison, set the output variable BISON to its path if found.
25 # Reject versions before 2.3 (the earliest version in the buildfarm
26 # as of 2022). Note we do not accept other implementations of yacc.
28 AC_DEFUN([PGAC_PATH_BISON],
29 [PGAC_PATH_PROGS(BISON, bison)
31 if test "$BISON"; then
32 pgac_bison_version=`$BISON --version 2>/dev/null | sed q`
33 AC_MSG_NOTICE([using $pgac_bison_version])
34 if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 2.3) exit 0; else exit 1;}'
37 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
38 *** Bison version 2.3 or later is required, but this is $pgac_bison_version.])
41 # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
42 # of the now preferred %name-prefix "base_yy", but the latter
43 # doesn't work with Bison 2.3 or less. So for now we silence the
44 # deprecation warnings.
45 if echo "$pgac_bison_version" | $AWK '{ if ([$]4 >= 3) exit 0; else exit 1;}'
47 BISONFLAGS="$BISONFLAGS -Wno-deprecated"
51 if test -z "$BISON"; then
53 *** Without Bison you will not be able to build PostgreSQL from Git nor
54 *** change any of the parser definition files. You can obtain Bison from
55 *** a GNU mirror site. (If you are using the official distribution of
56 *** PostgreSQL then you do not need to worry about this, because the Bison
57 *** output is pre-generated.)])
59 dnl We don't need AC_SUBST(BISON) because PGAC_PATH_PROGS did it
67 # Look for Flex, set the output variable FLEX to its path if found.
68 # Reject versions before 2.5.35 (the earliest version in the buildfarm
69 # as of 2022). Also find Flex if its installed under `lex', but do not
70 # accept other Lex programs.
72 AC_DEFUN([PGAC_PATH_FLEX],
73 [AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
74 [# Let the user override the test
75 if test -n "$FLEX"; then
76 pgac_cv_path_flex=$FLEX
80 for pgac_dir in $PATH; do
82 if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
85 for pgac_prog in flex lex; do
86 pgac_candidate="$pgac_dir/$pgac_prog"
87 if test -f "$pgac_candidate" \
88 && $pgac_candidate --version </dev/null >/dev/null 2>&1
90 echo '%%' > conftest.l
91 if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
92 pgac_flex_version=`$pgac_candidate --version 2>/dev/null`
93 if echo "$pgac_flex_version" | sed ['s/[.a-z]/ /g'] | $AWK '{ if ([$]1 == 2 && ([$]2 > 5 || ([$]2 == 5 && [$]3 >= 35))) exit 0; else exit 1;}'
95 pgac_cv_path_flex=$pgac_candidate
99 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
100 *** Flex version 2.5.35 or later is required, but this is $pgac_flex_version.])
106 rm -f conftest.l lex.yy.c
107 : ${pgac_cv_path_flex=no}
109 ])[]dnl AC_CACHE_CHECK
111 if test x"$pgac_cv_path_flex" = x"no"; then
113 *** Without Flex you will not be able to build PostgreSQL from Git nor
114 *** change any of the scanner definition files. You can obtain Flex from
115 *** a GNU mirror site. (If you are using the official distribution of
116 *** PostgreSQL then you do not need to worry about this because the Flex
117 *** output is pre-generated.)])
121 FLEX=$pgac_cv_path_flex
122 pgac_flex_version=`$FLEX --version 2>/dev/null`
123 AC_MSG_NOTICE([using $pgac_flex_version])
134 # PostgreSQL sometimes loads libldap_r and plain libldap into the same
135 # process. Check for OpenLDAP versions known not to tolerate doing so; assume
136 # non-OpenLDAP implementations are safe. The dblink test suite exercises the
137 # hazardous interaction directly.
139 AC_DEFUN([PGAC_LDAP_SAFE],
140 [AC_CACHE_CHECK([for compatible LDAP implementation], [pgac_cv_ldap_safe],
141 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
143 #if !defined(LDAP_VENDOR_VERSION) || \
144 (defined(LDAP_API_FEATURE_X_OPENLDAP) && \
145 LDAP_VENDOR_VERSION >= 20424 && LDAP_VENDOR_VERSION <= 20431)
148 [pgac_cv_ldap_safe=yes],
149 [pgac_cv_ldap_safe=no])])
151 if test "$pgac_cv_ldap_safe" != yes; then
153 *** With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, each backend
154 *** process that loads libpq (via WAL receiver, dblink, or postgres_fdw) and
155 *** also uses LDAP will crash on exit.])
160 # PGAC_CHECK_READLINE
161 # -------------------
162 # Check for the readline library and dependent libraries, either
163 # termcap or curses. Also try libedit, since NetBSD's is compatible.
164 # Add the required flags to LIBS, define HAVE_LIBREADLINE.
166 AC_DEFUN([PGAC_CHECK_READLINE],
167 [AC_REQUIRE([AC_CANONICAL_HOST])
169 AC_CACHE_CHECK([for library containing readline], [pgac_cv_check_readline],
170 [pgac_cv_check_readline=no
172 if test x"$with_libedit_preferred" != x"yes"
173 then READLINE_ORDER="-lreadline -ledit"
174 else READLINE_ORDER="-ledit -lreadline"
176 for pgac_rllib in $READLINE_ORDER ; do
177 for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
178 LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
179 AC_TRY_LINK_FUNC([readline], [[
180 # Older NetBSD and OpenBSD have a broken linker that does not
181 # recognize dependent libraries; assume curses is needed if we didn't
182 # find any dependency.
185 if test x"$pgac_lib" = x"" ; then
190 pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
194 if test "$pgac_cv_check_readline" != no ; then
199 ])[]dnl AC_CACHE_CHECK
201 if test "$pgac_cv_check_readline" != no ; then
202 LIBS="$pgac_cv_check_readline $LIBS"
203 AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library])
206 ])# PGAC_CHECK_READLINE
210 # PGAC_READLINE_VARIABLES
211 # -----------------------
212 # Some Readline versions lack rl_completion_suppress_quote.
213 # Libedit lacks rl_filename_quote_characters and rl_filename_quoting_function
215 AC_DEFUN([PGAC_READLINE_VARIABLES],
216 [AC_CACHE_CHECK([for rl_completion_suppress_quote], pgac_cv_var_rl_completion_suppress_quote,
217 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
218 #if defined(HAVE_READLINE_READLINE_H)
219 #include <readline/readline.h>
220 #elif defined(HAVE_EDITLINE_READLINE_H)
221 #include <editline/readline.h>
222 #elif defined(HAVE_READLINE_H)
223 #include <readline.h>
226 [rl_completion_suppress_quote = 1;])],
227 [pgac_cv_var_rl_completion_suppress_quote=yes],
228 [pgac_cv_var_rl_completion_suppress_quote=no])])
229 if test x"$pgac_cv_var_rl_completion_suppress_quote" = x"yes"; then
230 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_QUOTE, 1,
231 [Define to 1 if you have the global variable 'rl_completion_suppress_quote'.])
233 AC_CACHE_CHECK([for rl_filename_quote_characters], pgac_cv_var_rl_filename_quote_characters,
234 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
235 #if defined(HAVE_READLINE_READLINE_H)
236 #include <readline/readline.h>
237 #elif defined(HAVE_EDITLINE_READLINE_H)
238 #include <editline/readline.h>
239 #elif defined(HAVE_READLINE_H)
240 #include <readline.h>
243 [rl_filename_quote_characters = "x";])],
244 [pgac_cv_var_rl_filename_quote_characters=yes],
245 [pgac_cv_var_rl_filename_quote_characters=no])])
246 if test x"$pgac_cv_var_rl_filename_quote_characters" = x"yes"; then
247 AC_DEFINE(HAVE_RL_FILENAME_QUOTE_CHARACTERS, 1,
248 [Define to 1 if you have the global variable 'rl_filename_quote_characters'.])
250 AC_CACHE_CHECK([for rl_filename_quoting_function], pgac_cv_var_rl_filename_quoting_function,
251 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
252 #if defined(HAVE_READLINE_READLINE_H)
253 #include <readline/readline.h>
254 #elif defined(HAVE_EDITLINE_READLINE_H)
255 #include <editline/readline.h>
256 #elif defined(HAVE_READLINE_H)
257 #include <readline.h>
260 [rl_filename_quoting_function = 0;])],
261 [pgac_cv_var_rl_filename_quoting_function=yes],
262 [pgac_cv_var_rl_filename_quoting_function=no])])
263 if test x"$pgac_cv_var_rl_filename_quoting_function" = x"yes"; then
264 AC_DEFINE(HAVE_RL_FILENAME_QUOTING_FUNCTION, 1,
265 [Define to 1 if you have the global variable 'rl_filename_quoting_function'.])
267 ])# PGAC_READLINE_VARIABLES
273 # We check for bind_textdomain_codeset() not just gettext(). GNU gettext
274 # before 0.10.36 does not have that function, and is generally too incomplete
277 AC_DEFUN([PGAC_CHECK_GETTEXT],
279 AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [],
280 [AC_MSG_ERROR([a gettext implementation is required for NLS])])
281 AC_CHECK_HEADER([libintl.h], [],
282 [AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
283 PGAC_PATH_PROGS(MSGFMT, msgfmt)
284 AC_ARG_VAR(MSGFMT, [msgfmt program for NLS])dnl
285 if test -z "$MSGFMT"; then
286 AC_MSG_ERROR([msgfmt is required for NLS])
288 AC_CACHE_CHECK([for msgfmt flags], pgac_cv_msgfmt_flags,
289 [if test x"$MSGFMT" != x"" && "$MSGFMT" --version 2>&1 | grep "GNU" >/dev/null; then
290 pgac_cv_msgfmt_flags=-c
292 AC_SUBST(MSGFMT_FLAGS, $pgac_cv_msgfmt_flags)
293 PGAC_PATH_PROGS(MSGMERGE, msgmerge)
294 PGAC_PATH_PROGS(XGETTEXT, xgettext)
295 ])# PGAC_CHECK_GETTEXT
301 # Check for a 'strip' program, and figure out if that program can
304 AC_DEFUN([PGAC_CHECK_STRIP],
306 AC_CHECK_TOOL(STRIP, strip, :)
308 AC_MSG_CHECKING([whether it is possible to strip libraries])
309 if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
310 STRIP_STATIC_LIB="$STRIP -x"
311 STRIP_SHARED_LIB="$STRIP --strip-unneeded"
317 STRIP_STATIC_LIB=$STRIP
318 STRIP_SHARED_LIB=$STRIP
328 AC_SUBST(STRIP_STATIC_LIB)
329 AC_SUBST(STRIP_SHARED_LIB)