Magellan Linux

Annotation of /trunk/include/haskell.sminc

Parent Directory Parent Directory | Revision Log Revision Log


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