1 # Copyright © 2005 Scott James Remnant <scott@netsplit.com>
2 # Copyright © 2008-2009,2015 Guillem Jover <guillem@debian.org>
6 # Define HAVE_VA_COPY if we have va_copy.
7 AC_DEFUN([DPKG_FUNC_VA_COPY], [
8 AC_CACHE_CHECK([for va_copy], [dpkg_cv_va_copy], [
22 AS_IF([test "x$dpkg_cv_va_copy" = "xyes"], [
23 AC_DEFINE([HAVE_VA_COPY], [1], [Define to 1 if the 'va_copy' macro exists])
27 # DPKG_FUNC_C99_SNPRINTF
28 # -----------------------
29 # Define HAVE_C99_SNPRINTF if we have C99 snprintf family semantics
30 AC_DEFUN([DPKG_FUNC_C99_SNPRINTF], [
31 AC_CACHE_CHECK([for C99 snprintf functions], [dpkg_cv_c99_snprintf], [
37 int test_vsnprintf(const char *fmt, ...)
43 n = vsnprintf(NULL, 0, fmt, args);
52 n = snprintf(NULL, 0, "format %s %d", "string", 10);
53 if (n != strlen("format string 10"))
56 n = test_vsnprintf("format %s %d", "string", 10);
57 if (n != strlen("format string 10"))
64 dpkg_cv_c99_snprintf=yes
66 dpkg_cv_c99_snprintf=no
68 dpkg_cv_c99_snprintf=maybe
71 AS_IF([test "x$dpkg_cv_c99_snprintf" = "xmaybe"], [
76 #if !defined(_XOPEN_VERSION) || _XOPEN_VERSION < 600
77 #error "snprintf() has conflicting semantics with C99 on SUSv2 and earlier"
81 dpkg_cv_c99_snprintf=yes
83 dpkg_cv_c99_snprintf=no
87 AS_IF([test "x$dpkg_cv_c99_snprintf" = "xyes"], [
88 AC_DEFINE([HAVE_C99_SNPRINTF], [1],
89 [Define to 1 if the 'snprintf' family is C99 conformant])
91 AM_CONDITIONAL([HAVE_C99_SNPRINTF], [test "x$dpkg_cv_c99_snprintf" = "xyes"])
92 ])# DPKG_FUNC_C99_SNPRINTF
96 # Define USE_MMAP if mmap() is available and it was requested
97 AC_DEFUN([DPKG_USE_MMAP], [
99 [AS_HELP_STRING([--enable-mmap],
100 [enable usage of unrealiable mmap if available])],
101 [], [enable_mmap=no])
103 AS_IF([test "x$enable_mmap" = "xyes"], [
104 AC_CHECK_FUNCS([mmap])
105 AC_DEFINE([USE_MMAP], [1], [Use unreliable mmap support])
109 # DPKG_USE_DISK_PREALLOCATE
110 # -------------------------
111 # Define USE_DISK_PREALLOCATE if disk size pre-allocation is available
112 # and it was requested.
113 AC_DEFUN([DPKG_USE_DISK_PREALLOCATE], [
114 AC_ARG_ENABLE([disk-preallocate],
115 [AS_HELP_STRING([--enable-disk-preallocate],
116 [enable usage of disk size pre-allocation])],
117 [], [enable_disk_preallocate=no])
119 AS_IF([test "x$enable_disk_preallocate" = "xyes"], [
120 AC_DEFINE([USE_DISK_PREALLOCATE], [1], [Use disk size pre-allocation])
124 # DPKG_CHECK_PROGNAME
125 # -------------------
126 # Check for system implementations of program name tracking.
127 AC_DEFUN([DPKG_CHECK_PROGNAME], [
128 AC_MSG_CHECKING([for program_invocation_short_name])
131 [[#include <errno.h>]],
132 [[const char *p = program_invocation_short_name;]])
134 AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
135 [Define to 1 if you have program_invocation_short_name])
141 AC_MSG_CHECKING([for __progname])
144 [[extern char *__progname;]],
145 [[printf("%s", __progname);]])
147 AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
152 ]) # DPKG_CHECK_PROGNAME
154 # DPKG_CHECK_COMPAT_FUNCS(LIST)
155 # -----------------------
156 # Check each function and define an automake conditional
157 AC_DEFUN([DPKG_CHECK_COMPAT_FUNCS], [
159 m4_foreach_w([ac_func], [$1], [
160 AM_CONDITIONAL([HAVE_]AS_TR_CPP(ac_func),
161 [test "x$ac_cv_func_[]AS_TR_SH(ac_func)" = "xyes"])
163 ]) # DPKG_CHECK_COMPAT_FUNCS