Magellan Linux

Annotation of /trunk/include/haskell.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5544 - (hide annotations) (download)
Thu Jul 1 15:35:26 2010 UTC (14 years, 4 months ago) by niro
Original Path: trunk/core/include/haskell.sminc
File size: 4860 byte(s)
-fixed whitespaces
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 5499 SDEPEND="${SDEPEND}
13 niro 5489 >= 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 niro 5492 SRC_URI=(
19     ${SRC_URI[*]}
20     http://hackage.haskell.org/packages/archive/${PNAME/#haskell-/}/${PVER}/${SRCFILE}
21     mirror://${PNAME}/${SRCFILE}
22     )
23 niro 5489
24 niro 5537 # 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 niro 5489 HASKELL_PNAME="${PNAME}"
30 niro 5537 SPECIAL_VARS="${SPECIAL_VARS} HASKELL_PNAME"
31 niro 5502 SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} haskell_preinstall haskell_postinstall haskell_preremove haskell_postremove"
32 niro 5489
33 niro 5537 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 niro 5540 haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!"
65 niro 5544 echo -e "${COLBLUE}--- ${COLRED}disabled haskell feature '${feature}'${COLDEFAULT}"
66 niro 5537 export HASKELL_FEATURES="${HASKELL_FEATURES/${feature}/}"
67     }
68    
69     haskell_enable_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}+++ ${COLGREEN}enabled haskell feature '${feature}'${COLDEFAULT}"
74 niro 5537 export HASKELL_FEATURES+=" ${feature}"
75     }
76    
77 niro 5489 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 niro 5537 haskell_feature split-objs && configure_opts+=" --enable-split-objs"
120     haskell_feature shared && configure_opts+=" --enable-shared"
121 niro 5500
122 niro 5489 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 niro 5538 haskell_src_build()
134     {
135     runhaskell $(haskell_ghc_setup_script) build || die
136     }
137    
138 niro 5489 haskell_src_compile()
139     {
140     cd ${SRCDIR}
141     haskell_src_configure || die
142 niro 5538 haskell_src_build || die
143 niro 5489 }
144    
145     haskell_src_install()
146     {
147     cd ${SRCDIR}
148     runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die
149    
150 niro 5493 # create register scripts
151 niro 5537 haskell_feature register && haskell_install_register || die
152 niro 5493
153 niro 5489 # install docs
154     local i
155     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
156     FAQ LICENSE NEWS README TODO prologue.txt
157     do
158     if [ -f ${SRCDIR}/${i} ]
159     then
160     minstalldocs ${i} || die
161     fi
162     done
163     }
164    
165     haskell_preinstall()
166     {
167     if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]]
168     then
169     echo "unregister haskell module ${HASKELL_PNAME} ..."
170     ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh
171     fi
172     }
173    
174     haskell_postinstall()
175     {
176     if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh ]]
177     then
178     echo "register haskell module ${HASKELL_PNAME} ..."
179     ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh
180     fi
181     }
182    
183     # haskell_preremove()
184     # {
185     # if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]]
186     # then
187     # echo "unregister haskell module ${HASKELL_PNAME} ..."
188     # ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh
189     # fi
190     # }
191    
192 niro 5502 # to be on the safe side, fix all broken packages afer a package remove
193     haskell_postremove()
194     {
195     if [[ -x $(which ghc-pkg) ]]
196     then
197     local broken="$(ghc-pkg check --simple-output)"
198     if [[ ! -z ${broken} ]]
199     then
200     echo "fixing broken haskell modules:"
201     local pkg
202     for pkg in ${broken}
203     do
204     echo " unregister ${pkg} ..."
205     ghc-pkg unregister ${pkg}
206     done
207     fi
208     fi
209     }
210    
211     export_inherits haskell src_prepare src_compile src_install preinstall postinstall postremove #preremove