aboutsummaryrefslogtreecommitdiff
blob: 3c61263adf0175b4bdea78ae8969c5da538c892a (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
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils toolchain-funcs qt3

DESCRIPTION="The Computational Geometry Algorithms Library is an Open
Source C++ library of geometric algorithms and data structures."
HOMEPAGE="http://www.cgal.org/"
DLPAGE="http://www.cgal.org/download/"
PKN="$(echo ${PN} | tr {a-z} {A-Z})"
PK="$(echo ${P} | tr {a-z} {A-Z})"
SRC_URI="${PK}.tar.gz"
#SRC_URI="ftp://ftp.mpi-sb.mpg.de/pub/outgoing/${PKN}/${PK}.tar.gz"

LICENSE="LGPL-2 QPL"
SLOT="0"
KEYWORDS="~x86"
IUSE="X zlib qt3 examples"
RESTRICT="fetch"

DEPEND="zlib? ( sys-libs/zlib )
	qt3? ( $(qt_min_version 3.0) )
	examples? ( $(qt_min_version 3.0) )
	X? ( virtual/x11 )
	dev-libs/mpfr
	sci-libs/libcore
	dev-libs/gmp
	dev-libs/boost"
RDEPEND="virtual/libc"

S="${WORKDIR}/${PK}"

pkg_nofetch() {
	einfo "Due to license restrictions that may apply to the file in this"
	einfo "package, you must download ${SRC_URI} file manually from"
	einfo "${DLPAGE} and put it in ${DISTDIR}."
}

src_unpack(){
	if use examples; then
		ewarn "Examples actualy require 28M of disk space."
	fi
	unpack "${A}"
	cd "${S}"
	epatch "${FILESDIR}/${PN}_soname.patch"
	# Patch from redhat bug #199168
	# http://bugzilla.redhat.com/bugzilla/attachment.cgi?id=135376
	# it should be not applied becauseof its textrelaction and issue
	# about undefined symbol: _ZN18QMetaObjectCleanUpC1EPKcPFP11QMetaObjectvE 
	# epatch "${FILESDIR}/${PN}_redhat.patch"
}

src_compile(){
	CGALDIR="${S}/cgal_install_dir"
	myconf="--prefix=${CGALDIR} \
		--with-boost=n \
		--with-boost-param-options=n \
		--with-core=n \
		--with-gmp=n \
		--with-gmpxx=n \
		--with-mpfr=n"

	use X && myconf="${myconf} --with-x11=n"
	use zlib && myconf="${myconf} --with-zlib=n"
	if use qt3 || use examples; then
		myconf="${myconf} --with-qt3mt=n --qt_incl_dir ${QTDIR}/include/ \
			--qt_lib_dir ${QTDIR}/lib"
	fi

	myconf="${myconf} --without-autofind"

	# we use CORE headers provided by libcore
	rm -r "${S}/include/CORE"
	
	./install_cgal ${myconf} -ni $(which $(tc-getCXX)) || \
		die "Unable to compile"
}

src_install(){
	SDIR="$(ls ${CGALDIR}/lib/)"
	LIBNAME="${CGALDIR}/lib/${SDIR}/libCGAL"

	dolib "${LIBNAME}.a" "${LIBNAME}.so" || die "Unable to install ${LIBNAME}"
	if use qt3 || use examples; then 
		dolib "${LIBNAME}Qt.a" ||\
			die "Unable to install ${LIBNAME}Qt.a"
		#"${LIBNAME}Qt.so"
	fi
	dosym "/usr/lib/libCGAL.so" "/usr/lib/libCGAL.so.1" && \
	dosym "/usr/lib/libCGAL.so" "/usr/lib/libCGAL.so.1.0.0" || \
		die "Unable to create symlinks" 

	CGALINC="${CGALDIR}/include/"
	rm -r "${CGALINC}/OpenNL/LICENSE.OPENNL" || \
			die "Unable to remove uneeded headers"
	if ! use qt3 || ! use examples ; then
		rm $(find ${CGALINC}/CGAL/ -name "Qt*") || \
			die "Unable to remove Qt headers"
	fi
	cp -rp "${CGALINC}" "${D}/usr/" || \
		die "Unable to install headers"

	sed "s:${CGALDIR}:/usr:g" -i \
		"${CGALDIR}/make/makefile_${SDIR}" || die "Unable to correct makefle"
	dodir "/usr/share/CGAL" || die "Unable to create share directory"
	cp "${CGALDIR}/make/makefile_${SDIR}" "${D}/usr/share/CGAL/makefile" || \
		die "Unable to install makefile"
	einfo "CGAL_MAKEFILE was installed in : /usr/share/CGAL/makefile"

	if use examples; then
		dodir /usr/share/doc/${P}
		cp -r "${S}/demo" "${D}/usr/share/doc/${P}"
		cp -r "${S}/examples" "${D}/usr/share/doc/${P}"
		einfo "There are 2 directories : demo and examples in"
		einfo "/usr/share/doc/${P}"
		einfo "which contains samples applications. To compile them"
		einfo "use the following command :"
		einfo "CGAL_MAKEFILE=/usr/share/CGAL/makefile make"
	fi
}