Explorar el Código

build: When cross-building assume a working snprintf on SUS >= v3

SUSv2 and earlier had conflicting semantics with the C99 snprintf()
ones. Because we expect a C99 environment, assume that if we are using
SUSv3 or newer then we have a working snprintf() implementation.
Guillem Jover hace 11 años
padre
commit
5294116c6d
Se han modificado 2 ficheros con 19 adiciones y 2 borrados
  1. 2 0
      debian/changelog
  2. 17 2
      m4/dpkg-funcs.m4

+ 2 - 0
debian/changelog

@@ -51,6 +51,8 @@ dpkg (1.18.0) UNRELEASED; urgency=low
     reproducible regardless of the build system filesystem, and document
     how the value is computed and that it is just an approximation.
     Closes: #650077
+  * Fix support for cross-building dpkg:
+    - Assume a working C99 snprintf on SUS >= v3.
 
  -- Guillem Jover <guillem@debian.org>  Tue, 09 Dec 2014 23:53:18 +0100
 

+ 17 - 2
m4/dpkg-funcs.m4

@@ -1,5 +1,5 @@
 # Copyright © 2005 Scott James Remnant <scott@netsplit.com>
-# Copyright © 2008, 2009 Guillem Jover <guillem@debian.org>
+# Copyright © 2008-2009,2015 Guillem Jover <guillem@debian.org>
 
 # DPKG_FUNC_VA_COPY
 # -----------------
@@ -60,7 +60,22 @@ int main()
 	]])],
 	[dpkg_cv_c99_snprintf=yes],
 	[dpkg_cv_c99_snprintf=no],
-	[dpkg_cv_c99_snprintf=no])])
+	[dpkg_cv_c99_snprintf=maybe])
+
+  AS_IF([test "x$dpkg_cv_c99_snprintf" = "xmaybe"],
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#define _GNU_SOURCE 1
+#include <unistd.h>
+#if !defined(_XOPEN_VERSION) || _XOPEN_VERSION < 600
+#error "snprintf() has conflicting semantics with C99 on SUSv2 and earlier"
+#endif
+]]
+      )],
+      [dpkg_cv_c99_snprintf=yes],
+      [dpkg_cv_c99_snprintf=no]
+    )
+  )
+])
 AS_IF([test "x$dpkg_cv_c99_snprintf" = "xyes"],
 	[AC_DEFINE([HAVE_C99_SNPRINTF], 1,
 	           [Define to 1 if the 'snprintf' family is C99 conformant])],