#!/bin/bash

cd /tmp || error "Could not move to tmp folder"

install_packages libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev automake build-essential || exit 1
rm -rf /tmp/pacman

# use theofficialgman fork with pacman renamed as pacman_sdl (many code changes) to prevent conflicts with programs that look for 'pacman' as an indicator of an Arch/Manjaro system
git_clone https://github.com/theofficialgman/pacman.git || exit 1
cd pacman || error "Could not move to directory"
./autogen.sh || error "Autogen failed"
./configure || error "configure failed"
make -j$(nproc) || error "Could not build source"
sudo make install || error "Could not install pacman"

rm -rf /tmp/pacman

sudo wget -qO /usr/local/share/pacman_sdl/txt/gamecontrollerdb.txt  https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

status_green 'Installation is now done! To run: Menu -> Games -> Pacman (SDL)'


