]> granicus.if.org Git - postgresql/blob - config/programs.m4
Record full paths of programs sought by "configure".
[postgresql] / config / programs.m4
1 # config/programs.m4
2
3
4 # PGAC_PATH_BISON
5 # ---------------
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.
9
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)
14 fi
15
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;}'
20   then
21     AC_MSG_WARN([
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.])
24     BISON=""
25   fi
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;}'
31   then
32     BISONFLAGS="$BISONFLAGS -Wno-deprecated"
33   fi
34 fi
35
36 if test -z "$BISON"; then
37   AC_MSG_WARN([
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.)])
43 fi
44 # We don't need AC_SUBST(BISON) because AC_PATH_PROG did it
45 AC_SUBST(BISONFLAGS)
46 ])# PGAC_PATH_BISON
47
48
49
50 # PGAC_PATH_FLEX
51 # --------------
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.
58
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
64 else
65   pgac_save_IFS=$IFS
66   IFS=$PATH_SEPARATOR
67   for pgac_dir in $PATH; do
68     IFS=$pgac_save_IFS
69     if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
70       pgac_dir=`pwd`
71     fi
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
76       then
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;}'
81           then
82             pgac_cv_path_flex=$pgac_candidate
83             break 2
84           else
85             AC_MSG_WARN([
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.])
88           fi
89         fi
90       fi
91     done
92   done
93   rm -f conftest.l lex.yy.c
94   : ${pgac_cv_path_flex=no}
95 fi
96 ])[]dnl AC_CACHE_CHECK
97
98 if test x"$pgac_cv_path_flex" = x"no"; then
99   AC_MSG_WARN([
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.)])
105
106   FLEX=
107 else
108   FLEX=$pgac_cv_path_flex
109   pgac_flex_version=`$FLEX --version 2>/dev/null`
110   AC_MSG_NOTICE([using $pgac_flex_version])
111 fi
112
113 AC_SUBST(FLEX)
114 AC_SUBST(FLEXFLAGS)
115 ])# PGAC_PATH_FLEX
116
117
118
119 # PGAC_LDAP_SAFE
120 # --------------
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.
125
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(
129 [#include <ldap.h>
130 #if !defined(LDAP_VENDOR_VERSION) || \
131      (defined(LDAP_API_FEATURE_X_OPENLDAP) && \
132       LDAP_VENDOR_VERSION >= 20424 && LDAP_VENDOR_VERSION <= 20431)
133 choke me
134 #endif], [])],
135 [pgac_cv_ldap_safe=yes],
136 [pgac_cv_ldap_safe=no])])
137
138 if test "$pgac_cv_ldap_safe" != yes; then
139   AC_MSG_WARN([
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.])
143 fi])
144
145
146
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.
152
153 AC_DEFUN([PGAC_CHECK_READLINE],
154 [AC_REQUIRE([AC_CANONICAL_HOST])
155
156 AC_CACHE_CHECK([for library containing readline], [pgac_cv_check_readline],
157 [pgac_cv_check_readline=no
158 pgac_save_LIBS=$LIBS
159 if test x"$with_libedit_preferred" != x"yes"
160 then    READLINE_ORDER="-lreadline -ledit"
161 else    READLINE_ORDER="-ledit -lreadline"
162 fi
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.
170       case $host_os in
171         netbsd* | openbsd* | irix*)
172           if test x"$pgac_lib" = x"" ; then
173             pgac_lib=" -lcurses"
174           fi ;;
175       esac
176
177       pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
178       break
179     ]])
180   done
181   if test "$pgac_cv_check_readline" != no ; then
182     break
183   fi
184 done
185 LIBS=$pgac_save_LIBS
186 ])[]dnl AC_CACHE_CHECK
187
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])
191 fi
192
193 ])# PGAC_CHECK_READLINE
194
195
196
197 # PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
198 # ---------------------------------------
199 # Readline versions < 2.1 don't have rl_completion_append_character
200
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>
208 #endif
209 ],
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
217
218
219
220 # PGAC_CHECK_GETTEXT
221 # ------------------
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
224 # to be usable.
225
226 AC_DEFUN([PGAC_CHECK_GETTEXT],
227 [
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])
235   fi
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
239 fi])
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
244
245
246
247 # PGAC_CHECK_STRIP
248 # ----------------
249 # Check for a 'strip' program, and figure out if that program can
250 # strip libraries.
251
252 AC_DEFUN([PGAC_CHECK_STRIP],
253 [
254   AC_CHECK_TOOL(STRIP, strip, :)
255
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"
260     AC_MSG_RESULT(yes)
261   else
262     case $host_os in
263       darwin*)
264         STRIP="$STRIP -x"
265         STRIP_STATIC_LIB=$STRIP
266         STRIP_SHARED_LIB=$STRIP
267         AC_MSG_RESULT(yes)
268         ;;
269       *)
270         STRIP_STATIC_LIB=:
271         STRIP_SHARED_LIB=:
272         AC_MSG_RESULT(no)
273         ;;
274     esac
275   fi
276   AC_SUBST(STRIP_STATIC_LIB)
277   AC_SUBST(STRIP_SHARED_LIB)
278 ])# PGAC_CHECK_STRIP