1# config/programs.m4 2 3 4# PGAC_PATH_PROGS 5# --------------- 6# This wrapper for AC_PATH_PROGS behaves like that macro except when 7# VARIABLE is already set; in that case we just accept the value verbatim. 8# (AC_PATH_PROGS would accept it only if it looks like an absolute path.) 9# A desirable future improvement would be to convert a non-absolute-path 10# input into absolute form. 11AC_DEFUN([PGAC_PATH_PROGS], 12[if test -z "$$1"; then 13 AC_PATH_PROGS($@) 14else 15 # Report the value of $1 in configure's output in all cases. 16 AC_MSG_CHECKING([for $1]) 17 AC_MSG_RESULT([$$1]) 18fi 19]) 20 21 22# PGAC_PATH_BISON 23# --------------- 24# Look for Bison, set the output variable BISON to its path if found. 25# Reject versions before 1.875 (they have bugs or capacity limits). 26# Note we do not accept other implementations of yacc. 27 28AC_DEFUN([PGAC_PATH_BISON], 29[PGAC_PATH_PROGS(BISON, bison) 30 31if test "$BISON"; then 32 pgac_bison_version=`$BISON --version 2>/dev/null | sed q` 33 AC_MSG_NOTICE([using $pgac_bison_version]) 34 if echo "$pgac_bison_version" | $AWK '{ if ([$]4 < 1.875) exit 0; else exit 1;}' 35 then 36 AC_MSG_WARN([ 37*** The installed version of Bison, $BISON, is too old to use with PostgreSQL. 38*** Bison version 1.875 or later is required, but this is $pgac_bison_version.]) 39 BISON="" 40 fi 41 # Bison >=3.0 issues warnings about %name-prefix="base_yy", instead 42 # of the now preferred %name-prefix "base_yy", but the latter 43 # doesn't work with Bison 2.3 or less. So for now we silence the 44 # deprecation warnings. 45 if echo "$pgac_bison_version" | $AWK '{ if ([$]4 >= 3) exit 0; else exit 1;}' 46 then 47 BISONFLAGS="$BISONFLAGS -Wno-deprecated" 48 fi 49fi 50 51if test -z "$BISON"; then 52 AC_MSG_WARN([ 53*** Without Bison you will not be able to build PostgreSQL from Git nor 54*** change any of the parser definition files. You can obtain Bison from 55*** a GNU mirror site. (If you are using the official distribution of 56*** PostgreSQL then you do not need to worry about this, because the Bison 57*** output is pre-generated.)]) 58fi 59# We don't need AC_SUBST(BISON) because PGAC_PATH_PROGS did it 60AC_SUBST(BISONFLAGS) 61])# PGAC_PATH_BISON 62 63 64 65# PGAC_PATH_FLEX 66# -------------- 67# Look for Flex, set the output variable FLEX to its path if found. 68# Reject versions before 2.5.31, as we need a reasonably non-buggy reentrant 69# scanner. (Note: the well-publicized security problem in 2.5.31 does not 70# affect Postgres, and there are still distros shipping patched 2.5.31, 71# so allow it.) Also find Flex if its installed under `lex', but do not 72# accept other Lex programs. 73 74AC_DEFUN([PGAC_PATH_FLEX], 75[AC_CACHE_CHECK([for flex], pgac_cv_path_flex, 76[# Let the user override the test 77if test -n "$FLEX"; then 78 pgac_cv_path_flex=$FLEX 79else 80 pgac_save_IFS=$IFS 81 IFS=$PATH_SEPARATOR 82 for pgac_dir in $PATH; do 83 IFS=$pgac_save_IFS 84 if test -z "$pgac_dir" || test x"$pgac_dir" = x"."; then 85 pgac_dir=`pwd` 86 fi 87 for pgac_prog in flex lex; do 88 pgac_candidate="$pgac_dir/$pgac_prog" 89 if test -f "$pgac_candidate" \ 90 && $pgac_candidate --version </dev/null >/dev/null 2>&1 91 then 92 echo '%%' > conftest.l 93 if $pgac_candidate -t conftest.l 2>/dev/null | grep FLEX_SCANNER >/dev/null 2>&1; then 94 pgac_flex_version=`$pgac_candidate --version 2>/dev/null` 95 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;}' 96 then 97 pgac_cv_path_flex=$pgac_candidate 98 break 2 99 else 100 AC_MSG_WARN([ 101*** The installed version of Flex, $pgac_candidate, is too old to use with PostgreSQL. 102*** Flex version 2.5.31 or later is required, but this is $pgac_flex_version.]) 103 fi 104 fi 105 fi 106 done 107 done 108 rm -f conftest.l lex.yy.c 109 : ${pgac_cv_path_flex=no} 110fi 111])[]dnl AC_CACHE_CHECK 112 113if test x"$pgac_cv_path_flex" = x"no"; then 114 AC_MSG_WARN([ 115*** Without Flex you will not be able to build PostgreSQL from Git nor 116*** change any of the scanner definition files. You can obtain Flex from 117*** a GNU mirror site. (If you are using the official distribution of 118*** PostgreSQL then you do not need to worry about this because the Flex 119*** output is pre-generated.)]) 120 121 FLEX= 122else 123 FLEX=$pgac_cv_path_flex 124 pgac_flex_version=`$FLEX --version 2>/dev/null` 125 AC_MSG_NOTICE([using $pgac_flex_version]) 126fi 127 128AC_SUBST(FLEX) 129AC_SUBST(FLEXFLAGS) 130])# PGAC_PATH_FLEX 131 132 133 134# PGAC_LDAP_SAFE 135# -------------- 136# PostgreSQL sometimes loads libldap_r and plain libldap into the same 137# process. Check for OpenLDAP versions known not to tolerate doing so; assume 138# non-OpenLDAP implementations are safe. The dblink test suite exercises the 139# hazardous interaction directly. 140 141AC_DEFUN([PGAC_LDAP_SAFE], 142[AC_CACHE_CHECK([for compatible LDAP implementation], [pgac_cv_ldap_safe], 143[AC_COMPILE_IFELSE([AC_LANG_PROGRAM( 144[#include <ldap.h> 145#if !defined(LDAP_VENDOR_VERSION) || \ 146 (defined(LDAP_API_FEATURE_X_OPENLDAP) && \ 147 LDAP_VENDOR_VERSION >= 20424 && LDAP_VENDOR_VERSION <= 20431) 148choke me 149#endif], [])], 150[pgac_cv_ldap_safe=yes], 151[pgac_cv_ldap_safe=no])]) 152 153if test "$pgac_cv_ldap_safe" != yes; then 154 AC_MSG_WARN([ 155*** With OpenLDAP versions 2.4.24 through 2.4.31, inclusive, each backend 156*** process that loads libpq (via WAL receiver, dblink, or postgres_fdw) and 157*** also uses LDAP will crash on exit.]) 158fi]) 159 160 161 162# PGAC_CHECK_READLINE 163# ------------------- 164# Check for the readline library and dependent libraries, either 165# termcap or curses. Also try libedit, since NetBSD's is compatible. 166# Add the required flags to LIBS, define HAVE_LIBREADLINE. 167 168AC_DEFUN([PGAC_CHECK_READLINE], 169[AC_REQUIRE([AC_CANONICAL_HOST]) 170 171AC_CACHE_CHECK([for library containing readline], [pgac_cv_check_readline], 172[pgac_cv_check_readline=no 173pgac_save_LIBS=$LIBS 174if test x"$with_libedit_preferred" != x"yes" 175then READLINE_ORDER="-lreadline -ledit" 176else READLINE_ORDER="-ledit -lreadline" 177fi 178for pgac_rllib in $READLINE_ORDER ; do 179 for pgac_lib in "" " -ltermcap" " -lncurses" " -lcurses" ; do 180 LIBS="${pgac_rllib}${pgac_lib} $pgac_save_LIBS" 181 AC_TRY_LINK_FUNC([readline], [[ 182 # Older NetBSD, OpenBSD, and Irix have a broken linker that does not 183 # recognize dependent libraries; assume curses is needed if we didn't 184 # find any dependency. 185 case $host_os in 186 netbsd* | openbsd* | irix*) 187 if test x"$pgac_lib" = x"" ; then 188 pgac_lib=" -lcurses" 189 fi ;; 190 esac 191 192 pgac_cv_check_readline="${pgac_rllib}${pgac_lib}" 193 break 194 ]]) 195 done 196 if test "$pgac_cv_check_readline" != no ; then 197 break 198 fi 199done 200LIBS=$pgac_save_LIBS 201])[]dnl AC_CACHE_CHECK 202 203if test "$pgac_cv_check_readline" != no ; then 204 LIBS="$pgac_cv_check_readline $LIBS" 205 AC_DEFINE(HAVE_LIBREADLINE, 1, [Define if you have a function readline library]) 206fi 207 208])# PGAC_CHECK_READLINE 209 210 211 212# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER 213# --------------------------------------- 214# Readline versions < 2.1 don't have rl_completion_append_character 215 216AC_DEFUN([PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER], 217[AC_CACHE_CHECK([for rl_completion_append_character], pgac_cv_var_rl_completion_append_character, 218[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h> 219#ifdef HAVE_READLINE_READLINE_H 220# include <readline/readline.h> 221#elif defined(HAVE_READLINE_H) 222# include <readline.h> 223#endif 224], 225[rl_completion_append_character = 'x';])], 226[pgac_cv_var_rl_completion_append_character=yes], 227[pgac_cv_var_rl_completion_append_character=no])]) 228if test x"$pgac_cv_var_rl_completion_append_character" = x"yes"; then 229AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1, 230 [Define to 1 if you have the global variable 'rl_completion_append_character'.]) 231fi])# PGAC_VAR_RL_COMPLETION_APPEND_CHARACTER 232 233 234 235# PGAC_CHECK_GETTEXT 236# ------------------ 237# We check for bind_textdomain_codeset() not just gettext(). GNU gettext 238# before 0.10.36 does not have that function, and is generally too incomplete 239# to be usable. 240 241AC_DEFUN([PGAC_CHECK_GETTEXT], 242[ 243 AC_SEARCH_LIBS(bind_textdomain_codeset, intl, [], 244 [AC_MSG_ERROR([a gettext implementation is required for NLS])]) 245 AC_CHECK_HEADER([libintl.h], [], 246 [AC_MSG_ERROR([header file <libintl.h> is required for NLS])]) 247 PGAC_PATH_PROGS(MSGFMT, msgfmt) 248 if test -z "$MSGFMT"; then 249 AC_MSG_ERROR([msgfmt is required for NLS]) 250 fi 251 AC_CACHE_CHECK([for msgfmt flags], pgac_cv_msgfmt_flags, 252[if test x"$MSGFMT" != x"" && "$MSGFMT" --version 2>&1 | grep "GNU" >/dev/null; then 253 pgac_cv_msgfmt_flags=-c 254fi]) 255 AC_SUBST(MSGFMT_FLAGS, $pgac_cv_msgfmt_flags) 256 PGAC_PATH_PROGS(MSGMERGE, msgmerge) 257 PGAC_PATH_PROGS(XGETTEXT, xgettext) 258])# PGAC_CHECK_GETTEXT 259 260 261 262# PGAC_CHECK_STRIP 263# ---------------- 264# Check for a 'strip' program, and figure out if that program can 265# strip libraries. 266 267AC_DEFUN([PGAC_CHECK_STRIP], 268[ 269 AC_CHECK_TOOL(STRIP, strip, :) 270 271 AC_MSG_CHECKING([whether it is possible to strip libraries]) 272 if test x"$STRIP" != x"" && "$STRIP" -V 2>&1 | grep "GNU strip" >/dev/null; then 273 STRIP_STATIC_LIB="$STRIP -x" 274 STRIP_SHARED_LIB="$STRIP --strip-unneeded" 275 AC_MSG_RESULT(yes) 276 else 277 case $host_os in 278 darwin*) 279 STRIP="$STRIP -x" 280 STRIP_STATIC_LIB=$STRIP 281 STRIP_SHARED_LIB=$STRIP 282 AC_MSG_RESULT(yes) 283 ;; 284 *) 285 STRIP_STATIC_LIB=: 286 STRIP_SHARED_LIB=: 287 AC_MSG_RESULT(no) 288 ;; 289 esac 290 fi 291 AC_SUBST(STRIP_STATIC_LIB) 292 AC_SUBST(STRIP_SHARED_LIB) 293])# PGAC_CHECK_STRIP 294