git-merge-changelog: Simplify installation instructions.
[gnulib.git] / m4 / argp.m4
bloba093c4d7451edf565a4f65e64902664c5e5bb1dc
1 # argp.m4
2 # serial 17
3 dnl Copyright (C) 2003-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_ARGP],
10   AC_REQUIRE([AC_C_INLINE])
11   AC_REQUIRE([AC_C_RESTRICT])
12   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
14   dnl Rename argp_parse to another symbol, so that clang's ASAN does not
15   dnl intercept it.
16   dnl See <https://lists.gnu.org/archive/html/bug-gnulib/2023-12/msg00035.html>.
17   AC_DEFINE([argp_parse], [rpl_argp_parse],
18     [Define to the name of argp_parse outside libc.])
20   AC_CHECK_DECLS([program_invocation_name],
21     [],
22     [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_NAME], [1],
23        [Define to 1 to add extern declaration of program_invocation_name to argp.h])],
24     [[#include <errno.h>]])
25   AC_CHECK_DECLS([program_invocation_short_name],
26     [],
27     [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_SHORT_NAME], [1],
28        [Define to 1 to add extern declaration of program_invocation_short_name to argp.h])],
29     [[#include <errno.h>]])
31   # Check if program_invocation_name and program_invocation_short_name
32   # are defined elsewhere. It is improbable that only one of them will
33   # be defined and other not, I prefer to stay on the safe side and to
34   # test each one separately.
35   AC_MSG_CHECKING([whether program_invocation_name is defined])
36   AC_LINK_IFELSE(
37     [AC_LANG_PROGRAM(
38        [[extern char *program_invocation_name;]],
39        [[program_invocation_name = "test";]])],
40     [AC_DEFINE([HAVE_PROGRAM_INVOCATION_NAME], [1],
41        [Define if program_invocation_name is defined])
42      AC_MSG_RESULT([yes])
43     ],
44     [AC_MSG_RESULT([no])])
46   AC_MSG_CHECKING([whether program_invocation_short_name is defined])
47   AC_LINK_IFELSE(
48     [AC_LANG_PROGRAM(
49        [[extern char *program_invocation_short_name;]],
50        [[program_invocation_short_name = "test";]])],
51     [AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
52        [Define if program_invocation_short_name is defined])
53      AC_MSG_RESULT([yes])
54     ],
55     [AC_MSG_RESULT([no])])
57   AC_CHECK_DECLS_ONCE([clearerr_unlocked])
58   AC_CHECK_DECLS_ONCE([feof_unlocked])
59   AC_CHECK_DECLS_ONCE([ferror_unlocked])
60   AC_CHECK_DECLS_ONCE([fflush_unlocked])
61   AC_CHECK_DECLS_ONCE([fgets_unlocked])
62   AC_CHECK_DECLS_ONCE([fputc_unlocked])
63   AC_CHECK_DECLS_ONCE([fputs_unlocked])
64   AC_CHECK_DECLS_ONCE([fread_unlocked])
65   AC_CHECK_DECLS_ONCE([fwrite_unlocked])
66   AC_CHECK_DECLS_ONCE([getc_unlocked])
67   AC_CHECK_DECLS_ONCE([getchar_unlocked])
68   AC_CHECK_DECLS_ONCE([putc_unlocked])
69   AC_CHECK_DECLS_ONCE([putchar_unlocked])
70   AC_CHECK_FUNCS_ONCE([flockfile funlockfile])
71   AC_CHECK_HEADERS_ONCE([features.h linewrap.h])
72   AC_REQUIRE([AC_FUNC_STRERROR_R])
75 dnl argp-parse.c depends on GNU getopt internals, therefore use GNU getopt
76 dnl always.
77 AC_DEFUN([gl_REPLACE_GETOPT_ALWAYS], [])