summaryrefslogtreecommitdiff
blob: a2fe48cdaa0efc8c442a6af49a152d04ba095325 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-gfx/povray/povray-3.50c.ebuild,v 1.19 2004/08/07 23:18:08 slarti Exp $

inherit gcc eutils

DESCRIPTION="The Persistence Of Vision Ray Tracer"
SRC_URI="ftp://ftp.povray.org/pub/povray/Official/Unix/povuni_s.tgz"
HOMEPAGE="http://www.povray.org/"

SLOT="0"
LICENSE="povlegal-3.5"
KEYWORDS="x86 ppc alpha amd64"
IUSE="icc X svga"

DEPEND="media-libs/libpng
	media-libs/tiff
	media-libs/jpeg
	sys-libs/zlib
	X? ( virtual/x11 )
	icc? ( dev-lang/icc )
	svga? ( media-libs/svgalib )"

pkg_setup() {
	if use icc
	then
		einfo "using icc"
	else
	export WANT_GCC_3="yes"

	if [ "$(gcc-major-version)" -lt "3" -o "$(gcc-minor-version)" -lt "2" ]
	then
		eerror "This build needs gcc-3.2 or later"
		die "This build needs gcc-3.2 or later"
	fi
	fi
}

src_unpack() {
	unpack ${A} ; cd ${S}
	use amd64 && epatch ${FILESDIR}/${P}-amd64.patch
}

src_compile() {
	local myconf

	use X && myconf="${myconf} --with-x" \
		|| myconf="${myconf} --without-x"\
		CFLAGS="${CFLAGS} -DX_DISPLAY_MISSING"

	econf ${myconf} || die

	# fix system default povray.ini to point to install directory
	cp povray.ini povray.ini.orig
	sed -e "s:/usr/local/:/usr/:" povray.ini.orig > povray.ini

	cd src

	cp Makefile makefile.orig

	DCPU=`echo ${CPPFLAGS} | sed -e "s/.*i\(.86\).*/\\1/"`
	echo "s/^CPPFLAGS.*-DCPU=686/CPPFLAGS = -DCPU=${DCPU}/" > makefile.sed

	# Change the header file with the banner when you start povray
	cp optout.h optout.h.orig
	sed -e "s/DISTRIBUTION_MESSAGE_2.*$/DISTRIBUTION_MESSAGE_2 \"Gentoo Linux - `uname -n` - ${USER}\"/" optout.h.orig > optout.h
	cp optout.h optout.h.orig
	sed -e "s/#error You must complete the following DISTRIBUTION_MESSAGE macro//" optout.h.orig > optout.h

	# rphillips - removed because of compilation issues
	# echo "s/^CPPFLAGS =/CPPFLAGS = -ansi -c/" >> makefile.sed

	if use icc; then
		# ICC CPPFLAGS
		echo "s/g++/icc/" >> makefile.sed
		echo "s/gcc/icc/" >> makefile.sed

		# Should pull from /etc/make.conf
		# If you have a P4 add -tpp7 after the -O3
		# If you want lean/mean replace -axiMKW with -x? (see icc docs for -x)
		# Note: -ipo breaks povray
		# Note: -ip breaks povray on a P3
		# echo "s/^CPPFLAGS =/CPPFLAGS = -O3 -axiMKW /" >> makefile.sed
		# This is optimized for my Pentium 2:
		echo "s/^CPPFLAGS =/CPPFLAGS = -O3 -xM -ip /" >> makefile.sed
		# This is optimized for Pentium 3 (semi-untested, I don't own one):
		#echo "s/^CPPFLAGS =/CPPFLAGS = -O3 -xK /" >> makefile.sed
		#This is optimized for Pentium 4 (untested, I don't own one):
		#echo "s/^CPPFLAGS =/CPPFLAGS = -O3 -xW -ip -tpp7 /" >> makefile.sed

	else
		# GCC CPPFLAGS
		echo "s/^CPPFLAGS =/CPPFLAGS = -finline-functions -ffast-math /" >> makefile.sed
		echo "s/^CPPFLAGS =/CPPFLAGS = ${CFLAGS} /" >> makefile.sed

	fi

	# fix library dependency
	if use X; then
		echo 's/LIBS = \(.*\)/LIBS = \1 -ldl -lpthread/' >> makefile.sed
	else
		echo 's/LIBS = \(.*\)/LIBS = \1 -ldl/' >> makefile.sed
	fi


	# strip the x86 specific options if on non x86
	if [ ${ARCH} != "x86" ]; then
		echo "s/-minline-all-stringops//" >> makefile.sed
		echo "s/-malign-double//" >> makefile.sed
		echo "s/-mcpu=i586//" >> makefile.sed
	 	echo "s/-march=i586//" >> makefile.sed
	fi

	cp Makefile Makefile.orig
	sed -f makefile.sed Makefile.orig > Makefile

	cd ${P}

	# stl compatibility
	epatch ${FILESDIR}/gentoo-${PV}.patch

	einfo Building povray
	emake || die
}

src_install() {
	emake DESTDIR=${D} install || die
	mv ${D}/etc/povray.ini ${D}/usr/share/povray-3.5/

	dodir /etc
	dosym /usr/share/povray-3.5/povray.ini /etc/povray.ini
}

pkg_postinst() {
	einfo "Installing configuration files"
	einfo "*Warning* I/O Security disabled by default"
	einfo "          Check /etc/povray.conf to enable"

	echo -e "[File I/O Security]\nnone" > /etc/povray.conf
}