### this file is sourced not run

# adapted from https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=xwit

PKGNAME=xwit
PKGVER=3.4 # rev 15 from Debian
PKGBUILD=1
PKGARCH=x86_64

TARBALL=${PKGNAME}_${PKGVER}.orig.tar.gz
MD5SUM='bac527aab86715fcd76f44d9cf970ade'
SRC_URL=http://ftp.de.debian.org/debian/pool/main/x/$PKGNAME/$TARBALL
BUNDLE=

# http://software.jaos.org/git/slapt-get/plain/FAQ.html#slgFAQ19
SLACKREQ='libX11'
# http://software.jaos.org/git/slapt-get/plain/FAQ.html#slgFAQ44
SLACKSUG=
# http://software.jaos.org/git/slapt-get/plain/FAQ.html#slgFAQ31
SLACKCON=

SLACKDESC="$PKGNAME: xwit $PKGVER (command line X11 tool)
$PKGNAME:  
$PKGNAME: Xwit will resize, iconify, pop, and move windows, without involving
$PKGNAME: a window manager. Also change an icon, title or name, set the screen
$PKGNAME: saver going, change key autorepeat settings, move the mouse cursor, etc.
$PKGNAME: 
$PKGNAME: License: other
$PKGNAME: 
$PKGNAME: 
$PKGNAME: http://packages.debian.org/stable/x11/xwit
$PKGNAME: 
"

pkg_prepare() {
	# get original sources
	pkg_prepare_default || return 1

	# get Debian patches
	tarball="${PKGNAME}_${PKGVER}-15.debian.tar.gz"
	src_url="http://ftp.de.debian.org/debian/pool/main/x/${PKGNAME}/${tarball}"
	md5sum='c52c9626fb87f8f6e375c429cbdafcc7'
	TARBALL=$tarball SRC_URL=$src_url MD5SUM=$md5sum pkg_prepare_default
}

### default pkg_package
### build
pkg_build() {
	cd /tmp/${PKGNAME}-${PKGVER}.orig &&
	while read p; do
		patch -p1 < "../debian/patches/$p" || return 1
	done < ../debian/patches/series

	echo Compiling... &&
	gcc -Wall -O2 -g -Wstrict-prototypes -Wmissing-prototypes -c -o xwit.o xwit.c &&
	gcc -Wall -O2 -g -Wstrict-prototypes -Wmissing-prototypes -c -o ClientWin.o ClientWin.c &&
	gcc -Wall -O2 -g -Wstrict-prototypes -Wmissing-prototypes -c -o dsimple.o dsimple.c &&
	gcc -Wall -O2 -g -Wstrict-prototypes -Wmissing-prototypes -Wl,-z,defs -lX11 -o xwit xwit.o ClientWin.o dsimple.o &&

	echo Installing... &&
	install -D -m644 xwit.man /usr/share/man/man1/xwit.1 &&
	install -D -m755 xwit /usr/bin/xwit &&

	echo Packaging... &&
	pkg_build_slackdesc
}

