[vlc-devel] [PATCH] contrib/libpng: force C89 mode when using GCC (fixes #16760)
Sean McGovern
gseanmcg at gmail.com
Tue Mar 29 19:35:55 CEST 2016
---
Apparently this library lives 20+ years in the past...
---
contrib/src/png/force-c89.patch | 34 ++++++++++++++++++++++++++++++++++
contrib/src/png/rules.mak | 3 ++-
2 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 contrib/src/png/force-c89.patch
diff --git a/contrib/src/png/force-c89.patch b/contrib/src/png/force-c89.patch
new file mode 100644
index 0000000..1877df4
--- /dev/null
+++ b/contrib/src/png/force-c89.patch
@@ -0,0 +1,34 @@
+From 12e63e91af1378225993b36e25ce3252b54e751a Mon Sep 17 00:00:00 2001
+From: Dagobert Michelsen <dam at opencsw.org>
+Date: Mon, 14 Mar 2016 16:21:06 +0100
+Subject: [PATCH] Force back to C89 if needed. This fixes #245
+
+---
+ configure.ac | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index 3b8746a..ee3ea05 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -114,6 +114,20 @@ AC_ARG_ENABLE(werror,
+ CFLAGS="$sav_CFLAGS"
+ fi],)
+
++# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89
++# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1
++# This is incompatible with the new default mode, so we test for that and force the
++AC_MSG_CHECKING([if we need to force back C standard to C89])
++AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define _POSIX_SOURCE 1
++#include <stdio.h>
++])],AC_MSG_RESULT(no),[
++if test "x$GCC" != "xyes"; then
++ AC_MSG_ERROR([Forcing back to C89 is required but the flags are unknown for other compilers than GCC])
++fi
++AC_MSG_RESULT(yes)
++CFLAGS="$CFLAGS -std=c89"
++])
++
+ # Checks for header files.
+ AC_HEADER_STDC
+
diff --git a/contrib/src/png/rules.mak b/contrib/src/png/rules.mak
index 61f835e..0cde547 100644
--- a/contrib/src/png/rules.mak
+++ b/contrib/src/png/rules.mak
@@ -17,12 +17,13 @@ png: libpng-$(PNG_VERSION).tar.xz .sum-png
$(APPLY) $(SRC)/png/winrt.patch
$(APPLY) $(SRC)/png/bins.patch
$(APPLY) $(SRC)/png/automake.patch
+ $(APPLY) $(SRC)/png/force-c89.patch
$(MOVE)
DEPS_png = zlib $(DEPS_zlib)
.png: png
$(RECONF)
- cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
+ cd $< && $(HOSTVARS) CC="`echo ${CC} | ${SED-sed} 's: -std=[a-z0-9]*::'`" ./configure $(HOSTCONF)
cd $< && $(MAKE) install
touch $@
--
1.7.9.2
More information about the vlc-devel
mailing list