]> sjero.net Git - wget/blob - m4/gnulib-common.m4
Import "quote" module from gnulib; update the rest.
[wget] / m4 / gnulib-common.m4
1 # gnulib-common.m4 serial 3
2 dnl Copyright (C) 2007 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 # gl_MODULE_INDICATOR([modulename])
8 # defines a C macro indicating the presence of the given module.
9 AC_DEFUN([gl_MODULE_INDICATOR],
10 [
11   AC_DEFINE([GNULIB_]translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1],
12     [Define to 1 when using the gnulib module ]$1[.])
13 ])
14
15 # AC_PROG_MKDIR_P
16 # is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
17 # Remove this macro when we can assume autoconf >= 2.60.
18 m4_ifdef([AC_PROG_MKDIR_P], [], [
19   AC_DEFUN([AC_PROG_MKDIR_P],
20     [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
21      MKDIR_P='$(mkdir_p)'
22      AC_SUBST([MKDIR_P])])])
23
24 # AC_C_RESTRICT
25 # This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61,
26 # so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
27 # works.
28 # This definition can be removed once autoconf >= 2.62 can be assumed.
29 AC_DEFUN([AC_C_RESTRICT],
30 [AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
31   [ac_cv_c_restrict=no
32    # The order here caters to the fact that C++ does not require restrict.
33    for ac_kw in __restrict __restrict__ _Restrict restrict; do
34      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
35       [[typedef int * int_ptr;
36         int foo (int_ptr $ac_kw ip) {
37         return ip[0];
38        }]],
39       [[int s[1];
40         int * $ac_kw t = s;
41         t[0] = 0;
42         return foo(t)]])],
43       [ac_cv_c_restrict=$ac_kw])
44      test "$ac_cv_c_restrict" != no && break
45    done
46   ])
47  AH_VERBATIM([restrict],
48 [/* Define to the equivalent of the C99 'restrict' keyword, or to
49    nothing if this is not supported.  Do not define if restrict is
50    supported directly.  */
51 #undef restrict
52 /* Work around a bug in Sun C++: it does not support _Restrict, even
53    though the corresponding Sun C compiler does, which causes
54    "#define restrict _Restrict" in the previous line.  Perhaps some future
55    version of Sun C++ will work with _Restrict; if so, it'll probably
56    define __RESTRICT, just as Sun C does.  */
57 #if defined __SUNPRO_CC && !defined __RESTRICT
58 # define _Restrict
59 #endif])
60  case $ac_cv_c_restrict in
61    restrict) ;;
62    no) AC_DEFINE([restrict], []) ;;
63    *)  AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
64  esac
65 ])