gentoo/media-libs/glfw/glfw-2.7.7.ebuild

125 lines
2.8 KiB
Bash

# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-libs/glfw/glfw-2.7.7.ebuild,v 1.2 2013/02/04 20:28:40 mr_bones_ Exp $
EAPI=5
inherit eutils multilib toolchain-funcs
DESCRIPTION="The Portable OpenGL FrameWork"
HOMEPAGE="http://glfw.sourceforge.net/"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
LICENSE="ZLIB"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~x86-winnt"
IUSE="examples static-libs"
DEPEND="!x86-winnt? (
x11-libs/libX11
x11-libs/libXrandr
)
virtual/glu
virtual/opengl"
RDEPEND="${DEPEND}"
src_prepare() {
sed -i \
-e "s:\"docs/:\"/usr/share/doc/${PF}/pdf/:" \
readme.html || die
epatch "${FILESDIR}"/${P}-{dyn,pkgconfig}.patch
# find key paths for our CHOST
case ${CHOST} in
*-mingw*)
# TODO: makefile could be set based on CBUILD
libdir="win32"
makefile="Makefile.win32.cross-mgw"
;;
*)
libdir="x11"
makefile="Makefile.x11.in"
esac
# respect ldflags
sed -i \
-e "s/\$(LFLAGS)/\$(LDFLAGS) \$(LFLAGS)/" \
{lib/$libdir,examples}/$makefile || die
# respect cflags in linking command
# build system is messing up CFLAGS variable, so sed is the easy way to go
sed -i \
-e "/^libglfw.so/{n;s/\$(CC)/\$(CC) ${CFLAGS}/;}" \
lib/$libdir/$makefile || die
if use !static-libs ; then
sed -i \
-e '/^all:/s/libglfw.a//' \
lib/$libdir/$makefile || die
fi
}
src_configure() {
[[ ${CHOST} != *-mingw* ]] && sh ./compile.sh
}
src_compile() {
makefile="${makefile%.in}"
local env="AR=$(tc-getAR) CC=$(tc-getCC) PREFIX=/usr LIBDIR=$(get_libdir)"
if [[ ${CHOST} == *-mingw* ]]; then
env="$env TARGET= DLLTOOL=${CHOST}-dlltool"
fi
emake -C lib/$libdir $env -f $makefile all libglfw.pc
use examples && emake -C examples CC=$(tc-getCC) -f $makefile all
}
src_install() {
local dynlib
if [[ ${CHOST} = *-mingw* ]]; then
dynlib="glfw.dll"
else
dynlib="libglfw.so.2.7.7"
fi
use static-libs && dolib.a lib/$libdir/libglfw.a
dolib.so "lib/$libdir/$dynlib"
[[ ${CHOST} != *-mingw* ]] && dosym $dynlib /usr/$(get_libdir)/${dynlib%.$PV}
insinto /usr/$(get_libdir)/pkgconfig
doins lib/$libdir/libglfw.pc
doheader -r include/GL
dohtml -r readme.html
insinto /usr/share/doc/${PF}/pdf
doins docs/*.pdf
dodoc docs/readme.txt
if use examples; then
local f
local MY_EXAMPLES="boing gears listmodes mipmaps
mtbench mthello particles pong3d splitview
triangle wave"
local MY_PICS="mipmaps.tga pong3d_field.tga pong3d_instr.tga
pong3d_menu.tga pong3d_title.tga
pong3d_winner1.tga pong3d_winner2.tga"
docompress -x /usr/share/doc/${PF}/examples
insinto /usr/share/doc/${PF}/examples
doins examples/$makefile
for f in $MY_EXAMPLES; do
doins examples/${f}.c
done
for f in $MY_PICS; do
doins examples/${f}
done
insopts -m0755
for f in $MY_EXAMPLES; do
doins examples/${f}${exesuffix}
done
fi
}