6 # Look for Bison, set the output variable BISON to its path if found.
7 # Reject versions before 1.875 (they have bugs or capacity limits).
8 # Note we do not accept other implementations of yacc.
10 AC_DEFUN([PGAC_PATH_BISON],
11 [# Let the user override the search
12 if test -z "$BISON"; then
13 AC_PATH_PROGS(BISON, bison)
16 if test "$BISON"; then
17 pgac_bison_version=`$BISON --version 2>/dev/null | sed q`
18 AC_MSG_NOTICE([using $pgac_bison_version])
19 if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 1.875) exit 0; else exit 1;}'
22 *** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
23 *** Bison version 1.875 or later is required, but this is $pgac_bison_version.])
26 # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead
27 # of the now preferred %name-prefix "base_yy", but the latter
28 # doesn't work with Bison 2.3 or less. So for now we silence the
29 # deprecation warnings.
30 if echo "$pgac_bison_version" | $AWK '{ if ([$]4 >= 3) exit 0; else exit 1;}'
32 BISONFLAGS="$BISONFLAGS -Wno-deprecated"
36 if test -z "$BISON"; then
38 *** Without Bison you will not be able to build PostgreSQL from Git nor
39 *** change any of the parser definition files. You can obtain Bison from
40 *** a GNU mirror site. (If you are using the official distribution of
41 *** PostgreSQL then you do not need to worry about this, because the Bison
42 *** output is pre-generated.)])
44 # We don't need AC_SUBST(BISON) because AC_PATH_PROG did it
52 # Look for Flex, set the output variable FLEX to its path if found.
53 # Reject versions before 2.5.31, as we need a reasonably non-buggy reentrant
54 # scanner. (Note: the well-publicized security problem in 2.5.31 does not
55 # affect Postgres, and there are still distros shipping patched 2.5.31,
56 # so allow it.) Also find Flex if its installed under `lex', but do not
57 # accept other Lex programs.
59 AC_DEFUN([PGAC_PATH_FLEX],
60 [AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
61 [# Let the user override the test
62 if test -n "$FLEX"; then
63 pgac_cv_path_flex=$FLEX
67 for pgac_dir in $PATH; do
69 if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
72 for pgac_prog in flex lex; do
73 pgac_candidate="$pgac_dir/$pgac_prog"
74 if test -f "$pgac_candidate" \
75 && $pgac_candidate --version </dev/null >/dev/null 2>&1
77 echo '%%' > conftest.l
78 if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
79 pgac_flex_version=`$pgac_candidate --version 2>/dev/null`
80 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;}'
82 pgac_cv_path_flex=$pgac_candidate
86 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
87 *** Flex version 2.5.31 or later is required, but this is $pgac_flex_version.])
93 rm -f conftest.l lex.yy.c
94 : ${pgac_cv_path_flex=no}
96 ])[]dnl AC_CACHE_CHECK
98 if test x"$pgac_cv_path_flex" = x"no"; then
100 *** Without Flex you will not be able to build PostgreSQL from Git nor
101 *** change any of the scanner definition files. You can obtain Flex from
102 *** a GNU mirror site. (If you are using the official distribution of
103 *** PostgreSQL then you do not need to worry about this because the Flex
104 *** output is pre-generated.)])
108 FLEX=$pgac_cv_path_flex
109 pgac_flex_version=`$FLEX --version 2>/dev/null`
110 AC_MSG_NOTICE([using $pgac_flex_version])
121 # PostgreSQL sometimes loads libldap_r and plain libldap into the same
122 # process. Check for OpenLDAP versions known not to tolerate doing so; assume
123 # non-OpenLDAP implementations are safe. The dblink test suite exercises the
124 # hazardous interaction directly.
126 AC_DEFUN([PGAC_LDAP_SAFE],
127 [AC_CACHE_CHECK([for compatible LDAP implementation], [pgac_cv_ldap_safe],
128 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
130 #if !defined(LDAP_VENDOR_VERSION) || \
131 (defined(LDAP_API_FEATURE_X_OPENLDAP) && \
132 LDAP_VENDOR_VERSION >= 20424 && LDAP_VENDOR_VERSION <= 20431)
135 [pgac_cv_ldap_safe=yes],
136 [pgac_cv_ldap_safe=no])])
138 if test "$pgac_cv_ldap_safe" != yes; then
140 *** With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, each backend
141 *** process that loads libpq (via WAL receiver, dblink, or postgres_fdw) and
142 *** also uses LDAP will crash on exit.])
147 # PGAC_CHECK_READLINE
148 # -------------------
149 # Check for the readline library and dependent libraries, either
150 # termcap or curses. Also try libedit, since NetBSD's is compatible.
151 # Add the required flags to LIBS, define HAVE_LIBREADLINE.
153 AC_DEFUN([PGAC_CHECK_READLINE],
154 [AC_REQUIRE([AC_CANONICAL_HOST])
156 AC_CACHE_CHECK([for library containing readline], [pgac_cv_check_readline],
157 [pgac_cv_check_readline=no
159 if test x"$with_libedit_preferred" != x"yes"
160 then READLINE_ORDER="-lreadline -ledit"
161 else READLINE_ORDER="-ledit -lreadline"
163 for pgac_rllib in $READLINE_ORDER ; do
164 for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
165 LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
166 AC_TRY_LINK_FUNC([readline], [[
167 # Older NetBSD, OpenBSD, and Irix have a broken linker that does not
168 # recognize dependent libraries; assume curses is needed if we didn't
169 # find any dependency.
171 netbsd* | openbsd* | irix*)
172 if test x"$pgac_lib" = x"" ; then
177 pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
181 if test "$pgac_cv_check_readline" != no ; then
186 ])[]dnl AC_CACHE_CHECK
188 if test "$pgac_cv_check_readline" != no ; then
189 LIBS="$pgac_cv_check_readline $LIBS"
190 AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library])
193 ])# PGAC_CHECK_READLINE
197 # PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
198 # ---------------------------------------
199 # Readline versions < 2.1 don't have rl_completion_append_character
201 AC_DEFUN([PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER],
202 [AC_CACHE_CHECK([for rl_completion_append_character], pgac_cv_var_rl_completion_append_character,
203 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>
204 #ifdef HAVE_READLINE_READLINE_H
205 # include <readline/readline.h>
206 #elif defined(HAVE_READLINE_H)
207 # include <readline.h>
210 [rl_completion_append_character = 'x';])],
211 [pgac_cv_var_rl_completion_append_character=yes],
212 [pgac_cv_var_rl_completion_append_character=no])])
213 if test x"$pgac_cv_var_rl_completion_append_character" = x"yes"; then
214 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
215 [Define to 1 if you have the global variable 'rl_completion_append_character'.])
216 fi])# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
222 # We check for bind_textdomain_codeset() not just gettext(). GNU gettext
223 # before 0.10.36 does not have that function, and is generally too incomplete
226 AC_DEFUN([PGAC_CHECK_GETTEXT],
228 AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [],
229 [AC_MSG_ERROR([a gettext implementation is required for NLS])])
230 AC_CHECK_HEADER([libintl.h], [],
231 [AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
232 AC_PATH_PROGS(MSGFMT, msgfmt)
233 if test -z "$MSGFMT"; then
234 AC_MSG_ERROR([msgfmt is required for NLS])
236 AC_CACHE_CHECK([for msgfmt flags], pgac_cv_msgfmt_flags,
237 [if test x"$MSGFMT" != x"" && "$MSGFMT" --version 2>&1 | grep "GNU" >/dev/null; then
238 pgac_cv_msgfmt_flags=-c
240 AC_SUBST(MSGFMT_FLAGS, $pgac_cv_msgfmt_flags)
241 AC_PATH_PROGS(MSGMERGE, msgmerge)
242 AC_PATH_PROGS(XGETTEXT, xgettext)
243 ])# PGAC_CHECK_GETTEXT
249 # Check for a 'strip' program, and figure out if that program can
252 AC_DEFUN([PGAC_CHECK_STRIP],
254 AC_CHECK_TOOL(STRIP, strip, :)
256 AC_MSG_CHECKING([whether it is possible to strip libraries])
257 if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
258 STRIP_STATIC_LIB="$STRIP -x"
259 STRIP_SHARED_LIB="$STRIP --strip-unneeded"
265 STRIP_STATIC_LIB=$STRIP
266 STRIP_SHARED_LIB=$STRIP
276 AC_SUBST(STRIP_STATIC_LIB)
277 AC_SUBST(STRIP_SHARED_LIB)