programs.m4 7.5 KB
Newer Older
1
# config/programs.m4
2 3


4 5 6
# PGAC_PATH_BISON
# ---------------
# Look for Bison, set the output variable BISON to its path if found.
7 8 9
# Reject versions before 1.875 (they have bugs or capacity limits).
# 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_PATH_PROGS(BISON, bison)
14 15
fi

16 17 18 19
if test "$BISON"; then
  pgac_bison_version=`$BISON --version 2>/dev/null | sed q`
  AC_MSG_NOTICE([using $pgac_bison_version])
  if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 1.875) exit 0; else exit 1;}'
20 21
  then
    AC_MSG_WARN([
22 23
*** The installed version of Bison, $BISON, is too old to use with PostgreSQL.
*** Bison version 1.875 or later is required, but this is $pgac_bison_version.])
24
    BISON=""
25 26 27
  fi
fi

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 37 38
# We don't need AC_SUBST(BISON) because AC_PATH_PROG did it
AC_SUBST(BISONFLAGS)
])# PGAC_PATH_BISON
39

40 41 42 43 44


# PGAC_PATH_FLEX
# --------------
# Look for Flex, set the output variable FLEX to its path if found.
45 46 47 48 49
# Reject versions before 2.5.31, as we need a reasonably non-buggy reentrant
# scanner.  (Note: the well-publicized security problem in 2.5.31 does not
# affect Postgres, and there are still distros shipping patched 2.5.31,
# so allow it.)  Also find Flex if its installed under `lex', but do not
# accept other Lex programs.
50 51 52 53 54 55 56 57

AC_DEFUN([PGAC_PATH_FLEX],
[AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
[# Let the user override the test
if test -n "$FLEX"; then
  pgac_cv_path_flex=$FLEX
else
  pgac_save_IFS=$IFS
58
  IFS=$PATH_SEPARATOR
59
  for pgac_dir in $PATH; do
60
    IFS=$pgac_save_IFS
61 62 63 64 65 66
    if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
      pgac_dir=`pwd`
    fi
    for pgac_prog in flex lex; do
      pgac_candidate="$pgac_dir/$pgac_prog"
      if test -f "$pgac_candidate" \
67
        && $pgac_candidate --version </dev/null >/dev/null 2>&1
68 69 70
      then
        echo '%%'  > conftest.l
        if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
71 72 73 74 75 76 77 78
          pgac_flex_version=`$pgac_candidate --version 2>/dev/null`
          if echo "$pgac_flex_version" | sed ['s/[.a-z]/ /g'] | $AWK '{ if ([$]1 = 2 && [$]2 = 5 && [$]3 >= 31) exit 0; else exit 1;}'
          then
            pgac_cv_path_flex=$pgac_candidate
            break 2
          else
            AC_MSG_WARN([
*** 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 81 82 83 84
          fi
        fi
      fi
    done
  done
85
  rm -f conftest.l lex.yy.c
86 87 88 89 90 91
  : ${pgac_cv_path_flex=no}
fi
])[]dnl AC_CACHE_CHECK

if test x"$pgac_cv_path_flex" = x"no"; then
  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 96
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)])
97 98 99 100

  FLEX=
else
  FLEX=$pgac_cv_path_flex
101
  pgac_flex_version=`$FLEX --version 2>/dev/null`
102
  AC_MSG_NOTICE([using $pgac_flex_version])
103 104 105 106 107
fi

AC_SUBST(FLEX)
AC_SUBST(FLEXFLAGS)
])# PGAC_PATH_FLEX
108 109 110 111 112 113 114 115 116 117



# PGAC_CHECK_READLINE
# -------------------
# Check for the readline library and dependent libraries, either
# termcap or curses.  Also try libedit, since NetBSD's is compatible.
# Add the required flags to LIBS, define HAVE_LIBREADLINE.

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 124 125 126 127
if test x"$with_libedit_preferred" != x"yes"
then	READLINE_ORDER="-lreadline -ledit"
else	READLINE_ORDER="-ledit -lreadline"
fi
for pgac_rllib in $READLINE_ORDER ; do
128 129
  for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
    LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS"
130
    AC_TRY_LINK_FUNC([readline], [[
131 132 133 134 135 136 137 138
      # Older NetBSD, OpenBSD, and Irix have a broken linker that does not
      # recognize dependent libraries; assume curses is needed if we didn't
      # find any dependency.
      case $host_os in
        netbsd* | openbsd* | irix*)
          if test x"$pgac_lib" = x"" ; then
            pgac_lib=" -lcurses"
          fi ;;
139 140 141
      esac

      pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
142
      break
143
    ]])
144
  done
145 146 147
  if test "$pgac_cv_check_readline" != no ; then
    break
  fi
148 149
done
LIBS=$pgac_save_LIBS
150
])[]dnl AC_CACHE_CHECK
151 152 153

if test "$pgac_cv_check_readline" != no ; then
  LIBS="$pgac_cv_check_readline $LIBS"
154 155 156 157
  AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library])
fi

])# PGAC_CHECK_READLINE
P
Peter Eisentraut 已提交
158 159 160



161 162 163 164 165
# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
# ---------------------------------------
# Readline versions < 2.1 don't have rl_completion_append_character

AC_DEFUN([PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER],
166 167
[AC_CACHE_CHECK([for rl_completion_append_character], pgac_cv_var_rl_completion_append_character,
[AC_TRY_LINK([#include <stdio.h>
168 169 170 171 172 173 174
#ifdef HAVE_READLINE_READLINE_H
# include <readline/readline.h>
#elif defined(HAVE_READLINE_H)
# include <readline.h>
#endif
],
[rl_completion_append_character = 'x';],
175 176 177
[pgac_cv_var_rl_completion_append_character=yes],
[pgac_cv_var_rl_completion_append_character=no])])
if test x"$pgac_cv_var_rl_completion_append_character" = x"yes"; then
178
AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
179 180
          [Define to 1 if you have the global variable 'rl_completion_append_character'.])
fi])# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER
181 182 183



P
Peter Eisentraut 已提交
184 185
# PGAC_CHECK_GETTEXT
# ------------------
186 187 188
# We check for bind_textdomain_codeset() not just gettext().  GNU gettext
# before 0.10.36 does not have that function, and is generally too incomplete
# to be usable.
P
Peter Eisentraut 已提交
189 190 191

AC_DEFUN([PGAC_CHECK_GETTEXT],
[
192
  AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [],
P
Peter Eisentraut 已提交
193 194 195 196 197 198 199
                 [AC_MSG_ERROR([a gettext implementation is required for NLS])])
  AC_CHECK_HEADER([libintl.h], [],
                  [AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
  AC_CHECK_PROGS(MSGFMT, msgfmt)
  if test -z "$MSGFMT"; then
    AC_MSG_ERROR([msgfmt is required for NLS])
  fi
200 201 202 203 204
  AC_CACHE_CHECK([for msgfmt flags], pgac_cv_msgfmt_flags,
[if test x"$MSGFMT" != x"" && "$MSGFMT" --version 2>&1 | grep "GNU" >/dev/null; then
    pgac_cv_msgfmt_flags=-c
fi])
  AC_SUBST(MSGFMT_FLAGS, $pgac_cv_msgfmt_flags)
P
Peter Eisentraut 已提交
205 206 207
  AC_CHECK_PROGS(MSGMERGE, msgmerge)
  AC_CHECK_PROGS(XGETTEXT, xgettext)
])# PGAC_CHECK_GETTEXT
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225



# PGAC_CHECK_STRIP
# ----------------
# Check for a 'strip' program, and figure out if that program can
# strip libraries.

AC_DEFUN([PGAC_CHECK_STRIP],
[
  AC_CHECK_TOOL(STRIP, strip, :)

  AC_MSG_CHECKING([whether it is possible to strip libraries])
  if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then
    STRIP_STATIC_LIB="$STRIP -x"
    STRIP_SHARED_LIB="$STRIP --strip-unneeded"
    AC_MSG_RESULT(yes)
  else
P
Peter Eisentraut 已提交
226 227 228 229 230 231 232 233 234 235 236 237 238
    case $host_os in
      darwin*)
        STRIP="$STRIP -x"
        STRIP_STATIC_LIB=$STRIP
        STRIP_SHARED_LIB=$STRIP
        AC_MSG_RESULT(yes)
        ;;
      *)
        STRIP_STATIC_LIB=:
        STRIP_SHARED_LIB=:
        AC_MSG_RESULT(no)
        ;;
    esac
239 240 241 242
  fi
  AC_SUBST(STRIP_STATIC_LIB)
  AC_SUBST(STRIP_SHARED_LIB)
])# PGAC_CHECK_STRIP