### this file is sourced not run
PKGVER=2025.09.24 # git master pull date

PKGBUILD=1
PKGARCH=x86_64

# source: step
hash=f99e0b1c7a5b094f5a04b14101899d0cb4ece69d
hash7=${hash#???????}; hash7=${hash%"$hash7"}
TARBALL=polybar-$PKGVER-${hash7}.tar.gz
SRC_URL=https://github.com/polybar/polybar/archive/${hash}.tar.gz
MD5SUM=b863ec4372f895babb842e5eaf66d432

hash_XPP=2f9ff5afc28f67f1dc24898e99a2d4ccf443e512
hash7_XPP=${hash_XPP#???????}; hash7_XPP=${hash_XPP%"$hash7_XPP"}
TARBALL_XPP=polybar-xpp-20231022-${hash7_XPP}.tar.gz
SRC_URL_XPP=https://github.com/polybar/xpp/archive/${hash_XPP}.tar.gz
MD5SUM_XPP=64b951ec32c7fceb9529c8e10857fbec

BUNDLE=

SLACKREQ="\
libuv
cairo
libxcb
xcb-proto
xcb-util-image
xcb-util-wm
xcb-util-cursor
xcb-util-xrm
alsa-lib
curl
wireless-tools"
#i3-wm jsoncpp
#libmpdclient
#libpulse

SLACKDESC="polybar: polybar $PKGVER $hash7 (desktop status bar)
polybar:
polybar: A fast and easy-to-use status bar.
polybar: This build does not enable i3-wm, mpd and pulseaudio support.
polybar:
polybar:
polybar:
polybar: https://github.com/polybar/polybar
polybar:
polybar:
polybar:
"
SLACKSUG=''

pkg_download() {
	pkg_check "$SRC_DIR" "$TARBALL"       "$MD5SUM"        "$SRC_URL" &&
	# xpp git module
	pkg_check "$SRC_DIR" "$TARBALL_XPP"   "$MD5SUM_XPP"    "$SRC_URL_XPP"
	# not downloading i3ipcpp git module (we build without i3-wm support)
}
### default pkg_prepare
pkg_prepare() {
	if pkg_download; then
		echo extracting $TARBALL ... &&
		tar -xf $SRC_DIR/$TARBALL -C ./tmp &&

		echo extracting $TARBALL_XPP ... &&
		tar -xf $SRC_DIR/$TARBALL_XPP -C ./tmp/polybar*/lib &&

		(
			cd ./tmp/polybar*/lib &&
			# remove links to git modules
			rm -r i3ipcpp xpp &&
			mv xpp-* xpp
		) &&

		# fix version
		sed -i -e "/execute_process(COMMAND git describe --tags --dirty=-git/s/git.*/echo $VERSION/" tmp/polybar*/include/CMakeLists.txt
	else
		return 1
	fi
}
### default pkg_package
### build
pkg_build() {
	CMAKEFLAGS="$CMAKEFLAGS
	-DPYTHON_EXECUTABLE=/usr/bin/python3
	-DPYTHON_XCBGEN=/usr/lib/python3.11/site-packages
	-DCMAKE_INSTALL_DOCDIR=/usr/share/doc/polyglot-$PKGVER
	-DCMAKE_BUILD_TYPE=Release
	-DBUILD_DOC=OFF
	"
	# We have sphinx but it doesn't work in chroot, and no # other
	# fatdog64 pkgbuild actually uses it as of 2025-12-12. # So we skip
	# building docs with cmake and sphinx, and use pandoc instead.

	export PYTHON=python3
	pkg_build_cmake &&

	(
		cd ../doc/man &&
		for p in *.rst; do
			o=${p%.rst} d=/usr/share/man/man${o##*.}
			pandoc -s -tman $p > $o &&
			install -Dm644 $o $d/$o || exit 1
		done
	) &&

	pkg_build_slackdesc
}

# vim:ft=sh:

