Skip to content

Instantly share code, notes, and snippets.

@btarg
Last active June 3, 2020 20:32
Show Gist options
  • Save btarg/7ec16ec5d746253e7ad7dd6ed12dbfbc to your computer and use it in GitHub Desktop.
Save btarg/7ec16ec5d746253e7ad7dd6ed12dbfbc to your computer and use it in GitHub Desktop.
Download and build SM64PC for MYSYS2 on Windows (get-sm64pc) [LEGACY: get the new script here https://sm64pc.info/forum/viewtopic.php?f=4&t=2&i=2]
#!/bin/bash
# https://www.reddit.com/r/SM64PC/comments/ggnghp/how_to_download_sm64pc/fqno5zw?utm_source=share&utm_medium=web2x
# Please use -h or --help for usage.
# Setup
TEMP=$(getopt -o o:fh --long outpath:,flush,help -- "$@")
eval set -- "$TEMP"
# Defaults
OFLAG=0
OUTPATH=""
FLUSH=0
# Help
usage() {
echo "This script will go to home in MSYS2 (~), download the repo, and build the Windows OpenGL 64-bit EXE."
echo " Requirements:"
echo " 1) Install MSYS2 (64-bit) for Windows. Run it with mingw64.exe."
echo " 2) Install prereqs in MSYS2:"
echo " pacman -S mingw-w64-i686-glew mingw-w64-x86_64-glew mingw-w64-i686-SDL2 mingw-w64-x86_64-SDL2 python3"
echo ""
echo "Usage: $0 [-o /drive/path/to/output/] [-f] /drive/path/to/base.file " 1>&2
echo " -o | --outpath Copies the output EXE to the specified directory, overwriting EXE if present."
echo " -f | --flush Nukes everything in the output folder, including save files, ReShade settings, etc..."
echo ""
echo "Example to just build normally:"
echo " $0 /c/path/to/you/know/the/file.z64"
echo ""
echo "Example to build and push to other folder, deleting all previous game data."
echo " $0 -o /c/Users/Me/Desktop/game /c/path/to/you/know/the/file.z64"
echo ""
echo "For more info, please refer to the repo Wiki:"
echo " https://github.com/sm64pc/sm64pc/wiki"
echo ""
}
exit_early() {
usage
exit 1
}
while true; do
case "$1" in
-o | --outpath ) OFLAG=1; OUTPATH=$2; shift 2 ;;
-f | --flush ) FLUSH=1 ; shift ;;
-h | --help) exit_early ;;
-- ) if [ -n "$2" ]
then
ARGUMENT1=$2
if [ -n "$3" ]
then
ARGUMENT2=$3
if [ -n "$4" ]
then
shift 3
echo "Unexpected options: \"$@\" . Too many arguments. Exiting."
exit 1;
fi
fi
fi
shift 2; break;;
* ) break ;;
esac
done
BASEFILE=$ARGUMENT1
# Check the path has a trailing slash, because I'm a courteous motherfucker.
length=${#OUTPATH}
last_char=${OUTPATH:length-1:1}
[[ $last_char != "/" ]] && OUTPATH="$OUTPATH/"; :
# Check if everything is good for the build.
if [ -z "$BASEFILE" ]; then
echo "No base file provided! Exiting. Nothing was done."
exit 1
elif [ ! -f "$BASEFILE" ]; then
echo "$BASEFILE does not exist."
echo "Check your path and try again. Exiting. Nothing was done."
exit 1
fi
# Do the build
cd ~
rm -rf sm64pc/
git clone https://github.com/sm64pc/sm64pc
cp $BASEFILE sm64pc/
cd sm64pc/tools/audiofile-0.3.6/
autoreconf -i
PATH=/mingw64/bin:/mingw32/bin:$PATH LIBS=-lstdc++ ./configure --disable-docs
PATH=/mingw64/bin:/mingw32/bin:$PATH make
mkdir ../lib
cp libaudiofile/.libs/libaudiofile.a ../lib/
cp libaudiofile/.libs/libaudiofile.la ../lib/
cd ..
sed -r "s#laudiofile#laudiofile -lstdc\+\+#" Makefile > Makefile-new
rm Makefile && cp Makefile-new Makefile && rm Makefile-new
PATH=/mingw64/bin:/mingw32/bin:$PATH make
cd ..
PATH=/mingw32/bin:/mingw64/bin:$PATH make
# Handle extra output options
if [ $OFLAG -eq "1" ]; then
if [ ! -d "$OUTPATH" ]; then
echo "$OUTPATH does not exist."
echo "The EXE was built successfully, but no copy actions were taken."
exit 1
fi
if [ $FLUSH -eq "1" ]; then
rm $OUTPATH*
fi
cp -f ~/sm64pc/build/us_pc/sm64.us.f3dex2e.exe $OUTPATH
fi
exit 0
@btarg
Copy link
Author

btarg commented Jun 3, 2020

Don't use this, use the new script instead https://sm64pc.info/forum/viewtopic.php?f=4&t=2&i=2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment