view emulation/retroarch/retroarch.sh @ 1217:27d1a83dc8d6

misc: change shebang to /bin/sh
author David Demelier <markand@malikania.fr>
date Thu, 30 Sep 2021 08:49:59 +0200
parents 6710613b88b9
children 57dc83a39b13
line wrap: on
line source

#!/bin/sh
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

# TODO: add OSS options

PKGNAME=retroarch
PKGVERSION=1.7.7
PKGREVISION=1
PKGLICENSE="GPLv30"
PKGSUMMARY="official frontend for libretro cores"
PKGDOWNLOAD="https://github.com/libretro/RetroArch/releases/download/v$PKGVERSION/RetroArch-$PKGVERSION.tar.xz"
PKGOPTIONS="ALSA
            DBUS
            FFMPEG
            FLAC
            JACK
            KMS
            OPENAL
            OPENGL
            PULSEAUDIO
            QT
            SDL2
            TTF
            UDEV
            USB
            WAYLAND
            X
            ZLIB"
PKGDEPENDS=""
PKGPROTECT="etc/retroarch.cfg"

: ${CHOST:=$(uname -m)-linux-musl}
: ${CBUILD:=$(uname -m)-linux-musl}
: ${CC:=clang}
: ${CFLAGS:=-O2}
: ${CXX:=clang++}
: ${CXXFLAGS:=-O2}
: ${LDFLAGS:=}
: ${ALSA:=yes}
: ${DBUS:=no}
: ${FFMPEG:=yes}
: ${FLAC:=yes}
: ${JACK:=yes}
: ${KMS:=yes}
: ${OPENAL:=yes}
: ${OPENGL:=yes}
: ${PULSEAUDIO:=yes}
: ${QT:=yes}
: ${SDL2:=yes}
: ${TTF:=yes}
: ${UDEV:=yes}
: ${USB:=yes}
: ${WAYLAND:=yes}
: ${X:=yes}
: ${ZLIB:=yes}

if [ "$ALSA" = "yes" ]; then
	PKGDEPENDS="alsa-lib"
	with_alsa="--enable-alsa"
else
	with_alsa="--disable-alsa"
fi

if [ "$DBUS" = "yes" ]; then
	PKGDEPENDS="dbus $PKGDEPENDS"
	with_dbus="--enable-dbus"
else
	with_dbus="--disable-dbus"
fi

if [ "$FFMPEG" = "yes" ]; then
	PKGDEPENDS="ffmpeg $PKGDEPENDS"
	with_ffmpeg="--enable-ffmpeg"
else
	with_ffmpeg="--disable-ffmpeg"
fi

if [ "$FLAC" = "yes" ]; then
	PKGDEPENDS="flac $PKGDEPENDS"
	with_flac="--enable-flac"
else
	with_flac="--disable-flac"
fi

if [ "$JACK" = "yes" ]; then
	PKGDEPENDS="jack2 $PKGDEPENDS"
	with_jack="--enable-jack"
else
	with_jack="--disable-jack"
fi

if [ "$KMS" = "yes" ]; then
	PKGDEPENDS="mesa libdrm $PKGDEPENDS"
	with_kms="--enable-kms"
else
	with_kms="--disable-kms"
fi

if [ "$OPENAL" = "yes" ]; then
	PKGDEPENDS="openal-soft $PKGDEPENDS"
	with_openal="--enable-al"
else
	with_openal="--disable-al"
fi

if [ "$OPENGL" = "yes" ]; then
	if [ "$KMS" != "yes" ]; then
		PKGDEPENDS="mesa $PKGDEPENDS"
	fi

	with_opengl="--enable-opengl"
else
	with_opengl="--disable-opengl"
fi

if [ "$PULSEAUDIO" = "yes" ]; then
	PKGDEPENDS="pulseaudio $PKGDEPENDS"
	with_pulseaudio="--enable-pulse"
else
	with_pulseaudio="--disable-pulse"
fi

if [ "$QT" = "yes" ];then
	PKGDEPENDS="qtbase $PKGDEPENDS"
	with_qt="--enable-qt"
else
	with_qt="--disable-qt"
fi

if [ "$SDL2" = "yes" ]; then
	PKGDEPENDS="sdl2 $PKGDEPENDS"
	with_sdl2="--enable-sdl2"
else
	with_sdl2="--disable-sdl2"
fi

if [ "$TTF" = "yes" ]; then
	PKGDEPENDS="freetype $PKGDEPENDS"
	with_ttf="--enable-freetype"
else
	with_ttf="--disable-freetype"
fi

if [ "$UDEV" = "yes" ]; then
	PKGDEPENDS="eudev $PKGDEPENDS"
	with_udev="--enable-udev"
else
	with_udev="--disable-udev"
fi

if [ "$USB" = "yes" ]; then
	PKGDEPENDS="libusb $PKGDEPENDS"
	with_usb="--enable-libusb"
else
	with_usb="--disable-libusb"
fi

if [ "$WAYLAND" = "yes" ]; then
	PKGDEPENDS="wayland wayland-protocols $PKGDEPENDS"
	with_wayland="--enable-wayland"
else
	with_wayland="--disable-wayland"
fi

if [ "$X" = "yes" ]; then
	PKGDEPENDS="libxcb
	            libxext
	            libxinerama
	            libxrandr
	            libxshmfence
	            libxxf86vm $PKGDEPENDS"
	with_x="--enable-x11 --enable-xinerama --enable-xrandr"
else
	with_x="--disable-x11 --disable-xinerama --disable-xrandr"
fi

if [ "$ZLIB" = "yes" ]; then
	PKGDEPENDS="zlib $PKGDEPENDS"
	with_zlib="--enable-zlib"
else
	with_zlib="--disable-zlib"
fi

rm -rf RetroArch-$PKGVERSION
tar xvf RetroArch-$PKGVERSION.tar.xz
cd RetroArch-$PKGVERSION

# Disable core updater because they are not binary compatible and
# shipped with Vanilla Linux.
sed -i -e "s|# menu_show_core_updater.*|menu_show_core_updater = false|" retroarch.cfg

# Adapt core and their info directories respectively.
sed -i \
	-e "s|# libretro_directory.*|libretro_directory = /lib/libretro|" \
	-e "s|# libretro_info_path.*|libretro_info_path = /share/libretro/info|" retroarch.cfg

# Adapt assets directory.
sed -i -e "s|# assets_directory.*|assets_directory = /share/retroarch/assets|" retroarch.cfg

# --prefix=/.: does not accept an empty prefix.
CC="$CC" \
CFLAGS="$CFLAGS" \
LDFLAGS="$LDFLAGS" \
PKG_CONF_PATH=/bin/pkgconf \
./configure \
	--build=$CBUILD \
	--host=$CHOST \
	--prefix=/. \
	--disable-sdl \
	--disable-systemd \
	$with_alsa \
	$with_dbus \
	$with_ffmpeg \
	$with_jack \
	$with_kms \
	$with_openal \
	$with_opengl \
	$with_pulseaudio \
	$with_qt \
	$with_sdl2 \
	$with_ttf \
	$with_udev \
	$with_usb \
	$with_wayland \
	$with_x \
	$with_zlib
make CC="$CC" CXX="$CXX"
make install DESTDIR=$DESTDIR

cd ..
rm -rf RetroArch-$PKGVERSION