From 797ada8383083115dc88462941f1ecb3319cf498 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 10 May 2022 10:03:42 -0700
Subject: [PATCH] Use stb_image by default for autotools builds
---
Makefile.am | 1 +
Makefile.in | 27 ++++++++++++++++-----------
configure | 50 ++++++++++++++++++++++++++++++++++----------------
configure.ac | 11 +++++++++--
4 files changed, 60 insertions(+), 29 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 11b8a0a..502888d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,6 +24,7 @@ libSDL2_image_la_SOURCES = \
IMG_pnm.c \
IMG_qoi.c \
IMG_svg.c \
+ IMG_stb.c \
IMG_tga.c \
IMG_tif.c \
IMG_xcf.c \
diff --git a/Makefile.in b/Makefile.in
index ad22bc8..de3c263 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -147,15 +147,15 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
am__DEPENDENCIES_1 =
am__libSDL2_image_la_SOURCES_DIST = IMG.c IMG_avif.c IMG_bmp.c \
IMG_gif.c IMG_jpg.c IMG_jxl.c IMG_lbm.c IMG_pcx.c IMG_png.c \
- IMG_pnm.c IMG_qoi.c IMG_svg.c IMG_tga.c IMG_tif.c IMG_xcf.c \
- IMG_xpm.c IMG_xv.c IMG_webp.c IMG_WIC.c IMG_ImageIO.m miniz.h \
- nanosvg.h nanosvgrast.h qoi.h
+ IMG_pnm.c IMG_qoi.c IMG_svg.c IMG_stb.c IMG_tga.c IMG_tif.c \
+ IMG_xcf.c IMG_xpm.c IMG_xv.c IMG_webp.c IMG_WIC.c \
+ IMG_ImageIO.m miniz.h nanosvg.h nanosvgrast.h qoi.h
@USE_IMAGEIO_TRUE@am__objects_1 = IMG_ImageIO.lo
am_libSDL2_image_la_OBJECTS = IMG.lo IMG_avif.lo IMG_bmp.lo IMG_gif.lo \
IMG_jpg.lo IMG_jxl.lo IMG_lbm.lo IMG_pcx.lo IMG_png.lo \
- IMG_pnm.lo IMG_qoi.lo IMG_svg.lo IMG_tga.lo IMG_tif.lo \
- IMG_xcf.lo IMG_xpm.lo IMG_xv.lo IMG_webp.lo IMG_WIC.lo \
- $(am__objects_1)
+ IMG_pnm.lo IMG_qoi.lo IMG_svg.lo IMG_stb.lo IMG_tga.lo \
+ IMG_tif.lo IMG_xcf.lo IMG_xpm.lo IMG_xv.lo IMG_webp.lo \
+ IMG_WIC.lo $(am__objects_1)
libSDL2_image_la_OBJECTS = $(am_libSDL2_image_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -191,11 +191,12 @@ am__depfiles_remade = ./$(DEPDIR)/IMG.Plo ./$(DEPDIR)/IMG_ImageIO.Plo \
./$(DEPDIR)/IMG_jpg.Plo ./$(DEPDIR)/IMG_jxl.Plo \
./$(DEPDIR)/IMG_lbm.Plo ./$(DEPDIR)/IMG_pcx.Plo \
./$(DEPDIR)/IMG_png.Plo ./$(DEPDIR)/IMG_pnm.Plo \
- ./$(DEPDIR)/IMG_qoi.Plo ./$(DEPDIR)/IMG_svg.Plo \
- ./$(DEPDIR)/IMG_tga.Plo ./$(DEPDIR)/IMG_tif.Plo \
- ./$(DEPDIR)/IMG_webp.Plo ./$(DEPDIR)/IMG_xcf.Plo \
- ./$(DEPDIR)/IMG_xpm.Plo ./$(DEPDIR)/IMG_xv.Plo \
- ./$(DEPDIR)/showanim.Po ./$(DEPDIR)/showimage.Po
+ ./$(DEPDIR)/IMG_qoi.Plo ./$(DEPDIR)/IMG_stb.Plo \
+ ./$(DEPDIR)/IMG_svg.Plo ./$(DEPDIR)/IMG_tga.Plo \
+ ./$(DEPDIR)/IMG_tif.Plo ./$(DEPDIR)/IMG_webp.Plo \
+ ./$(DEPDIR)/IMG_xcf.Plo ./$(DEPDIR)/IMG_xpm.Plo \
+ ./$(DEPDIR)/IMG_xv.Plo ./$(DEPDIR)/showanim.Po \
+ ./$(DEPDIR)/showimage.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -457,6 +458,7 @@ libSDL2_image_la_SOURCES = \
IMG_pnm.c \
IMG_qoi.c \
IMG_svg.c \
+ IMG_stb.c \
IMG_tga.c \
IMG_tif.c \
IMG_xcf.c \
@@ -611,6 +613,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IMG_png.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IMG_pnm.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IMG_qoi.Plo@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IMG_stb.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IMG_svg.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IMG_tga.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IMG_tif.Plo@am__quote@ # am--include-marker
@@ -1010,6 +1013,7 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/IMG_png.Plo
-rm -f ./$(DEPDIR)/IMG_pnm.Plo
-rm -f ./$(DEPDIR)/IMG_qoi.Plo
+ -rm -f ./$(DEPDIR)/IMG_stb.Plo
-rm -f ./$(DEPDIR)/IMG_svg.Plo
-rm -f ./$(DEPDIR)/IMG_tga.Plo
-rm -f ./$(DEPDIR)/IMG_tif.Plo
@@ -1080,6 +1084,7 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/IMG_png.Plo
-rm -f ./$(DEPDIR)/IMG_pnm.Plo
-rm -f ./$(DEPDIR)/IMG_qoi.Plo
+ -rm -f ./$(DEPDIR)/IMG_stb.Plo
-rm -f ./$(DEPDIR)/IMG_svg.Plo
-rm -f ./$(DEPDIR)/IMG_tga.Plo
-rm -f ./$(DEPDIR)/IMG_tif.Plo
diff --git a/configure b/configure
index 0b4e874..a7292d5 100755
--- a/configure
+++ b/configure
@@ -943,6 +943,7 @@ enable_libtool_lock
enable_dependency_tracking
enable_silent_rules
enable_imageio
+enable_stb_image
enable_avif
enable_avif_shared
enable_bmp
@@ -1630,6 +1631,8 @@ Optional Features:
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-imageio use native Mac OS X frameworks for loading images
[default=yes]
+ --enable-stb-image use stb_image for loading JPG and PNG images
+ [default=yes]
--enable-avif support loading AVIF images [default=yes]
--enable-avif-shared dynamically load AVIF support [default=yes]
--enable-bmp support loading BMP/ICO/CUR images [default=yes]
@@ -4108,13 +4111,13 @@ if ${lt_cv_nm_interface+:} false; then :
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
- (eval echo "\"\$as_me:4111: $ac_compile\"" >&5)
+ (eval echo "\"\$as_me:4114: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
- (eval echo "\"\$as_me:4114: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval echo "\"\$as_me:4117: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
- (eval echo "\"\$as_me:4117: output\"" >&5)
+ (eval echo "\"\$as_me:4120: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
@@ -5328,7 +5331,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 5331 "configure"' > conftest.$ac_ext
+ echo '#line 5334 "configure"' > conftest.$ac_ext
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -7153,11 +7156,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7156: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7159: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7160: \$? = $ac_status" >&5
+ echo "$as_me:7163: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7502,11 +7505,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7505: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7508: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:7509: \$? = $ac_status" >&5
+ echo "$as_me:7512: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -7607,11 +7610,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7610: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7613: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7614: \$? = $ac_status" >&5
+ echo "$as_me:7617: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -7662,11 +7665,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:7665: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:7668: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:7669: \$? = $ac_status" >&5
+ echo "$as_me:7672: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -10097,7 +10100,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10100 "configure"
+#line 10103 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10193,7 +10196,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10196 "configure"
+#line 10199 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12795,6 +12798,13 @@ $as_echo "$have_gcc_fvisibility" >&6; }
fi
}
+# Check whether --enable-stb_image was given.
+if test "${enable_stb_image+set}" = set; then :
+ enableval=$enable_stb_image;
+else
+ enable_stb_image=yes
+fi
+
# Check whether --enable-avif was given.
if test "${enable_avif+set}" = set; then :
enableval=$enable_avif;
@@ -13288,6 +13298,14 @@ rm -f core conftest.err conftest.$ac_objext \
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
+if test x$enable_stb_image = xyes; then
+ $as_echo "#define LOAD_JPG 1" >>confdefs.h
+
+ $as_echo "#define LOAD_PNG 1" >>confdefs.h
+
+ $as_echo "#define USE_STBIMAGE 1" >>confdefs.h
+
+fi
if test x$enable_avif = xyes; then
pkg_failed=no
@@ -13495,7 +13513,7 @@ $as_echo "$as_me: WARNING: AVIF image loading disabled" >&2;}
fi
fi
-if (test x$enable_jpg = xyes || test x$enable_tif = xyes) && test x$enable_imageio != xyes; then
+if ((test x$enable_jpg = xyes && test x$enable_stb_image != xyes) || test x$enable_tif = xyes) && test x$enable_imageio != xyes; then
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjpeg" >&5
@@ -13909,7 +13927,7 @@ $as_echo "$as_me: WARNING: JXL image loading disabled" >&2;}
fi
fi
-if test x$enable_png = xyes -a x$enable_imageio != xyes; then
+if test x$enable_png = xyes -a $enable_stb_image != xyes -a x$enable_imageio != xyes; then
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpng" >&5
diff --git a/configure.ac b/configure.ac
index 49e6469..aba92b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -196,6 +196,8 @@ CheckVisibilityHidden()
}
dnl Check command-line options
+AC_ARG_ENABLE([stb_image], [AS_HELP_STRING([--enable-stb-image], [use stb_image for loading JPG and PNG images [default=yes]])],
+ [], [enable_stb_image=yes])
AC_ARG_ENABLE([avif], [AS_HELP_STRING([--enable-avif], [support loading AVIF images [default=yes]])],
[], [enable_avif=yes])
AC_ARG_ENABLE([avif-shared], [AS_HELP_STRING([--enable-avif-shared], [dynamically load AVIF support [default=yes]])],
@@ -255,6 +257,11 @@ AM_PATH_SDL2($SDL_VERSION,
CFLAGS="$CFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
+if test x$enable_stb_image = xyes; then
+ AC_DEFINE([LOAD_JPG])
+ AC_DEFINE([LOAD_PNG])
+ AC_DEFINE([USE_STBIMAGE])
+fi
if test x$enable_avif = xyes; then
PKG_CHECK_MODULES([LIBAVIF], [libavif], [dnl
have_avif_hdr=yes
@@ -295,7 +302,7 @@ if test x$enable_avif = xyes; then
fi
fi
-if (test x$enable_jpg = xyes || test x$enable_tif = xyes) && test x$enable_imageio != xyes; then
+if ((test x$enable_jpg = xyes && test x$enable_stb_image != xyes) || test x$enable_tif = xyes) && test x$enable_imageio != xyes; then
PKG_CHECK_MODULES([LIBJPEG], [libjpeg], [dnl
have_jpg_hdr=yes
have_jpg_lib=yes
@@ -375,7 +382,7 @@ if test x$enable_jxl = xyes; then
fi
fi
-if test x$enable_png = xyes -a x$enable_imageio != xyes; then
+if test x$enable_png = xyes -a $enable_stb_image != xyes -a x$enable_imageio != xyes; then
PKG_CHECK_MODULES([LIBPNG], [libpng], [dnl
have_png_hdr=yes
have_png_lib=yes