Fix another minor page deletion buffer lock issue.
[pgsql.git] / config / programs.m4
blob6a118ece24eebfd8c00f849883f59b346440766e
1 # config/programs.m4
4 # PGAC_PATH_PROGS
5 # ---------------
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
13   AC_PATH_PROGS($@)
14 else
15   # Report the value of $1 in configure's output in all cases.
16   AC_MSG_CHECKING([for $1])
17   AC_MSG_RESULT([$$1])
22 # PGAC_PATH_BISON
23 # ---------------
24 # Look for Bison, set the output variable BISON to its path if found.
25 # Reject versions before 1.875 (they have bugs or capacity limits).
26 # 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 < 1.875) exit 0; else exit 1;}'
35   then
36     AC_MSG_WARN([
37 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
38 *** Bison version 1.875 or later is required, but this is $pgac_bison_version.])
39     BISON=""
40   fi
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;}'
46   then
47     BISONFLAGS="$BISONFLAGS -Wno-deprecated"
48   fi
51 if test -z "$BISON"; then
52   AC_MSG_WARN([
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
60 AC_SUBST(BISONFLAGS)
61 ])# PGAC_PATH_BISON
65 # PGAC_PATH_FLEX
66 # --------------
67 # Look for Flex, set the output variable FLEX to its path if found.
68 # Reject versions before 2.5.31, as we need a reasonably non-buggy reentrant
69 # scanner.  (Note: the well-publicized security problem in 2.5.31 does not
70 # affect Postgres, and there are still distros shipping patched 2.5.31,
71 # so allow it.)  Also find Flex if its installed under `lex', but do not
72 # accept other Lex programs.
74 AC_DEFUN([PGAC_PATH_FLEX],
75 [AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
76 [# Let the user override the test
77 if test -n "$FLEX"; then
78   pgac_cv_path_flex=$FLEX
79 else
80   pgac_save_IFS=$IFS
81   IFS=$PATH_SEPARATOR
82   for pgac_dir in $PATH; do
83     IFS=$pgac_save_IFS
84     if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
85       pgac_dir=`pwd`
86     fi
87     for pgac_prog in flex lex; do
88       pgac_candidate="$pgac_dir/$pgac_prog"
89       if test -f "$pgac_candidate" \
90         && $pgac_candidate --version </dev/null >/dev/null 2>&1
91       then
92         echo '%%'  > conftest.l
93         if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
94           pgac_flex_version=`$pgac_candidate --version 2>/dev/null`
95           if echo "$pgac_flex_version" | sed ['s/[.a-z]/ /g'] | $AWK '{ if ([$]1 == 2 && ([$]2 > 5 || ([$]2 == 5 && [$]3 >= 31))) exit 0; else exit 1;}'
96           then
97             pgac_cv_path_flex=$pgac_candidate
98             break 2
99           else
100             AC_MSG_WARN([
101 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
102 *** Flex version 2.5.31 or later is required, but this is $pgac_flex_version.])
103           fi
104         fi
105       fi
106     done
107   done
108   rm -f conftest.l lex.yy.c
109   : ${pgac_cv_path_flex=no}
111 ])[]dnl AC_CACHE_CHECK
113 if test x"$pgac_cv_path_flex" = x"no"; then
114   AC_MSG_WARN([
115 *** Without Flex you will not be able to build PostgreSQL from Git nor
116 *** change any of the scanner definition files.  You can obtain Flex from
117 *** a GNU mirror site.  (If you are using the official distribution of
118 *** PostgreSQL then you do not need to worry about this because the Flex
119 *** output is pre-generated.)])
121   FLEX=
122 else
123   FLEX=$pgac_cv_path_flex
124   pgac_flex_version=`$FLEX --version 2>/dev/null`
125   AC_MSG_NOTICE([using $pgac_flex_version])
128 AC_SUBST(FLEX)
129 AC_SUBST(FLEXFLAGS)
130 ])# PGAC_PATH_FLEX
134 # PGAC_LDAP_SAFE
135 # --------------
136 # PostgreSQL sometimes loads libldap_r and plain libldap into the same
137 # process.  Check for OpenLDAP versions known not to tolerate doing so; assume
138 # non-OpenLDAP implementations are safe.  The dblink test suite exercises the
139 # hazardous interaction directly.
141 AC_DEFUN([PGAC_LDAP_SAFE],
142 [AC_CACHE_CHECK([for compatible LDAP implementation], [pgac_cv_ldap_safe],
143 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
144 [#include <ldap.h>
145 #if !defined(LDAP_VENDOR_VERSION) || \
146      (defined(LDAP_API_FEATURE_X_OPENLDAP) && \
147       LDAP_VENDOR_VERSION >= 20424 && LDAP_VENDOR_VERSION <= 20431)
148 choke me
149 #endif], [])],
150 [pgac_cv_ldap_safe=yes],
151 [pgac_cv_ldap_safe=no])])
153 if test "$pgac_cv_ldap_safe" != yes; then
154   AC_MSG_WARN([
155 *** With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, each backend
156 *** process that loads libpq (via WAL receiver, dblink, or postgres_fdw) and
157 *** also uses LDAP will crash on exit.])
158 fi])
162 # PGAC_CHECK_READLINE
163 # -------------------
164 # Check for the readline library and dependent libraries, either
165 # termcap or curses.  Also try libedit, since NetBSD's is compatible.
166 # Add the required flags to LIBS, define HAVE_LIBREADLINE.
168 AC_DEFUN([PGAC_CHECK_READLINE],
169 [AC_REQUIRE([AC_CANONICAL_HOST])
171 AC_CACHE_CHECK([for library containing readline], [pgac_cv_check_readline],
172 [pgac_cv_check_readline=no
173 pgac_save_LIBS=$LIBS
174 if test x"$with_libedit_preferred" != x"yes"
175 then    READLINE_ORDER="-lreadline -ledit"
176 else    READLINE_ORDER="-ledit -lreadline"
178 for pgac_rllib in $READLINE_ORDER ; do
179   for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
180     LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
181     AC_TRY_LINK_FUNC([readline], [[
182       # Older NetBSD and OpenBSD have a broken linker that does not
183       # recognize dependent libraries; assume curses is needed if we didn't
184       # find any dependency.
185       case $host_os in
186         netbsd* | openbsd*)
187           if test x"$pgac_lib" = x"" ; then
188             pgac_lib=" -lcurses"
189           fi ;;
190       esac
192       pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
193       break
194     ]])
195   done
196   if test "$pgac_cv_check_readline" != no ; then
197     break
198   fi
199 done
200 LIBS=$pgac_save_LIBS
201 ])[]dnl AC_CACHE_CHECK
203 if test "$pgac_cv_check_readline" != no ; then
204   LIBS="$pgac_cv_check_readline $LIBS"
205   AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library])
208 ])# PGAC_CHECK_READLINE
212 # PGAC_READLINE_VARIABLES
213 # -----------------------
214 # Readline versions < 2.1 don't have rl_completion_append_character,
215 # and some versions lack rl_completion_suppress_quote.
216 # Libedit lacks rl_filename_quote_characters and rl_filename_quoting_function
218 AC_DEFUN([PGAC_READLINE_VARIABLES],
219 [AC_CACHE_CHECK([for rl_completion_append_character], pgac_cv_var_rl_completion_append_character,
220 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
221 #if defined(HAVE_READLINE_READLINE_H)
222 #include <readline/readline.h>
223 #elif defined(HAVE_EDITLINE_READLINE_H)
224 #include <editline/readline.h>
225 #elif defined(HAVE_READLINE_H)
226 #include <readline.h>
227 #endif
229 [rl_completion_append_character = 'x';])],
230 [pgac_cv_var_rl_completion_append_character=yes],
231 [pgac_cv_var_rl_completion_append_character=no])])
232 if test x"$pgac_cv_var_rl_completion_append_character" = x"yes"; then
233 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
234           [Define to 1 if you have the global variable 'rl_completion_append_character'.])
236 AC_CACHE_CHECK([for rl_completion_suppress_quote], pgac_cv_var_rl_completion_suppress_quote,
237 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
238 #if defined(HAVE_READLINE_READLINE_H)
239 #include <readline/readline.h>
240 #elif defined(HAVE_EDITLINE_READLINE_H)
241 #include <editline/readline.h>
242 #elif defined(HAVE_READLINE_H)
243 #include <readline.h>
244 #endif
246 [rl_completion_suppress_quote = 1;])],
247 [pgac_cv_var_rl_completion_suppress_quote=yes],
248 [pgac_cv_var_rl_completion_suppress_quote=no])])
249 if test x"$pgac_cv_var_rl_completion_suppress_quote" = x"yes"; then
250 AC_DEFINE(HAVE_RL_COMPLETION_SUPPRESS_QUOTE, 1,
251           [Define to 1 if you have the global variable 'rl_completion_suppress_quote'.])
253 AC_CACHE_CHECK([for rl_filename_quote_characters], pgac_cv_var_rl_filename_quote_characters,
254 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
255 #if defined(HAVE_READLINE_READLINE_H)
256 #include <readline/readline.h>
257 #elif defined(HAVE_EDITLINE_READLINE_H)
258 #include <editline/readline.h>
259 #elif defined(HAVE_READLINE_H)
260 #include <readline.h>
261 #endif
263 [rl_filename_quote_characters = "x";])],
264 [pgac_cv_var_rl_filename_quote_characters=yes],
265 [pgac_cv_var_rl_filename_quote_characters=no])])
266 if test x"$pgac_cv_var_rl_filename_quote_characters" = x"yes"; then
267 AC_DEFINE(HAVE_RL_FILENAME_QUOTE_CHARACTERS, 1,
268           [Define to 1 if you have the global variable 'rl_filename_quote_characters'.])
270 AC_CACHE_CHECK([for rl_filename_quoting_function], pgac_cv_var_rl_filename_quoting_function,
271 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
272 #if defined(HAVE_READLINE_READLINE_H)
273 #include <readline/readline.h>
274 #elif defined(HAVE_EDITLINE_READLINE_H)
275 #include <editline/readline.h>
276 #elif defined(HAVE_READLINE_H)
277 #include <readline.h>
278 #endif
280 [rl_filename_quoting_function = 0;])],
281 [pgac_cv_var_rl_filename_quoting_function=yes],
282 [pgac_cv_var_rl_filename_quoting_function=no])])
283 if test x"$pgac_cv_var_rl_filename_quoting_function" = x"yes"; then
284 AC_DEFINE(HAVE_RL_FILENAME_QUOTING_FUNCTION, 1,
285           [Define to 1 if you have the global variable 'rl_filename_quoting_function'.])
287 ])# PGAC_READLINE_VARIABLES
291 # PGAC_CHECK_GETTEXT
292 # ------------------
293 # We check for bind_textdomain_codeset() not just gettext().  GNU gettext
294 # before 0.10.36 does not have that function, and is generally too incomplete
295 # to be usable.
297 AC_DEFUN([PGAC_CHECK_GETTEXT],
299   AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [],
300                  [AC_MSG_ERROR([a gettext implementation is required for NLS])])
301   AC_CHECK_HEADER([libintl.h], [],
302                   [AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
303   PGAC_PATH_PROGS(MSGFMT, msgfmt)
304   AC_ARG_VAR(MSGFMT, [msgfmt program for NLS])dnl
305   if test -z "$MSGFMT"; then
306     AC_MSG_ERROR([msgfmt is required for NLS])
307   fi
308   AC_CACHE_CHECK([for msgfmt flags], pgac_cv_msgfmt_flags,
309 [if test x"$MSGFMT" != x"" && "$MSGFMT" --version 2>&1 | grep "GNU" >/dev/null; then
310     pgac_cv_msgfmt_flags=-c
311 fi])
312   AC_SUBST(MSGFMT_FLAGS, $pgac_cv_msgfmt_flags)
313   PGAC_PATH_PROGS(MSGMERGE, msgmerge)
314   PGAC_PATH_PROGS(XGETTEXT, xgettext)
315 ])# PGAC_CHECK_GETTEXT
319 # PGAC_CHECK_STRIP
320 # ----------------
321 # Check for a 'strip' program, and figure out if that program can
322 # strip libraries.
324 AC_DEFUN([PGAC_CHECK_STRIP],
326   AC_CHECK_TOOL(STRIP, strip, :)
328   AC_MSG_CHECKING([whether it is possible to strip libraries])
329   if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
330     STRIP_STATIC_LIB="$STRIP -x"
331     STRIP_SHARED_LIB="$STRIP --strip-unneeded"
332     AC_MSG_RESULT(yes)
333   else
334     case $host_os in
335       darwin*)
336         STRIP="$STRIP -x"
337         STRIP_STATIC_LIB=$STRIP
338         STRIP_SHARED_LIB=$STRIP
339         AC_MSG_RESULT(yes)
340         ;;
341       *)
342         STRIP_STATIC_LIB=:
343         STRIP_SHARED_LIB=:
344         AC_MSG_RESULT(no)
345         ;;
346     esac
347   fi
348   AC_SUBST(STRIP_STATIC_LIB)
349   AC_SUBST(STRIP_SHARED_LIB)
350 ])# PGAC_CHECK_STRIP