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

# source: james
TARBALL=dosbox-x-v0.83.0.tar.gz
MD5SUM=9643b18550f15283ab4679222ec251c4
SRC_URL=https://github.com/joncampbell123/dosbox-x/archive/$TARBALL
BUNDLE=

SLACKREQ='libpng' # internal libSDL and libSDL-net
SLACKDESC="dosbox-x: dosbox-x $PKGVER (DOS emulator)
dosbox-x: 
dosbox-x: Dosbox-X is a Jon Campbell fork of Dosbox with focus on accurate 
dosbox-x: emulation and retro-development. It features fine-grained control 
dosbox-x: over the emulated machine and in-emulator menu support. This is a 
dosbox-x: minimal build-debug build, there is no menu item or documentation. 
dosbox-x: Start is from terminal as dosbox-x.
dosbox-x: 
dosbox-x: 
dosbox-x: https://github.com/joncampbell123/dosbox-x/
dosbox-x: 
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/dosbox-x* &&
	patch -Np1 -i ../pkg/enable-printer-emulation.patch
}

### default pkg_package
### build
pkg_build() {
	unset CFLAGS CXXFLAGS # build with default CFLAGS, not -Os
	LDFLAGS="$LDFLAGS -Wl,--as-needed"
	CONFFLAGS="$CONFFLAGS --enable-core-inline --enable-avcodec"
	
	cd /tmp/dosbox-x* &&
	sed -i -e 's|F11|F12|g' src/shell/shell.cpp && # default host key in Linux is F12
	# use build-debug instaed	
	#./autogen.sh &&
	#pkg_build_autoconf &&
	./build-debug &&
	make install &&
	
	pkg_build_slackdesc &&

	# desktop
	mkdir -p /usr/share/applications /usr/share/pixmaps &&
	install -m644 src/dosbox.png /usr/share/icons/dosbox-x-48.png &&
	install -m644 /tmp/pkg/dosbox-x.desktop /usr/share/applications &&
	
	# docs
	install -m644 README.* /usr/share/dosbox-x &&

	# fonts
	cp -a /tmp/pkg/FONTS /usr/share/dosbox-x &&
	cat > /usr/share/dosbox-x/printing.txt << "EOF" &&
https://sourceforge.net/p/dosbox/patches/43/
https://www.vogons.org/viewtopic.php?p=32371#32371

The printer emulates a black/white 48-dot matrix printer
supporting ESC/P and ESC/P2.

ESC/P(2) were the quasi-standards for matrix printers,
so the printer is able to emulate most 24/48-dot printers
from EPSON and other manufacturers.

If you enable printer emulation, copy the FONTS directory
to $HOME/.dosbox
EOF
	true
}
