|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Install script for Simple Game Engine dependencies on Linux |
| 4 | +# This script installs all required dependencies for building the Simple Game Engine |
| 5 | + |
| 6 | +set -e # Exit on any error |
| 7 | + |
| 8 | +echo "Installing Simple Game Engine dependencies for Linux..." |
| 9 | + |
| 10 | +# Detect the Linux distribution |
| 11 | +if [ -f /etc/os-release ]; then |
| 12 | + . /etc/os-release |
| 13 | + OS=$NAME |
| 14 | + VER=$VERSION_ID |
| 15 | +elif type lsb_release >/dev/null 2>&1; then |
| 16 | + OS=$(lsb_release -si) |
| 17 | + VER=$(lsb_release -sr) |
| 18 | +elif [ -f /etc/lsb-release ]; then |
| 19 | + . /etc/lsb-release |
| 20 | + OS=$DISTRIB_ID |
| 21 | + VER=$DISTRIB_RELEASE |
| 22 | +elif [ -f /etc/debian_version ]; then |
| 23 | + OS=Debian |
| 24 | + VER=$(cat /etc/debian_version) |
| 25 | +else |
| 26 | + OS=$(uname -s) |
| 27 | + VER=$(uname -r) |
| 28 | +fi |
| 29 | + |
| 30 | +echo "Detected OS: $OS $VER" |
| 31 | + |
| 32 | +# Function to install dependencies on Ubuntu/Debian |
| 33 | +install_ubuntu_debian() { |
| 34 | + echo "Installing dependencies for Ubuntu/Debian..." |
| 35 | + |
| 36 | + # Update package list |
| 37 | + sudo apt update |
| 38 | + |
| 39 | + # Install build essentials |
| 40 | + sudo apt install -y build-essential cmake git |
| 41 | + |
| 42 | + # Install Vulkan SDK |
| 43 | + echo "Installing Vulkan SDK..." |
| 44 | + wget -qO - https://packages.lunarg.com/lunarg-signing-key-pub.asc | sudo apt-key add - |
| 45 | + sudo wget -qO /etc/apt/sources.list.d/lunarg-vulkan-focal.list https://packages.lunarg.com/vulkan/lunarg-vulkan-focal.list |
| 46 | + sudo apt update |
| 47 | + sudo apt install -y vulkan-sdk |
| 48 | + |
| 49 | + # Install other dependencies |
| 50 | + sudo apt install -y \ |
| 51 | + libglfw3-dev \ |
| 52 | + libglm-dev \ |
| 53 | + libopenal-dev \ |
| 54 | + libktx-dev \ |
| 55 | + libstb-dev |
| 56 | + |
| 57 | + # Install Slang compiler (for shader compilation) |
| 58 | + echo "Installing Slang compiler..." |
| 59 | + if [ ! -f /usr/local/bin/slangc ]; then |
| 60 | + SLANG_VERSION="2024.1.21" |
| 61 | + wget "https://github.com/shader-slang/slang/releases/download/v${SLANG_VERSION}/slang-${SLANG_VERSION}-linux-x86_64.tar.gz" |
| 62 | + tar -xzf "slang-${SLANG_VERSION}-linux-x86_64.tar.gz" |
| 63 | + sudo cp slang/bin/slangc /usr/local/bin/ |
| 64 | + sudo chmod +x /usr/local/bin/slangc |
| 65 | + rm -rf slang "slang-${SLANG_VERSION}-linux-x86_64.tar.gz" |
| 66 | + fi |
| 67 | +} |
| 68 | + |
| 69 | +# Function to install dependencies on Fedora/RHEL/CentOS |
| 70 | +install_fedora_rhel() { |
| 71 | + echo "Installing dependencies for Fedora/RHEL/CentOS..." |
| 72 | + |
| 73 | + # Install build essentials |
| 74 | + sudo dnf install -y gcc gcc-c++ cmake git |
| 75 | + |
| 76 | + # Install Vulkan SDK |
| 77 | + echo "Installing Vulkan SDK..." |
| 78 | + sudo dnf install -y vulkan-devel vulkan-tools |
| 79 | + |
| 80 | + # Install other dependencies |
| 81 | + sudo dnf install -y \ |
| 82 | + glfw-devel \ |
| 83 | + glm-devel \ |
| 84 | + openal-soft-devel |
| 85 | + |
| 86 | + # Note: Some packages might need to be built from source on RHEL/CentOS |
| 87 | + echo "Note: Some dependencies (libktx, libstb, tinygltf) may need to be built from source" |
| 88 | + echo "Please refer to the project documentation for manual installation instructions" |
| 89 | +} |
| 90 | + |
| 91 | +# Function to install dependencies on Arch Linux |
| 92 | +install_arch() { |
| 93 | + echo "Installing dependencies for Arch Linux..." |
| 94 | + |
| 95 | + # Update package database |
| 96 | + sudo pacman -Sy |
| 97 | + |
| 98 | + # Install build essentials |
| 99 | + sudo pacman -S --noconfirm base-devel cmake git |
| 100 | + |
| 101 | + # Install dependencies |
| 102 | + sudo pacman -S --noconfirm \ |
| 103 | + vulkan-devel \ |
| 104 | + glfw-wayland \ |
| 105 | + glm \ |
| 106 | + openal |
| 107 | + |
| 108 | + # Install AUR packages (requires yay or another AUR helper) |
| 109 | + if command -v yay &> /dev/null; then |
| 110 | + yay -S --noconfirm libktx stb |
| 111 | + else |
| 112 | + echo "Note: Please install yay or another AUR helper to install libktx and stb packages" |
| 113 | + echo "Alternatively, build these dependencies from source" |
| 114 | + fi |
| 115 | +} |
| 116 | + |
| 117 | +# Install dependencies based on detected OS |
| 118 | +case "$OS" in |
| 119 | + "Ubuntu"* | "Debian"* | "Linux Mint"*) |
| 120 | + install_ubuntu_debian |
| 121 | + ;; |
| 122 | + "Fedora"* | "Red Hat"* | "CentOS"* | "Rocky"*) |
| 123 | + install_fedora_rhel |
| 124 | + ;; |
| 125 | + "Arch"* | "Manjaro"*) |
| 126 | + install_arch |
| 127 | + ;; |
| 128 | + *) |
| 129 | + echo "Unsupported Linux distribution: $OS" |
| 130 | + echo "Please install the following dependencies manually:" |
| 131 | + echo "- CMake (3.29 or later)" |
| 132 | + echo "- Vulkan SDK" |
| 133 | + echo "- GLFW3 development libraries" |
| 134 | + echo "- GLM (OpenGL Mathematics) library" |
| 135 | + echo "- OpenAL development libraries" |
| 136 | + echo "- KTX library" |
| 137 | + echo "- STB library" |
| 138 | + echo "- tinygltf library" |
| 139 | + echo "- Slang compiler" |
| 140 | + exit 1 |
| 141 | + ;; |
| 142 | +esac |
| 143 | + |
| 144 | +echo "" |
| 145 | +echo "Dependencies installation completed!" |
| 146 | +echo "" |
| 147 | +echo "To build the Simple Game Engine:" |
| 148 | +echo "1. cd to the simple_engine directory" |
| 149 | +echo "2. mkdir build && cd build" |
| 150 | +echo "3. cmake .." |
| 151 | +echo "4. make -j$(nproc)" |
| 152 | +echo "" |
| 153 | +echo "Or use the provided CMake build command:" |
| 154 | +echo "cmake --build cmake-build-debug --target SimpleEngine -j 10" |
0 commit comments