Skip to content

Commit

Permalink
Use stb_image by default for autotools builds
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed May 10, 2022
1 parent e7e2329 commit 797ada8
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 29 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
27 changes: 16 additions & 11 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
50 changes: 34 additions & 16 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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=$?
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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]])],
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

This comment has been minimized.

Copy link
@sezero

sezero May 10, 2022

Contributor

@slouken: What has libjpeg has to with our tiff support? libtiff may internally depend on libjpeg, but our tiff support does not - or am I missing something?

This comment has been minimized.

Copy link
@sezero

sezero May 10, 2022

Contributor

Looks like it's coming from this old commit where the user has a static libtiff which depends on libjpeg: 994b4b0
I think we should remove that || test x$enable_tif = xyes from libjpeg discovery / enablement.

This comment has been minimized.

Copy link
@slouken

slouken May 10, 2022

Author Collaborator

Agreed.

PKG_CHECK_MODULES([LIBJPEG], [libjpeg], [dnl
have_jpg_hdr=yes
have_jpg_lib=yes
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 797ada8

Please sign in to comment.