Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
# getopt.m4 serial 41
|
2012-05-26 23:14:36 +00:00
|
|
|
dnl Copyright (C) 2002-2006, 2008-2012 Free Software Foundation, Inc.
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
dnl This file is free software; the Free Software Foundation
|
|
|
|
dnl gives unlimited permission to copy and/or distribute it,
|
|
|
|
dnl with or without modifications, as long as this notice is preserved.
|
|
|
|
|
2011-01-09 07:33:50 +00:00
|
|
|
# Request a POSIX compliant getopt function.
|
|
|
|
AC_DEFUN([gl_FUNC_GETOPT_POSIX],
|
|
|
|
[
|
|
|
|
m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX])
|
|
|
|
AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
|
2011-06-15 22:27:54 +00:00
|
|
|
dnl Other modules can request the gnulib implementation of the getopt
|
|
|
|
dnl functions unconditionally, by defining gl_REPLACE_GETOPT_ALWAYS.
|
|
|
|
dnl argp.m4 does this.
|
|
|
|
m4_ifdef([gl_REPLACE_GETOPT_ALWAYS], [
|
|
|
|
gl_GETOPT_IFELSE([], [])
|
|
|
|
REPLACE_GETOPT=1
|
|
|
|
], [
|
|
|
|
REPLACE_GETOPT=0
|
|
|
|
gl_GETOPT_IFELSE([
|
|
|
|
REPLACE_GETOPT=1
|
|
|
|
],
|
|
|
|
[])
|
|
|
|
])
|
|
|
|
if test $REPLACE_GETOPT = 1; then
|
|
|
|
dnl Arrange for getopt.h to be created.
|
|
|
|
gl_GETOPT_SUBSTITUTE_HEADER
|
|
|
|
fi
|
2011-01-09 07:33:50 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
# Request a POSIX compliant getopt function with GNU extensions (such as
|
|
|
|
# options with optional arguments) and the functions getopt_long,
|
|
|
|
# getopt_long_only.
|
|
|
|
AC_DEFUN([gl_FUNC_GETOPT_GNU],
|
|
|
|
[
|
|
|
|
m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
|
|
|
|
|
|
|
|
AC_REQUIRE([gl_FUNC_GETOPT_POSIX])
|
|
|
|
])
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
|
2011-01-09 07:33:50 +00:00
|
|
|
# emacs' configure.in uses this.
|
|
|
|
AC_DEFUN([gl_GETOPT_IFELSE],
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
[
|
2011-01-09 07:33:50 +00:00
|
|
|
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
|
|
|
|
AS_IF([test -n "$gl_replace_getopt"], [$1], [$2])
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
])
|
|
|
|
|
2011-01-09 07:33:50 +00:00
|
|
|
# Determine whether to replace the entire getopt facility.
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
|
|
|
|
[
|
2011-01-09 07:33:50 +00:00
|
|
|
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
|
|
AC_REQUIRE([AC_PROG_AWK]) dnl for awk that supports ENVIRON
|
|
|
|
|
|
|
|
dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt.
|
|
|
|
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
|
|
|
|
|
|
|
|
gl_CHECK_NEXT_HEADERS([getopt.h])
|
|
|
|
if test $ac_cv_header_getopt_h = yes; then
|
|
|
|
HAVE_GETOPT_H=1
|
|
|
|
else
|
|
|
|
HAVE_GETOPT_H=0
|
|
|
|
fi
|
|
|
|
AC_SUBST([HAVE_GETOPT_H])
|
|
|
|
|
|
|
|
gl_replace_getopt=
|
|
|
|
|
|
|
|
dnl Test whether <getopt.h> is available.
|
|
|
|
if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
|
|
|
|
AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes])
|
|
|
|
fi
|
|
|
|
|
|
|
|
dnl Test whether the function getopt_long is available.
|
|
|
|
if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
|
|
|
|
AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes])
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
fi
|
|
|
|
|
2011-01-09 07:33:50 +00:00
|
|
|
dnl mingw's getopt (in libmingwex.a) does weird things when the options
|
|
|
|
dnl strings starts with '+' and it's not the first call. Some internal state
|
|
|
|
dnl is left over from earlier calls, and neither setting optind = 0 nor
|
|
|
|
dnl setting optreset = 1 get rid of this internal state.
|
|
|
|
dnl POSIX is silent on optind vs. optreset, so we allow either behavior.
|
|
|
|
dnl POSIX 2008 does not specify leading '+' behavior, but see
|
|
|
|
dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on
|
|
|
|
dnl the next version of POSIX. For now, we only guarantee leading '+'
|
|
|
|
dnl behavior with getopt-gnu.
|
|
|
|
if test -z "$gl_replace_getopt"; then
|
|
|
|
AC_CACHE_CHECK([whether getopt is POSIX compatible],
|
|
|
|
[gl_cv_func_getopt_posix],
|
|
|
|
[
|
2011-07-08 10:00:52 +00:00
|
|
|
dnl BSD getopt_long uses an incompatible method to reset option
|
|
|
|
dnl processing. Existence of the optreset variable, in and of
|
2011-01-24 04:53:39 +00:00
|
|
|
dnl itself, is not a reason to replace getopt, but knowledge
|
|
|
|
dnl of the variable is needed to determine how to reset and
|
|
|
|
dnl whether a reset reparses the environment. Solaris
|
|
|
|
dnl supports neither optreset nor optind=0, but keeps no state
|
|
|
|
dnl that needs a reset beyond setting optind=1; detect Solaris
|
|
|
|
dnl by getopt_clip.
|
2011-07-08 10:00:52 +00:00
|
|
|
AC_LINK_IFELSE(
|
2011-01-24 04:53:39 +00:00
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[[#include <unistd.h>]],
|
|
|
|
[[int *p = &optreset; return optreset;]])],
|
|
|
|
[gl_optind_min=1],
|
|
|
|
[AC_COMPILE_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM(
|
|
|
|
[[#include <getopt.h>]],
|
|
|
|
[[return !getopt_clip;]])],
|
|
|
|
[gl_optind_min=1],
|
|
|
|
[gl_optind_min=0])])
|
|
|
|
|
2011-01-09 07:33:50 +00:00
|
|
|
dnl This test fails on mingw and succeeds on many other platforms.
|
2011-01-24 04:53:39 +00:00
|
|
|
gl_save_CPPFLAGS=$CPPFLAGS
|
|
|
|
CPPFLAGS="$CPPFLAGS -DOPTIND_MIN=$gl_optind_min"
|
2011-01-09 07:33:50 +00:00
|
|
|
AC_RUN_IFELSE([AC_LANG_SOURCE([[
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
{
|
2011-07-08 10:00:52 +00:00
|
|
|
static char program[] = "program";
|
|
|
|
static char a[] = "-a";
|
|
|
|
static char foo[] = "foo";
|
|
|
|
static char bar[] = "bar";
|
|
|
|
char *argv[] = { program, a, foo, bar, NULL };
|
2011-01-09 07:33:50 +00:00
|
|
|
int c;
|
|
|
|
|
|
|
|
optind = OPTIND_MIN;
|
|
|
|
opterr = 0;
|
|
|
|
|
2011-07-08 10:00:52 +00:00
|
|
|
c = getopt (4, argv, "ab");
|
2011-01-09 07:33:50 +00:00
|
|
|
if (!(c == 'a'))
|
|
|
|
return 1;
|
2011-07-08 10:00:52 +00:00
|
|
|
c = getopt (4, argv, "ab");
|
2011-01-09 07:33:50 +00:00
|
|
|
if (!(c == -1))
|
|
|
|
return 2;
|
|
|
|
if (!(optind == 2))
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
/* Some internal state exists at this point. */
|
|
|
|
{
|
2011-07-08 10:00:52 +00:00
|
|
|
static char program[] = "program";
|
|
|
|
static char donald[] = "donald";
|
|
|
|
static char p[] = "-p";
|
|
|
|
static char billy[] = "billy";
|
|
|
|
static char duck[] = "duck";
|
|
|
|
static char a[] = "-a";
|
|
|
|
static char bar[] = "bar";
|
|
|
|
char *argv[] = { program, donald, p, billy, duck, a, bar, NULL };
|
2011-01-09 07:33:50 +00:00
|
|
|
int c;
|
|
|
|
|
|
|
|
optind = OPTIND_MIN;
|
|
|
|
opterr = 0;
|
|
|
|
|
2011-07-08 10:00:52 +00:00
|
|
|
c = getopt (7, argv, "+abp:q:");
|
2011-01-09 07:33:50 +00:00
|
|
|
if (!(c == -1))
|
|
|
|
return 4;
|
|
|
|
if (!(strcmp (argv[0], "program") == 0))
|
|
|
|
return 5;
|
|
|
|
if (!(strcmp (argv[1], "donald") == 0))
|
|
|
|
return 6;
|
|
|
|
if (!(strcmp (argv[2], "-p") == 0))
|
|
|
|
return 7;
|
|
|
|
if (!(strcmp (argv[3], "billy") == 0))
|
|
|
|
return 8;
|
|
|
|
if (!(strcmp (argv[4], "duck") == 0))
|
|
|
|
return 9;
|
|
|
|
if (!(strcmp (argv[5], "-a") == 0))
|
|
|
|
return 10;
|
|
|
|
if (!(strcmp (argv[6], "bar") == 0))
|
|
|
|
return 11;
|
|
|
|
if (!(optind == 1))
|
|
|
|
return 12;
|
|
|
|
}
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
/* Detect Mac OS X 10.5, AIX 7.1 bug. */
|
2011-01-09 07:33:50 +00:00
|
|
|
{
|
2011-07-08 10:00:52 +00:00
|
|
|
static char program[] = "program";
|
|
|
|
static char ab[] = "-ab";
|
|
|
|
char *argv[3] = { program, ab, NULL };
|
2011-01-09 07:33:50 +00:00
|
|
|
optind = OPTIND_MIN;
|
|
|
|
opterr = 0;
|
|
|
|
if (getopt (2, argv, "ab:") != 'a')
|
|
|
|
return 13;
|
|
|
|
if (getopt (2, argv, "ab:") != '?')
|
|
|
|
return 14;
|
|
|
|
if (optopt != 'b')
|
|
|
|
return 15;
|
|
|
|
if (optind != 2)
|
|
|
|
return 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
]])],
|
|
|
|
[gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no],
|
|
|
|
[case "$host_os" in
|
|
|
|
mingw*) gl_cv_func_getopt_posix="guessing no";;
|
|
|
|
darwin* | aix*) gl_cv_func_getopt_posix="guessing no";;
|
|
|
|
*) gl_cv_func_getopt_posix="guessing yes";;
|
|
|
|
esac
|
|
|
|
])
|
2011-01-24 04:53:39 +00:00
|
|
|
CPPFLAGS=$gl_save_CPPFLAGS
|
2011-01-09 07:33:50 +00:00
|
|
|
])
|
|
|
|
case "$gl_cv_func_getopt_posix" in
|
|
|
|
*no) gl_replace_getopt=yes ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then
|
|
|
|
AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_getopt_gnu],
|
|
|
|
[# Even with POSIXLY_CORRECT, the GNU extension of leading '-' in the
|
|
|
|
# optstring is necessary for programs like m4 that have POSIX-mandated
|
|
|
|
# semantics for supporting options interspersed with files.
|
|
|
|
# Also, since getopt_long is a GNU extension, we require optind=0.
|
|
|
|
# Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT;
|
|
|
|
# so take care to revert to the correct (non-)export state.
|
|
|
|
dnl GNU Coding Standards currently allow awk but not env; besides, env
|
|
|
|
dnl is ambiguous with environment values that contain newlines.
|
|
|
|
gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
|
|
|
|
case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
|
|
|
|
xx) gl_had_POSIXLY_CORRECT=exported ;;
|
|
|
|
x) gl_had_POSIXLY_CORRECT=yes ;;
|
|
|
|
*) gl_had_POSIXLY_CORRECT= ;;
|
|
|
|
esac
|
|
|
|
POSIXLY_CORRECT=1
|
|
|
|
export POSIXLY_CORRECT
|
|
|
|
AC_RUN_IFELSE(
|
|
|
|
[AC_LANG_PROGRAM([[#include <getopt.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <string.h>
|
Merge from gnulib, using build-aux to remove clutter.
* m4/largefile.m4: New file, so that Emacs does not mess up when
accessing files with large inode numbers in MacOS X 10.5 and later.
* m4/nocrash.m4: New file, to avoid triggering background debugger
and/or create core dumps during 'configure'.
* build-aux/move-if-change: Renamed from move-if-change.
* build-aux/snippet/arg-nonnull.h: Renamed from arg-nonnull.h.
* build-aux/snippet/c++defs.h: Renamed from c++defs.h.
* build-aux/snippet/warn-on-use.h: Renamed from warn-on-use.h.
* build-aux/snippet/_Noreturn.h: New file, for draft C1X _Noreturn.
* .bzrignore: The autogenerated files compile, config.guess,
config.sub, depcomp, install-sh, and missing are now in build-aux.
* Makefile.in (epaths-force, sync-from-gnulib):
move-if-change is now in build-aux.
(GNULIB_TOOL_FLAGS): Avoid threadlib; this is now a prerequisite
of gnulib's pthread_sigmask module, but Emacs doesn't need it.
(mkdir): install-sh is now in build-aux.
* config.bat: c++defs.h is now in build-aux/snippets.
* configure.in: Specify AC_CONFIG_AUX_DIR with build-aux (the
usual parameter).
* lib/gnulib.mk, m4/gl-comp.m4: Regenerate.
* lib/makefile.w32-in (ARG_NONNULL_H): arg-nonnull.h moved
to build-aux/snippet.
* lib/pthread_sigmask.c, lib/stdlib.in.h, m4/extensions.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/pthread_sigmask.m4:
Merge from gnuilib. This fixes porting bugs on Cygwin, Irix, and
Solaris, enables MacOS extensions, and enables nocrash during
'configure'.
* make-dist: Adjust to new build-aux and build-aux/snippit dirs.
* admin/notes/copyright: The files compile, config.guess, config.sub,
depcomp, install-sh, missing, and move-if-change are now in the
new build-aux subdirectory. The files arg-nonnull.h, c++defs.h,
and warn-on-use.h are now in build-aux/snippets. New file
build-aux/snippets/_Noreturn.h.
* leim/Makefile.in (install): install-sh is now in build-aux.
* lib-src/Makefile.in ($(DESTDIR)${archlibdir}): install-sh moved
to build-aux.
* msdos/sedlibmk.inp (CONFIG_CLEAN_VPATH_FILES): Adjust to snippet moves
from top level to build-aux/snippet.
* src/Makefile.in (gl-stamp): move-if-change is now in build-aux.
2011-07-24 22:15:47 +00:00
|
|
|
]GL_NOCRASH[
|
2011-01-09 07:33:50 +00:00
|
|
|
]], [[
|
|
|
|
int result = 0;
|
Merge from gnulib, using build-aux to remove clutter.
* m4/largefile.m4: New file, so that Emacs does not mess up when
accessing files with large inode numbers in MacOS X 10.5 and later.
* m4/nocrash.m4: New file, to avoid triggering background debugger
and/or create core dumps during 'configure'.
* build-aux/move-if-change: Renamed from move-if-change.
* build-aux/snippet/arg-nonnull.h: Renamed from arg-nonnull.h.
* build-aux/snippet/c++defs.h: Renamed from c++defs.h.
* build-aux/snippet/warn-on-use.h: Renamed from warn-on-use.h.
* build-aux/snippet/_Noreturn.h: New file, for draft C1X _Noreturn.
* .bzrignore: The autogenerated files compile, config.guess,
config.sub, depcomp, install-sh, and missing are now in build-aux.
* Makefile.in (epaths-force, sync-from-gnulib):
move-if-change is now in build-aux.
(GNULIB_TOOL_FLAGS): Avoid threadlib; this is now a prerequisite
of gnulib's pthread_sigmask module, but Emacs doesn't need it.
(mkdir): install-sh is now in build-aux.
* config.bat: c++defs.h is now in build-aux/snippets.
* configure.in: Specify AC_CONFIG_AUX_DIR with build-aux (the
usual parameter).
* lib/gnulib.mk, m4/gl-comp.m4: Regenerate.
* lib/makefile.w32-in (ARG_NONNULL_H): arg-nonnull.h moved
to build-aux/snippet.
* lib/pthread_sigmask.c, lib/stdlib.in.h, m4/extensions.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/pthread_sigmask.m4:
Merge from gnuilib. This fixes porting bugs on Cygwin, Irix, and
Solaris, enables MacOS extensions, and enables nocrash during
'configure'.
* make-dist: Adjust to new build-aux and build-aux/snippit dirs.
* admin/notes/copyright: The files compile, config.guess, config.sub,
depcomp, install-sh, missing, and move-if-change are now in the
new build-aux subdirectory. The files arg-nonnull.h, c++defs.h,
and warn-on-use.h are now in build-aux/snippets. New file
build-aux/snippets/_Noreturn.h.
* leim/Makefile.in (install): install-sh is now in build-aux.
* lib-src/Makefile.in ($(DESTDIR)${archlibdir}): install-sh moved
to build-aux.
* msdos/sedlibmk.inp (CONFIG_CLEAN_VPATH_FILES): Adjust to snippet moves
from top level to build-aux/snippet.
* src/Makefile.in (gl-stamp): move-if-change is now in build-aux.
2011-07-24 22:15:47 +00:00
|
|
|
|
|
|
|
nocrash_init();
|
|
|
|
|
2011-01-09 07:33:50 +00:00
|
|
|
/* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
|
2011-01-09 07:33:50 +00:00
|
|
|
OSF/1 5.1, Solaris 10. */
|
|
|
|
{
|
2011-07-08 10:00:52 +00:00
|
|
|
static char conftest[] = "conftest";
|
|
|
|
static char plus[] = "-+";
|
|
|
|
char *argv[3] = { conftest, plus, NULL };
|
2011-01-09 07:33:50 +00:00
|
|
|
opterr = 0;
|
2011-07-08 10:00:52 +00:00
|
|
|
if (getopt (2, argv, "+a") != '?')
|
2011-01-09 07:33:50 +00:00
|
|
|
result |= 1;
|
|
|
|
}
|
|
|
|
/* This code succeeds on glibc 2.8, mingw,
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
|
2011-01-09 07:33:50 +00:00
|
|
|
IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */
|
|
|
|
{
|
2011-07-08 10:00:52 +00:00
|
|
|
static char program[] = "program";
|
|
|
|
static char p[] = "-p";
|
|
|
|
static char foo[] = "foo";
|
|
|
|
static char bar[] = "bar";
|
|
|
|
char *argv[] = { program, p, foo, bar, NULL };
|
2011-01-09 07:33:50 +00:00
|
|
|
|
|
|
|
optind = 1;
|
|
|
|
if (getopt (4, argv, "p::") != 'p')
|
|
|
|
result |= 2;
|
|
|
|
else if (optarg != NULL)
|
|
|
|
result |= 4;
|
|
|
|
else if (getopt (4, argv, "p::") != -1)
|
|
|
|
result |= 6;
|
|
|
|
else if (optind != 2)
|
|
|
|
result |= 8;
|
|
|
|
}
|
|
|
|
/* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */
|
|
|
|
{
|
2011-07-08 10:00:52 +00:00
|
|
|
static char program[] = "program";
|
|
|
|
static char foo[] = "foo";
|
|
|
|
static char p[] = "-p";
|
|
|
|
char *argv[] = { program, foo, p, NULL };
|
2011-01-09 07:33:50 +00:00
|
|
|
optind = 0;
|
|
|
|
if (getopt (3, argv, "-p") != 1)
|
|
|
|
result |= 16;
|
|
|
|
else if (getopt (3, argv, "-p") != 'p')
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
result |= 16;
|
2011-01-09 07:33:50 +00:00
|
|
|
}
|
|
|
|
/* This code fails on glibc 2.11. */
|
|
|
|
{
|
2011-07-08 10:00:52 +00:00
|
|
|
static char program[] = "program";
|
|
|
|
static char b[] = "-b";
|
|
|
|
static char a[] = "-a";
|
|
|
|
char *argv[] = { program, b, a, NULL };
|
2011-01-09 07:33:50 +00:00
|
|
|
optind = opterr = 0;
|
|
|
|
if (getopt (3, argv, "+:a:b") != 'b')
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
result |= 32;
|
2011-01-09 07:33:50 +00:00
|
|
|
else if (getopt (3, argv, "+:a:b") != ':')
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
result |= 32;
|
2011-01-09 07:33:50 +00:00
|
|
|
}
|
2011-07-08 10:00:52 +00:00
|
|
|
/* This code dumps core on glibc 2.14. */
|
|
|
|
{
|
|
|
|
static char program[] = "program";
|
|
|
|
static char w[] = "-W";
|
|
|
|
static char dummy[] = "dummy";
|
|
|
|
char *argv[] = { program, w, dummy, NULL };
|
|
|
|
optind = opterr = 1;
|
|
|
|
if (getopt (3, argv, "W;") != 'W')
|
Merge from gnulib.
* lib/filemode.h, lib/signal.in.h, lib/stat.c, lib/stdint.in.h:
* lib/stdlib.in.h, lib/unistd.in.h, m4/extensions.m4, m4/getloadavg.m4:
* m4/getopt.m4, m4/gnulib-common.m4, m4/largefile.m4, m4/mktime.m4:
* m4/multiarch.m4, m4/nocrash.m4, m4/stdio_h.m4, m4/time_r.m4:
Copy new versions from gnulib, incorporating the following changes:
2012-06-22 time_r: fix typo that always overrode localtime_r decl
2012-06-22 Write "Mac OS X" instead of "MacOS X".
2012-06-21 mktime: fix integer overflow in 'configure'-time test
2012-06-21 nonblocking: Avoid compilation error on mingw64.
2012-06-19 stat, fstat: Avoid warnings on mingw64.
2012-06-19 getopt-gnu: Fix exit code overflow in autoconf test.
2012-06-22 17:20:00 +00:00
|
|
|
result |= 64;
|
2011-07-08 10:00:52 +00:00
|
|
|
}
|
2011-01-09 07:33:50 +00:00
|
|
|
return result;
|
|
|
|
]])],
|
|
|
|
[gl_cv_func_getopt_gnu=yes],
|
|
|
|
[gl_cv_func_getopt_gnu=no],
|
|
|
|
[dnl Cross compiling. Guess based on host and declarations.
|
|
|
|
case $host_os:$ac_cv_have_decl_optreset in
|
|
|
|
*-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;;
|
|
|
|
*:yes) gl_cv_func_getopt_gnu=no;;
|
|
|
|
*) gl_cv_func_getopt_gnu=yes;;
|
|
|
|
esac
|
|
|
|
])
|
|
|
|
case $gl_had_POSIXLY_CORRECT in
|
|
|
|
exported) ;;
|
|
|
|
yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;;
|
|
|
|
*) AS_UNSET([POSIXLY_CORRECT]) ;;
|
|
|
|
esac
|
|
|
|
])
|
|
|
|
if test "$gl_cv_func_getopt_gnu" = "no"; then
|
|
|
|
gl_replace_getopt=yes
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
])
|
|
|
|
|
2011-01-09 07:33:50 +00:00
|
|
|
# emacs' configure.in uses this.
|
|
|
|
AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
[
|
2011-01-09 07:33:50 +00:00
|
|
|
GETOPT_H=getopt.h
|
|
|
|
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
|
|
|
|
[Define to rpl_ if the getopt replacement functions and variables
|
|
|
|
should be used.])
|
|
|
|
AC_SUBST([GETOPT_H])
|
Merge gnulib getopt implementation into Emacs.
* Makefile.in (AUTOCONF_INPUTS): New macro.
($(srcdir)/configure, $(srcdir)/src/stamp-h.in): Depend on it,
so that these files also depend on m4/getopt.m4.
* configure.in: Configure getopt by including m4/getopt.m4,
and configuring a getopt replacement if necessary.
* make-dist: Add m4 subdirectory. Unlink lib-src/getopt.h.
* m4/getopt.m4: New file.
* lib-src/Makefile.in (mostlyclean): Remove getopt.h, getopt.h-t.
(GETOPT_H): New macro, from gnulib.
(getopt.h): New rule, from gnulib.
(GETOPTOBJS): Now autoconfigured.
(GETOPTDEPS): getopt.h is now autoconfigured.
(getopt.o, getopt1.o): Depend on $(GETOPT_H), not ${srcdir}/getopt.h.
(getopt.o): Depend on ${srcdir}/gettext.h.
(movemail.o): Depend on $(GETOPT_H).
* lib-src/getopt.c, lib-src/getopt1.c: Sync from gnulib.
* lib-src/getopt_.h, lib-src/getopt_int.h, lib-src/gettext.h:
New files, from gnulib.
* lib-src/getopt.h: Removed (now is getopt_.h).
* nt/inc/gettext.h: Remove; no longer needed now that
lib-src/gettext.h exists.
* src/s/cygwin.h (C_SWITCH_SYSTEM): Remove, since gettext.h is
now part of lib-src.
2005-07-26 21:43:13 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
# Prerequisites of lib/getopt*.
|
2011-01-09 07:33:50 +00:00
|
|
|
# emacs' configure.in uses this.
|
|
|
|
AC_DEFUN([gl_PREREQ_GETOPT],
|
|
|
|
[
|
|
|
|
AC_CHECK_DECLS_ONCE([getenv])
|
|
|
|
])
|