SDL_image: Remove large third party dependencies for the distribution archive

From d67e9ed513f6061e5791c21a7d22f1f074d587fa Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 10 May 2022 10:11:58 -0700
Subject: [PATCH] Remove large third party dependencies for the distribution
 archive

By default SDL_image will be built without them, and they can be added for additional functionality
---
 Makefile.am          |  3 +--
 Makefile.in          |  3 +--
 external/download.sh | 16 ++++++++++++++++
 3 files changed, 18 insertions(+), 4 deletions(-)
 create mode 100755 external/download.sh

diff --git a/Makefile.am b/Makefile.am
index 502888d..8e69b1a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -81,5 +81,4 @@ rpm: $(PACKAGE)-$(VERSION).tar.gz
 	rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
 
 dist-hook:
-	-rm -rf `find $(distdir)/external -name '.git*'`
-	-rm -rf `find $(distdir)/external -name '*.yml'`
+	ls $(distdir)/external | fgrep -v download.sh | while read dir; do rm -rf "$(distdir)/external/$$dir"; done
diff --git a/Makefile.in b/Makefile.in
index de3c263..000dcfe 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1149,8 +1149,7 @@ rpm: $(PACKAGE)-$(VERSION).tar.gz
 	rpmbuild -ta $(PACKAGE)-$(VERSION).tar.gz
 
 dist-hook:
-	-rm -rf `find $(distdir)/external -name '.git*'`
-	-rm -rf `find $(distdir)/external -name '*.yml'`
+	ls $(distdir)/external | fgrep -v download.sh | while read dir; do rm -rvf "$(distdir)/external/$$dir"; done
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
diff --git a/external/download.sh b/external/download.sh
new file mode 100755
index 0000000..2ab7cbb
--- /dev/null
+++ b/external/download.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname "$0")/..
+cat .gitmodules | \
+while true; do
+    read module || break
+    read line; set -- $line
+    path=$3
+    read line; set -- $line
+    url=$3
+    read line; set -- $line
+    branch=$3
+    git clone $url $path -b $branch
+done