[PATCH] MNG detection fails with libjpeg-turbo

The Wanderer <[email protected]>
Newsgroups gmane.comp.video.mplayer.devel
Organization This space intentionally left blank.
Message-ID <[email protected]>
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.

https://github.com/libjpeg-turbo/libjpeg-turbo/issues/17
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

_______________________________________________
MPlayer-dev-eng mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
libmng-detection-fix.diff (text/x-diff, 1.1 KB)
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; }
+EOF
+  shift 4
+  compile_check $TMPC $@
+}
+
 yasm_check() {
   echo >> "$TMPLOG"
   cat "$TMPS" >> "$TMPLOG"
@@ -5303,7 +5313,7 @@
 if test "$_mng" = auto ; then
   _mng=no
   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
   done
 fi
 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>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEJCOqsZEc2qVC44pUBKk1jTQoMmsFAlobJdoACgkQBKk1jTQo
MmvfmA//U/pdhkn5ULt3oDljtIkIG3uxYt8A0XFrB1AQ7M880oMH9hCOvP7k3LmN
fLNZ6rIpCXNh5CkpRjMezgZ1b9r5SUOztD2ykh1c8TQjyQezV+pbXOZ/pdZn8Gzh
lGlmpXrAEWvqbEJGLlli11dBEN0ZwD7I0MabKOl+TDKXBc5JZ/uLoBHzDXbhoHky
A+5Q+yQpCSESKjKo9muJ1lEm+FS1irCWR3KN+nxvil9tURRwZzOkqoVbn2xu6PZs
YY25iHwKbfFHqocQjZxnDIsAd6/YFg/KKk0PCQ5ZRjlaKkidXRQB/Q2v8VC6r+67
LUFIxRoeiruEHD0o9oc2FrzulmCejCUdbZTrkjBqOxT5DrUERwlta6UXkbum4h6F
epZRT03Gp42VNvCp/ujmx1EAGuo7yBXSQPhmrdHtm+N0rv6yOSG+izX1rHqnvWLH
Obi+caANQAAizP0qFvvg34UicKbizOK9ECy73LD+hJS3ZJuhLc+96G0aM4YVdOjn
0jW40W4u6rBCCIF3NfAUmzeUxVd8QSoPLIPbH7mKBbVSxMndqWLuEEP7BtPQc22n
iFgbLUmJ2ASshqrpQ/XFWnX3Ua/ZRF6K/1Jx3dXtX/qo66l3aahe+XnocqRimTi4
VzBvYhqOw1b+vZ90DFSVZwBikR+l70oCV5Wu23TAgrGYgHTF094=
=0e0+
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.