### this file is sourced not run
PKGVER=1.3.6
PKGBUILD=2 # this is the new one with "sessiondir" support instead of "sessions"
PKGARCH=x86_64

# source: james
TARBALL=slim-$PKGVER.tar.gz
MD5SUM=d40d256394f9ef34cef34d2aa9cb52e6
SRC_URL=http://downloads.sourceforge.net/slim.berlios/$TARBALL
BUNDLE=

SLACKREQ='libX11 libpng libjpeg-turbo freetype2'
SLACKDESC="slim: slim $PKGVER (Graphical login manager)  
slim:  
slim: SLiM is a Desktop-independent graphical login manager for X11. It aims 
slim: to be light and simple, although completely configurable through themes 
slim: and an option file; is suitable for machines on which remote login 
slim: functionalities are not needed.  
slim: 
slim: Note: this one is a new build that uses 'sessiondir'. 
slim: If you need the old one that uses 'sessions', use earlier version.
slim: 
slim: 
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/slim* &&

	# fixes and enhancements
	patch -Np1 -i ../pkg/patches/slim-1.3.6-slimlock.patch &&
	##patch -Rp1 -i ../pkg/patches/slim-1.3.6-sessiondir.patch && # undo this patch
	patch -Np1 -i ../pkg/patches/slim-fix-env-alloc.patch &&
	patch -Np1 -i ../pkg/patches/add-xserver-setup.patch &&
	patch -Np1 -i ../pkg/patches/sorted-sessiondir.patch &&
	patch -Np1 -i ../pkg/patches/dont-reset-session.patch &&

	# gcc 12 FTBFS
	sed -i -e '/WinGC < 0/ s/WinGC/(long)&/' panel.cpp &&

	# Fatdog's custom build
	sed -i -e 's|"halt"|"poweroff"|' const.h &&
	
	# set libdir to lib64 and disable systemd stuff
	sed -i -e 's|"/lib"|"/lib64"|'  \
		-e 's|"Linux"|"NoSystemd"|' \
		CMakeLists.txt &&
	true
}

### default package

### build
pkg_build() {
	cd /tmp/slim*

	CMAKEFLAGS="$CMAKEFLAGS -DBUILD_SHARED_LIBS=0" &&
	pkg_build_cmake &&
	pkg_build_slackdesc &&
	rm -f /usr/$LIBDIR/libslim.a &&

	# Fatdog config
	install -m644 /tmp/pkg/slim.conf /etc/slim.conf &&
	cp -r /tmp/pkg/theme /usr/share/slim/themes/fatdog &&
		
	# install pdf docs in case people don't use devx
	install -m644 /tmp/pkg/slim.1.pdf /usr/share/doc
}
