Make shell scripts executable and use Unix line endings.

This commit is contained in:
zturtleman 2018-07-30 14:26:43 +00:00
parent bcb911f1e8
commit b8de73c963

364
engine/make-linux-portable.sh Normal file → Executable file
View file

@ -1,182 +1,182 @@
#!/bin/sh #!/bin/sh
ARCH=$1 ARCH=$1
ERROR=0 ERROR=0
# Install directory for Spearmint SDL2 builds (i.e., /home/zack/Local/SDL-2.0.X). # Install directory for Spearmint SDL2 builds (i.e., /home/zack/Local/SDL-2.0.X).
DIR=/home/zack/Local DIR=/home/zack/Local
# SDL version to install and compile against. # SDL version to install and compile against.
# See available versions at http://clover.moe/downloads/spearmint-make-linux-portable-deps/ # See available versions at http://clover.moe/downloads/spearmint-make-linux-portable-deps/
SDLVERSION=2.0.8 SDLVERSION=2.0.8
# #
# Use make-linux-portable.local file to set DIR and (optionally) SDLVERSION # Use make-linux-portable.local file to set DIR and (optionally) SDLVERSION
# #
SETTINGS="$(dirname $0)/make-linux-portable.local" SETTINGS="$(dirname $0)/make-linux-portable.local"
if [ -f "$SETTINGS" ] ; then if [ -f "$SETTINGS" ] ; then
. "$SETTINGS" # source "$SETTINGS" . "$SETTINGS" # source "$SETTINGS"
if [ -z "$DIR" ] || [ ! -d "$DIR" ]; then if [ -z "$DIR" ] || [ ! -d "$DIR" ]; then
echo "Error: DIR specified in '$SETTINGS' not found." echo "Error: DIR specified in '$SETTINGS' not found."
echo echo
ERROR=1 ERROR=1
fi fi
else else
# Require settings file to exist but only error if specified arch # Require settings file to exist but only error if specified arch
if [ -n "$ARCH" ]; then if [ -n "$ARCH" ]; then
echo "Error: You need to create '$SETTINGS', see usage." echo "Error: You need to create '$SETTINGS', see usage."
echo echo
ERROR=1 ERROR=1
fi fi
fi fi
if [ -z "$ARCH" ] || [ $ERROR -ne 0 ]; then if [ -z "$ARCH" ] || [ $ERROR -ne 0 ]; then
echo "Usage: make-linux-portable.sh <arch> [make options]" echo "Usage: make-linux-portable.sh <arch> [make options]"
echo " arch can be x86 or x86_64" echo " arch can be x86 or x86_64"
echo echo
echo "================================================================================" echo "================================================================================"
echo "This script allows shipping lib/x86/libSDL2-2.0.so.0 in the game downloads" echo "This script allows shipping lib/x86/libSDL2-2.0.so.0 in the game downloads"
echo "so that SDL2 does not need to be installed separately on the player's computer." echo "so that SDL2 does not need to be installed separately on the player's computer."
echo "It requires compiling SDL2 with \"./configure --disable-rpath\" and compiling" echo "It requires compiling SDL2 with \"./configure --disable-rpath\" and compiling"
echo "the game client with \"-Wl,-rpath,'\$ORIGIN/lib/x86'\"." echo "the game client with \"-Wl,-rpath,'\$ORIGIN/lib/x86'\"."
echo echo
echo "This script also simplifies compiling the game client for x86 from x86_64 host." echo "This script also simplifies compiling the game client for x86 from x86_64 host."
echo "================================================================================" echo "================================================================================"
echo echo
echo "DIRECTIONS" echo "DIRECTIONS"
echo echo
echo "1. Create a directory to store Spearmint SDL2 builds and create a file named" echo "1. Create a directory to store Spearmint SDL2 builds and create a file named"
echo "'$SETTINGS' containing:" echo "'$SETTINGS' containing:"
echo echo
echo " # Example comment line" echo " # Example comment line"
echo " DIR=/path/to/spearmint-make-linux-portable-deps" echo " DIR=/path/to/spearmint-make-linux-portable-deps"
echo echo
echo "2. To build the game clients (and download Spearmint SDL2 builds if needed) run" echo "2. To build the game clients (and download Spearmint SDL2 builds if needed) run"
echo "the following commands:" echo "the following commands:"
echo echo
echo " make clean-release ARCH=x86" echo " make clean-release ARCH=x86"
echo " ./make-linux-portable.sh x86 -j2" echo " ./make-linux-portable.sh x86 -j2"
echo " make clean-release ARCH=x86_64" echo " make clean-release ARCH=x86_64"
echo " ./make-linux-portable.sh x86_64 -j2" echo " ./make-linux-portable.sh x86_64 -j2"
echo echo
echo "Note: make clean-release ARCH=... is only needed if you previously compiled as" echo "Note: make clean-release ARCH=... is only needed if you previously compiled as"
echo "non-portable." echo "non-portable."
echo echo
echo "3. Make the following files are included relative to the game client in the" echo "3. Make the following files are included relative to the game client in the"
echo "downloads:" echo "downloads:"
echo echo
echo " ./lib/x86/libSDL2-2.0.so.0" echo " ./lib/x86/libSDL2-2.0.so.0"
echo " ./lib/x86_64/libSDL2-2.0.so.0" echo " ./lib/x86_64/libSDL2-2.0.so.0"
echo echo
echo "Note: lib directories will be created in build/release-linux-x86/ and" echo "Note: lib directories will be created in build/release-linux-x86/ and"
echo "build/release-linux-x86/" echo "build/release-linux-x86/"
echo echo
echo echo
echo "COMPATIBILITY" echo "COMPATIBILITY"
echo echo
echo "The game client should run on any GNU/Linux distro as long as the glibc library" echo "The game client should run on any GNU/Linux distro as long as the glibc library"
echo "installed on the computer is new enough. Spearmint releases are built on Debian" echo "installed on the computer is new enough. Spearmint releases are built on Debian"
echo "7 (wheezy) so that the highest possible glibc verion that can be required is" echo "7 (wheezy) so that the highest possible glibc verion that can be required is"
echo "2.13. See https://distrowatch.com for which glibc version is included in each" echo "2.13. See https://distrowatch.com for which glibc version is included in each"
echo "GNU/Linux distro/release." echo "GNU/Linux distro/release."
echo echo
echo "The client/server may require a lower glibc version than compiled against. The" echo "The client/server may require a lower glibc version than compiled against. The"
echo "minimum required glibc version is printed after running this script." echo "minimum required glibc version is printed after running this script."
exit $ERROR exit $ERROR
fi fi
if [ ! -d "$DIR/SDL-$SDLVERSION" ] ; then if [ ! -d "$DIR/SDL-$SDLVERSION" ] ; then
echo "Downloading Spearmint SDL-$SDLVERSION builds into '$DIR'..." echo "Downloading Spearmint SDL-$SDLVERSION builds into '$DIR'..."
# Download SDL2 libs and headers into $DIR. # Download SDL2 libs and headers into $DIR.
if [ ! -f "$DIR/SDL-$SDLVERSION.tar.xz" ] ; then if [ ! -f "$DIR/SDL-$SDLVERSION.tar.xz" ] ; then
# Yes, wget and curl use -o with different capitalization to set output filename. # Yes, wget and curl use -o with different capitalization to set output filename.
if command -v wget >/dev/null 2>&1 ; then if command -v wget >/dev/null 2>&1 ; then
wget -O "$DIR/SDL-$SDLVERSION.tar.xz" "http://clover.moe/downloads/spearmint-make-linux-portable-deps/SDL-$SDLVERSION.tar.xz" wget -O "$DIR/SDL-$SDLVERSION.tar.xz" "http://clover.moe/downloads/spearmint-make-linux-portable-deps/SDL-$SDLVERSION.tar.xz"
ERROR=$? ERROR=$?
elif command -v curl >/dev/null 2>&1 ; then elif command -v curl >/dev/null 2>&1 ; then
curl -o "$DIR/SDL-$SDLVERSION.tar.xz" "http://clover.moe/downloads/spearmint-make-linux-portable-deps/SDL-$SDLVERSION.tar.xz" curl -o "$DIR/SDL-$SDLVERSION.tar.xz" "http://clover.moe/downloads/spearmint-make-linux-portable-deps/SDL-$SDLVERSION.tar.xz"
ERROR=$? ERROR=$?
else else
echo "Error: Need to install wget or curl to download Spearmint SDL2 builds." echo "Error: Need to install wget or curl to download Spearmint SDL2 builds."
exit 1 exit 1
fi fi
if [ $ERROR -ne 0 ] ; then if [ $ERROR -ne 0 ] ; then
echo "Error: Failed to download SDL-$SDLVERSION!" echo "Error: Failed to download SDL-$SDLVERSION!"
exit 1 exit 1
fi fi
fi fi
# Extract into $DIR/SDL-$SDLVERSION/. # Extract into $DIR/SDL-$SDLVERSION/.
tar xJf "$DIR/SDL-$SDLVERSION.tar.xz" -C "$DIR" tar xJf "$DIR/SDL-$SDLVERSION.tar.xz" -C "$DIR"
# Edit prefix in sdl2-config to point to the install directory. # Edit prefix in sdl2-config to point to the install directory.
sed -i -e "s|/home/zack/Local|$DIR|" "$DIR/SDL-$SDLVERSION/build-x86/bin/sdl2-config" sed -i -e "s|/home/zack/Local|$DIR|" "$DIR/SDL-$SDLVERSION/build-x86/bin/sdl2-config"
sed -i -e "s|/home/zack/Local|$DIR|" "$DIR/SDL-$SDLVERSION/build-x86_64/bin/sdl2-config" sed -i -e "s|/home/zack/Local|$DIR|" "$DIR/SDL-$SDLVERSION/build-x86_64/bin/sdl2-config"
fi fi
SDL_PREFIX="$DIR/SDL-$SDLVERSION/build-$ARCH" SDL_PREFIX="$DIR/SDL-$SDLVERSION/build-$ARCH"
if [ ! -d "$SDL_PREFIX" ] ; then if [ ! -d "$SDL_PREFIX" ] ; then
echo "Arch '$ARCH' not found in '$DIR/SDL-$SDLVERSION'" echo "Arch '$ARCH' not found in '$DIR/SDL-$SDLVERSION'"
exit 1 exit 1
fi fi
SDL_CFLAGS=$("$SDL_PREFIX/bin/sdl2-config" --cflags) SDL_CFLAGS=$("$SDL_PREFIX/bin/sdl2-config" --cflags)
SDL_LIBS=$("$SDL_PREFIX/bin/sdl2-config" --libs) SDL_LIBS=$("$SDL_PREFIX/bin/sdl2-config" --libs)
# Don't pass arch ($1) to make in $* # Don't pass arch ($1) to make in $*
shift 1 shift 1
make ARCH=$ARCH USE_PORTABLE_RPATH=1 SDL_CFLAGS="$SDL_CFLAGS" SDL_LIBS="$SDL_LIBS" $* make ARCH=$ARCH USE_PORTABLE_RPATH=1 SDL_CFLAGS="$SDL_CFLAGS" SDL_LIBS="$SDL_LIBS" $*
# Check if make failed. # Check if make failed.
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
exit 2 exit 2
fi fi
# Copy SDL lib to where the game client will read it from # Copy SDL lib to where the game client will read it from
if [ ! -d build/release-linux-$ARCH/lib/$ARCH/ ] ; then if [ ! -d build/release-linux-$ARCH/lib/$ARCH/ ] ; then
mkdir -p build/release-linux-$ARCH/lib/$ARCH/ mkdir -p build/release-linux-$ARCH/lib/$ARCH/
fi fi
if [ ! -f build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0 ] || [ $(stat -c %Y build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0) != $(stat -c %Y "$SDL_PREFIX/lib/libSDL2-2.0.so.0") ] ; then if [ ! -f build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0 ] || [ $(stat -c %Y build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0) != $(stat -c %Y "$SDL_PREFIX/lib/libSDL2-2.0.so.0") ] ; then
cp --preserve=timestamps "$SDL_PREFIX/lib/libSDL2-2.0.so.0" build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0 cp --preserve=timestamps "$SDL_PREFIX/lib/libSDL2-2.0.so.0" build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0
fi fi
# It's interesting to see why a glibc version is required. # It's interesting to see why a glibc version is required.
# Another interesting thing is "ldd -v filename" to see what libaries are requires. # Another interesting thing is "ldd -v filename" to see what libaries are requires.
VERBOSE=0 VERBOSE=0
if [ $VERBOSE -eq 1 ] ; then if [ $VERBOSE -eq 1 ] ; then
# Find glibc lines, remove text before GLIBC, then sort by required glibc version # Find glibc lines, remove text before GLIBC, then sort by required glibc version
# "sort -t _ -k 2 -V" is short form of "sort --field-separator='_' --key=2 --version-sort" # "sort -t _ -k 2 -V" is short form of "sort --field-separator='_' --key=2 --version-sort"
echo echo
echo "spearmint-server_$ARCH:" echo "spearmint-server_$ARCH:"
objdump -T build/release-linux-$ARCH/spearmint-server_$ARCH | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V objdump -T build/release-linux-$ARCH/spearmint-server_$ARCH | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V
echo echo
echo "spearmint_$ARCH:" echo "spearmint_$ARCH:"
objdump -T build/release-linux-$ARCH/spearmint_$ARCH | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V objdump -T build/release-linux-$ARCH/spearmint_$ARCH | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V
echo echo
echo "spearmint-renderer-opengl1_$ARCH.so:" echo "spearmint-renderer-opengl1_$ARCH.so:"
objdump -T build/release-linux-$ARCH/spearmint-renderer-opengl1_$ARCH.so | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V objdump -T build/release-linux-$ARCH/spearmint-renderer-opengl1_$ARCH.so | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V
echo echo
echo "spearmint-renderer-opengl2_$ARCH.so:" echo "spearmint-renderer-opengl2_$ARCH.so:"
objdump -T build/release-linux-$ARCH/spearmint-renderer-opengl2_$ARCH.so | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V objdump -T build/release-linux-$ARCH/spearmint-renderer-opengl2_$ARCH.so | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V
echo echo
echo "lib/$ARCH/libSDL2-2.0.so.0:" echo "lib/$ARCH/libSDL2-2.0.so.0:"
objdump -T build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0 | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V objdump -T build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0 | grep GLIBC | sed -e "s/.*GLIBC_/GLIBC_/g" | sort -t _ -k 2 -V
fi fi
# Find glibc lines, remove text before and including GLIBC_, remove trailing function name, sort by required glibc version, then grab the last (highest) version # Find glibc lines, remove text before and including GLIBC_, remove trailing function name, sort by required glibc version, then grab the last (highest) version
# "sort -uV" is short form of "sort --unique --version-sort" # "sort -uV" is short form of "sort --unique --version-sort"
GLIBC_SERVER=$(objdump -T build/release-linux-$ARCH/spearmint-server_$ARCH | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1) GLIBC_SERVER=$(objdump -T build/release-linux-$ARCH/spearmint-server_$ARCH | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1)
GLIBC_C1=$(objdump -T build/release-linux-$ARCH/spearmint_$ARCH | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1) GLIBC_C1=$(objdump -T build/release-linux-$ARCH/spearmint_$ARCH | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1)
GLIBC_C2=$(objdump -T build/release-linux-$ARCH/spearmint-renderer-opengl1_$ARCH.so | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1) GLIBC_C2=$(objdump -T build/release-linux-$ARCH/spearmint-renderer-opengl1_$ARCH.so | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1)
GLIBC_C3=$(objdump -T build/release-linux-$ARCH/spearmint-renderer-opengl2_$ARCH.so | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1) GLIBC_C3=$(objdump -T build/release-linux-$ARCH/spearmint-renderer-opengl2_$ARCH.so | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1)
GLIBC_C4=$(objdump -T build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0 | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1) GLIBC_C4=$(objdump -T build/release-linux-$ARCH/lib/$ARCH/libSDL2-2.0.so.0 | grep GLIBC | sed -e "s/.*GLIBC_//g" | cut -d' ' -f1 | sort -uV | tail -1)
GLIBC_CLIENT=$(printf "$GLIBC_C1\n$GLIBC_C2\n$GLIBC_C3\n$GLIBC_C4\n" | sort -uV | tail -1) GLIBC_CLIENT=$(printf "$GLIBC_C1\n$GLIBC_C2\n$GLIBC_C3\n$GLIBC_C4\n" | sort -uV | tail -1)
echo echo
echo "Information you can add to your download page:" echo "Information you can add to your download page:"
echo " The GNU/Linux $ARCH client requires glibc '$GLIBC_CLIENT' or later." echo " The GNU/Linux $ARCH client requires glibc '$GLIBC_CLIENT' or later."
echo " The GNU/Linux $ARCH server requires glibc '$GLIBC_SERVER' or later." echo " The GNU/Linux $ARCH server requires glibc '$GLIBC_SERVER' or later."