* lib/argz_.h: ensure error_t definition is obtained in same
[gnulib.git] / m4 / argz.m4
1 # Portability macros for glibc argz.                    -*- Autoconf -*-
2 #
3 #   Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
4 #   Written by Gary V. Vaughan <gary@gnu.org>
5 #
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.
9
10 # serial 5 argz.m4
11
12 AC_DEFUN([gl_FUNC_ARGZ],
13 [gl_PREREQ_ARGZ
14
15 AC_CHECK_HEADERS([argz.h], [], [], [AC_INCLUDES_DEFAULT])
16
17 AC_CHECK_TYPES([error_t],
18   [],
19   [AC_DEFINE([error_t], [int],
20    [Define to a type to use for `error_t' if it is not otherwise available.])
21    AC_DEFINE([__error_t_defined], [1], [Define so that glibc/gnulib argp.h
22     does not typedef error_t.])],
23   [#if defined(HAVE_ARGZ_H)
24 #  include <argz.h>
25 #endif])
26
27 ARGZ_H=
28 AC_CHECK_FUNCS([argz_append argz_create_sep argz_insert argz_next \
29         argz_stringify], [], [ARGZ_H=argz.h; AC_LIBOBJ([argz])])
30
31 dnl if have system argz functions, allow forced use of 
32 dnl libltdl-supplied implementation (and default to do so
33 dnl on "known bad" systems). Could use a runtime check, but
34 dnl (a) detecting malloc issues is notoriously unreliable
35 dnl (b) only known system that declares argz functions,
36 dnl     provides them, yet they are broken, is cygwin
37 dnl     releases prior to 16-Mar-2007 (1.5.24 and earlier)
38 dnl So, it's more straightforward simply to special case 
39 dnl this for known bad systems.
40 AS_IF([test -z "$ARGZ_H"],
41     [AC_CACHE_CHECK(
42         [if argz actually works],
43         [lt_cv_sys_argz_works],
44         [case $host_os in #(
45          *cygwin*)
46            lt_cv_sys_argz_works=no
47            if test "$cross_compiling" != no; then
48              lt_cv_sys_argz_works="guessing no"
49            else
50              save_IFS=$IFS
51              IFS=-.
52              set x `uname -r | $SED -e 's/^\([[0-9\.]]*\).*/\1/'`
53              IFS=$save_IFS
54              lt_os_major=$[]{2-0}
55              lt_os_minor=$[]{3-0}
56              lt_os_micro=$[]{4-0}
57              if test "$lt_os_major" -gt 1 ||
58                 { test "$lt_os_major" -eq 1 &&
59                   { test "$lt_os_minor" -gt 5 ||
60                     { test "$lt_os_minor" -eq 5 &&
61                       test "$lt_os_micro" -gt 24; }; }; }; then
62                lt_cv_sys_argz_works=yes
63              fi
64            fi
65            ;; #(
66          *) lt_cv_sys_argz_works=yes ;;
67          esac])
68      AS_IF([test $lt_cv_sys_argz_works != yes],
69         [AC_DEFINE([SYSTEM_ARGZ_IS_BROKEN], 1,
70                    [This value is set to 1 to indicate that the system argz facility does not work])
71         ARGZ_H=argz.h
72         AC_LIBOBJ([argz])])])
73
74 AC_SUBST([ARGZ_H])
75 ])
76
77 # Prerequisites of lib/argz.c.
78 AC_DEFUN([gl_PREREQ_ARGZ], [:])