gnulib-common.m4 2.4 KB

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