6 # Look for Bison, set the output variable YACC 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_YACC],
11 [# Let the user override the search
12 if test -z "$YACC"; then
13 AC_CHECK_PROGS(YACC, ['bison -y'])
17 pgac_yacc_version=`$YACC --version 2>/dev/null | sed q`
18 AC_MSG_NOTICE([using $pgac_yacc_version])
19 if echo "$pgac_yacc_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 "$YACC"; 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.) To use a different yacc program (possible,
35 *** but not recommended), set the environment variable YACC before running
38 # We don't need AC_SUBST(YACC) because AC_PATH_PROG did it
46 # Look for Flex, set the output variable FLEX to its path if found.
47 # Avoid the buggy version 2.5.3. Also find Flex if its installed
48 # under `lex', but do not accept other Lex programs.
50 AC_DEFUN([PGAC_PATH_FLEX],
51 [AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
52 [# Let the user override the test
53 if test -n "$FLEX"; then
54 pgac_cv_path_flex=$FLEX
58 for pgac_dir in $PATH; do
60 if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
63 for pgac_prog in flex lex; do
64 pgac_candidate="$pgac_dir/$pgac_prog"
65 if test -f "$pgac_candidate" \
66 && $pgac_candidate --version </dev/null >/dev/null 2>&1
68 echo '%%' > conftest.l
69 if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
70 if $pgac_candidate --version | grep ' 2\.5\.3$' >/dev/null 2>&1; then
71 pgac_broken_flex=$pgac_candidate
75 pgac_cv_path_flex=$pgac_candidate
81 rm -f conftest.l lex.yy.c
82 : ${pgac_cv_path_flex=no}
84 ])[]dnl AC_CACHE_CHECK
86 if test x"$pgac_cv_path_flex" = x"no"; then
87 if test -n "$pgac_broken_flex"; then
89 *** The Flex version 2.5.3 you have at $pgac_broken_flex contains a bug. You
90 *** should get version 2.5.4 or later.])
94 *** Without Flex you will not be able to build PostgreSQL from CVS or
95 *** change any of the scanner definition files. You can obtain Flex from
96 *** a GNU mirror site. (If you are using the official distribution of
97 *** PostgreSQL then you do not need to worry about this because the Flex
98 *** output is pre-generated.)])
102 FLEX=$pgac_cv_path_flex
103 pgac_flex_version=`$FLEX -V 2>/dev/null`
104 AC_MSG_NOTICE([using $pgac_flex_version])
113 # PGAC_CHECK_READLINE
114 # -------------------
115 # Check for the readline library and dependent libraries, either
116 # termcap or curses. Also try libedit, since NetBSD's is compatible.
117 # Add the required flags to LIBS, define HAVE_LIBREADLINE.
119 AC_DEFUN([PGAC_CHECK_READLINE],
120 [AC_REQUIRE([AC_CANONICAL_HOST])
122 AC_CACHE_VAL([pgac_cv_check_readline],
123 [pgac_cv_check_readline=no
125 if test x"$with_libedit_preferred" != x"yes"
126 then READLINE_ORDER="-lreadline -ledit"
127 else READLINE_ORDER="-ledit -lreadline"
129 for pgac_rllib in $READLINE_ORDER ; do
130 AC_MSG_CHECKING([for ${pgac_rllib}])
131 for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
132 LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
133 AC_TRY_LINK_FUNC([readline], [[
134 # Older NetBSD, OpenBSD, and Irix have a broken linker that does not
135 # recognize dependent libraries; assume curses is needed if we didn't
136 # find any dependency.
138 netbsd* | openbsd* | irix*)
139 if test x"$pgac_lib" = x"" ; then
144 pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
148 if test "$pgac_cv_check_readline" != no ; then
149 AC_MSG_RESULT([yes ($pgac_cv_check_readline)])
158 if test "$pgac_cv_check_readline" != no ; then
159 LIBS="$pgac_cv_check_readline $LIBS"
160 AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library])
163 ])# PGAC_CHECK_READLINE
167 # PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
168 # ---------------------------------------
169 # Readline versions < 2.1 don't have rl_completion_append_character
171 AC_DEFUN([PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER],
172 [AC_MSG_CHECKING([for rl_completion_append_character])
173 AC_TRY_LINK([#include <stdio.h>
174 #ifdef HAVE_READLINE_READLINE_H
175 # include <readline/readline.h>
176 #elif defined(HAVE_READLINE_H)
177 # include <readline.h>
180 [rl_completion_append_character = 'x';],
182 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
183 [Define to 1 if you have the global variable 'rl_completion_append_character'.])],
184 [AC_MSG_RESULT(no)])])# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
190 # We check for bind_textdomain_codeset() not just gettext(). GNU gettext
191 # before 0.10.36 does not have that function, and is generally too incomplete
194 AC_DEFUN([PGAC_CHECK_GETTEXT],
196 AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [],
197 [AC_MSG_ERROR([a gettext implementation is required for NLS])])
198 AC_CHECK_HEADER([libintl.h], [],
199 [AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
200 AC_CHECK_PROGS(MSGFMT, msgfmt)
201 if test -z "$MSGFMT"; then
202 AC_MSG_ERROR([msgfmt is required for NLS])
204 AC_CHECK_PROGS(MSGMERGE, msgmerge)
205 AC_CHECK_PROGS(XGETTEXT, xgettext)
206 ])# PGAC_CHECK_GETTEXT
212 # Check for a 'strip' program, and figure out if that program can
215 AC_DEFUN([PGAC_CHECK_STRIP],
217 AC_CHECK_TOOL(STRIP, strip, :)
219 AC_MSG_CHECKING([whether it is possible to strip libraries])
220 if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
221 STRIP_STATIC_LIB="$STRIP -x"
222 STRIP_SHARED_LIB="$STRIP --strip-unneeded"
229 AC_SUBST(STRIP_STATIC_LIB)
230 AC_SUBST(STRIP_SHARED_LIB)