SDL_image: updates to external libs

From 74e8d577216e3c3a969e67b68b2e4769fcbf8fdd Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Thu, 13 Feb 2025 18:33:20 +0300
Subject: [PATCH] updates to external libs

---
 VisualC/external/include/webp/types.h   |  8 +++++---
 external/libwebp-1.0.3/CMakeLists.txt   |  8 ++++++++
 external/libwebp-1.0.3/Makefile.vc      | 16 +---------------
 external/libwebp-1.0.3/configure        |  1 +
 external/libwebp-1.0.3/configure.ac     |  3 ++-
 external/libwebp-1.0.3/src/webp/types.h |  8 +++++---
 6 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/VisualC/external/include/webp/types.h b/VisualC/external/include/webp/types.h
index 0ce2622e4..6eb4005bc 100644
--- a/VisualC/external/include/webp/types.h
+++ b/VisualC/external/include/webp/types.h
@@ -39,11 +39,13 @@ typedef long long int int64_t;
 #ifndef WEBP_EXTERN
 // This explicitly marks library functions and allows for changing the
 // signature for e.g., Windows DLL builds.
-# if defined(__GNUC__) && __GNUC__ >= 4
+# if defined(_WIN32) && defined(WEBP_DLL)
+#  define WEBP_EXTERN __declspec(dllexport)
+# elif defined(__GNUC__) && __GNUC__ >= 4
 #  define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
 # else
-#  define WEBP_EXTERN extern
-# endif  /* __GNUC__ >= 4 */
+#   define WEBP_EXTERN extern
+# endif
 #endif  /* WEBP_EXTERN */
 
 // Macro to check ABI compatibility (same major revision number)
diff --git a/external/libwebp-1.0.3/CMakeLists.txt b/external/libwebp-1.0.3/CMakeLists.txt
index 54caecc93..ce0d9e598 100644
--- a/external/libwebp-1.0.3/CMakeLists.txt
+++ b/external/libwebp-1.0.3/CMakeLists.txt
@@ -66,6 +66,10 @@ if(WEBP_UNICODE)
   add_definitions(-DUNICODE -D_UNICODE)
 endif()
 
+if(WIN32 AND BUILD_SHARED_LIBS)
+  add_definitions(-DWEBP_DLL)
+endif()
+
 set(prefix ${CMAKE_INSTALL_PREFIX})
 set(exec_prefix "\$\{prefix\}")
 set(libdir "\$\{prefix\}/lib")
@@ -73,6 +77,10 @@ set(includedir "\$\{prefix\}/include")
 set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
 set(INSTALLED_LIBRARIES)
 
+if(NOT WIN32)
+set(CMAKE_C_VISIBILITY_PRESET hidden)
+endif()
+
 # ##############################################################################
 # Android only.
 if(ANDROID)
diff --git a/external/libwebp-1.0.3/Makefile.vc b/external/libwebp-1.0.3/Makefile.vc
index 8a54559ad..fc8ad0f33 100644
--- a/external/libwebp-1.0.3/Makefile.vc
+++ b/external/libwebp-1.0.3/Makefile.vc
@@ -119,8 +119,7 @@ LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME).lib
 LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME).lib
 LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME).lib
 !ELSE IF "$(DLLBUILD)" == "TRUE"
-DLLINC = webp_dll.h
-CC     = $(CC) /I$(DIROBJ) /FI$(DLLINC) $(RTLIB) /DWEBP_DLL
+CC     = $(CC) /I$(DIROBJ) $(RTLIB) /DWEBP_DLL
 LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib
 LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME)_dll.lib
 LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME)_dll.lib
@@ -410,9 +409,6 @@ $(LIBWEBPDEMUX): $(LIBWEBPDEMUX_OBJS)
 $(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS): $(OUTPUT_DIRS)
 
 !IF "$(DLLBUILD)" == "TRUE"
-$(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS): \
-    $(DIROBJ)\$(DLLINC)
-
 {$(DIROBJ)}.c{$(DIROBJ)}.obj:
 	$(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$@  $<
 
@@ -431,9 +427,6 @@ $(LIBWEBPDEMUX): $(LIBWEBP) $(DIROBJ)\demux\$(LIBWEBPDEMUX_BASENAME:_debug=).res
 $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX):
 	$(LNKDLL) /out:$(DIRBIN)\$(@B:_dll=.dll) /implib:$@ $(LFLAGS) $**
 	-xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y
-
-clean::
-	@-erase /s $(DIROBJ)\$(DLLINC) 2> NUL
 !ELSE
 $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX):
 	$(LNKLIB) /out:$@ $**
@@ -443,13 +436,6 @@ $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX):
 $(OUTPUT_DIRS):
 	@if not exist "$(@)" mkdir "$(@)"
 
-# generate a helper include to define WEBP_EXTERN suitable for the DLL build
-$(DIROBJ)\$(DLLINC):
-	@echo #ifndef WEBP_DLL_H_ > $@
-	@echo #define WEBP_DLL_H_ >> $@
-	@echo #define WEBP_EXTERN __declspec(dllexport) >> $@
-	@echo #endif  /* WEBP_DLL_H_ */ >> $@
-
 .SUFFIXES: .c .obj .res .exe
 # File-specific flag builds. Note batch rules take precedence over wildcards,
 # so for now name each file individually.
diff --git a/external/libwebp-1.0.3/configure b/external/libwebp-1.0.3/configure
index eeeca1068..8d17b5f40 100755
--- a/external/libwebp-1.0.3/configure
+++ b/external/libwebp-1.0.3/configure
@@ -17258,6 +17258,7 @@ ac_clean_files=$ac_clean_files_save
 test $ac_write_fail = 0 ||
   as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
 
+$SED -i 's/-DDLL_EXPORT/-DWEBP_DLL/' config.status
 
 # configure is writing to config.log, and then calls config.status.
 # config.status does its own redirection, appending to config.log.
diff --git a/external/libwebp-1.0.3/configure.ac b/external/libwebp-1.0.3/configure.ac
index 501d9335b..86997396d 100644
--- a/external/libwebp-1.0.3/configure.ac
+++ b/external/libwebp-1.0.3/configure.ac
@@ -736,7 +736,8 @@ AC_CONFIG_FILES([Makefile src/Makefile man/Makefile \
                  src/libwebp.pc src/libwebpdecoder.pc \
                  src/demux/libwebpdemux.pc src/mux/libwebpmux.pc])
 
-
+dnl fix exports from MinGW builds
+AC_CONFIG_COMMANDS_POST([$SED -i 's/-DDLL_EXPORT/-DWEBP_DLL/' config.status])
 AC_OUTPUT
 
 AC_MSG_NOTICE([
diff --git a/external/libwebp-1.0.3/src/webp/types.h b/external/libwebp-1.0.3/src/webp/types.h
index 0ce2622e4..6eb4005bc 100644
--- a/external/libwebp-1.0.3/src/webp/types.h
+++ b/external/libwebp-1.0.3/src/webp/types.h
@@ -39,11 +39,13 @@ typedef long long int int64_t;
 #ifndef WEBP_EXTERN
 // This explicitly marks library functions and allows for changing the
 // signature for e.g., Windows DLL builds.
-# if defined(__GNUC__) && __GNUC__ >= 4
+# if defined(_WIN32) && defined(WEBP_DLL)
+#  define WEBP_EXTERN __declspec(dllexport)
+# elif defined(__GNUC__) && __GNUC__ >= 4
 #  define WEBP_EXTERN extern __attribute__ ((visibility ("default")))
 # else
-#  define WEBP_EXTERN extern
-# endif  /* __GNUC__ >= 4 */
+#   define WEBP_EXTERN extern
+# endif
 #endif  /* WEBP_EXTERN */
 
 // Macro to check ABI compatibility (same major revision number)