openjpeg: Win32-compatible OpenJPEG-2.0 detection
authorРуслан Ижбулатов <lrn1986@gmail.com>
Tue, 6 May 2014 09:28:14 +0000 (09:28 +0000)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 22 Jul 2014 12:32:46 +0000 (14:32 +0200)
OpenJPEG 2.0 API uses stdcall on W32 by default. This prevents normal
autoconf library macros from finding its functions.
A more compatible check is to acutally link a program that includes a
real header.

https://bugzilla.gnome.org/show_bug.cgi?id=733487

configure.ac

index 1a46afb..2146756 100644 (file)
@@ -2553,7 +2553,18 @@ translit(dnm, m, l) AM_CONDITIONAL(USE_OPENJPEG, true)
 AG_GST_CHECK_FEATURE(OPENJPEG, [openjpeg library], openjpeg, [
   HAVE_OPENJPEG="no"
 
-  AG_GST_CHECK_LIBHEADER(OPENJPEG, openjp2, opj_version, ,openjpeg-2.0/openjpeg.h, OPENJPEG_LIBS="-lopenjp2")
+  save_LIBS="$LIBS"
+  save_CFLAGS="$CFLAGS"
+  OPENJPEG_LIBS="-lopenjp2"
+  LIBS="$LIBS $OPENJPEG_LIBS"
+  CFLAGS="$CFLAGS $OPENJPEG_CFLAGS"
+  AC_LINK_IFELSE([
+    AC_LANG_PROGRAM([#include <openjpeg-2.0/openjpeg.h>],
+                    [return (int) *opj_version ();])
+                 ], [HAVE_OPENJPEG=yes], [HAVE_OPENJPEG=no])
+  LIBS="$save_LIBS"
+  CFLAGS="$save_CFLAGS"
+
   if test x"$HAVE_OPENJPEG" = x"no"; then
     PKG_CHECK_MODULES(OPENJPEG, libopenjpeg1,
       HAVE_OPENJPEG="yes",