dpkg-funcs.m4 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # Copyright © 2005 Scott James Remnant <scott@netsplit.com>
  2. # Copyright © 2008, 2009 Guillem Jover <guillem@debian.org>
  3. # DPKG_FUNC_VA_COPY
  4. # -----------------
  5. # Define HAVE_VA_COPY if we have va_copy, fail if they can't be assigned
  6. AC_DEFUN([DPKG_FUNC_VA_COPY],
  7. [AC_CACHE_CHECK([for va_copy], [dpkg_cv_va_copy],
  8. [AC_RUN_IFELSE([AC_LANG_SOURCE(
  9. [[#include <stdarg.h>
  10. int main()
  11. {
  12. va_list v1, v2;
  13. va_copy (v1, v2);
  14. exit (0);
  15. }
  16. ]])],
  17. [dpkg_cv_va_copy=yes],
  18. [dpkg_cv_va_copy=no],
  19. [dpkg_cv_va_copy=no])])
  20. AS_IF([test "x$dpkg_cv_va_copy" = "xyes"],
  21. [AC_DEFINE([HAVE_VA_COPY], 1,
  22. [Define to 1 if the 'va_copy' macro exists])])
  23. ])# DPKG_FUNC_VA_COPY
  24. # DPKG_FUNC_C99_SNPRINTF
  25. # -----------------------
  26. # Define HAVE_C99_SNPRINTF if we have C99 snprintf family semantics
  27. AC_DEFUN([DPKG_FUNC_C99_SNPRINTF],
  28. [AC_CACHE_CHECK([for C99 snprintf functions], [dpkg_cv_c99_snprintf],
  29. [AC_RUN_IFELSE([AC_LANG_SOURCE([[
  30. #include <stdarg.h>
  31. #include <stdio.h>
  32. #include <string.h>
  33. int test_vsnprintf(const char *fmt, ...)
  34. {
  35. int n;
  36. va_list ap;
  37. va_start(ap, fmt);
  38. n = vsnprintf(NULL, 0, fmt, ap);
  39. va_end(ap);
  40. return n;
  41. }
  42. int main()
  43. {
  44. int n;
  45. n = snprintf(NULL, 0, "format %s %d", "string", 10);
  46. if (n != strlen("format string 10"))
  47. return 1;
  48. n = test_vsnprintf("format %s %d", "string", 10);
  49. if (n != strlen("format string 10"))
  50. return 1;
  51. return 0;
  52. }
  53. ]])],
  54. [dpkg_cv_c99_snprintf=yes],
  55. [dpkg_cv_c99_snprintf=no],
  56. [dpkg_cv_c99_snprintf=no])])
  57. AS_IF([test "x$dpkg_cv_c99_snprintf" = "xyes"],
  58. [AC_DEFINE([HAVE_C99_SNPRINTF], 1,
  59. [Define to 1 if the 'snprintf' family is C99 conformant])],
  60. )
  61. AM_CONDITIONAL(HAVE_C99_SNPRINTF, [test "x$dpkg_cv_c99_snprintf" = "xyes"])
  62. ])# DPKG_FUNC_C99_SNPRINTF
  63. # DPKG_MMAP
  64. # ---------
  65. # Define USE_MMAP if mmap() is available and it was requested
  66. AC_DEFUN([DPKG_MMAP],
  67. [
  68. AC_ARG_ENABLE([mmap],
  69. AS_HELP_STRING([--enable-mmap],
  70. [enable usage of unrealiable mmap if available]),
  71. [
  72. AC_CHECK_FUNCS([mmap])
  73. AC_DEFINE(USE_MMAP, 1, [Use unreliable mmap support])
  74. ],
  75. []
  76. )
  77. ])
  78. # DPKG_FUNC_ASYNC_SYNC
  79. # --------------------
  80. # Define HAVE_ASYNC_SYNC if sync() is asynchronous
  81. AC_DEFUN([DPKG_FUNC_ASYNC_SYNC],
  82. [
  83. AC_CANONICAL_HOST
  84. AC_MSG_CHECKING([whether sync is asynchronous])
  85. AS_CASE([$host_os],
  86. [linux-*], [dpkg_cv_async_sync=no],
  87. [dpkg_cv_async_sync=yes])
  88. AS_IF([test "x$dpkg_cv_async_sync" = "xyes"],
  89. [AC_DEFINE([HAVE_ASYNC_SYNC], 1,
  90. [Define to 1 if the 'sync' function is asynchronous])])
  91. AC_MSG_RESULT([$dpkg_cv_async_sync])
  92. ])# DPKG_FUNC_ASYNC_SYNC
  93. # DPKG_CHECK_COMPAT_FUNCS(LIST)
  94. # -----------------------
  95. # Check each function and define an automake conditional
  96. AC_DEFUN([DPKG_CHECK_COMPAT_FUNCS],
  97. [
  98. AC_CHECK_FUNCS([$1])
  99. m4_foreach_w([ac_func], [$1], [
  100. AM_CONDITIONAL(HAVE_[]AS_TR_CPP(ac_func),
  101. [test "x$ac_cv_func_[]AS_TR_SH(ac_func)" = "xyes"])
  102. ])
  103. ]) # DPKG_CHECK_COMPAT_FUNCS