Magellan Linux

Annotation of /trunk/core/include/haskell.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5537 - (hide annotations) (download)
Thu Jul 1 15:22:06 2010 UTC (13 years, 10 months ago) by niro
File size: 4612 byte(s)
-added haskell feature support and fixed SPECIAL_VARS
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     haskell_feature_is_supported || die "haskell feature '${feature}' not supported!"
65     export HASKELL_FEATURES="${HASKELL_FEATURES/${feature}/}"
66     }
67    
68     haskell_enable_feature()
69     {
70     local feature="$1"
71     haskell_feature_is_supported || die "haskell feature '${feature}' not supported!"
72     export HASKELL_FEATURES+=" ${feature}"
73     }
74    
75 niro 5489 haskell_ghc_version()
76     {
77     local ver
78     ver=$(ghc --numeric-version)
79     echo "${ver}"
80     }
81    
82     haskell_ghc_setup_script()
83     {
84     local setup
85     if [[ -e Setup.lhs ]]
86     then
87     setup="Setup.lhs"
88     elif [[ -e Setup.hs ]]
89     then
90     setup="Setup.hs"
91     else
92     die "unkown setup script"
93     fi
94    
95     echo "${setup}"
96     }
97    
98     haskell_install_register()
99     {
100     runhaskell $(haskell_ghc_setup_script) register --gen-script || die
101     runhaskell $(haskell_ghc_setup_script) unregister --gen-script || die
102    
103     minstalldir /usr/share/haskell/${PNAME} || die
104     minstallexec register.sh /usr/share/haskell/${PNAME} || die
105     minstallexec unregister.sh /usr/share/haskell/${PNAME} || die
106     }
107    
108     haskell_src_prepare()
109     {
110     munpack ${SRCFILE} || die
111     }
112    
113     haskell_src_configure()
114     {
115     local configure_opts="$@"
116    
117 niro 5537 haskell_feature split-objs && configure_opts+=" --enable-split-objs"
118     haskell_feature shared && configure_opts+=" --enable-shared"
119 niro 5500
120 niro 5489 runhaskell $(haskell_ghc_setup_script) configure \
121     --ghc \
122     --prefix=/usr \
123     --libdir=/usr/$(mlibdir) \
124     --libsubdir=ghc-$(haskell_ghc_version)/${PNAME/#haskell-/}-${PVER} \
125     --datadir=/usr/share \
126     --datasubdir=ghc-$(haskell_ghc_version)/${PNAME/#haskell-/}-${PVER} \
127     ${configure_opts} \
128     || die
129     }
130    
131     haskell_src_compile()
132     {
133     cd ${SRCDIR}
134     haskell_src_configure || die
135     runhaskell $(haskell_ghc_setup_script) build || die
136     }
137    
138     haskell_src_install()
139     {
140     cd ${SRCDIR}
141     runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die
142    
143 niro 5493 # create register scripts
144 niro 5537 haskell_feature register && haskell_install_register || die
145 niro 5493
146 niro 5489 # install docs
147     local i
148     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
149     FAQ LICENSE NEWS README TODO prologue.txt
150     do
151     if [ -f ${SRCDIR}/${i} ]
152     then
153     minstalldocs ${i} || die
154     fi
155     done
156     }
157    
158     haskell_preinstall()
159     {
160     if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]]
161     then
162     echo "unregister haskell module ${HASKELL_PNAME} ..."
163     ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh
164     fi
165     }
166    
167     haskell_postinstall()
168     {
169     if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh ]]
170     then
171     echo "register haskell module ${HASKELL_PNAME} ..."
172     ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh
173     fi
174     }
175    
176     # haskell_preremove()
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 niro 5502 # to be on the safe side, fix all broken packages afer a package remove
186     haskell_postremove()
187     {
188     if [[ -x $(which ghc-pkg) ]]
189     then
190     local broken="$(ghc-pkg check --simple-output)"
191     if [[ ! -z ${broken} ]]
192     then
193     echo "fixing broken haskell modules:"
194     local pkg
195     for pkg in ${broken}
196     do
197     echo " unregister ${pkg} ..."
198     ghc-pkg unregister ${pkg}
199     done
200     fi
201     fi
202     }
203    
204     export_inherits haskell src_prepare src_compile src_install preinstall postinstall postremove #preremove