2 # Copyright © 2005 Scott James Remnant <scott@netsplit.com>
3 # Copyright © 2008-2009,2015 Guillem Jover <guillem@debian.org>
7 # Define HAVE_VA_COPY if we have va_copy.
8 AC_DEFUN([DPKG_FUNC_VA_COPY], [
9 AC_CACHE_CHECK([for va_copy], [dpkg_cv_va_copy], [
23 AS_IF([test "x$dpkg_cv_va_copy" = "xyes"], [
24 AC_DEFINE([HAVE_VA_COPY], [1], [Define to 1 if the 'va_copy' macro exists])
30 # Define HAVE_FSYNC_DIR if we can fsync(2) directories.
31 AC_DEFUN([DPKG_FUNC_FSYNC_DIR], [
32 AC_CACHE_CHECK([whether fsync works on directories], [dpkg_cv_fsync_dir], [
35 #include <sys/types.h>
41 DIR *dir = opendir(".");
56 dpkg_cv_fsync_dir=maybe
59 AS_IF([test "x$dpkg_cv_fsync_dir" = "xmaybe"], [
62 # On AIX fsync(3) requires writable file descriptors, which
63 # opendir(3) does not provide, but even then fsync(3) nor
64 # fsync_range(3) always work on directories anyway.
67 # On other systems we assume this works.
73 AS_IF([test "x$dpkg_cv_fsync_dir" = "xyes"], [
74 AC_DEFINE([HAVE_FSYNC_DIR], [1],
75 [Define to 1 if the 'fsync' function works on directories])
79 # DPKG_FUNC_C99_SNPRINTF
80 # -----------------------
81 # Define HAVE_C99_SNPRINTF if we have C99 snprintf family semantics
82 AC_DEFUN([DPKG_FUNC_C99_SNPRINTF], [
83 AC_CACHE_CHECK([for C99 snprintf functions], [dpkg_cv_c99_snprintf], [
89 int test_vsnprintf(const char *fmt, ...)
95 n = vsnprintf(NULL, 0, fmt, args);
103 n = snprintf(NULL, 0, "format %s %d", "string", 10);
104 if (n != strlen("format string 10"))
107 n = test_vsnprintf("format %s %d", "string", 10);
108 if (n != strlen("format string 10"))
112 dpkg_cv_c99_snprintf=yes
114 dpkg_cv_c99_snprintf=no
116 dpkg_cv_c99_snprintf=maybe
119 AS_IF([test "x$dpkg_cv_c99_snprintf" = "xmaybe"], [
122 #define _GNU_SOURCE 1
124 #if !defined(_XOPEN_VERSION) || _XOPEN_VERSION < 600
125 #error "snprintf() has conflicting semantics with C99 on SUSv2 and earlier"
129 dpkg_cv_c99_snprintf=yes
131 dpkg_cv_c99_snprintf=no
135 AS_IF([test "x$dpkg_cv_c99_snprintf" = "xyes"], [
136 AC_DEFINE([HAVE_C99_SNPRINTF], [1],
137 [Define to 1 if the 'snprintf' family is C99 conformant])
139 AM_CONDITIONAL([HAVE_C99_SNPRINTF], [test "x$dpkg_cv_c99_snprintf" = "xyes"])
140 ])# DPKG_FUNC_C99_SNPRINTF
144 # Define USE_MMAP if mmap() is available and it was requested
145 AC_DEFUN([DPKG_USE_MMAP], [
146 AC_ARG_ENABLE([mmap],
147 [AS_HELP_STRING([--enable-mmap],
148 [enable usage of unrealiable mmap if available])],
149 [], [enable_mmap=no])
151 AS_IF([test "x$enable_mmap" = "xyes"], [
152 AC_CHECK_FUNCS([mmap])
153 AC_DEFINE([USE_MMAP], [1], [Use unreliable mmap support])
157 # DPKG_USE_DISK_PREALLOCATE
158 # -------------------------
159 # Define USE_DISK_PREALLOCATE if disk size pre-allocation is available
160 # and it was requested.
161 AC_DEFUN([DPKG_USE_DISK_PREALLOCATE], [
162 AC_ARG_ENABLE([disk-preallocate],
163 [AS_HELP_STRING([--enable-disk-preallocate],
164 [enable usage of disk size pre-allocation])],
165 [], [enable_disk_preallocate=no])
167 AS_IF([test "x$enable_disk_preallocate" = "xyes"], [
168 AC_DEFINE([USE_DISK_PREALLOCATE], [1], [Use disk size pre-allocation])
172 # DPKG_CHECK_PROGNAME
173 # -------------------
174 # Check for system implementations of program name tracking.
175 AC_DEFUN([DPKG_CHECK_PROGNAME], [
176 AC_MSG_CHECKING([for program_invocation_short_name])
181 const char *p = program_invocation_short_name;
184 AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
185 [Define to 1 if you have program_invocation_short_name])
191 AC_MSG_CHECKING([for __progname])
195 extern char *__progname;
197 printf("%s", __progname);
200 AC_DEFINE([HAVE___PROGNAME], [1], [Define to 1 if you have __progname])
205 ]) # DPKG_CHECK_PROGNAME
207 # DPKG_CHECK_COMPAT_FUNCS(LIST)
208 # -----------------------
209 # Check each function and define an automake conditional
210 AC_DEFUN([DPKG_CHECK_COMPAT_FUNCS], [
212 m4_foreach_w([ac_func], [$1], [
213 AM_CONDITIONAL([HAVE_]AS_TR_CPP(ac_func),
214 [test "x$ac_cv_func_[]AS_TR_SH(ac_func)" = "xyes"])
216 ]) # DPKG_CHECK_COMPAT_FUNCS