immutable: Add tests.
[gnulib.git] / m4 / argz.m4
blobd587bd8c4052f0f167fff1a9768b1a8f397777e6
1 # Portability macros for glibc argz.                    -*- Autoconf -*-
3 #   Copyright (C) 2004-2021 Free Software Foundation, Inc.
4 #   Written by Gary V. Vaughan <gary@gnu.org>
6 # This file is free software; the Free Software Foundation gives
7 # unlimited permission to copy and/or distribute it, with or without
8 # modifications, as long as this notice is preserved.
10 # serial 13 argz.m4
12 AC_DEFUN([gl_FUNC_ARGZ],
13 [gl_PREREQ_ARGZ
15 AC_REQUIRE([AC_C_RESTRICT])
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
18 AC_CHECK_HEADERS([argz.h], [], [], [AC_INCLUDES_DEFAULT])
20 AC_CHECK_TYPES([error_t],
21   [],
22   [AC_DEFINE([error_t], [int],
23    [Define to a type to use for 'error_t' if it is not otherwise available.])
24    AC_DEFINE([__error_t_defined], [1], [Define so that glibc/gnulib argp.h
25     does not typedef error_t.])],
26   [#if defined(HAVE_ARGZ_H)
27 #  include <argz.h>
28 #endif])
30 ARGZ_H=
31 AC_CHECK_FUNC([argz_replace], [], [ARGZ_H=argz.h])
33 dnl if have system argz functions, allow forced use of
34 dnl libltdl-supplied implementation (and default to do so
35 dnl on "known bad" systems). Could use a runtime check, but
36 dnl (a) detecting malloc issues is notoriously unreliable
37 dnl (b) only known system that declares argz functions,
38 dnl     provides them, yet they are broken, is cygwin
39 dnl     releases prior to 5-May-2007 (1.5.24 and earlier)
40 dnl So, it's more straightforward simply to special case
41 dnl this for known bad systems.
42 AS_IF([test -z "$ARGZ_H"],
43     [AC_CACHE_CHECK(
44         [if argz actually works],
45         [lt_cv_sys_argz_works],
46         [[case $host_os in #(
47          *cygwin*)
48            lt_cv_sys_argz_works=no
49            if test "$cross_compiling" != no; then
50              lt_cv_sys_argz_works="$gl_cross_guess_normal"
51            else
52              lt_sed_extract_leading_digits='s/^\([0-9\.]*\).*/\1/'
53              save_IFS=$IFS
54              IFS=-.
55              set x `uname -r | sed -e "$lt_sed_extract_leading_digits"`
56              IFS=$save_IFS
57              lt_os_major=${2-0}
58              lt_os_minor=${3-0}
59              lt_os_micro=${4-0}
60              if test "$lt_os_major" -gt 1 \
61                 || { test "$lt_os_major" -eq 1 \
62                   && { test "$lt_os_minor" -gt 5 \
63                     || { test "$lt_os_minor" -eq 5 \
64                       && test "$lt_os_micro" -gt 24; }; }; }; then
65                lt_cv_sys_argz_works=yes
66              fi
67            fi
68            ;; #(
69          *) lt_cv_sys_argz_works=yes ;;
70          esac]])
71      AS_IF([test "$lt_cv_sys_argz_works" = yes],
72         [AC_DEFINE([HAVE_WORKING_ARGZ], [1],
73                    [This value is set to 1 to indicate that the system argz facility works])],
74         [ARGZ_H=argz.h])])
76 AC_SUBST([ARGZ_H])
77 AM_CONDITIONAL([GL_GENERATE_ARGZ_H], [test -n "$ARGZ_H"])
80 # Prerequisites of lib/argz.c.
81 AC_DEFUN([gl_PREREQ_ARGZ], [:])