]> granicus.if.org Git - postgresql/blob - config/programs.m4
Consistently quote encoding and locale names in messages
[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 fi
27
28 if test -z "$BISON"; then
29   AC_MSG_WARN([
30 *** Without Bison you will not be able to build PostgreSQL from Git 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.)])
35 fi
36 # We don't need AC_SUBST(BISON) because AC_PATH_PROG did it
37 AC_SUBST(BISONFLAGS)
38 ])# PGAC_PATH_BISON
39
40
41
42 # PGAC_PATH_FLEX
43 # --------------
44 # Look for Flex, set the output variable FLEX to its path if found.
45 # Reject versions before 2.5.31, as we need a reasonably non-buggy reentrant
46 # scanner.  (Note: the well-publicized security problem in 2.5.31 does not
47 # affect Postgres, and there are still distros shipping patched 2.5.31,
48 # so allow it.)  Also find Flex if its installed under `lex', but do not
49 # accept other Lex programs.
50
51 AC_DEFUN([PGAC_PATH_FLEX],
52 [AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
53 [# Let the user override the test
54 if test -n "$FLEX"; then
55   pgac_cv_path_flex=$FLEX
56 else
57   pgac_save_IFS=$IFS
58   IFS=$PATH_SEPARATOR
59   for pgac_dir in $PATH; do
60     IFS=$pgac_save_IFS
61     if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
62       pgac_dir=`pwd`
63     fi
64     for pgac_prog in flex lex; do
65       pgac_candidate="$pgac_dir/$pgac_prog"
66       if test -f "$pgac_candidate" \
67         && $pgac_candidate --version </dev/null >/dev/null 2>&1
68       then
69         echo '%%'  > conftest.l
70         if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
71           pgac_flex_version=`$pgac_candidate --version 2>/dev/null`
72           if echo "$pgac_flex_version" | sed ['s/[.a-z]/ /g'] | $AWK '{ if ([$]1 = 2 && [$]2 = 5 && [$]3 >= 31) exit 0; else exit 1;}'
73           then
74             pgac_cv_path_flex=$pgac_candidate
75             break 2
76           else
77             AC_MSG_WARN([
78 *** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL.
79 *** Flex version 2.5.31 or later is required, but this is $pgac_flex_version.])
80           fi
81         fi
82       fi
83     done
84   done
85   rm -f conftest.l lex.yy.c
86   : ${pgac_cv_path_flex=no}
87 fi
88 ])[]dnl AC_CACHE_CHECK
89
90 if test x"$pgac_cv_path_flex" = x"no"; then
91   AC_MSG_WARN([
92 *** Without Flex you will not be able to build PostgreSQL from Git nor
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.)])
97
98   FLEX=
99 else
100   FLEX=$pgac_cv_path_flex
101   pgac_flex_version=`$FLEX --version 2>/dev/null`
102   AC_MSG_NOTICE([using $pgac_flex_version])
103 fi
104
105 AC_SUBST(FLEX)
106 AC_SUBST(FLEXFLAGS)
107 ])# PGAC_PATH_FLEX
108
109
110
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.
116
117 AC_DEFUN([PGAC_CHECK_READLINE],
118 [AC_REQUIRE([AC_CANONICAL_HOST])
119
120 AC_CACHE_CHECK([for library containing readline], [pgac_cv_check_readline],
121 [pgac_cv_check_readline=no
122 pgac_save_LIBS=$LIBS
123 if test x"$with_libedit_preferred" != x"yes"
124 then    READLINE_ORDER="-lreadline -ledit"
125 else    READLINE_ORDER="-ledit -lreadline"
126 fi
127 for pgac_rllib in $READLINE_ORDER ; do
128   for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
129     LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
130     AC_TRY_LINK_FUNC([readline], [[
131       # Older NetBSD, OpenBSD, and Irix have a broken linker that does not
132       # recognize dependent libraries; assume curses is needed if we didn't
133       # find any dependency.
134       case $host_os in
135         netbsd* | openbsd* | irix*)
136           if test x"$pgac_lib" = x"" ; then
137             pgac_lib=" -lcurses"
138           fi ;;
139       esac
140
141       pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
142       break
143     ]])
144   done
145   if test "$pgac_cv_check_readline" != no ; then
146     break
147   fi
148 done
149 LIBS=$pgac_save_LIBS
150 ])[]dnl AC_CACHE_CHECK
151
152 if test "$pgac_cv_check_readline" != no ; then
153   LIBS="$pgac_cv_check_readline $LIBS"
154   AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library])
155 fi
156
157 ])# PGAC_CHECK_READLINE
158
159
160
161 # PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
162 # ---------------------------------------
163 # Readline versions < 2.1 don't have rl_completion_append_character
164
165 AC_DEFUN([PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER],
166 [AC_CACHE_CHECK([for rl_completion_append_character], pgac_cv_var_rl_completion_append_character,
167 [AC_TRY_LINK([#include <stdio.h>
168 #ifdef HAVE_READLINE_READLINE_H
169 # include <readline/readline.h>
170 #elif defined(HAVE_READLINE_H)
171 # include <readline.h>
172 #endif
173 ],
174 [rl_completion_append_character = 'x';],
175 [pgac_cv_var_rl_completion_append_character=yes],
176 [pgac_cv_var_rl_completion_append_character=no])])
177 if test x"$pgac_cv_var_rl_completion_append_character" = x"yes"; then
178 AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
179           [Define to 1 if you have the global variable 'rl_completion_append_character'.])
180 fi])# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
181
182
183
184 # PGAC_CHECK_GETTEXT
185 # ------------------
186 # We check for bind_textdomain_codeset() not just gettext().  GNU gettext
187 # before 0.10.36 does not have that function, and is generally too incomplete
188 # to be usable.
189
190 AC_DEFUN([PGAC_CHECK_GETTEXT],
191 [
192   AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [],
193                  [AC_MSG_ERROR([a gettext implementation is required for NLS])])
194   AC_CHECK_HEADER([libintl.h], [],
195                   [AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
196   AC_CHECK_PROGS(MSGFMT, msgfmt)
197   if test -z "$MSGFMT"; then
198     AC_MSG_ERROR([msgfmt is required for NLS])
199   fi
200   AC_CHECK_PROGS(MSGMERGE, msgmerge)
201   AC_CHECK_PROGS(XGETTEXT, xgettext)
202 ])# PGAC_CHECK_GETTEXT
203
204
205
206 # PGAC_CHECK_STRIP
207 # ----------------
208 # Check for a 'strip' program, and figure out if that program can
209 # strip libraries.
210
211 AC_DEFUN([PGAC_CHECK_STRIP],
212 [
213   AC_CHECK_TOOL(STRIP, strip, :)
214
215   AC_MSG_CHECKING([whether it is possible to strip libraries])
216   if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
217     STRIP_STATIC_LIB="$STRIP -x"
218     STRIP_SHARED_LIB="$STRIP --strip-unneeded"
219     AC_MSG_RESULT(yes)
220   else
221     STRIP_STATIC_LIB=:
222     STRIP_SHARED_LIB=:
223     AC_MSG_RESULT(no)
224   fi
225   AC_SUBST(STRIP_STATIC_LIB)
226   AC_SUBST(STRIP_SHARED_LIB)
227 ])# PGAC_CHECK_STRIP