Improve sublink pullup code to handle ANY/EXISTS sublinks that are at top
[PostgreSQL.git] / config / programs.m4
blob6eb6b4948d85dee344a0a40c0753a073002bca97
1 # $PostgreSQL$
4 # PGAC_PATH_YACC
5 # --------------
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'])
16 if test "$YACC"; then
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;}'
20   then
21     AC_MSG_WARN([
22 *** The installed version of Bison is too old to use with PostgreSQL.
23 *** Bison version 1.875 or later is required.])
24     YACC=""
25   fi
28 if test -z "$YACC"; then
29   AC_MSG_WARN([
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
36 *** 'configure'.])
38 # We don't need AC_SUBST(YACC) because AC_PATH_PROG did it
39 AC_SUBST(YFLAGS)
40 ])# PGAC_PATH_YACC
44 # PGAC_PATH_FLEX
45 # --------------
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
55 else
56   pgac_save_IFS=$IFS
57   IFS=$PATH_SEPARATOR
58   for pgac_dir in $PATH; do
59     IFS=$pgac_save_IFS
60     if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
61       pgac_dir=`pwd`
62     fi
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
67       then
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
72             continue
73           fi
75           pgac_cv_path_flex=$pgac_candidate
76           break 2
77         fi
78       fi
79     done
80   done
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
88     AC_MSG_WARN([
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.])
91   fi
93   AC_MSG_WARN([
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.)])
100   FLEX=
101 else
102   FLEX=$pgac_cv_path_flex
103   pgac_flex_version=`$FLEX -V 2>/dev/null`
104   AC_MSG_NOTICE([using $pgac_flex_version])
107 AC_SUBST(FLEX)
108 AC_SUBST(FLEXFLAGS)
109 ])# PGAC_PATH_FLEX
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
124 pgac_save_LIBS=$LIBS
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.
137       case $host_os in
138         netbsd* | openbsd* | irix*)
139           if test x"$pgac_lib" = x"" ; then
140             pgac_lib=" -lcurses"
141           fi ;;
142       esac
144       pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
145       break
146     ]])
147   done
148   if test "$pgac_cv_check_readline" != no ; then
149     AC_MSG_RESULT([yes ($pgac_cv_check_readline)])
150     break
151   else
152     AC_MSG_RESULT(no)
153   fi
154 done
155 LIBS=$pgac_save_LIBS
156 ])[]dnl AC_CACHE_VAL
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>
178 #endif
180 [rl_completion_append_character = 'x';],
181 [AC_MSG_RESULT(yes)
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
188 # PGAC_CHECK_GETTEXT
189 # ------------------
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
192 # to be usable.
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])
203   fi
204   AC_CHECK_PROGS(MSGMERGE, msgmerge)
205   AC_CHECK_PROGS(XGETTEXT, xgettext)
206 ])# PGAC_CHECK_GETTEXT
210 # PGAC_CHECK_STRIP
211 # ----------------
212 # Check for a 'strip' program, and figure out if that program can
213 # strip libraries.
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"
223     AC_MSG_RESULT(yes)
224   else
225     STRIP_STATIC_LIB=:
226     STRIP_SHARED_LIB=:
227     AC_MSG_RESULT(no)
228   fi
229   AC_SUBST(STRIP_STATIC_LIB)
230   AC_SUBST(STRIP_SHARED_LIB)
231 ])# PGAC_CHECK_STRIP