# openbox - A highly configurable stacking window manager
# Generated from manifest.tsv by gen-ports.py. Edit the manifest, not this file,
# unless the package needs something the template cannot express - in which case
# drop a `recipe.local` beside it and it will be preserved.
name=openbox
version=3.6.1
release=2
desc="A highly configurable stacking window manager"
url="http://openbox.org/"
license="GPL-2.0-or-later"
depend="glibc libx11 libxml2 pango glib libxrandr libxinerama libxcursor imlib2 startup-notification"
makedepend=""
source="http://openbox.org/dist/openbox/openbox-3.6.1.tar.gz"
sha256="SKIP"

build() {
	cd "openbox-3.6.1"
	# Some release tarballs are raw git-tag archives with no generated
	# ./configure at all (only configure.ac/Makefile.am) - a proper "make
	# dist" tarball ships one, a GitHub/GitLab auto-generated source
	# archive does not. Bootstrap it ourselves when that happens.
	[ -x ./configure ] || autoreconf -fi
	# Not every configure script accepts the same options - sqlite rejects
	# --disable-nls outright, for instance - so only pass the ones this one
	# actually advertises. Guessing wrong fails the whole build.
	_opts="--prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --disable-librsvg"
	_help=$(./configure --help 2>/dev/null)
	case "$_help" in *--disable-static*)  _opts="$_opts --disable-static" ;; esac
	case "$_help" in *--disable-nls*)     _opts="$_opts --disable-nls" ;; esac
	# bmake is not GNU make - automake's dependency-tracking .deps
	# fragments need nested variable expansion bmake doesn't have.
	case "$_help" in *--disable-dependency-tracking*) _opts="$_opts --disable-dependency-tracking" ;; esac
	# shellcheck disable=SC2086
	./configure $_opts
	gmake -j"$JOBS"
}

package() {
	cd "openbox-3.6.1"
	# -j1: scraps-build exports MAKEFLAGS=-j$JOBS globally, so this inherits
	# real parallelism even with no -j of its own. Fine for the build, but
	# openbox's own install-sh -d (used throughout `make install` for every
	# shared parent directory - /usr/share, /usr/share/themes, /etc/xdg/
	# openbox, ...) is a plain `mkdir` with no -p and no tolerance for
	# losing a race to another install-sh instance creating the same
	# directory - "mkdir: 'X': File exists" and a hard install failure,
	# non-deterministically depending on scheduling. Installing files has
	# nothing to gain from parallelism anyway.
	gmake -j1 DESTDIR="$pkgdir" install
}
