]> granicus.if.org Git - postgresql/blob - config/programs.m4
Fix the readline test to find dependent libraries on NetBSD and OpenBSD.
[postgresql] / config / programs.m4
1 # $Header: /cvsroot/pgsql/config/programs.m4,v 1.7 2001/08/28 14:59:11 petere Exp $
2
3
4 # PGAC_PATH_FLEX
5 # --------------
6 # Look for Flex, set the output variable FLEX to its path if found.
7 # Avoid the buggy version 2.5.3. Also find Flex if its installed
8 # under `lex', but do not accept other Lex programs.
9
10 AC_DEFUN([PGAC_PATH_FLEX],
11 [AC_CACHE_CHECK([for flex], pgac_cv_path_flex,
12 [# Let the user override the test
13 if test -n "$FLEX"; then
14   pgac_cv_path_flex=$FLEX
15 else
16   pgac_save_IFS=$IFS
17   IFS=:
18   for pgac_dir in $PATH; do
19     if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then
20       pgac_dir=`pwd`
21     fi
22     for pgac_prog in flex lex; do
23       pgac_candidate="$pgac_dir/$pgac_prog"
24       if test -f "$pgac_candidate" \
25         && $pgac_candidate --version </dev/null >/dev/null 2>&1
26       then
27         echo '%%'  > conftest.l
28         if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then
29           if $pgac_candidate --version | grep '2\.5\.3' >/dev/null 2>&1; then
30             pgac_broken_flex=$pgac_candidate
31             continue
32           fi
33
34           pgac_cv_path_flex=$pgac_candidate
35           break 2
36         fi
37       fi
38     done
39   done
40   IFS=$pgac_save_IFS
41   rm -f conftest.l
42   : ${pgac_cv_path_flex=no}
43 fi
44 ])[]dnl AC_CACHE_CHECK
45
46 if test x"$pgac_cv_path_flex" = x"no"; then
47   if test -n "$pgac_broken_flex"; then
48     AC_MSG_WARN([
49 *** The Flex version 2.5.3 you have at $pgac_broken_flex contains a bug. You
50 *** should get version 2.5.4 or later.])
51   fi
52
53   AC_MSG_WARN([
54 *** Without Flex you will not be able to build PostgreSQL from CVS or
55 *** change any of the scanner definition files.  You can obtain Flex from
56 *** a GNU mirror site.  (If you are using the official distribution of
57 *** PostgreSQL then you do not need to worry about this because the Flex
58 *** output is pre-generated.)])
59 fi
60
61 if test x"$pgac_cv_path_flex" = x"no"; then
62   FLEX=
63 else
64   FLEX=$pgac_cv_path_flex
65 fi
66
67 AC_SUBST(FLEX)
68 AC_SUBST(FLEXFLAGS)
69 ])# PGAC_PATH_FLEX
70
71
72
73 # PGAC_CHECK_READLINE
74 # -------------------
75 # Check for the readline library and dependent libraries, either
76 # termcap or curses.  Also try libedit, since NetBSD's is compatible.
77 # Add the required flags to LIBS, define HAVE_LIBREADLINE.
78
79 AC_DEFUN([PGAC_CHECK_READLINE],
80 [AC_REQUIRE([AC_CANONICAL_HOST])
81 AC_MSG_CHECKING([for readline])
82
83 AC_CACHE_VAL([pgac_cv_check_readline],
84 [pgac_cv_check_readline=no
85 for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do
86   for pgac_rllib in -lreadline -ledit ; do
87     pgac_save_LIBS=$LIBS
88     LIBS="${pgac_rllib}${pgac_lib} $LIBS"
89     AC_TRY_LINK_FUNC([readline], [[
90       # NetBSD and OpenBSD have a broken linker that does not
91       # recognize dependent libraries
92       case $host_os in netbsd* | openbsd* )
93         case $pgac_lib in
94           *curses*) ;;
95           *) pgac_lib=" -lcurses" ;;
96         esac
97       esac
98
99       pgac_cv_check_readline="${pgac_rllib}${pgac_lib}"
100       break 2
101     ]])
102     LIBS=$pgac_save_LIBS
103   done
104 done
105 LIBS=$pgac_save_LIBS
106 ])[]dnl AC_CACHE_VAL
107
108 if test "$pgac_cv_check_readline" != no ; then
109   AC_DEFINE(HAVE_LIBREADLINE)
110   LIBS="$pgac_cv_check_readline $LIBS"
111   AC_MSG_RESULT([yes ($pgac_cv_check_readline)])
112 else
113   AC_MSG_RESULT(no)
114 fi])# PGAC_CHECK_READLINE
115
116
117
118 # PGAC_CHECK_GETTEXT
119 # ------------------
120
121 AC_DEFUN([PGAC_CHECK_GETTEXT],
122 [
123   AC_SEARCH_LIBS(gettext, intl, [],
124                  [AC_MSG_ERROR([a gettext implementation is required for NLS])])
125   AC_CHECK_HEADER([libintl.h], [],
126                   [AC_MSG_ERROR([header file <libintl.h> is required for NLS])])
127   AC_CHECK_PROGS(MSGFMT, msgfmt)
128   if test -z "$MSGFMT"; then
129     AC_MSG_ERROR([msgfmt is required for NLS])
130   fi
131   AC_CHECK_PROGS(MSGMERGE, msgmerge)
132 dnl FIXME: We should probably check for version >=0.10.36.
133   AC_CHECK_PROGS(XGETTEXT, xgettext)
134
135   # Note: share/locale is always the default, independent of $datadir
136   localedir='${prefix}/share/locale'
137   if test x"$prefix" = x"NONE"; then
138     exp_localedir="$ac_default_prefix/share/locale"
139   else
140     exp_localedir="$prefix/share/locale"
141   fi
142
143   AC_SUBST(localedir)
144   AC_DEFINE_UNQUOTED(LOCALEDIR, ["$exp_localedir"],
145                      [location of locale files])
146 ])# PGAC_CHECK_GETTEXT