dpkg-funcs.m4 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_FUNC_ASYNC_SYNC
  64. # --------------------
  65. # Define HAVE_ASYNC_SYNC if sync() is asynchronous
  66. AC_DEFUN([DPKG_FUNC_ASYNC_SYNC],
  67. [
  68. AC_CANONICAL_HOST
  69. AC_MSG_CHECKING([whether sync is asynchronous])
  70. AS_CASE([$host_os],
  71. [linux-*], [dpkg_cv_async_sync=no],
  72. [dpkg_cv_async_sync=yes])
  73. AS_IF([test "x$dpkg_cv_async_sync" = "xyes"],
  74. [AC_DEFINE([HAVE_ASYNC_SYNC], 1,
  75. [Define to 1 if the 'sync' function is asynchronous])])
  76. AC_MSG_RESULT([$dpkg_cv_async_sync])
  77. ])# DPKG_FUNC_ASYNC_SYNC
  78. # DPKG_CHECK_COMPAT_FUNCS(LIST)
  79. # -----------------------
  80. # Check each function and define an automake conditional
  81. AC_DEFUN([DPKG_CHECK_COMPAT_FUNCS],
  82. [
  83. AC_CHECK_FUNCS([$1])
  84. m4_foreach_w([ac_func], [$1], [
  85. AM_CONDITIONAL(HAVE_[]AS_TR_CPP(ac_func),
  86. [test "x$ac_cv_func_[]AS_TR_SH(ac_func)" = "xyes"])
  87. ])
  88. ]) # DPKG_CHECK_COMPAT_FUNCS