Web lists-archives.com

[MPlayer-dev-eng] [PATCH] MNG detection fails with libjpeg-turbo

With current SVN (and for as long as I can remember checking), the
configure check for the availability of libmng fails. Today I finally
got around to looking into why.

The test performs a compile check against libmng.h, which includes
jpeglib.h. With libjpeg-turbo (the source of jpeglib.h in current
Debian), this test fails because FILE is undefined. This is typedef is
normally expected to come from stdio.h.

indicates that this is intentional, for backwards compatibility with
libjpeg, and that "it is actually a design requirement of the libjpeg
API that you include stdio.h before including jpeglib.h.".

This would seem to indicate that this has been broken for a very long
time, and quite possibly no one noticed (which would imply that no one
bothered trying to compile with MNG support). The last MNG-related
commits seem to have been in 2012; support was originally added in 2011.

The compilation check is performed by the return_statement_check
function, which only permits passing one header-file argument. There is
an existing statement_check_broken function, specifically for use with
headers which don't include some of their own dependencies; however, it
hardcodes a 'return 0', whereas return_statement_check permits passing
in an expression to be used in the return statement.

Rather than try to add an ' 0' to all callers of statement_check_broken,
I've duplicated it into return_statement_check_broken, which adds the
return-statement argument from return_statement_check.

With that, detection of libmng succeeds. With an include of stdio.h
added to vo_mng.c, compilation also succeeds.

The attached patch makes both changes.

   The Wanderer

The reasonable man adapts himself to the world; the unreasonable one
persists in trying to adapt the world to himself. Therefore all
progress depends on the unreasonable man.         -- George Bernard Shaw
Index: configure
--- configure	(revision 38007)
+++ configure	(working copy)
@@ -177,6 +177,16 @@
   compile_check $TMPC $@
+return_statement_check_broken() {
+  cat > $TMPC << EOF
+#include <$1>
+#include <$2>
+int main(void) { $3; return $4; }
+  shift 4
+  compile_check $TMPC $@
 yasm_check() {
   echo >> "$TMPLOG"
   cat "$TMPS" >> "$TMPLOG"
@@ -5303,7 +5313,7 @@
 if test "$_mng" = auto ; then
   for mnglibs in '-lmng -lz' '-lmng -ljpeg -lz' ; do
-    return_statement_check libmng.h 'const char * p_ver = mng_version_text()' '!p_ver || p_ver[0] == 0' $mnglibs && _mng=yes
+    return_statement_check_broken stdio.h libmng.h 'const char * p_ver = mng_version_text()' '!p_ver || p_ver[0] == 0' $mnglibs && _mng=yes
 echores "$_mng"
Index: libvo/vo_mng.c
--- libvo/vo_mng.c	(revision 38007)
+++ libvo/vo_mng.c	(working copy)
@@ -20,6 +20,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>

Attachment: signature.asc
Description: OpenPGP digital signature

MPlayer-dev-eng mailing list