summaryrefslogtreecommitdiff
blob: 02d003306559bc765d2ca14dc05bbd103e11af3c (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
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-gfx/asymptote/asymptote-1.29.ebuild,v 1.3 2007/08/28 21:13:22 centic Exp $

inherit eutils elisp-common

DESCRIPTION="A vector graphics language that provides a framework for technical drawing"
HOMEPAGE="http://asymptote.sourceforge.net"
SRC_URI="mirror://sourceforge/asymptote/${P}.src.tgz"
LICENSE="GPL-2"

SLOT="0"
KEYWORDS="~amd64 x86"

IUSE="boehm-gc doc fftw emacs gsl vim-syntax"

RDEPEND=">=sys-libs/readline-4.3-r5
	>=sys-libs/ncurses-5.4-r5
	dev-libs/libsigsegv
	boehm-gc? ( >=dev-libs/boehm-gc-6.7 <dev-libs/boehm-gc-7.0 )
	virtual/tetex
	fftw? ( >=sci-libs/fftw-3.0.1 )
	emacs? ( virtual/emacs )
	gsl? ( sci-libs/gsl )
	vim-syntax? ( app-editors/vim )"
DEPEND="${RDEPEND}
	>=sys-devel/autoconf-2.5
	>=sys-devel/bison-1.875
	>=sys-devel/flex-2.5.4a-r5
	doc? ( >=media-gfx/imagemagick-6.1.3.2
		virtual/ghostscript
		>=sys-apps/texinfo-4.7-r1 )"

pkg_setup() {
	# checking if Boehm garbage collector was compiled with c++ support
	if use boehm-gc ; then
		if ! built_with_use dev-libs/boehm-gc nocxx ; then
			einfo "dev-libs/boehm-gc has been compiled with nocxx use flag disabled"
		else
			echo
			eerror "You have to rebuild dev-libs/boehm-gc enabling c++ support"
			die
		fi
	fi

	if ! built_with_use dev-lang/python tk; then
		eerror "Please reemerge dev-lang/python with 'tk' support or xasy will"
		eerror "not work. In order to fix this, execute the following:"
		eerror "echo \"dev-lang/python tk\" >> /etc/portage/package.use"
		eerror "and reemerge dev-lang/python before emerging asymptote."
		die "requires dev-lang/python with use-flag 'tk'!!"
	fi
}

src_unpack() {
	unpack ${A}

	cd ${S}

	# Fixing fftw and gsl enabling
	epatch ${FILESDIR}/${P}-configure-ac.patch
	einfo "Patching configure.ac"
	sed -i \
		-e "s:Datadir/doc/asymptote:Datadir/doc/${PF}:" \
		configure.ac || die "sed configure.ac failed"

	einfo "Building configure"
	WANT_AUTOCONF=2.5 autoconf

	epatch ${FILESDIR}/${P}-makefile.patch
}

src_compile() {
	for dir in `find /var/cache/fonts -type d`; do addwrite ${dir}; done

	# for the CPPFLAGS see http://sourceforge.net/forum/forum.php?thread_id=1683277&forum_id=409349
	myconf="--with-latex=/usr/share/texmf/tex/latex --disable-gc-debug CPPFLAGS=-DHAVE_SYS_TYPES_H"
	if use boehm-gc; then
		myconf="${myconf} --enable-gc=system"
	else
		myconf="${myconf} --disable-gc"
	fi

	econf ${myconf} $(use_with fftw) $(use_with gsl) || die "econf failed"
	emake || die "emake failed"
}

src_install() {
	for dir in `find /var/cache/fonts -type d`; do addwrite ${dir}; done

	if use doc; then
		target="install-all"
	else
		target="install"
	fi

	make DESTDIR=${D} ${target} || die "make install failed"

	dodoc BUGS ChangeLog README ReleaseNotes TODO

	if use emacs ; then
		elisp-site-file-install base/asy-mode.el
		elisp-site-file-install base/asy-keywords.el
		elisp-site-file-install "${FILESDIR}"/64asy-gentoo.el
	fi

	if use vim-syntax ; then
		insinto /usr/share/vim/vimfiles/syntax
		doins base/asy.vim
	fi
}

pkg_postinst() {
	einfo 'Updating TeX tree...'
	texhash &> /dev/null

	elog 'Use the variable ASYMPTOTE_PSVIEWER to set the postscript viewer'
	elog 'Use the variable ASYMPTOTE_PDFVIEWER to set the PDF viewer'

	use emacs && elisp-site-regen
}

pkg_postrm() {
	einfo 'Updating TeX tree...'
	texhash &> /dev/null

	[ -f "${SITELISP}"/site-gentoo.el ] && elisp-site-regen
}