Magellan Linux

Contents of /trunk/include/haskell.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5545 - (show annotations) (download)
Thu Jul 1 15:38:38 2010 UTC (13 years, 10 months ago) by niro
Original Path: trunk/core/include/haskell.sminc
File size: 4872 byte(s)
- fixed logic
1 # $Id$
2
3 # default includes
4 sminclude mtools
5
6 # some sane default values
7 : ${PCATEGORIE="dev-haskell"}
8 : ${DESCRIPTION="${PNAME}"}
9 : ${HOMEPAGE="http://hackage.haskell.org/package/${PNAME/#haskell-/}"}
10
11 # some sane default dependencies
12 SDEPEND="${SDEPEND}
13 >= dev-lang/ghc-6.12"
14
15 # default SRCFILE SRCDIR and SRC_URI
16 : ${SRCFILE="${PNAME/#haskell-/}-${PVER}.tar.gz"}
17 : ${SRCDIR="${BUILDDIR}/${PNAME/#haskell-/}-${PVER}"}
18 SRC_URI=(
19 ${SRC_URI[*]}
20 http://hackage.haskell.org/packages/archive/${PNAME/#haskell-/}/${PVER}/${SRCFILE}
21 mirror://${PNAME}/${SRCFILE}
22 )
23
24 # possible features which are supported atm
25 HASKELL_POSSIBLE_FEATURES="split-objs shared register haddock"
26 # default haskell features
27 HASKELL_FEATURES="split-objs shared register"
28
29 HASKELL_PNAME="${PNAME}"
30 SPECIAL_VARS="${SPECIAL_VARS} HASKELL_PNAME"
31 SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} haskell_preinstall haskell_postinstall haskell_preremove haskell_postremove"
32
33 haskell_feature()
34 {
35 local search="$1"
36 local feature
37 for feature in ${HASKELL_FEATURES}
38 do
39 # feature was found
40 [[ ${search} = ${feature} ]] && return 0
41 done
42
43 # feature was *not* found
44 return 1
45 }
46
47 haskell_feature_is_supported()
48 {
49 local search="$1"
50 local feature
51 for feature in ${HASKELL_POSSIBLE_FEATURES}
52 do
53 # feature was found
54 [[ ${search} = ${feature} ]] && return 0
55 done
56
57 # feature was *not* found
58 return 1
59 }
60
61 haskell_disable_feature()
62 {
63 local feature="$1"
64 haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!"
65 echo -e "${COLBLUE}--- ${COLRED}disabled haskell feature '${feature}'${COLDEFAULT}"
66 export HASKELL_FEATURES="${HASKELL_FEATURES/${feature}/}"
67 }
68
69 haskell_enable_feature()
70 {
71 local feature="$1"
72 haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!"
73 echo -e "${COLBLUE}+++ ${COLGREEN}enabled haskell feature '${feature}'${COLDEFAULT}"
74 export HASKELL_FEATURES+=" ${feature}"
75 }
76
77 haskell_ghc_version()
78 {
79 local ver
80 ver=$(ghc --numeric-version)
81 echo "${ver}"
82 }
83
84 haskell_ghc_setup_script()
85 {
86 local setup
87 if [[ -e Setup.lhs ]]
88 then
89 setup="Setup.lhs"
90 elif [[ -e Setup.hs ]]
91 then
92 setup="Setup.hs"
93 else
94 die "unkown setup script"
95 fi
96
97 echo "${setup}"
98 }
99
100 haskell_install_register()
101 {
102 runhaskell $(haskell_ghc_setup_script) register --gen-script || die
103 runhaskell $(haskell_ghc_setup_script) unregister --gen-script || die
104
105 minstalldir /usr/share/haskell/${PNAME} || die
106 minstallexec register.sh /usr/share/haskell/${PNAME} || die
107 minstallexec unregister.sh /usr/share/haskell/${PNAME} || die
108 }
109
110 haskell_src_prepare()
111 {
112 munpack ${SRCFILE} || die
113 }
114
115 haskell_src_configure()
116 {
117 local configure_opts="$@"
118
119 haskell_feature split-objs && configure_opts+=" --enable-split-objs"
120 haskell_feature shared && configure_opts+=" --enable-shared"
121
122 runhaskell $(haskell_ghc_setup_script) configure \
123 --ghc \
124 --prefix=/usr \
125 --libdir=/usr/$(mlibdir) \
126 --libsubdir=ghc-$(haskell_ghc_version)/${PNAME/#haskell-/}-${PVER} \
127 --datadir=/usr/share \
128 --datasubdir=ghc-$(haskell_ghc_version)/${PNAME/#haskell-/}-${PVER} \
129 ${configure_opts} \
130 || die
131 }
132
133 haskell_src_build()
134 {
135 runhaskell $(haskell_ghc_setup_script) build || die
136 }
137
138 haskell_src_compile()
139 {
140 cd ${SRCDIR}
141 haskell_src_configure || die
142 haskell_src_build || die
143 }
144
145 haskell_src_install()
146 {
147 cd ${SRCDIR}
148 runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die
149
150 # create register scripts
151 if haskell_feature register
152 then
153 haskell_install_register || die
154 fi
155
156 # install docs
157 local i
158 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
159 FAQ LICENSE NEWS README TODO prologue.txt
160 do
161 if [ -f ${SRCDIR}/${i} ]
162 then
163 minstalldocs ${i} || die
164 fi
165 done
166 }
167
168 haskell_preinstall()
169 {
170 if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]]
171 then
172 echo "unregister haskell module ${HASKELL_PNAME} ..."
173 ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh
174 fi
175 }
176
177 haskell_postinstall()
178 {
179 if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh ]]
180 then
181 echo "register haskell module ${HASKELL_PNAME} ..."
182 ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh
183 fi
184 }
185
186 # haskell_preremove()
187 # {
188 # if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]]
189 # then
190 # echo "unregister haskell module ${HASKELL_PNAME} ..."
191 # ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh
192 # fi
193 # }
194
195 # to be on the safe side, fix all broken packages afer a package remove
196 haskell_postremove()
197 {
198 if [[ -x $(which ghc-pkg) ]]
199 then
200 local broken="$(ghc-pkg check --simple-output)"
201 if [[ ! -z ${broken} ]]
202 then
203 echo "fixing broken haskell modules:"
204 local pkg
205 for pkg in ${broken}
206 do
207 echo " unregister ${pkg} ..."
208 ghc-pkg unregister ${pkg}
209 done
210 fi
211 fi
212 }
213
214 export_inherits haskell src_prepare src_compile src_install preinstall postinstall postremove #preremove