fi
+echo "$as_me:$LINENO: checking for struct option" >&5
+echo $ECHO_N "checking for struct option... $ECHO_C" >&6
+if test "${ac_cv_type_struct_option+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+#ifdef HAVE_GETOPT_H
+include <getopt.h>
+#endif
+
+#ifdef F77_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+if ((struct option *) 0)
+ return 0;
+if (sizeof (struct option))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_type_struct_option=yes
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+ac_cv_type_struct_option=no
+fi
+rm -f conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_type_struct_option" >&5
+echo "${ECHO_T}$ac_cv_type_struct_option" >&6
+if test $ac_cv_type_struct_option = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_OPTION 1
+_ACEOF
+
+
+fi
+
+
if test "$with_zlib" = yes; then
# Check that <zlib.h> defines z_streamp (versions before about 1.0.4
# did not). While we could work around the lack of z_streamp, it
-
-for ac_func in crypt fseeko getopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
+for ac_func in crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
LIBOBJS="$LIBOBJS getaddrinfo.$ac_objext"
fi
+# similarly, use system's getopt_long() only if system provides struct option.
+if test x"$ac_cv_type_struct_option" = xyes ; then
+
+for ac_func in getopt_long
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+#line $LINENO "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+char (*f) ();
+
+#ifdef F77_DUMMY_MAIN
+# ifdef __cplusplus
+ extern "C"
+# endif
+ int F77_DUMMY_MAIN() { return 1; }
+#endif
+int
+main ()
+{
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+f = $ac_func;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+cat conftest.$ac_ext >&5
+eval "$as_ac_var=no"
+fi
+rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+else
+ LIBOBJS="$LIBOBJS $ac_func.$ac_objext"
+fi
+done
+
+
+else
+ LIBOBJS="$LIBOBJS getopt_long.$ac_objext"
+fi
+
# BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
# We override the previous test that said fseeko/ftello didn't exist
# OS tests are also done in include/c.h and port/fseeko.c
dnl Process this file with autoconf to produce a configure script.
-dnl $Header: /cvsroot/pgsql/configure.in,v 1.277 2003/08/04 22:30:30 pgsql Exp $
+dnl $Header: /cvsroot/pgsql/configure.in,v 1.278 2003/08/07 21:11:57 tgl Exp $
dnl
dnl Developers, please strive to achieve this order:
dnl
#include <sys/socket.h>
#include <sys/ucred.h>])
+AC_CHECK_TYPES([struct option], [], [],
+[#ifdef HAVE_GETOPT_H
+include <getopt.h>
+#endif])
+
if test "$with_zlib" = yes; then
# Check that <zlib.h> defines z_streamp (versions before about 1.0.4
# did not). While we could work around the lack of z_streamp, it
AC_CHECK_FUNCS([fpclass fp_class fp_class_d class], [break])
fi
-AC_REPLACE_FUNCS([crypt fseeko getopt getopt_long getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
+AC_REPLACE_FUNCS([crypt fseeko getopt getrusage inet_aton random rint srandom strcasecmp strdup strerror strtol strtoul])
# system's version of getaddrinfo(), if any, may be used only if we found
# a definition for struct addrinfo; see notes in src/include/getaddrinfo.h
AC_LIBOBJ(getaddrinfo)
fi
+# similarly, use system's getopt_long() only if system provides struct option.
+if test x"$ac_cv_type_struct_option" = xyes ; then
+ AC_REPLACE_FUNCS([getopt_long])
+else
+ AC_LIBOBJ(getopt_long)
+fi
+
# BSD/OS & NetBSD use a custom fseeko/ftello built on fsetpos/fgetpos
# We override the previous test that said fseeko/ftello didn't exist
# OS tests are also done in include/c.h and port/fseeko.c
* Portions Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
- * Portions Copyright (c) 2003
- * PostgreSQL Global Development Group
+ * Portions Copyright (c) 2003, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/include/getopt_long.h,v 1.2 2003/08/04 00:43:29 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/include/getopt_long.h,v 1.3 2003/08/07 21:11:58 tgl Exp $
*/
+#ifndef GETOPT_LONG_H
+#define GETOPT_LONG_H
+
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
/* These are picked up from the system's getopt() facility. */
extern int opterr;
/* Some systems have this, otherwise you need to define it somewhere. */
extern int optreset;
+#ifndef HAVE_STRUCT_OPTION
+
struct option
{
const char *name;
#define no_argument 0
#define required_argument 1
-int getopt_long(int argc, char *const argv[],
+#endif
+
+#ifndef HAVE_GETOPT_LONG
+
+extern int getopt_long(int argc, char *const argv[],
const char *optstring,
const struct option * longopts, int *longindex);
+
+#endif
+
+#endif /* GETOPT_LONG_H */