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_CHECK_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 is too old to use with PostgreSQL.
23 *** Bison version 1.875 or later is required.])
28 if test -z "$BISON"; then
30 *** Without Bison you will not be able to build PostgreSQL from CVS nor
31 *** change any of the parser definition files. You can obtain Bison from
32 *** a GNU mirror site. (If you are using the official distribution of
33 *** PostgreSQL then you do not need to worry about this, because the Bison
34 *** output is pre-generated.)])
36 # We don't need AC_SUBST(BISON) because AC_PATH_PROG did it
44 # Look for Flex, set the output variable FLEX to its path if found.
45 # Avoid the buggy version 2.5.3. Also find Flex if its installed
46 # under `lex', but do not accept other Lex programs.
48 AC_DEFUN([PGAC_PATH_FLEX],
49 [AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
50 [# Let the user override the test
51 if test -n "$FLEX"; then
52 pgac_cv_path_flex=$FLEX
56 for pgac_dir in $PATH; do
58 if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
61 for pgac_prog in flex lex; do
62 pgac_candidate="$pgac_dir/$pgac_prog"
63 if test -f "$pgac_candidate" \
64 && $pgac_candidate --version </dev/null >/dev/null 2>&1
66 echo '%%' > conftest.l
67 if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
68 if $pgac_candidate --version | grep ' 2\.5\.3$' >/dev/null 2>&1; then
69 pgac_broken_flex=$pgac_candidate
73 pgac_cv_path_flex=$pgac_candidate
79 rm -f conftest.l lex.yy.c
80 : ${pgac_cv_path_flex=no}
82 ])[]dnl AC_CACHE_CHECK
84 if test x"$pgac_cv_path_flex" = x"no"; then
85 if test -n "$pgac_broken_flex"; then
87 *** The Flex version 2.5.3 you have at $pgac_broken_flex contains a bug. You
88 *** should get version 2.5.4 or later.])
92 *** Without Flex you will not be able to build PostgreSQL from CVS or
93 *** change any of the scanner definition files. You can obtain Flex from
94 *** a GNU mirror site. (If you are using the official distribution of
95 *** PostgreSQL then you do not need to worry about this because the Flex
96 *** output is pre-generated.)])
100 FLEX=$pgac_cv_path_flex
101 pgac_flex_version=`$FLEX -V 2>/dev/null`
102 AC_MSG_NOTICE([using $pgac_flex_version])
111 # PGAC_CHECK_READLINE
112 # -------------------
113 # Check for the readline library and dependent libraries, either
114 # termcap or curses. Also try libedit, since NetBSD's is compatible.
115 # Add the required flags to LIBS, define HAVE_LIBREADLINE.
117 AC_DEFUN([PGAC_CHECK_READLINE],
118 [AC_REQUIRE([AC_CANONICAL_HOST])
120 AC_CACHE_VAL([pgac_cv_check_readline],
121 [pgac_cv_check_readline=no
123 if test x"$with_libedit_preferred" != x"yes"
124 then READLINE_ORDER="-lreadline -ledit"
125 else READLINE_ORDER="-ledit -lreadline"
127 for pgac_rllib in $READLINE_ORDER ; do
128 AC_MSG_CHECKING([for ${pgac_rllib}])
129 for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
130 LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
131 AC_TRY_LINK_FUNC([readline], [[
132 # Older NetBSD, OpenBSD, and Irix have a broken linker that does not
133 # recognize dependent libraries; assume curses is needed if we didn't
134 # find any dependency.
136 netbsd* | openbsd* | irix*)
137 if test x"$pgac_lib" = x"" ; then
142 pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
146 if test "$pgac_cv_check_readline" != no ; then
147 AC_MSG_RESULT([yes ($pgac_cv_check_readline)])
156 if test "$pgac_cv_check_readline" != no ; then
157 LIBS="$pgac_cv_check_readline $LIBS"
158 AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library])
161 ])# PGAC_CHECK_READLINE
165 # PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
166 # ---------------------------------------
167 # Readline versions < 2.1 don't have rl_completion_append_character
169 AC_DEFUN([PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER],
170 [AC_MSG_CHECKING([for rl_completion_append_character])
171 AC_TRY_LINK([#include <stdio.h>
172 #ifdef HAVE_READLINE_READLINE_H
173 # include <readline/readline.h>
174 #elif defined(HAVE_READLINE_H)
175 # include <readline.h>
178 [rl_completion_append_character = 'x';],
180 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
181 [Define to 1 if you have the global variable 'rl_completion_append_character'.])],
182 [AC_MSG_RESULT(no)])])# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
188 # We check for bind_textdomain_codeset() not just gettext(). GNU gettext
189 # before 0.10.36 does not have that function, and is generally too incomplete
192 AC_DEFUN([PGAC_CHECK_GETTEXT],
194 AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [],
195 [AC_MSG_ERROR([a gettext implementation is required for NLS])])
196 AC_CHECK_HEADER([libintl.h], [],
197 [AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
198 AC_CHECK_PROGS(MSGFMT, msgfmt)
199 if test -z "$MSGFMT"; then
200 AC_MSG_ERROR([msgfmt is required for NLS])
202 AC_CHECK_PROGS(MSGMERGE, msgmerge)
203 AC_CHECK_PROGS(XGETTEXT, xgettext)
204 ])# PGAC_CHECK_GETTEXT
210 # Check for a 'strip' program, and figure out if that program can
213 AC_DEFUN([PGAC_CHECK_STRIP],
215 AC_CHECK_TOOL(STRIP, strip, :)
217 AC_MSG_CHECKING([whether it is possible to strip libraries])
218 if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
219 STRIP_STATIC_LIB="$STRIP -x"
220 STRIP_SHARED_LIB="$STRIP --strip-unneeded"
227 AC_SUBST(STRIP_STATIC_LIB)
228 AC_SUBST(STRIP_SHARED_LIB)