dpkg-funcs.m4 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_CHECK_COMPAT_FUNCS(LIST)
  64. # -----------------------
  65. # Check each function and define an automake conditional
  66. AC_DEFUN([DPKG_CHECK_COMPAT_FUNCS],
  67. [
  68. AC_CHECK_FUNCS([$1])
  69. m4_foreach_w([ac_func], [$1], [
  70. AM_CONDITIONAL(HAVE_[]AS_TR_CPP(ac_func),
  71. [test "x$ac_cv_func_[]AS_TR_SH(ac_func)" = "xyes"])
  72. ])
  73. ]) # DPKG_CHECK_COMPAT_FUNCS