Contents of /branches/R11-unstable/include/haskell.sminc
Parent Directory | Revision Log
Revision 5578 -
(show annotations)
(download)
Fri Jul 2 13:40:50 2010 UTC (14 years, 4 months ago) by niro
Original Path: trunk/core/include/haskell.sminc
File size: 5090 byte(s)
Fri Jul 2 13:40:50 2010 UTC (14 years, 4 months ago) by niro
Original Path: trunk/core/include/haskell.sminc
File size: 5090 byte(s)
-Introduce HASKELL_PACKAGE varibale
1 | # $Id$ |
2 | |
3 | # default includes |
4 | sminclude mtools |
5 | |
6 | # some sane default values |
7 | : ${HASKELL_PACKAGE="${PNAME/#haskell-/}"} |
8 | : ${PCATEGORIE="dev-haskell"} |
9 | : ${DESCRIPTION="${PNAME}"} |
10 | : ${HOMEPAGE="http://hackage.haskell.org/package/${HASKELL_PACKAGE}"} |
11 | |
12 | # 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} |
21 | >= dev-lang/ghc-6.12" |
22 | |
23 | # default SRCFILE SRCDIR and SRC_URI |
24 | : ${SRCFILE="${HASKELL_PACKAGE}-${PVER}.tar.gz"} |
25 | : ${SRCDIR="${BUILDDIR}/${HASKELL_PACKAGE}-${PVER}"} |
26 | SRC_URI=( |
27 | ${SRC_URI[*]} |
28 | http://hackage.haskell.org/packages/archive/${HASKELL_PACKAGE}/${PVER}/${SRCFILE} |
29 | 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}" |
38 | SPECIAL_VARS="${SPECIAL_VARS} HASKELL_PNAME" |
39 | 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() |
86 | { |
87 | local ver |
88 | ver=$(ghc --numeric-version) |
89 | echo "${ver}" |
90 | } |
91 | |
92 | haskell_ghc_setup_script() |
93 | { |
94 | local setup |
95 | if [[ -e Setup.lhs ]] |
96 | then |
97 | setup="Setup.lhs" |
98 | elif [[ -e Setup.hs ]] |
99 | then |
100 | setup="Setup.hs" |
101 | else |
102 | die "unkown setup script" |
103 | fi |
104 | |
105 | echo "${setup}" |
106 | } |
107 | |
108 | haskell_install_register() |
109 | { |
110 | runhaskell $(haskell_ghc_setup_script) register --gen-script || die |
111 | runhaskell $(haskell_ghc_setup_script) unregister --gen-script || die |
112 | |
113 | minstalldir /usr/share/haskell/${PNAME} || die |
114 | minstallexec register.sh /usr/share/haskell/${PNAME} || die |
115 | minstallexec unregister.sh /usr/share/haskell/${PNAME} || die |
116 | } |
117 | |
118 | haskell_src_prepare() |
119 | { |
120 | munpack ${SRCFILE} || die |
121 | } |
122 | |
123 | haskell_src_configure() |
124 | { |
125 | local configure_opts="$@" |
126 | |
127 | haskell_feature split-objs && configure_opts+=" --enable-split-objs" |
128 | haskell_feature shared && configure_opts+=" --enable-shared" |
129 | |
130 | runhaskell $(haskell_ghc_setup_script) configure \ |
131 | --ghc \ |
132 | --prefix=/usr \ |
133 | --libdir=/usr/$(mlibdir) \ |
134 | --libsubdir=ghc-$(haskell_ghc_version)/${HASKELL_PACKAGE}-${PVER} \ |
135 | --datadir=/usr/share \ |
136 | --datasubdir=ghc-$(haskell_ghc_version)/${HASKELL_PACKAGE}-${PVER} \ |
137 | ${configure_opts} \ |
138 | || die |
139 | } |
140 | |
141 | haskell_src_build() |
142 | { |
143 | runhaskell $(haskell_ghc_setup_script) build || die |
144 | } |
145 | |
146 | haskell_src_compile() |
147 | { |
148 | cd ${SRCDIR} |
149 | haskell_src_configure || die |
150 | haskell_src_build || die |
151 | } |
152 | |
153 | haskell_src_install() |
154 | { |
155 | cd ${SRCDIR} |
156 | runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die |
157 | |
158 | # create register scripts |
159 | if haskell_feature register |
160 | then |
161 | haskell_install_register || die |
162 | fi |
163 | |
164 | # install docs |
165 | local i |
166 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
167 | FAQ LICENSE NEWS README TODO prologue.txt |
168 | do |
169 | if [ -f ${SRCDIR}/${i} ] |
170 | then |
171 | minstalldocs ${i} || die |
172 | fi |
173 | done |
174 | } |
175 | |
176 | haskell_preinstall() |
177 | { |
178 | if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]] |
179 | then |
180 | echo "unregister haskell module ${HASKELL_PNAME} ..." |
181 | ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh |
182 | fi |
183 | } |
184 | |
185 | haskell_postinstall() |
186 | { |
187 | if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh ]] |
188 | then |
189 | echo "register haskell module ${HASKELL_PNAME} ..." |
190 | ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh |
191 | fi |
192 | } |
193 | |
194 | # haskell_preremove() |
195 | # { |
196 | # if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]] |
197 | # then |
198 | # echo "unregister haskell module ${HASKELL_PNAME} ..." |
199 | # ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh |
200 | # fi |
201 | # } |
202 | |
203 | # 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 |