2024-02-12 10:09:10 -05:00
|
|
|
dnl SPDX-License-Identifier: FSFULLR
|
|
|
|
|
2023-09-24 08:48:52 -04:00
|
|
|
# getopt.m4 serial 49 (modified version)
|
|
|
|
dnl Copyright (C) 2002-2006, 2008-2023 Free Software Foundation, Inc.
|
2007-12-08 17:42:33 -05: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.
|
|
|
|
|
2023-09-24 08:48:52 -04:00
|
|
|
# This version has been modified to reduce complexity since we only need
|
|
|
|
# GNU getopt_long and do not care about replacing getopt.
|
2007-12-08 17:42:33 -05:00
|
|
|
|
2023-09-24 08:48:52 -04:00
|
|
|
# Check for 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],
|
2007-12-08 17:42:33 -05:00
|
|
|
[
|
2023-09-24 08:48:52 -04:00
|
|
|
AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
|
2007-12-08 17:42:33 -05:00
|
|
|
|
2023-09-24 08:48:52 -04:00
|
|
|
if test -n "$gl_replace_getopt"; then
|
|
|
|
gl_GETOPT_SUBSTITUTE
|
|
|
|
fi
|
2007-12-08 17:42:33 -05:00
|
|
|
])
|
|
|
|
|
|
|
|
AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
|
|
|
|
[
|
2023-09-24 08:48:52 -04:00
|
|
|
gl_replace_getopt=
|
|
|
|
|
|
|
|
if test -z "$gl_replace_getopt"; then
|
|
|
|
AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes])
|
2007-12-08 17:42:33 -05:00
|
|
|
fi
|
|
|
|
|
2023-09-24 08:48:52 -04:00
|
|
|
if test -z "$gl_replace_getopt"; then
|
|
|
|
AC_CHECK_FUNCS([getopt_long], [], [gl_replace_getopt=yes])
|
2009-03-01 01:58:41 -05:00
|
|
|
fi
|
|
|
|
|
2008-11-19 13:46:52 -05:00
|
|
|
dnl BSD getopt_long uses a way to reset option processing, that is different
|
|
|
|
dnl from GNU and Solaris (which copied the GNU behavior). We support both
|
|
|
|
dnl GNU and BSD style resetting of getopt_long(), so there's no need to use
|
|
|
|
dnl GNU getopt_long() on BSD due to different resetting style.
|
2023-09-24 08:48:52 -04:00
|
|
|
if test -z "$gl_replace_getopt"; then
|
2008-11-19 13:46:52 -05:00
|
|
|
AC_CHECK_DECL([optreset],
|
|
|
|
[AC_DEFINE([HAVE_OPTRESET], 1,
|
|
|
|
[Define to 1 if getopt.h declares extern int optreset.])],
|
|
|
|
[], [#include <getopt.h>])
|
2007-12-08 17:42:33 -05:00
|
|
|
fi
|
|
|
|
|
2023-09-24 08:48:52 -04:00
|
|
|
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. We don't use that feature, so this
|
2008-11-19 13:46:52 -05:00
|
|
|
dnl is not a problem for us. Thus, the respective test was removed here.
|
2023-09-24 08:48:52 -04:00
|
|
|
|
2023-09-24 10:09:16 -04:00
|
|
|
dnl Checks for getopt handling '-' as a leading character in an option
|
2023-09-24 08:48:52 -04:00
|
|
|
dnl string were removed, since we also don't use that feature.
|
|
|
|
|
2007-12-08 17:42:33 -05:00
|
|
|
])
|
|
|
|
|
2023-09-24 08:48:52 -04:00
|
|
|
AC_DEFUN([gl_GETOPT_SUBSTITUTE],
|
2007-12-08 17:42:33 -05:00
|
|
|
[
|
2023-09-24 08:48:52 -04:00
|
|
|
AC_LIBOBJ([getopt])
|
|
|
|
AC_LIBOBJ([getopt1])
|
|
|
|
|
|
|
|
AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
|
|
|
|
|
|
|
|
AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
|
|
|
|
[Define to rpl_ if the getopt replacement functions and variables
|
|
|
|
should be used.])
|
|
|
|
|
|
|
|
GETOPT_H=getopt.h
|
|
|
|
AC_SUBST([GETOPT_H])
|
2007-12-08 17:42:33 -05:00
|
|
|
])
|
|
|
|
|
2023-09-24 08:48:52 -04:00
|
|
|
AC_DEFUN([gl_GETOPT], [gl_FUNC_GETOPT_GNU])
|