# SliTaz package receipt.

PACKAGE="freeglut"
VERSION="3.2.2"
CATEGORY="x-window"
SHORT_DESC="OpenGL utility toolkit."
MAINTAINER="b1+slitaz@nagel.org"
LICENSE="GPL"
WEB_SITE="https://web.archive.org/web/20220516194849/https://sourceforge.net/projects/freeglut/"

TARBALL="$PACKAGE-$VERSION.tar.gz"
WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL"

SUGGESTED="nvidia"
DEPENDS="glibc-base libdrm mesa libglu-mesa
	xorg-libX11 xorg-libXau xorg-libXdamage xorg-libXdmcp
	xorg-libXext xorg-libXfixes xorg-libXi xorg-libXxf86vm"
BUILD_DEPENDS="cmake libglu-mesa libglu-mesa-dev libxcb-dev mesa mesa-dev 
	xorg-inputproto xorg-libX11-dev xorg-libXau-dev xorg-libXdamage-dev 
	xorg-libXdmcp-dev xorg-libXext-dev xorg-libXfixes-dev xorg-libXi-dev 
	xorg-libXxf86vm-dev xorg-xproto"

# What is the latest version available today?
current_version()
{
	wget -O - https://sourceforge.net/projects/freeglut/files/freeglut/ 2>/dev/null | \
	sed '/scope="row/!d;s|.*href="|"https://sourceforge.net|;q' | xargs wget -O - 2>/dev/null | \
	sed '/scope="row/!d;s|.*/freeglut/||;s|/.*||;q'
}

# Rules to configure and make the package.
compile_rules()
{
	# Binutils 2.22 break many packages build without LDFLAGS set correctly.
	export LDFLAGS="$LDFLAGS -Wl,--copy-dt-needed-entries"
	
	# fixes an issue with the radeon[hd] ATI opensource drivers
	# ref: http://bugs.gentoo.org/show_bug.cgi?id=295163
#	patch -p0 -i $stuff/2.6.0-GFX_radeon.patch
#	sed -i 's/-Werror//' configure

	mkdir	_build &&
	cd	_build &&
	cmake	..				\
		-D CMAKE_INSTALL_PREFIX=/usr &&
#	sed -i '/XF86VMODE/d' config.status
	make &&
	make install DESTDIR=$DESTDIR
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	cook_copy_files	*.so*
}