summaryrefslogtreecommitdiff
blob: 29bda8a206f251fcd2447c7ad6adc57d893cd003 (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
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit eutils toolchain-funcs

MY_PV="${PV/_beta/b}"
MY_P="${PN}-${MY_PV}"

DESCRIPTION="A portable, high performance parallel ray tracing system"
HOMEPAGE="http://jedi.ks.uiuc.edu/~johns/raytracer/"
SRC_URI="http://jedi.ks.uiuc.edu/~johns/raytracer/files/${MY_PV}/${MY_P}.tar.gz"

SLOT="0"
LICENSE="BSD"
KEYWORDS="~amd64 ~ppc ~x86 ~x64-macos ~x86-macos"
IUSE="doc examples jpeg mpi +opengl openmp png threads"

PATCHES=(	"${FILESDIR}/${PF}-ldflags.patch"
		"${FILESDIR}/${PF}-shared.patch"  )

CDEPEND="
	jpeg? ( virtual/jpeg:0= )
	mpi? ( virtual/mpi )
	opengl? (
		virtual/glu
		virtual/opengl
		)
	png? ( media-libs/libpng:0= )"
DEPEND="${CDEPEND}
	virtual/pkgconfig"
RDEPEND="${CDEPEND}"

S="${WORKDIR}/${PN}/unix"

src_prepare() {
	emakeconf=()
	use jpeg && \
		emakeconf+=(
			USEJPEG=-DUSEJPEG
			JPEGLIB=-ljpeg
		)

	use png && \
		emakeconf+=(
			USEPNG=-DUSEPNG
			PNGINC="$($(tc-getPKG_CONFIG) --cflags libpng)"
			PNGLIB="$($(tc-getPKG_CONFIG) --libs libpng)"
			)

	if use mpi ; then
		sed \
			-e "s:MPIDIR=:MPIDIR=/usr:g" \
			-e "s:linux-lam:linux-mpi:g" \
			-i Make-config || die "sed failed"
	fi

	LIBSLINE='"'
	CFLAGSLINE='"'
	use mpi || CCLINE='"CC = $(tc-getCC)"'
	use mpi && CCLINE='"CC = mpicc"'
	LIBSLINE+="LIBS = -L. -ltachyon \$(MISCLIB) -lm"
	CFLAGSLINE+="CFLAGS = -DLinux \$(MISCFLAGS)"

	use threads && CFLAGSLINE+=" \$(THREADSFLAGS) -D_REENTRANT"
	use threads && LIBSLINE+=" -lpthread"
	use openmp && CFLAGSLINE+=" -fopenmp -D_REENTRANT"
	use opengl && CFLAGSLINE+=" -DUSEOPENGL \$(LINUX_GLX_INCS)"
	use opengl && LIBSLINE+=" \$(LINUX_GLX_LIBS)"
	use mpi && CFLAGSLINE+=" \$(MPIFLAGS)"

	CFLAGSLINE+=" ${CFLAGS}"
	CFLAGSLINE+='" \'
	LIBSLINE+=" ${LDFLAGS}"
	LIBSLINE+='" \'

	export TACHYON_MAKE_TARGET="gentoo"

	echo "gentoo:" >> Make-arch
	echo "	\$(MAKE) all \\" >> Make-arch
	echo '	"ARCH = gentoo" \' >> Make-arch
	echo '	"STRIP = touch" \' >> Make-arch
	echo "	${LIBSLINE}" >> Make-arch
	echo "	${CFLAGSLINE}" >> Make-arch
	echo "	${CCLINE}" >> Make-arch

	default
}

src_compile() {
	emake "${TACHYON_MAKE_TARGET}" "${emakeconf[@]}" VERSION="${PV}"
}

src_install() {
	cd .. || die
	dodoc Changes README

	insinto "/usr/include/${PN}"
	doins src/*.h

	use doc && docinto html && dodoc -r docs/tachyon/.

	cd "compile/${TACHYON_MAKE_TARGET}" || die

	dobin "${PN}"
	dolib.so lib${PN}.so*

	if use examples; then
		cd "${S}/../scenes" || die
		insinto "/usr/share/${PN}/examples"
		doins *
	fi
}