### this file is sourced not run
PKGVER=3.2.4.2020.01
PKGBUILD=1
PKGARCH=x86_64

# source: james
TARBALL=cdemu-$PKGVER-3f6cf51.tar.gz
MD5SUM=d2b16c0e36ff53236cdd2d9e9ee4b3eb
SRC_URL=https://github.com/cdemu/cdemu/archive/3f6cf51950b3f208c0880e1881c2febbd2495507.tar.gz
BUNDLE=

SLACKREQ='libao'
SLACKDESC="cdemu: cdemu $PKGVER (CD Emulator)
cdemu: 
cdemu: CDemu is a software suite designed to emulate an optical drive and 
cdemu: disc (including CD-ROMs and DVD-ROMs) on the Linux operating system. 
cdemu: Sort-of daemontools for Linux.
cdemu:
cdemu: https://cdemu.sourceforge.io/about/
cdemu:
cdemu: This package only contains the CLI programs. To make it work you need
cdemu: the vhba kernel module, which you have to build yourself.
cdemu: Module source: https://github.com/cdemu/cdemu/tree/master/vhba-module
"

# Note: mime-database useful only for gui, we don't ship gcdemu so no need to update
#SLACKINSTALL='update-mime-database ./usr/share/mime'

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/cdemu* &&

	# buid libmirage
	# disable update mime to make build runs faster
	rm -f /usr/bin/update-mime-database &&
	ln -s /bin/true /usr/bin/update-mime-database &&
	
	cd libmirage &&
	mkdir build && cd build &&
	cmake .. -DCMAKE_INSTALL_PREFIX=/usr &&
	make $MAKEFLAGS && make install &&
	cd ../.. &&
	
	# build cdemu-client &&
	cd cdemu-client
	mkdir build && cd build &&
	cmake .. -DCMAKE_INSTALL_PREFIX=/usr &&
	make $MAKEFLAGS && make install &&
	cd ../.. &&
	# use python2. With python3 it requires extra 'gi' module ...
	sed -i -e '1 s/python3/python/' /usr/bin/cdemu &&

	# build cdemu-daemon &&
	cd cdemu-daemon &&
	mkdir build && cd build &&
	cmake .. -DCMAKE_INSTALL_PREFIX=/usr &&
	make $MAKEFLAGS && make install &&
	cd ../.. &&

	# build gtk3 cdemu-client &&
	# don't build it, it depends on stuff we don't ship
	#cd gcdemu &&
	#mkdir build && cd build &&
	#cmake .. -DCMAKE_INSTALL_PREFIX=/usr &&
	#make $MAKEFLAGS && make install &&
	#cd ../.. &&
	
	# build gtk3 image-analyzer &&
	# don't build it, it depends on stuff we don't ship
	#cd image-analyzer &&
	#mkdir build && cd build &&
	#cmake .. -DCMAKE_INSTALL_PREFIX=/usr &&
	#make $MAKEFLAGS && make install &&
	#cd ../.. &&

	# cleanup
	rm -f /usr/bin/update-mime-database &&
	pkg_build_slackdesc
}


