diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ebac7d..c32040d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,14 +2,37 @@ cmake_minimum_required(VERSION 3.5.0) project (saland) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${saland_SOURCE_DIR}/src/cmake") +# Define install paths +set(INSTALL_BIN_DIR "bin" CACHE STRING "Install executable in this directory") +set(INSTALL_DATA_DIR "share/salandgame" CACHE STRING "Install data to this directory") +set(INSTALL_MAN_DIR "share/man/man6" CACHE STRING "Install the man page to this directory") +set(INSTALL_APPLICATIONS_DIR "share/applications" CACHE STRING "Install the .desktop file to this directory") +set(INSTALL_ICONS_DIR "share/icons/hicolor" CACHE STRING "Install the icon in a subfolder in this directory") +set(INSTALL_LOCALE_DIR "${INSTALL_DATA_DIR}/locale/" CACHE STRING "Install translation to this dir") +set(INSTALL_METAINFO_DIR "share/metainfo" CACHE STRING "Install appstream matedata to this directory") + +if (NOT WIN32 AND NOT STANDALONE) + #The path to the data dir must be compiled into the binary + if (IS_ABSOLUTE ${INSTALL_DATA_DIR}) + add_definitions(-DSHAREDIR=\"${INSTALL_DATA_DIR}\") + else() + add_definitions(-DSHAREDIR=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_DATA_DIR}\") + endif() + if (IS_ABSOLUTE ${INSTALL_DATA_DIR}) + add_definitions(-DLOCALEDIR=\"${INSTALL_LOCALE_DIR}\") + else() + add_definitions(-DLOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_LOCALE_DIR}\") + endif() +endif() + # -Wno-deprecated-declarations is needed until all supported platforms are using PhysFS 3.0.1+. # This will happen once Debian 10 is realeased set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wsuggest-override -Wno-deprecated-declarations -std=c++11 -g") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -g") if (WIN32) - SET(GUI_TYPE WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686") + SET(GUI_TYPE WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686") if(NOT _WIN32_WINNT AND NOT WINVER) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WIN32_WINNT=0x0601 -DWINVER=0x0601") endif() diff --git a/extra/docker/Dockerfile.Ubuntu18.04build_Standalone b/extra/docker/Dockerfile.Ubuntu18.04build_Standalone new file mode 100644 index 0000000..752a491 --- /dev/null +++ b/extra/docker/Dockerfile.Ubuntu18.04build_Standalone @@ -0,0 +1,21 @@ +FROM ubuntu:18.04 + +ENV TZ=UTC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt-get update && apt-get install -y build-essential cmake pkg-config libfreetype6-dev libvorbis-dev libgl1-mesa-dev libpulse-dev libpng-dev zip gettext xorg-dev + +COPY extra/standalone/compile_requirements.sh / +RUN /compile_requirements.sh + + + +COPY . /staging/saland-game + +ENV SALAND_VERSION UNKNOWN + + + +RUN cd /staging/saland-game && \ +./packdata.sh && \ +cmake -D Boost_USE_STATIC_LIBS=ON -D INSTALL_DATA_DIR=. -D CMAKE_INSTALL_PREFIX=. -D STANDALONE=1 . && make diff --git a/extra/standalone/.gitignore b/extra/standalone/.gitignore new file mode 100644 index 0000000..dcd5906 --- /dev/null +++ b/extra/standalone/.gitignore @@ -0,0 +1 @@ +staging diff --git a/extra/standalone/README.txt b/extra/standalone/README.txt new file mode 100644 index 0000000..53bdf7e --- /dev/null +++ b/extra/standalone/README.txt @@ -0,0 +1,10 @@ +Saland Adventures - Linux build + +This is the standalone version. It is precompiled and includes the necessary libraries to run. + +Only 64 bit systems are supported. +Tested on: Yet to be tested. +Some systems might require the game to be launched from the command line. +PulseAudio is required for sound. + +Check https://salandgame.github.io for more info. diff --git a/extra/standalone/build_standalone.sh b/extra/standalone/build_standalone.sh new file mode 100755 index 0000000..4a9a413 --- /dev/null +++ b/extra/standalone/build_standalone.sh @@ -0,0 +1,39 @@ +#! /bin/bash +set -e + +if [ "$#" -ne 1 ]; then + echo "Must be called with $0 " + exit 1 +fi + +ARCHIVENAME=$1 + +rm -rf staging +mkdir -p staging/$ARCHIVENAME/x86_64 +mkdir -p staging/$ARCHIVENAME/docs +cp saland_standalone_launcher staging/$ARCHIVENAME/saland +cp README.txt staging/$ARCHIVENAME/README +chmod +x staging/$ARCHIVENAME/saland + +cd ../.. + +docker build -f extra/docker/Dockerfile.Ubuntu18.04build_Standalone . -t saland_test + +echo Copying to: $(pwd)/extra/standalone/staging/$ARCHIVENAME + +docker run -it --rm -v $(pwd)/extra/standalone/staging/$ARCHIVENAME/:/output saland_test /bin/bash -c "cp /staging/saland-game/saland /output/x86_64/ && \ +cp /usr/local/lib/libSDL2-2.0.so.0 /output/x86_64/ && \ +cp /usr/local/lib/libphysfs.so.1 /output/x86_64/ && \ +cp /usr/local/lib/libSDL2_mixer-2.0.so.0 /output/x86_64/ && \ +cp /usr/local/lib/libSDL2_ttf-2.0.so.0 /output/x86_64/ && \ +cp /usr/lib/x86_64-linux-gnu/libfreetype.so.6 /output/x86_64/ && \ +cp /usr/lib/x86_64-linux-gnu/libpng16.so /output/x86_64/ && \ +cp /usr/local/lib/libSDL2_image-2.0.so.0 /output/x86_64/" + +docker run -it --rm -v $(pwd)/extra/standalone/staging/$ARCHIVENAME/:/output saland_test /bin/bash -c "\ +cp -r /staging/saland-game/packages /output/ && \ +cp /staging/saland-game/COPYING /output/ && \ +cp /staging/saland-game/README.md /output/docs/README_ORG.md && \ +chown -R 1000 /output" + +exit 0 diff --git a/extra/standalone/compile_requirements.sh b/extra/standalone/compile_requirements.sh new file mode 100755 index 0000000..bc99d70 --- /dev/null +++ b/extra/standalone/compile_requirements.sh @@ -0,0 +1,42 @@ +#! /bin/bash +set -euo pipefail + +#https://github.com/erincatto/box2d/archive/v2.4.1.tar.gz +mkdir -p /staging/deps && cd /staging/deps && curl https://files.poulsander.com/~poul19/public_files/box2d-2.4.1.tar.gz | tar -zx && cd box2d-2.4.1 && ls -lrt +cd /staging/deps/box2d-2.4.1 && cmake . && make && make install + +mkdir -p /staging/deps && cd /staging/deps && curl https://libsdl.org/release/SDL2-2.0.12.tar.gz | tar -zx && cd SDL2-2.0.12 && ls -lrt +cd /staging/deps/SDL2-2.0.12 && ./configure --enable-shared --enable-static && make && make install + +#https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz +mkdir -p /staging/deps && cd /staging/deps && curl https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz | tar -zx && cd SDL2_image-2.0.5 && ls -lrt +cd /staging/deps/SDL2_image-2.0.5 && ./configure --enable-shared --enable-static && make && make install + +#https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4.tar.gz +mkdir -p /staging/deps && cd /staging/deps && curl https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4.tar.gz | tar -zx && cd SDL2_mixer-2.0.4 && ls -lrt +cd /staging/deps/SDL2_mixer-2.0.4 && ./configure --enable-shared --enable-static && make && make install + +#https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz +mkdir -p /staging/deps && cd /staging/deps && curl https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz | tar -zx && cd SDL2_ttf-2.0.15 && ls -lrt +cd /staging/deps/SDL2_ttf-2.0.15 && ./configure --enable-shared --enable-static && make && make install + +#http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-1.0.4.tar.gz +mkdir -p /staging/deps && cd /staging/deps && curl https://files.poulsander.com/~poul19/public_files/SDL2_gfx-1.0.4.tar.gz | tar -zx && cd SDL2_gfx-1.0.4 && ls -lrt +cd /staging/deps/SDL2_gfx-1.0.4 && ./configure --enable-shared --enable-static && make && make install + +mkdir -p /staging/deps && cd /staging/deps && curl https://icculus.org/physfs/downloads/physfs-3.0.2.tar.bz2 | tar -jx && cd physfs-3.0.2 && ls -lrt +cd /staging/deps/physfs-3.0.2 && cmake . && make && make install + +# boost +cd ~ +mkdir -p Downloads +cd Downloads +curl https://files.poulsander.com/~poul19/public_files/boost_1_65_1.tar.bz2 -O +tar xvfj boost_1_65_1.tar.bz2 +pushd boost_1_65_1 +./bootstrap.sh --with-libraries=program_options +./b2 install -j 2 --prefix=/usr link=static +popd + + +mkdir -p /staging/saland-game \ No newline at end of file diff --git a/extra/standalone/saland_standalone_launcher b/extra/standalone/saland_standalone_launcher new file mode 100644 index 0000000..c746488 --- /dev/null +++ b/extra/standalone/saland_standalone_launcher @@ -0,0 +1,13 @@ +#!/bin/bash + +# This file is based on the guide from https://itch.io/docs/itch/integrating/platforms/linux.html + +# Move to script's directory +cd "`dirname "$0"`" + +# Get the kernel/architecture information +ARCH=`uname -m` + +# Set the libpath and pick the proper binary +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./x86_64/ +./x86_64/saland "$@" diff --git a/src/saland.cpp b/src/saland.cpp index b77cfd3..18aa3f9 100644 --- a/src/saland.cpp +++ b/src/saland.cpp @@ -51,6 +51,20 @@ https://github.com/sago007/saland #include "os.hpp" #include "version.h" +//if SHAREDIR is not used we look in current directory +#ifndef SHAREDIR +#define SHAREDIR "." +#endif + +#ifndef LOCALEDIR +#define LOCALEDIR SHAREDIR"/locale" +#endif + +#ifndef PACKAGE +#define PACKAGE "salandgame" +#endif + + GlobalData globalData; class TitleScreen : public sago::GameStateInterface { @@ -265,6 +279,7 @@ void runGame() { int main(int argc, char* argv[]) { PHYSFS_init(argv[0]); + PHYSFS_addToSearchPath((std::string(SHAREDIR)+"/packages/saland-0001.data").c_str(), 1); PHYSFS_addToSearchPath((std::string(PHYSFS_getBaseDir())+"/packages/saland-0001.data").c_str(), 1); PHYSFS_addToSearchPath((std::string(PHYSFS_getBaseDir())+"/data").c_str(), 1); std::string savepath = getPathToSaveFiles();