summaryrefslogtreecommitdiff
blob: 33327d8f412e868da109df1744c0c674b15302c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-libs/gd/gd-1.8.4-r2.ebuild,v 1.1 2004/06/30 15:51:26 vapier Exp $

inherit eutils gcc

DESCRIPTION="A graphics library for fast image creation"
HOMEPAGE="http://www.boutell.com/gd/"
SRC_URI="http://www.boutell.com/gd/http/${P}.tar.gz"

LICENSE="as-is | BSD"
SLOT="0"
KEYWORDS="x86 ppc sparc hppa amd64 alpha ia64"
IUSE="X truetype freetype-version-1 jpeg"

DEPEND="media-libs/libpng
	jpeg? ( media-libs/jpeg )
	X? ( virtual/x11 )
	freetype-version-1? ( =media-libs/freetype-1* )
	!freetype-version-1?  (
		truetype? ( =media-libs/freetype-2* )
	)"

src_unpack() {
	unpack ${A}
	cd ${S}

	local compopts
	local libsopts
	local incopts

	use alpha \
		&& [ "$(gcc-getCC)" == "ccc" ] \
		&& epatch ${FILESDIR}/${PV}-dec-alpha-compiler.diff

	use X \
		&& compopts="${compopts} -DHAVE_XPM" \
		&& libsopts="${libsopts} -lXpm -lX11"
	use jpeg \
		&& compopts="${compopts} -DHAVE_LIBJPEG" \
		&& libsopts="${libsopts} -ljpeg" \
		|| epatch ${FILESDIR}/${PV}-jpeg-inc.patch

	compopts="${compopts} -DHAVE_LIBPNG"
	libsopts="${libsopts} -lpng"

	if use freetype-version-1 ; then
		compopts="${compopts} -DHAVE_LIBTTF"
		libsopts="${libsopts} -lttf"
		incopts="-I/usr/include/freetype"
	elif use truetype ; then
		compopts="${compopts} -DHAVE_LIBFREETYPE"
		libsopts="${libsopts} -lfreetype"
		incopts="-I/usr/include/freetype2"
	fi

	sed -i \
		-e "s:^\(CFLAGS\)=.*:\1=${CFLAGS} ${compopts} :" \
		-e "s:^\(LIBS\)=.*:\1=-lm -lgd -lz ${libsopts}:" \
		-e "s:^\(INCLUDEDIRS\)=:\1=${incopts} :" \
		-e "s:\(COMPILER=\)gcc:\1${CC:-gcc}:" \
		Makefile || die
}

src_compile() {
	emake || die
}

src_install() {
	dodir /usr/{bin,lib,include/gd-1}
	make \
		INSTALL_LIB=${D}/usr/lib \
		INSTALL_BIN=${D}/usr/bin \
		INSTALL_INCLUDE=${D}/usr/include/gd-1 \
		install || die
	preplib /usr

	dodoc readme.txt
	dohtml -r ./

	# now make it slotable
	mv ${D}/usr/lib/libgd{,1}.a
	if `has_version =media-libs/gd-2*` ; then
		rm -rf ${D}/usr/bin
	else
		dosym libgd1.a /usr/lib/libgd.a
		cd ${D}/usr/include/gd-1/
		for f in * ; do
			dosym gd-1/${f} /usr/include/${f}
		done
	fi
}