#Packager: Dimitris Tzemos <dijemos~at~gmail~dot~com>
# REQUIRES="mpv"

pkgname=minitube
pkgver=4.0
pkgrel=1dj
source=("https://github.com/flaviotordini/minitube/releases/download/$pkgver/minitube-$pkgver.tar.bz2" "fix_mpvwidget.patch" 
"add-opengl-in-pro-file.patch" "fix-actionbutton.patch")
docs=("AUTHORS" "CHANGES" "COPYING" "TODO")
url=https://flavio.tordini.org/minitube

doinst() {
if [ -x /usr/bin/update-desktop-database ]; then
  /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1
fi

if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
  if [ -x /usr/bin/gtk-update-icon-cache ]; then
    /usr/bin/gtk-update-icon-cache -f usr/share/icons/hicolor >/dev/null 2>&1
  fi
fi
}

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"minitube (YouTube desktop client)"
"Minitube is a YouTube desktop client. With it you can watch"
"YouTube videos in a new way: you type a keyword, Minitube"
"gives you an endless video stream. Minitube does not require"
"the Flash Player.  Minitube is not about cloning the original"
"YouTube web interface, it aims to create a new TV-like"
"experience."
""
"https://flavio.tordini.org/minitube"
)


build() {
	cd $startdir/src/$pkgname-$pkgver
	
	# 20220320 bkw: we need -fPIC even for 32-bit.
	if [ "$ARCH" = "i586" ]; then
		SLKCFLAGS="-O2 -march=i586 -mtune=i686 -fPIC"
	elif [ "$ARCH" = "i686" ]; then
		SLKCFLAGS="-O2 -march=i686 -mtune=i686 -fPIC"
	elif [ "$ARCH" = "x86_64" ]; then
		SLKCFLAGS="-O2 -fPIC"
	else
		SLKCFLAGS="-O2"
	fi
	
	 patch -p1 < $startdir/src/fix_mpvwidget.patch || return 1
	 patch -p1 < $startdir/src/add-opengl-in-pro-file.patch || return 1
	 patch -p1 < $startdir/src/fix-actionbutton.patch || return 1
	
	qmake-qt5 || return 1
	
	# Use our SLKCFLAGS plus the hardcoded ones from the Makefile
	make \
		CFLAGS="$SLKCFLAGS -pipe -Wall -W -D_REENTRANT \$(DEFINES)" \
		CXXFLAGS="$SLKCFLAGS -pipe -Wall -W -D_REENTRANT \$(DEFINES)" || return 1

	make install INSTALL_ROOT=$startdir/pkg || return 1
} 
