Magellan Linux

Annotation of /branches/R11-unstable/include/haskell.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5578 - (hide annotations) (download)
Fri Jul 2 13:40:50 2010 UTC (13 years, 10 months ago) by niro
Original Path: trunk/core/include/haskell.sminc
File size: 5090 byte(s)
-Introduce HASKELL_PACKAGE varibale
1 niro 5489 # $Id$
2    
3     # default includes
4     sminclude mtools
5    
6     # some sane default values
7 niro 5578 : ${HASKELL_PACKAGE="${PNAME/#haskell-/}"}
8 niro 5489 : ${PCATEGORIE="dev-haskell"}
9     : ${DESCRIPTION="${PNAME}"}
10 niro 5578 : ${HOMEPAGE="http://hackage.haskell.org/package/${HASKELL_PACKAGE}"}
11 niro 5489
12     # some sane default dependencies
13 niro 5571 # 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 niro 5499 SDEPEND="${SDEPEND}
21 niro 5489 >= dev-lang/ghc-6.12"
22    
23     # default SRCFILE SRCDIR and SRC_URI
24 niro 5578 : ${SRCFILE="${HASKELL_PACKAGE}-${PVER}.tar.gz"}
25     : ${SRCDIR="${BUILDDIR}/${HASKELL_PACKAGE}-${PVER}"}
26 niro 5492 SRC_URI=(
27     ${SRC_URI[*]}
28 niro 5578 http://hackage.haskell.org/packages/archive/${HASKELL_PACKAGE}/${PVER}/${SRCFILE}
29 niro 5492 mirror://${PNAME}/${SRCFILE}
30     )
31 niro 5489
32 niro 5537 # 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 niro 5489 HASKELL_PNAME="${PNAME}"
38 niro 5537 SPECIAL_VARS="${SPECIAL_VARS} HASKELL_PNAME"
39 niro 5502 SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} haskell_preinstall haskell_postinstall haskell_preremove haskell_postremove"
40 niro 5489
41 niro 5537 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 niro 5540 haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!"
73 niro 5544 echo -e "${COLBLUE}--- ${COLRED}disabled haskell feature '${feature}'${COLDEFAULT}"
74 niro 5537 export HASKELL_FEATURES="${HASKELL_FEATURES/${feature}/}"
75     }
76    
77     haskell_enable_feature()
78     {
79     local feature="$1"
80 niro 5540 haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!"
81 niro 5544 echo -e "${COLBLUE}+++ ${COLGREEN}enabled haskell feature '${feature}'${COLDEFAULT}"
82 niro 5537 export HASKELL_FEATURES+=" ${feature}"
83     }
84    
85 niro 5489 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 niro 5537 haskell_feature split-objs && configure_opts+=" --enable-split-objs"
128     haskell_feature shared && configure_opts+=" --enable-shared"
129 niro 5500
130 niro 5489 runhaskell $(haskell_ghc_setup_script) configure \
131     --ghc \
132     --prefix=/usr \
133     --libdir=/usr/$(mlibdir) \
134 niro 5578 --libsubdir=ghc-$(haskell_ghc_version)/${HASKELL_PACKAGE}-${PVER} \
135 niro 5489 --datadir=/usr/share \
136 niro 5578 --datasubdir=ghc-$(haskell_ghc_version)/${HASKELL_PACKAGE}-${PVER} \
137 niro 5489 ${configure_opts} \
138     || die
139     }
140    
141 niro 5538 haskell_src_build()
142     {
143     runhaskell $(haskell_ghc_setup_script) build || die
144     }
145    
146 niro 5489 haskell_src_compile()
147     {
148     cd ${SRCDIR}
149     haskell_src_configure || die
150 niro 5538 haskell_src_build || die
151 niro 5489 }
152    
153     haskell_src_install()
154     {
155     cd ${SRCDIR}
156     runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die
157    
158 niro 5493 # create register scripts
159 niro 5545 if haskell_feature register
160     then
161     haskell_install_register || die
162     fi
163 niro 5493
164 niro 5489 # 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 niro 5502 # 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