Last active
September 3, 2021 22:54
-
-
Save vmedea/d244c07eebf972ed74179fd651fea6e7 to your computer and use it in GitHub Desktop.
Build and install script for Fallow under Linux using mkxp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install and build dependencies for mkxp for running the game Fallow by Ada Rook. | |
# Script by Mara Huldra 2021. | |
# SPDX-License-Identifier: MIT | |
# Tested on Ubuntu 20.04 and Debian. | |
set -e | |
PREFIX="${PWD}/fallow-install" | |
BUILDDIR="${PWD}/fallow-build" | |
FALLOWHOME="${HOME}/.steam/debian-installation/steamapps/common/Fallow" | |
PAR=1 | |
IPRE="\e[95m" | |
TPRE="\e[37m" | |
WPRE="\e[91m" | |
POST="\e[0m" | |
# Argument parsing | |
while [[ $# -gt 0 ]]; do | |
key="$1" | |
case $key in | |
-i|--install-prefix) | |
PREFIX="$2" | |
shift | |
shift | |
;; | |
-b|--build-dir) | |
BUILDDIR="$2" | |
shift | |
shift | |
;; | |
-d|--data-dir) | |
FALLOWHOME="$2" | |
shift | |
shift | |
;; | |
-j|--jobs) | |
PAR="$2" | |
shift | |
shift | |
;; | |
-h|--help) | |
echo "Usage: $0 <...>" | |
echo | |
echo "-i|--install-prefix <install_prefix> Prefix to install binaries to (default ${PREFIX})." | |
echo "-b|--build-dir <build_dir> Temporary build directory (WILL BE DELETED, default ${BUILDDIR})." | |
echo "-d|--data-dir <fallow_home> Fallow installation directory (default ${FALLOWHOME})." | |
echo "-j|--jobs <n> Number of build threads (default ${PAR})." | |
exit 0 | |
;; | |
*) # unknown option | |
echo "Invalid argument $key. Valid arguments are: --install-prefix, --build-dir, --data-dir." | |
exit 1 | |
;; | |
esac | |
done | |
echo -e "${IPRE}Installing mkxp to ${PREFIX}${POST}" | |
echo -e "${IPRE}Assuming Fallow is installed in ${FALLOWHOME}${POST}" | |
echo -e "${IPRE}Using temporary build directory ${BUILDDIR}${POST}" | |
if [ ! -d "${FALLOWHOME}" ]; then | |
echo -e "${WPRE}Cannot find game installation (override with --data-dir).${POST}" | |
exit 1 | |
fi | |
mkdir -p "${PREFIX}" | |
echo -e "${TPRE}Install apt dependencies...${POST}" | |
set +e | |
sudo apt install autoconf automake libtool cmake libogg-dev libboost-program-options-dev libsigc++-2.0-dev libphysfs-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libopenal-dev libpixman-1-dev | |
result=$? | |
set -e | |
if [ $result != 0 ]; then | |
echo -e "${WPRE}Warning: sudo or apt failed, please check that the needed system dependencies have been installed.${POST}" | |
# Don't exit here. | |
fi | |
rm -rf ${BUILDDIR} | |
mkdir ${BUILDDIR} | |
echo -e "${TPRE}Download source dependencies...${POST}" | |
cd ${BUILDDIR} | |
wget https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.10.tar.bz2 | |
wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' | |
wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' | |
git clone --depth=1 https://github.com/Ancurio/SDL_sound.git | |
git clone --depth=1 https://github.com/Ancurio/mkxp.git | |
echo -e "${TPRE}Building source dependencies${POST}" | |
export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig" | |
# Build a minimal ruby 2.1 (for compatibility with RPG Maker XP) | |
cd ${BUILDDIR} | |
tar -jxf ruby-2.1.10.tar.bz2 | |
cd ruby-2.1.10 | |
# replace config.guess and config.sub, for newer architectures | |
cp ${BUILDDIR}/config.guess ${BUILDDIR}/config.sub tool | |
./configure --prefix="${PREFIX}" --with-ext=thread --disable-install-doc --enable-shared --disable-dln --disable-rubygems --with-static-linked-ext | |
make # do not use parallel build for this ruby, it will non-deterministically fail | |
make install | |
# Build Ancurio's SDL_sound fork | |
cd ${BUILDDIR}/SDL_sound | |
./bootstrap | |
./configure --prefix="${PREFIX}" | |
make -j ${PAR} | |
make install | |
# Build mkxp itself | |
cd ${BUILDDIR}/mkxp | |
mkdir build | |
cd build | |
cmake .. -DCMAKE_INSTALL_PREFIX:PATH="${PREFIX}" -DCMAKE_BUILD_TYPE=Release | |
make -j ${PAR} | |
cp mkxp.bin.* "${PREFIX}/bin/mkxp" | |
echo -e "${TPRE}Configuring game...${POST}" | |
# Preloaded game scripts | |
cat > "${PREFIX}/bin/win32_dummy.rb" << "END" | |
# mkxp dummy Win32 wrapper for the game Fallow by Ada Rook | |
class Win32API | |
def initialize(*args) | |
# Hide OS mouse cursor while over window, the game never uses mouse | |
Graphics.show_cursor = false | |
# You could set graphics.fullscreen here: | |
# Graphics.fullscreen = true | |
# But it is more straightforward to directly set fullscreen=true in mkxp.conf to start full-screen. | |
# The full-screen mode can always be toggled with Alt-Enter. | |
end | |
def call(*args) | |
end | |
end | |
END | |
# Create mkxp configuration file | |
cat > "${PREFIX}/bin/mkxp.conf" << END | |
execName=Fallow | |
rgssVersion=1 | |
fullscreen=true | |
fixedAspectRatio=true | |
smoothScaling=true | |
vsync=true | |
defScreenW=640 | |
defScreenH=480 | |
anyAltToggleFS=true | |
enableReset=false | |
useScriptNames=true | |
gameFolder=${FALLOWHOME} | |
preloadScript=${PREFIX}/bin/win32_dummy.rb | |
END | |
# Create run script | |
cat > "${PREFIX}/bin/fallow" << END | |
#!/bin/bash | |
set -e | |
PREFIX="${PREFIX}" | |
export LD_LIBRARY_PATH="\${PREFIX}/lib" | |
\${PREFIX}/bin/mkxp | |
END | |
chmod +x "${PREFIX}/bin/fallow" | |
echo -e "${IPRE}Installation successful${POST}" | |
echo "You can run the game with '${PREFIX}/bin/fallow'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment