summaryrefslogtreecommitdiffstats
path: root/gl/m4/getopt.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/getopt.m4')
-rw-r--r--gl/m4/getopt.m437
1 files changed, 25 insertions, 12 deletions
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index 50f4509..bb95c5e 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,5 +1,5 @@
1# getopt.m4 serial 44 1# getopt.m4 serial 47
2dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2008-2021 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -32,9 +32,16 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
32# getopt_long_only. 32# getopt_long_only.
33AC_DEFUN([gl_FUNC_GETOPT_GNU], 33AC_DEFUN([gl_FUNC_GETOPT_GNU],
34[ 34[
35 dnl Set the variable gl_getopt_required, so that all invocations of
36 dnl gl_GETOPT_CHECK_HEADERS in the scope of the current configure file
37 dnl will check for getopt with GNU extensions.
38 dnl This means that if one gnulib-tool invocation requests getopt-posix
39 dnl and another gnulib-tool invocation requests getopt-gnu, it is as if
40 dnl both had requested getopt-gnu.
35 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU]) 41 m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
36 42
37 AC_REQUIRE([gl_FUNC_GETOPT_POSIX]) 43 dnl No need to invoke gl_FUNC_GETOPT_POSIX here; this is automatically
44 dnl done through the module dependency getopt-gnu -> getopt-posix.
38]) 45])
39 46
40# Determine whether to replace the entire getopt facility. 47# Determine whether to replace the entire getopt facility.
@@ -295,8 +302,10 @@ dnl is ambiguous with environment values that contain newlines.
295 ]])], 302 ]])],
296 [gl_cv_func_getopt_gnu=yes], 303 [gl_cv_func_getopt_gnu=yes],
297 [gl_cv_func_getopt_gnu=no], 304 [gl_cv_func_getopt_gnu=no],
298 [dnl Cross compiling. Assume the worst, even on glibc platforms. 305 [dnl Cross compiling.
299 gl_cv_func_getopt_gnu="guessing no" 306 dnl Assume the worst, even on glibc platforms.
307 dnl But obey --enable-cross-guesses.
308 gl_cv_func_getopt_gnu="$gl_cross_guess_normal"
300 ]) 309 ])
301 case $gl_had_POSIXLY_CORRECT in 310 case $gl_had_POSIXLY_CORRECT in
302 exported) ;; 311 exported) ;;
@@ -354,15 +363,19 @@ dnl is ambiguous with environment values that contain newlines.
354 363
355AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], 364AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
356[ 365[
357 GETOPT_H=getopt.h 366 AC_CHECK_HEADERS_ONCE([sys/cdefs.h])
367 if test $ac_cv_header_sys_cdefs_h = yes; then
368 HAVE_SYS_CDEFS_H=1
369 else
370 HAVE_SYS_CDEFS_H=0
371 fi
372 AC_SUBST([HAVE_SYS_CDEFS_H])
373
358 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]], 374 AC_DEFINE([__GETOPT_PREFIX], [[rpl_]],
359 [Define to rpl_ if the getopt replacement functions and variables 375 [Define to rpl_ if the getopt replacement functions and variables
360 should be used.]) 376 should be used.])
377 GETOPT_H=getopt.h
378 GETOPT_CDEFS_H=getopt-cdefs.h
361 AC_SUBST([GETOPT_H]) 379 AC_SUBST([GETOPT_H])
362]) 380 AC_SUBST([GETOPT_CDEFS_H])
363
364# Prerequisites of lib/getopt*.
365AC_DEFUN([gl_PREREQ_GETOPT],
366[
367 AC_CHECK_DECLS_ONCE([getenv])
368]) 381])