*** empty log message ***
[gnulib.git] / m4 / off_t-format.m4
1 #serial 1                                                     -*- autoconf -*-
2
3 dnl FIXME
4 AC_DEFUN(jm_SYS_OFF_T_PRINTF_FORMAT,
5 [dnl
6     AC_CHECK_HEADERS(string.h stdlinb.h)
7     AC_CACHE_CHECK([for printf format that works with type off_t],
8                    jm_cv_sys_off_t_printf_format,
9     [
10      for i in '' L ll q; do
11        jm_OFF_T_FORMAT="$i"
12        export jm_OFF_T_FORMAT
13      AC_TRY_RUN([
14 #    include <sys/types.h>
15 #    include <stdio.h>
16 #    if HAVE_STDLIB_H
17 #     include <stdlib.h>
18 #    endif
19 #    if HAVE_STRING_H
20 #     include <string.h>
21 #    endif
22        int
23        main()
24        {
25          char buf[50];
26          static off_t x[] = {1, 255, 65535, 99999999};
27          char fmt[50];
28
29          /* this envvar should have one of these values: "", "L", "ll", "q"  */
30          char *f = getenv ("jm_OFF_T_FORMAT");
31          sprintf (fmt, "%%%sd %%%sx %%%sx %%%sd", f, f, f, f);
32
33          sprintf (buf, fmt, x[0], x[1], x[2], x[3]);
34          exit (strcmp (buf, "1 ff ffff 99999999"));
35        }
36        ], jm_cv_sys_off_t_printf_format=yes dnl The library version works.
37        , jm_cv_sys_off_t_printf_format=no dnl The library version does NOT work.
38        , jm_cv_sys_off_t_printf_format=no dnl We're cross compiling.
39        )
40      done
41     ])
42   fi
43
44   if test $am_cv_func_working_getline = no; then
45     AC_LIBOBJ(getline)
46   fi
47 ])