summaryrefslogtreecommitdiff
blob: d94af850170eb23b23e5e0e0b9a4f1a9c8abe504 (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
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-haskell/wash/wash-2.0.5.ebuild,v 1.1 2004/11/18 17:11:05 kosmikus Exp $

# the installation bundle is called WashNGo
MY_P="WashNGo"
MY_PV=${MY_P}-${PV}

DESCRIPTION="WASH is a family of embedded domain-specific languages for programming Web applications"
HOMEPAGE="http://www.informatik.uni-freiburg.de/~thiemann/haskell/WASH/"
SRC_URI="http://www.informatik.uni-freiburg.de/~thiemann/haskell/WASH/${MY_PV}.tgz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~x86"
IUSE="doc postgres"

DEPEND=">=virtual/ghc-6.2
	postgres? ( dev-haskell/c2hs
		>=dev-db/postgresql-7.4.3 )"

# RDEPEND: c2hs needed?

S=${WORKDIR}/${MY_PV}

src_compile() {
	local myopts
	myopts="${myopts} `use_enable postgres dbconnect`"
	myopts="${myopts} `use_enable doc build-docs`"
	# determine ghc library directory
	ghc_version=`best_version virtual/ghc | sed "s:.*/::"`
	test -n ${ghc_version} && ghclibdir="/usr/lib/${ghc_version}"
	test -n ${ghclibdir} || ghclibdir="/usr/lib"
	test -n ${ghclibdir} && myopts="${myopts} --libdir=${D}${ghclibdir}"
	./configure \
		--prefix="${D}usr" \
		--host=${CHOST} \
		${myopts} \
		--enable-register-package="${S}/${MY_PV}.conf" \
			|| die "configure failed"
	make depend || die "make depend failed"
	make all || die "make all failed"
}

src_install() {
	mkdir -p ${D}${ghclibdir}
	echo "[]" > ${S}/${MY_PV}.conf
	make install || die "make install failed"
	# fix references to D in temporary package configuration file
	cat ${S}/${MY_PV}.conf | sed "s:${D}::" \
		> ${D}${ghclibdir}/${MY_PV}.conf

	dodoc README
	if use doc; then
		cp -r Examples ${D}/usr/share/doc/${PF}
		cd doc
		dohtml -r *
	fi
}

pkg_postinst() {
	# packages: WASH/WASHHTML cgi/WASH-CGI dbconnect/DBCONNECT
	#    Utility/Utility Mail/WASHMail
	register_ghc_package Utility
	register_ghc_package WASHHTML
	register_ghc_package WASHMail
	register_ghc_package WASH-CGI
	register_ghc_package WASH
	use postgres && register_ghc_package DBCONNECT
}

pkg_postrm() {
	# check if another version is still there
	has_version "<${CATEGORY}/${PF}" \
		|| has_version ">${CATEGORY}/${PF}" \
		|| unregister_ghc_packages
}

register_ghc_package() {
	einfo "Registering $1 package"
	/usr/bin/ghc-pkg -f ${ghclibdir}/${MY_PV}.conf -s $1 \
		| /usr/bin/ghc-pkg -u --auto-ghci-libs
}

unregister_ghc_packages() {
	unregister_ghc_package DBCONNECT
	unregister_ghc_package WASH
	unregister_ghc_package WASH-CGI
	unregister_ghc_package WASHMail
	unregister_ghc_package WASHHTML
	unregister_ghc_package Utility
}

unregister_ghc_package() {
	einfo "Unregistering $1 package (warnings are safe to ignore)"
	/usr/sbin/ghc-pkg -r $1
}