diff mbox

[FFmpeg-devel] configure: fix detection of libopenjpeg

Message ID 19d3769b-2622-108a-bb9f-f40fbfb375af@googlemail.com
State Accepted
Headers show

Commit Message

Andreas Cadhalpun Oct. 12, 2016, 3:30 p.m. UTC
On 12.10.2016 03:35, Michael Bradshaw wrote:
> Oh man, I literally just wrote a patch for this today. You beat me by 6
> hours. Anyway, thanks for the patch!

What a coincidence!

> On Tue, Oct 11, 2016 at 11:37 AM, Andreas Cadhalpun <
> andreas.cadhalpun@googlemail.com> wrote:
> 
[...]
>> +enabled libopenjpeg       && { { check_lib2 openjpeg-2.1/openjpeg.h
>> opj_version -lopenjp2 -DOPJ_STATIC && add_cflags -DOPJ_STATIC; } ||
>>
> 
> Use add_cppflags instead of add_cflags. The macro isn't needed for linking.

Fixed.

>> +                               check_lib2 openjpeg-2.1/openjpeg.h
>> opj_version -lopenjp2 ||
>> +                               { check_lib openjpeg-2.0/openjpeg.h
>> opj_version -lopenjp2 -DOPJ_STATIC  && add_cflags -DOPJ_STATIC; } ||
>>
> 
> You can drop the changes for v2.0 and below. Only v2.1 needs the check. The
> new OPJ_STATIC behavior was introduced in OpenJPEG v2.1.1.

Thanks for sharing that information.
Updated patch attached.

Best regards,
Andreas

Comments

Michael Bradshaw Oct. 13, 2016, 1:11 a.m. UTC | #1
On Wed, Oct 12, 2016 at 8:30 AM, Andreas Cadhalpun <
andreas.cadhalpun@googlemail.com> wrote:
>
> Updated patch attached.


New patch looks good to me (though I don't have push privileges so can't
commit it).

Thanks!
Andreas Cadhalpun Oct. 13, 2016, 7:10 p.m. UTC | #2
On 13.10.2016 03:11, Michael Bradshaw wrote:
> On Wed, Oct 12, 2016 at 8:30 AM, Andreas Cadhalpun <
> andreas.cadhalpun@googlemail.com> wrote:
>>
>> Updated patch attached.
> 
> 
> New patch looks good to me (though I don't have push privileges so can't
> commit it).

I pushed it myself. Thanks for the review.

Best regards,
Andreas
diff mbox

Patch

From 5c9e02fa1a0f45d84fc31de4ba53d8362a10b4e5 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Date: Tue, 11 Oct 2016 20:28:35 +0200
Subject: [PATCH] configure: fix detection of libopenjpeg

Use check_lib2 to test the header together with the function. This is
necessary, because '-DOPJ_STATIC' changes what the included header does.

Also add '-DOPJ_STATIC' to CPPFLAGS, so that it isn't necessary to
hardcode this in libavcodec/libopenjpeg{dec,enc}.c.

Finally, check for non-static openjpeg 2.1, too.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
---
 configure                   | 9 +++++----
 libavcodec/libopenjpegdec.c | 2 --
 libavcodec/libopenjpegenc.c | 2 --
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 8fc71fb..2b71415 100755
--- a/configure
+++ b/configure
@@ -5710,10 +5710,11 @@  enabled libopencv         && { check_header opencv2/core/core_c.h &&
                                  require opencv opencv2/core/core_c.h cvCreateImageHeader -lopencv_core -lopencv_imgproc; } ||
                                require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader; }
 enabled libopenh264       && require_pkg_config openh264 wels/codec_api.h WelsGetCodecVersion
-enabled libopenjpeg       && { check_lib openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC ||
-                               check_lib openjpeg-2.0/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC ||
-                               check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
-                               check_lib openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC ||
+enabled libopenjpeg       && { { check_lib2 openjpeg-2.1/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
+                               check_lib2 openjpeg-2.1/openjpeg.h opj_version -lopenjp2 ||
+                               { check_lib openjpeg-2.0/openjpeg.h opj_version -lopenjp2 -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
+                               { check_lib openjpeg-1.5/openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
+                               { check_lib2 openjpeg.h opj_version -lopenjpeg -DOPJ_STATIC && add_cppflags -DOPJ_STATIC; } ||
                                die "ERROR: libopenjpeg not found"; }
 enabled libopenmpt        && require_pkg_config "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create
 enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index 65167e6..b4ce834 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -24,8 +24,6 @@ 
  * JPEG 2000 decoder using libopenjpeg
  */
 
-#define  OPJ_STATIC
-
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/intreadwrite.h"
diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
index 1443551..5042507 100644
--- a/libavcodec/libopenjpegenc.c
+++ b/libavcodec/libopenjpegenc.c
@@ -24,8 +24,6 @@ 
  * JPEG 2000 encoder using libopenjpeg
  */
 
-#define  OPJ_STATIC
-
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/imgutils.h"
-- 
2.9.3