An autoconf macro for its associated module.
[gnulib.git] / m4 / strtoumax.m4
1 # strtoumax.m4 serial 1
2 dnl Copyright (C) 2002 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
8
9 AC_DEFUN([gl_FUNC_STRTOUMAX],
10 [
11   dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
12   AC_REQUIRE([AC_PROG_CPP])
13   AC_REQUIRE([AC_PROG_EGREP])
14
15   AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro],
16     jm_cv_func_strtoumax_macro,
17     AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h>
18 #ifdef strtoumax
19  inttypes_h_defines_strtoumax
20 #endif],
21       jm_cv_func_strtoumax_macro=yes,
22       jm_cv_func_strtoumax_macro=no))
23
24   if test "$jm_cv_func_strtoumax_macro" != yes; then
25     AC_REPLACE_FUNCS(strtoumax)
26     if test $ac_cv_func_strtoumax = no; then
27       gl_PREREQ_STRTOUMAX
28     fi
29   fi
30 ])
31
32 # Prerequisites of lib/strtoumax.c.
33 AC_DEFUN([gl_PREREQ_STRTOUMAX], [
34   jm_AC_TYPE_UINTMAX_T
35   AC_CHECK_HEADERS_ONCE(stdlib.h)
36   AC_CHECK_DECLS_ONCE(strtoul)
37   AC_CHECK_DECLS(strtoull)
38   AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG])
39 ])