Skip to content
Snippets Groups Projects
Commit 1d26226d authored by Tom Lane's avatar Tom Lane
Browse files

Make an attempt at fixing our current Solaris 11 breakage: add a configure

probe for opterr (exactly like the one for optreset) and have getopt.c
define the variables only if configure doesn't find them in libc.
parent 090173a3
Branches
Tags
No related merge requests found
......@@ -18655,6 +18655,65 @@ fi
fi
 
 
{ echo "$as_me:$LINENO: checking for opterr" >&5
echo $ECHO_N "checking for opterr... $ECHO_C" >&6; }
if test "${pgac_cv_var_int_opterr+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <unistd.h>
int
main ()
{
extern int opterr; opterr = 1;
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
(eval "$ac_link") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext &&
$as_test_x conftest$ac_exeext; then
pgac_cv_var_int_opterr=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
pgac_cv_var_int_opterr=no
fi
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
conftest$ac_exeext conftest.$ac_ext
fi
{ echo "$as_me:$LINENO: result: $pgac_cv_var_int_opterr" >&5
echo "${ECHO_T}$pgac_cv_var_int_opterr" >&6; }
if test x"$pgac_cv_var_int_opterr" = x"yes"; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_INT_OPTERR 1
_ACEOF
fi
{ echo "$as_me:$LINENO: checking for optreset" >&5
echo $ECHO_N "checking for optreset... $ECHO_C" >&6; }
if test "${pgac_cv_var_int_optreset+set}" = set; then
......
dnl Process this file with autoconf to produce a configure script.
dnl $PostgreSQL: pgsql/configure.in,v 1.592 2009/03/27 19:58:11 tgl Exp $
dnl $PostgreSQL: pgsql/configure.in,v 1.593 2009/04/04 21:55:50 tgl Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
......@@ -1317,6 +1317,15 @@ AC_CHECK_FUNC(syslog,
[AC_CHECK_HEADER(syslog.h,
[AC_DEFINE(HAVE_SYSLOG, 1, [Define to 1 if you have the syslog interface.])])])
AC_CACHE_CHECK([for opterr], pgac_cv_var_int_opterr,
[AC_TRY_LINK([#include <unistd.h>],
[extern int opterr; opterr = 1;],
[pgac_cv_var_int_opterr=yes],
[pgac_cv_var_int_opterr=no])])
if test x"$pgac_cv_var_int_opterr" = x"yes"; then
AC_DEFINE(HAVE_INT_OPTERR, 1, [Define to 1 if you have the global variable 'int opterr'.])
fi
AC_CACHE_CHECK([for optreset], pgac_cv_var_int_optreset,
[AC_TRY_LINK([#include <unistd.h>],
[extern int optreset; optreset = 1;],
......
......@@ -221,6 +221,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the global variable 'int opterr'. */
#undef HAVE_INT_OPTERR
/* Define to 1 if you have the global variable 'int optreset'. */
#undef HAVE_INT_OPTRESET
......
/* $PostgreSQL: pgsql/src/port/getopt.c,v 1.11 2007/03/26 21:44:11 momjian Exp $ */
/* $PostgreSQL: pgsql/src/port/getopt.c,v 1.12 2009/04/04 21:55:50 tgl Exp $ */
/* This is used by psql under Win32 */
......@@ -37,12 +37,25 @@ static char sccsid[] = "@(#)getopt.c 8.3 (Berkeley) 4/27/95";
#endif /* LIBC_SCCS and not lint */
/*
* On some versions of Solaris, opterr and friends are defined in core libc
* rather than in a separate getopt module. Define these variables only
* if configure found they aren't there by default. (We assume that testing
* opterr is sufficient for all of these except optreset.)
*/
#ifndef HAVE_INT_OPTERR
int opterr = 1, /* if error message should be printed */
optind = 1, /* index into parent argv vector */
optopt, /* character checked for validity */
optreset; /* reset getopt */
optopt; /* character checked for validity */
char *optarg; /* argument associated with option */
#endif
#ifndef HAVE_INT_OPTRESET
int optreset; /* reset getopt */
#endif
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment