3 |
# default includes |
# default includes |
4 |
sminclude mtools |
sminclude mtools |
5 |
|
|
6 |
|
# upstream package name |
7 |
|
: ${HASKELL_PACKAGE="${PNAME/#haskell-/}"} |
8 |
|
|
9 |
# some sane default values |
# some sane default values |
10 |
: ${PCATEGORIE="dev-haskell"} |
: ${PCAT="dev-haskell"} |
11 |
: ${DESCRIPTION="${PNAME}"} |
: ${DESCRIPTION="${PNAME}"} |
12 |
: ${HOMEPAGE="http://hackage.haskell.org/package/${PNAME/#haskell-/}"} |
: ${HOMEPAGE="http://hackage.haskell.org/package/${HASKELL_PACKAGE}"} |
13 |
|
|
14 |
# some sane default dependencies |
# some sane default dependencies |
15 |
DEPEND="${DEPEND} |
# all packages with haskell in the name needs ghc as runtime |
16 |
|
if [[ ${PNAME/#haskell-/} != ${PNAME} ]] |
17 |
|
then |
18 |
|
DEPEND="${DEPEND} |
19 |
|
>= dev-lang/ghc-6.12" |
20 |
|
fi |
21 |
|
# all other only as SDEPEND |
22 |
|
SDEPEND="${SDEPEND} |
23 |
>= dev-lang/ghc-6.12" |
>= dev-lang/ghc-6.12" |
24 |
|
|
25 |
# default SRCFILE SRCDIR and SRC_URI |
# default SRCFILE SRCDIR and SRC_URI |
26 |
: ${SRCFILE="${PNAME/#haskell-/}-${PVER}.tar.gz"} |
: ${SRCFILE="${HASKELL_PACKAGE}-${PVER}.tar.gz"} |
27 |
: ${SRCDIR="${BUILDDIR}/${PNAME/#haskell-/}-${PVER}"} |
: ${SRCDIR="${BUILDDIR}/${HASKELL_PACKAGE}-${PVER}"} |
28 |
: ${SRC_URI=( "http://hackage.haskell.org/packages/archive/${PNAME/#haskell-/}/${PVER}/${SRCFILE}" "mirror://${PNAME}/${SRCFILE}" )} |
SRC_URI=( |
29 |
|
${SRC_URI[*]} |
30 |
|
http://hackage.haskell.org/packages/archive/${HASKELL_PACKAGE}/${PVER}/${SRCFILE} |
31 |
|
mirror://${PNAME}/${SRCFILE} |
32 |
|
) |
33 |
|
|
34 |
|
# possible features which are supported atm |
35 |
|
HASKELL_POSSIBLE_FEATURES="split-objs shared register haddock" |
36 |
|
# default haskell features |
37 |
|
HASKELL_FEATURES="split-objs shared register" |
38 |
|
|
39 |
HASKELL_PNAME="${PNAME}" |
HASKELL_PNAME="${PNAME}" |
40 |
SPECIAL_VARS="HASKELL_PNAME" |
SPECIAL_VARS="${SPECIAL_VARS} HASKELL_PNAME" |
41 |
|
SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} haskell_preinstall haskell_postinstall haskell_preremove haskell_postremove" |
42 |
|
|
43 |
|
haskell_feature() |
44 |
|
{ |
45 |
|
local search="$1" |
46 |
|
local feature |
47 |
|
for feature in ${HASKELL_FEATURES} |
48 |
|
do |
49 |
|
# feature was found |
50 |
|
[[ ${search} = ${feature} ]] && return 0 |
51 |
|
done |
52 |
|
|
53 |
|
# feature was *not* found |
54 |
|
return 1 |
55 |
|
} |
56 |
|
|
57 |
|
haskell_feature_is_supported() |
58 |
|
{ |
59 |
|
local search="$1" |
60 |
|
local feature |
61 |
|
for feature in ${HASKELL_POSSIBLE_FEATURES} |
62 |
|
do |
63 |
|
# feature was found |
64 |
|
[[ ${search} = ${feature} ]] && return 0 |
65 |
|
done |
66 |
|
|
67 |
|
# feature was *not* found |
68 |
|
return 1 |
69 |
|
} |
70 |
|
|
71 |
|
haskell_disable_feature() |
72 |
|
{ |
73 |
|
local feature="$1" |
74 |
|
haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!" |
75 |
|
echo -e "${COLBLUE}--- ${COLRED}disabled haskell feature '${feature}'${COLDEFAULT}" |
76 |
|
export HASKELL_FEATURES="${HASKELL_FEATURES/${feature}/}" |
77 |
|
} |
78 |
|
|
79 |
|
haskell_enable_feature() |
80 |
|
{ |
81 |
|
local feature="$1" |
82 |
|
haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!" |
83 |
|
echo -e "${COLBLUE}+++ ${COLGREEN}enabled haskell feature '${feature}'${COLDEFAULT}" |
84 |
|
export HASKELL_FEATURES+=" ${feature}" |
85 |
|
} |
86 |
|
|
87 |
haskell_ghc_version() |
haskell_ghc_version() |
88 |
{ |
{ |
126 |
{ |
{ |
127 |
local configure_opts="$@" |
local configure_opts="$@" |
128 |
|
|
129 |
|
haskell_feature split-objs && configure_opts+=" --enable-split-objs" |
130 |
|
haskell_feature shared && configure_opts+=" --enable-shared" |
131 |
|
|
132 |
runhaskell $(haskell_ghc_setup_script) configure \ |
runhaskell $(haskell_ghc_setup_script) configure \ |
133 |
--ghc \ |
--ghc \ |
134 |
--prefix=/usr \ |
--prefix=/usr \ |
135 |
--libdir=/usr/$(mlibdir) \ |
--libdir=/usr/$(mlibdir) \ |
136 |
--libsubdir=ghc-$(haskell_ghc_version)/${PNAME/#haskell-/}-${PVER} \ |
--libsubdir=ghc-$(haskell_ghc_version)/${HASKELL_PACKAGE}-${PVER} \ |
137 |
--datadir=/usr/share \ |
--datadir=/usr/share \ |
138 |
--datasubdir=ghc-$(haskell_ghc_version)/${PNAME/#haskell-/}-${PVER} \ |
--datasubdir=ghc-$(haskell_ghc_version)/${HASKELL_PACKAGE}-${PVER} \ |
139 |
${configure_opts} \ |
${configure_opts} \ |
140 |
|| die |
|| die |
141 |
} |
} |
142 |
|
|
143 |
|
haskell_src_build() |
144 |
|
{ |
145 |
|
runhaskell $(haskell_ghc_setup_script) build || die |
146 |
|
} |
147 |
|
|
148 |
haskell_src_compile() |
haskell_src_compile() |
149 |
{ |
{ |
150 |
cd ${SRCDIR} |
cd ${SRCDIR} |
151 |
haskell_src_configure || die |
haskell_src_configure || die |
152 |
runhaskell $(haskell_ghc_setup_script) build || die |
haskell_src_build || die |
153 |
} |
} |
154 |
|
|
155 |
haskell_src_install() |
haskell_src_install() |
156 |
{ |
{ |
157 |
cd ${SRCDIR} |
cd ${SRCDIR} |
|
|
|
158 |
runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die |
runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die |
159 |
|
|
160 |
|
# create register scripts |
161 |
|
if haskell_feature register |
162 |
|
then |
163 |
|
haskell_install_register || die |
164 |
|
fi |
165 |
|
|
166 |
# install docs |
# install docs |
167 |
local i |
local i |
168 |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
202 |
# fi |
# fi |
203 |
# } |
# } |
204 |
|
|
205 |
export_inherits haskell src_prepare src_compile src_install preinstall postinstall #preremove |
# to be on the safe side, fix all broken packages afer a package remove |
206 |
|
haskell_postremove() |
207 |
|
{ |
208 |
|
if [[ -x $(which ghc-pkg) ]] |
209 |
|
then |
210 |
|
local broken="$(ghc-pkg check --simple-output)" |
211 |
|
if [[ ! -z ${broken} ]] |
212 |
|
then |
213 |
|
echo "fixing broken haskell modules:" |
214 |
|
local pkg |
215 |
|
for pkg in ${broken} |
216 |
|
do |
217 |
|
echo " unregister ${pkg} ..." |
218 |
|
ghc-pkg unregister ${pkg} |
219 |
|
done |
220 |
|
fi |
221 |
|
fi |
222 |
|
} |
223 |
|
|
224 |
|
export_inherits haskell src_prepare src_compile src_install preinstall postinstall postremove #preremove |