Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
[libopenjpeg] Update configure scripts
Browse files Browse the repository at this point in the history
- Use pkg-config to detect libopenjpeg library
- Use PJ_VERSION_MAJOR and PJ_VERSION_MINOR to detect interface version.

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
  • Loading branch information
miurahr committed Feb 21, 2018
1 parent 9546088 commit 7d855cc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 54 deletions.
3 changes: 0 additions & 3 deletions config.h.in
Expand Up @@ -151,9 +151,6 @@
/* Should be defined in order to disable WebP support. */
#undef OMIT_WEBP

/* testing for OpenJpeg 2.1 */
#undef OPENJPEG_2_1

/* Name of package */
#undef PACKAGE

Expand Down
40 changes: 11 additions & 29 deletions configure.ac
Expand Up @@ -28,8 +28,6 @@ AH_TEMPLATE([NDEBUG],
AC_DEFINE(NDEBUG)
AH_TEMPLATE([TARGET_CPU],
[Should contain a text-string describing the intended target CPU])
AH_TEMPLATE([OPENJPEG_2_1],
[testing for OpenJpeg 2.1])

# config depending options
AH_TEMPLATE([OMIT_LZMA],
Expand Down Expand Up @@ -144,33 +142,17 @@ AC_SUBST(LIBPNG_LIBS)
AC_ARG_ENABLE(openjpeg, [AS_HELP_STRING(
[--enable-openjpeg], [enables OpenJpeg inclusion [default=yes]])],
[], [enable_openjpeg=yes])
if test x"$enable_openjpeg" != "xno"; then
#
# testing OpenJpeg-2 headers
# they could be either on -/include/openjpeg-2.0
# or on -/include/openjpeg-2.1
#
AC_CHECK_HEADERS(openjpeg-2.0/openjpeg.h)
AC_CHECK_HEADERS(openjpeg-2.1/openjpeg.h)
if test x"$ac_cv_header_openjpeg_2_0_openjpeg_h" != x"yes" &&
test x"$ac_cv_header_openjpeg_2_1_openjpeg_h" != x"yes";
then
AC_MSG_ERROR(['OpenJpeg-2' is required but the header (openjpeg.h) doesn't seem to be installed on this system])
fi
AC_CHECK_LIB(openjp2,opj_create_decompress,,AC_MSG_ERROR(['libopenjp2' is required but it doesn't seems to be installed on this system.]),-lm)
# testing for OpenJpeg 2.0 or 2.1
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#ifdef HAVE_OPENJPEG_2_1_OPENJPEG_H
#include <openjpeg-2.1/openjpeg.h>
#else
#include <openjpeg-2.0/openjpeg.h>
#endif]],
[[void *d; opj_stream_t *s; opj_stream_set_user_data (s, &d, NULL);]])],
[
AC_MSG_RESULT([yes])
AC_DEFINE(OPENJPEG_2_1)
],
[AC_MSG_RESULT([no])]
)
if test x"$enable_openjpeg" != "xno"; then
PKG_CHECK_MODULES(LIBOPENJPEG, libopenjp2,
[openjpeg2=yes],[openjpeg2=no])
if test x$openjpeg2 = xno; then
AC_MSG_ERROR("*** libopenjp2 library not found ***")
AC_DEFINE(OMIT_OPENJPEG)
else
AC_SUBST(LIBOPENJPEG_CFLAGS)
AC_SUBST(LIBOPENJPEG_LIBS)
AC_DEFINE(ENABLE_OPENJPEG)
fi
else
AC_DEFINE(OMIT_OPENJPEG)
fi
Expand Down
4 changes: 2 additions & 2 deletions src/Makefile.am
@@ -1,7 +1,7 @@

AM_CFLAGS = @LIBPNG_CFLAGS@ @LIBWEBP_CFLAGS@ @LIBLZMA_CFLAGS@ \
@LIBCAIRO_CFLAGS@ @LIBCURL_CFLAGS@ @LIBXML2_CFLAGS@ \
@LIBFREETYPE2_CFLAGS@
@LIBFREETYPE2_CFLAGS@ @LIBOPENJPEG_CFLAGS@

AM_CPPFLAGS = @CFLAGS@
AM_CPPFLAGS += -I$(top_srcdir)/headers
Expand All @@ -19,7 +19,7 @@ librasterlite2_la_SOURCES = rasterlite2.c rl2raw.c rl2codec.c \

librasterlite2_la_LIBADD = @LIBPNG_LIBS@ @LIBWEBP_LIBS@ \
@LIBLZMA_LIBS@ @LIBCAIRO_LIBS@ @LIBCURL_LIBS@ \
@LIBXML2_LIBS@ @LIBFREETYPE2_LIBS@
@LIBXML2_LIBS@ @LIBFREETYPE2_LIBS@ @LIBOPENJPEG_LIBS@

if MINGW
librasterlite2_la_LDFLAGS = -avoid-version -no-undefined
Expand Down
32 changes: 12 additions & 20 deletions src/rl2openjpeg.c
Expand Up @@ -57,15 +57,7 @@ the terms of any one of the MPL, the GPL or the LGPL.

#ifndef OMIT_OPENJPEG /* only if OpenJpeg is enabled */

#ifdef HAVE_OPENJPEG_2_1_OPENJPEG_H
#include <openjpeg-2.1/openjpeg.h>
#else
#ifdef __ANDROID__ /* Android specific */
#include <openjpeg.h>
#else
#include <openjpeg-2.0/openjpeg.h>
#endif
#endif

struct jp2_memfile
{
Expand Down Expand Up @@ -400,10 +392,10 @@ compress_jpeg2000 (rl2RasterPtr ptr, unsigned char **jpeg2000,
opj_stream_set_write_function (stream, write_callback);
opj_stream_set_seek_function (stream, seek_callback);
opj_stream_set_skip_function (stream, skip_callback);
#ifdef OPENJPEG_2_1
opj_stream_set_user_data (stream, &clientdata, NULL);
#else
#if OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR == 0
opj_stream_set_user_data (stream, &clientdata);
#else
opj_stream_set_user_data (stream, &clientdata, NULL);
#endif

if (!opj_start_compress (codec, image, stream))
Expand Down Expand Up @@ -760,10 +752,10 @@ rl2_decode_jpeg2000_scaled (int scale, const unsigned char *jpeg2000,
clientdata.size = jpeg2000_sz;
clientdata.eof = jpeg2000_sz;
clientdata.current = 0;
#ifdef OPENJPEG_2_1
opj_stream_set_user_data (stream, &clientdata, NULL);
#else
#if OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR == 0
opj_stream_set_user_data (stream, &clientdata);
#else
opj_stream_set_user_data (stream, &clientdata, NULL);
#endif
if (!opj_read_header (stream, codec, &image))
{
Expand Down Expand Up @@ -1332,10 +1324,10 @@ rl2_get_jpeg2000_infos (const char *path, unsigned int *xwidth,
clientdata.size = jpeg2000_sz;
clientdata.eof = jpeg2000_sz;
clientdata.current = 0;
#ifdef OPENJPEG_2_1
opj_stream_set_user_data (stream, &clientdata, NULL);
#else
#if OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR == 0
opj_stream_set_user_data (stream, &clientdata);
#else
opj_stream_set_user_data (stream, &clientdata, NULL);
#endif
if (!opj_read_header (stream, codec, &image))
{
Expand Down Expand Up @@ -1433,10 +1425,10 @@ rl2_get_jpeg2000_blob_type (const unsigned char *jpeg2000, int jpeg2000_sz,
clientdata.size = jpeg2000_sz;
clientdata.eof = jpeg2000_sz;
clientdata.current = 0;
#ifdef OPENJPEG_2_1
opj_stream_set_user_data (stream, &clientdata, NULL);
#else
#if OPJ_VERSION_MAJOR == 2 && OPJ_VERSION_MINOR == 0
opj_stream_set_user_data (stream, &clientdata);
#else
opj_stream_set_user_data (stream, &clientdata, NULL);
#endif
if (!opj_read_header (stream, codec, &image))
{
Expand Down

0 comments on commit 7d855cc

Please sign in to comment.