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

# source: james
TARBALL=eduke32_src_20220726-10118-9ae924b98.tar.xz
MD5SUM=244936f261ebbe0b72ab349265e49329
#SRC_URL=http://distro.ibiblio.org/fatdog/source/800/$TARBALL
SRC_URL=https://dukeworld.com/eduke32/synthesis/20220726-10118-9ae924b98/$TARBALL
BUNDLE=

SLACKREQ='libSDL libSDL-mixer libvorbis libflac libpng libvpx' # 
SLACKDESC="eduke32: eduke32 $PKGVER (DukeNukem 3D source port)
eduke32: 
eduke32: Duke Nukem 3D source port. Game data not included.
eduke32: Get DUKE3D.GRP from legal sources, put it in 
eduke32: /usr/share/games/eduke32
eduke32: 
eduke32: http://eduke32.com/
eduke32: 
eduke32: 
eduke32: 
eduke32: 
"

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	cd /tmp/eduke32*
	
	# this patch is for 2015.07 version
	#sed -i -e '718 a\
	#gdk-pixbuf-csource --extern --struct --raw --name=startbanner_pixdata $^ | sed "s/load_inc//" >> $@' \
	#	Makefile &&
	
	# Fix compilation (2022.07)
	# https://forums.duke4.net/topic/12083-ubuntu-compilation-error-%e2%80%98107000005e0f-102400005e0f%e2%80%99-is-not-a-constant-expression/
	sed -i 's/-frounding-math//' Common.mak &&
	
	# Fix mapster32 lauching eduke32 - instead of "./eduke32" just use "eduke32", since it's in the PATH
	sed -i 's|DEFAULT_GAME_LOCAL_EXEC "./" APPBASENAME|DEFAULT_GAME_LOCAL_EXEC APPBASENAME|' source/duke3d/src/astub.cpp &&
	
	make SDL_TARGET=1 &&

	install -m755 eduke32 mapster32 /usr/bin &&
	# help and samples for mapster32
	mkdir -p /usr/share/games/eduke32/samples &&
	install -m644 package/sdk/{*.hlp,*.HLP,names.h,tiles.cfg} /usr/share/games/eduke32 &&
	install -m644 package/sdk/samples/* /usr/share/games/eduke32/samples &&
	# dekstop file and icon from AUR (https://aur.archlinux.org/packages/eduke32)
	install -m644 /tmp/pkg/eduke32.desktop /usr/share/applications &&
	install -m644 /tmp/pkg/eduke32.png /usr/share/pixmaps &&
	pkg_build_slackdesc
}
