Contents of /trunk/include/haskell.sminc
Parent Directory | Revision Log
Revision 9880 -
(show annotations)
(download)
Sat Jan 14 01:48:34 2012 UTC (12 years, 8 months ago) by niro
File size: 5109 byte(s)
Sat Jan 14 01:48:34 2012 UTC (12 years, 8 months ago) by niro
File size: 5109 byte(s)
-imported from magellan-next
1 | # $Id$ |
2 | |
3 | # default includes |
4 | sminclude mtools |
5 | |
6 | # upstream package name |
7 | : ${HASKELL_PACKAGE="${PNAME/#haskell-/}"} |
8 | |
9 | # some sane default values |
10 | : ${PCAT="dev-haskell"} |
11 | : ${DESCRIPTION="${PNAME}"} |
12 | : ${HOMEPAGE="http://hackage.haskell.org/package/${HASKELL_PACKAGE}"} |
13 | |
14 | # some sane default dependencies |
15 | # 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" |
24 | |
25 | # default SRCFILE SRCDIR and SRC_URI |
26 | : ${SRCFILE="${HASKELL_PACKAGE}-${PVER}.tar.gz"} |
27 | : ${SRCDIR="${BUILDDIR}/${HASKELL_PACKAGE}-${PVER}"} |
28 | 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}" |
40 | 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() |
88 | { |
89 | local ver |
90 | ver=$(ghc --numeric-version) |
91 | echo "${ver}" |
92 | } |
93 | |
94 | haskell_ghc_setup_script() |
95 | { |
96 | local setup |
97 | if [[ -e Setup.lhs ]] |
98 | then |
99 | setup="Setup.lhs" |
100 | elif [[ -e Setup.hs ]] |
101 | then |
102 | setup="Setup.hs" |
103 | else |
104 | die "unkown setup script" |
105 | fi |
106 | |
107 | echo "${setup}" |
108 | } |
109 | |
110 | haskell_install_register() |
111 | { |
112 | runhaskell $(haskell_ghc_setup_script) register --gen-script || die |
113 | runhaskell $(haskell_ghc_setup_script) unregister --gen-script || die |
114 | |
115 | minstalldir /usr/share/haskell/${PNAME} || die |
116 | minstallexec register.sh /usr/share/haskell/${PNAME} || die |
117 | minstallexec unregister.sh /usr/share/haskell/${PNAME} || die |
118 | } |
119 | |
120 | haskell_src_prepare() |
121 | { |
122 | munpack ${SRCFILE} || die |
123 | } |
124 | |
125 | haskell_src_configure() |
126 | { |
127 | 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 \ |
133 | --ghc \ |
134 | --prefix=/usr \ |
135 | --libdir=/usr/$(mlibdir) \ |
136 | --libsubdir=ghc-$(haskell_ghc_version)/${HASKELL_PACKAGE}-${PVER} \ |
137 | --datadir=/usr/share \ |
138 | --datasubdir=ghc-$(haskell_ghc_version)/${HASKELL_PACKAGE}-${PVER} \ |
139 | ${configure_opts} \ |
140 | || die |
141 | } |
142 | |
143 | haskell_src_build() |
144 | { |
145 | runhaskell $(haskell_ghc_setup_script) build || die |
146 | } |
147 | |
148 | haskell_src_compile() |
149 | { |
150 | cd ${SRCDIR} |
151 | haskell_src_configure || die |
152 | haskell_src_build || die |
153 | } |
154 | |
155 | haskell_src_install() |
156 | { |
157 | cd ${SRCDIR} |
158 | 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 |
167 | local i |
168 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ |
169 | FAQ LICENSE NEWS README TODO prologue.txt |
170 | do |
171 | if [ -f ${SRCDIR}/${i} ] |
172 | then |
173 | minstalldocs ${i} || die |
174 | fi |
175 | done |
176 | } |
177 | |
178 | haskell_preinstall() |
179 | { |
180 | if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]] |
181 | then |
182 | echo "unregister haskell module ${HASKELL_PNAME} ..." |
183 | ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh |
184 | fi |
185 | } |
186 | |
187 | haskell_postinstall() |
188 | { |
189 | if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh ]] |
190 | then |
191 | echo "register haskell module ${HASKELL_PNAME} ..." |
192 | ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh |
193 | fi |
194 | } |
195 | |
196 | # haskell_preremove() |
197 | # { |
198 | # if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]] |
199 | # then |
200 | # echo "unregister haskell module ${HASKELL_PNAME} ..." |
201 | # ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh |
202 | # fi |
203 | # } |
204 | |
205 | # 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 |