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