configure: test jpeg lib before png and zlib

For some obscure reason finding the jpeg lib *after* configuring for
local zlib and/or local png lib failed and thus switched to using the
local jpeg unexpectedly. Searching for jpeg libs before png/zlib fixes
this issue.

Note: this is a pragmatic fix (aka workaround) rather than fixing the
underlying issue. It would be interesting to find out why this happened.
This commit is contained in:
Albrecht Schlosser 2023-03-25 16:12:15 +01:00
parent 40537ae335
commit 9c53d84ceb

View File

@ -667,6 +667,42 @@ STATICIMAGELIBS=""
AC_SUBST([IMAGELIBS])
AC_SUBST([STATICIMAGELIBS])
# Handle the JPEG lib linking mode (use fltk local or system lib)
# If --enable-(resp. --disable-)localjpeg parameter is not set by user
# Then we check the JPEG lib usability, with result in sysjpeglib_ok variable
# Check for System lib use if automatic mode or --disable-localjpeg is requested
sysjpeglib_ok=no
sysjpeginc_ok=no
AS_IF([test x$enable_localjpeg != xyes], [
AC_CHECK_LIB([jpeg], [jpeg_CreateCompress], [
AC_CHECK_HEADER([jpeglib.h], [sysjpeginc_ok=yes])
AS_IF([test x$sysjpeginc_ok = xyes], [
sysjpeglib_ok=yes
])
])
])
# Now set the jpeg lib and include flags according to the requested mode and availability
AS_IF([test x$enable_localjpeg = xyes -o x$sysjpeglib_ok = xno], [
JPEGINC="-I../jpeg"
JPEG="jpeg"
IMAGELIBS="-lfltk_jpeg $IMAGELIBS"
STATICIMAGELIBS="\$libdir/libfltk_jpeg.a $STATICIMAGELIBS"
AC_DEFINE([HAVE_LIBJPEG])
# Finally, warn user if system lib was requested but not found
AS_IF([test x$enable_localjpeg = xno], [
AC_MSG_WARN([Cannot find system jpeg lib or header: choosing the local lib mode.])
])
], [
JPEGINC=""
JPEG=""
IMAGELIBS="-ljpeg $IMAGELIBS"
STATICIMAGELIBS="-ljpeg $STATICIMAGELIBS"
AC_DEFINE([HAVE_LIBJPEG])
])
# Handle the ZLIB lib linking mode (use fltk local or system lib)
# If --enable-(resp. --disable-)localzlib parameter is not set by user
# Then we check the ZLIB lib usability, with result in syszlib_ok variable
@ -682,6 +718,7 @@ AS_IF([test x$enable_localzlib != xyes], [
])
])
# Handle the PNG lib linking mode (use fltk local or system lib)
# If --enable-(resp. --disable-)localpng parameter is not set by user
# Then we check the png lib usability with result in syspng_lib variable
@ -705,7 +742,8 @@ AS_IF([test x$enable_localpng != xyes], [
])
])
# If we use the system zlib, we must also use the system png zlib and vice versa
# If we use the system zlib, we must also use the system png lib and vice versa.
# If either of them is not available, we fall back to using both local libraries
AS_IF([test x$syspnglib_ok = xyes -a x$syszlib_ok != xyes], [
syspnglib_ok=no
@ -771,40 +809,6 @@ AS_IF([test x$enable_localpng = xyes -o x$syspnglib_ok = xno], [
])
# Handle the JPEG lib linking mode (use fltk local or system lib)
# If --enable-(resp. --disable-)localjpeg parameter is not set by user
# Then we check the JPEG lib usability, with result in sysjpeglib_ok variable
# Check for System lib use if automatic mode or --disable-localjpeg is requested
sysjpeglib_ok=no
sysjpeginc_ok=no
AS_IF([test x$enable_localjpeg != xyes], [
AC_CHECK_LIB([jpeg], [jpeg_CreateCompress], [
AC_CHECK_HEADER([jpeglib.h], [sysjpeginc_ok=yes])
AS_IF([test x$sysjpeginc_ok = xyes], [
sysjpeglib_ok=yes
])
])
])
# Now set the jpeg lib and include flags according to the requested mode and availability
AS_IF([test x$enable_localjpeg = xyes -o x$sysjpeglib_ok = xno], [
JPEGINC="-I../jpeg"
JPEG="jpeg"
IMAGELIBS="-lfltk_jpeg $IMAGELIBS"
STATICIMAGELIBS="\$libdir/libfltk_jpeg.a $STATICIMAGELIBS"
AC_DEFINE([HAVE_LIBJPEG])
# Finally, warn user if system lib was requested but not found
AS_IF([test x$enable_localjpeg = xno], [
AC_MSG_WARN([Cannot find system jpeg lib or header: choosing the local lib mode.])
])
], [
JPEGINC=""
JPEG=""
IMAGELIBS="-ljpeg $IMAGELIBS"
STATICIMAGELIBS="-ljpeg $STATICIMAGELIBS"
AC_DEFINE([HAVE_LIBJPEG])
])
AC_SUBST([JPEG])
AC_SUBST([JPEGINC])
AC_SUBST([PNG])