Magellan Linux

Annotation of /trunk/include/haskell.sminc

Parent Directory Parent Directory | Revision Log Revision Log


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