Magellan Linux

Annotation of /trunk/include/multilib.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (hide annotations) (download)
Fri Oct 10 13:29:42 2008 UTC (16 years ago) by niro
Original Path: trunk/core/include/multilib.sminc
File size: 8268 byte(s)
import repo
1 niro 2 # $Header: /magellan-cvs/smage/include/multilib.sminc,v 1.33 2007-11-13 15:49:09 niro Exp $
2     # multilib abis
3    
4     # do not define EMUL_LINUX_32 after inherit of multlib !!
5     # it may break i*86 builds
6    
7     # default ABIs to be build
8     case ${ARCH} in
9     x86_64)
10     : ${MULTILIB_ABIS="m32 m64"}
11     # default false
12     : ${EMUL_LINUX_32="false"}
13    
14     # add linux32 to the dependencies
15     if [[ ${EMUL_LINUX_32} = true ]]
16     then
17     EMUL_LINUX_32_SDEPENDS_x86_64=">= dev-util/linux32-1"
18     SPECIAL_VARS="${SPECIAL_VARS} EMUL_LINUX_32_SDEPENDS_x86_64"
19     fi
20     ;;
21     i*86)
22     : ${MULTILIB_ABIS="m32"}
23     # always false
24     EMUL_LINUX_32="false"
25     ;;
26     esac
27    
28     # add linux32 to the dependencies
29     if [[ ${EMUL_LINUX_32} = true ]]
30     then
31     # very dirty trick to get the dependencies right
32     # ; is the IFS, tr replaces ; with an crlfs
33     # the var ist decided with our common eval+echo magic
34     if [[ -z ${SDEPEND} ]]
35     then
36     SDEPEND="\$(eval echo \\\$EMUL_LINUX_32_SDEPENDS_\${ARCH/i*86/x86} | tr ';' '\n')"
37     else
38     SDEPEND="${SDEPEND}
39     \$(eval echo \\\$EMUL_LINUX_32_SDEPENDS_\${ARCH/i*86/x86} | tr ';' '\n')"
40     fi
41     fi
42    
43     ##
44     # overide some defaults to respect ABI_LIBDIR
45     ##
46     mlibdir()
47     {
48     local libdir=lib
49     [[ ${ARCH} = x86_64 ]] && libdir=lib64
50     [[ -n ${ABI_LIBDIR} ]] && libdir="${ABI_LIBDIR}"
51    
52     echo "${libdir}"
53     }
54    
55     ##
56     # multilib abi changers
57     ##
58     abi-m32()
59     {
60     export ABI="m32"
61     export CC="gcc -${ABI}"
62     export CXX="g++ -${ABI}"
63     export ABI_LIBDIR="lib"
64     export LDFLAGS="-L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}"
65     export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig"
66    
67     echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}"
68     echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'"
69     echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'"
70     echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'"
71     echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'"
72     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'"
73     echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'"
74    
75     # configure a linux32 emulated build
76     if [[ ${EMUL_LINUX_32} = true ]]
77     then
78     echo -e "${COLBLUE}*** ${COLGREEN} EMUL_LINUX_32${COLDEFAULT}='${EMUL_LINUX_32}'"
79     uname(){ linux32 uname $@; } && export -f uname
80     ORIG_CHOST="${CHOST}" && export CHOST="i686-pc-linux-gnu"
81     fi
82     echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
83    
84     # run any given command
85     eval $@ || die
86    
87     unset ABI CC CXX ABI_LIBDIR LDFLAGS PKG_CONFIG_PATH
88    
89     # restore original settings
90     if [[ ${EMUL_LINUX_32} = true ]]
91     then
92     unset uname
93     export CHOST="${ORIG_CHOST}" && unset ORIG_CHOST
94     fi
95     }
96    
97     abi-m64()
98     {
99     export ABI="m64"
100     export CC="gcc -${ABI}"
101     export CXX="g++ -${ABI}"
102     export ABI_LIBDIR="lib64"
103     export LDFLAGS="-L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}"
104     export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig"
105    
106     echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}"
107     echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'"
108     echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'"
109     echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'"
110     echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'"
111     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'"
112     echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
113     echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'"
114    
115     # run any given command
116     eval $@ || die
117    
118     unset ABI CC CXX ABI_LIBDIR LDFLAGS PKG_CONFIG_PATH
119     }
120    
121     only-m32()
122     {
123     local abi=m32
124     local i
125    
126     for i in ${MULTILIB_ABIS}
127     do
128     if [[ ${i} = ${abi} ]]
129     then
130     # export this for mpatch etc (to repect only-${abi})
131     export MULTILIB_ONLY_ABI=${abi}
132    
133     cd ${SRCDIR}-${abi}
134     abi-${abi} $@ || die
135    
136     # unset this is very important
137     unset MULTILIB_ONLY_ABI
138     fi
139     done
140     }
141    
142     only-m64()
143     {
144     local abi=m64
145     local i
146    
147     for i in ${MULTILIB_ABIS}
148     do
149     if [[ ${i} = ${abi} ]]
150     then
151     # export this for mpatch etc (to repect only-${abi})
152     export MULTILIB_ONLY_ABI=${abi}
153    
154     cd ${SRCDIR}-${abi}
155     abi-${abi} $@ || die
156    
157     # unset this is very important
158     unset MULTILIB_ONLY_ABI
159     fi
160     done
161     }
162    
163     all-abis()
164     {
165     local abi
166     for abi in ${MULTILIB_ABIS}
167     do
168     cd ${SRCDIR}-${abi}
169     abi-${abi} $@ || die
170     done
171     }
172    
173     ##
174     # multilib compile functions
175     ##
176    
177     # rename the old one
178     old_mconfigure=old$(typeset -f mconfigure)
179     eval ${old_mconfigure}
180     mconfigure()
181     {
182     local abi
183     local abis_to_run="${MULTILIB_ABIS}"
184    
185     # respect MULTILIB_ONLY_ABI variable
186     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
187    
188     for abi in ${abis_to_run}
189     do
190     cd ${SRCDIR}-${abi}
191     abi-${abi} oldmconfigure $@ || die
192     done
193     }
194    
195     # rename the old one
196     old_munpack=old$(typeset -f munpack)
197     eval "${old_munpack}"
198     munpack()
199     {
200     local abi
201     local abis_to_run="${MULTILIB_ABIS}"
202    
203     # respect MULTILIB_ONLY_ABI variable
204     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
205    
206     for abi in ${abis_to_run}
207     do
208     echo -e "${COLBLUE}*** ${COLGREEN}unpacking for ABI -${abi}${COLDEFAULT}"
209     oldmunpack ${SRCFILE} || die
210     mv ${SRCDIR} ${SRCDIR}-${abi} || die
211     done
212     }
213    
214     # rename the old one
215     old_mmake=old$(typeset -f mmake)
216     eval "${old_mmake}"
217     mmake()
218     {
219     local abi
220     local abis_to_run="${MULTILIB_ABIS}"
221    
222     # respect MULTILIB_ONLY_ABI variable
223     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
224    
225     for abi in ${abis_to_run}
226     do
227     echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}"
228     cd ${SRCDIR}-${abi}
229     abi-${abi} oldmmake $@ || die
230     done
231     }
232    
233     # rename the old one
234     old_minstall=old$(typeset -f minstall)
235     eval "${old_minstall}"
236     minstall()
237     {
238     local abi
239     local abis_to_run="${MULTILIB_ABIS}"
240    
241     # respect MULTILIB_ONLY_ABI variable
242     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
243    
244     for abi in ${abis_to_run}
245     do
246     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
247     cd ${SRCDIR}-${abi}
248     abi-${abi} oldminstall $@ || die
249     done
250     }
251    
252     minstall_destdir()
253     {
254     local abi
255     local abis_to_run="${MULTILIB_ABIS}"
256    
257     # respect MULTILIB_ONLY_ABI variable
258     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
259    
260     for abi in ${abis_to_run}
261     do
262     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
263     cd ${SRCDIR}-${abi}
264     make DESTDIR=${BINDIR} $@ install || die
265     done
266     }
267    
268     # rename the old one
269     old_mpatch=old$(typeset -f mpatch)
270     eval "${old_mpatch}"
271     mpatch()
272     {
273     local abi
274     local abis_to_run="${MULTILIB_ABIS}"
275    
276     # respect MULTILIB_ONLY_ABI variable
277     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
278    
279     for abi in ${abis_to_run}
280     do
281     echo -e "${COLBLUE}*** ${COLGREEN}appling patch for ABI -${abi}${COLDEFAULT}"
282     cd ${SRCDIR}-${abi}
283     oldmpatch $@ || die
284     done
285     }
286    
287     # rename the old one
288     old_mlibtoolize=old$(typeset -f mlibtoolize)
289     eval "${old_mlibtoolize}"
290     mlibtoolize()
291     {
292     local abi
293     local abis_to_run="${MULTILIB_ABIS}"
294    
295     # respect MULTILIB_ONLY_ABI variable
296     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
297    
298     for abi in ${abis_to_run}
299     do
300     echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}"
301     cd ${SRCDIR}-${abi}
302     oldmlibtoolize $@ || die
303     done
304     }
305    
306     minstalldocs()
307     {
308     local abi
309     local docfiles
310     docfiles="$@"
311    
312     local abis_to_run="${MULTILIB_ABIS}"
313    
314     # respect MULTILIB_ONLY_ABI variable
315     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
316    
317     for abi in ${abis_to_run}
318     do
319     cd ${SRCDIR}-${abi}
320     if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
321     then
322     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
323     fi
324    
325     for i in ${docfiles}
326     do
327     cat ${SRCDIR}-${abi}/${i} | gzip -9c > ${SRCDIR}-${abi}/${i}.gz || die "gzipping docs."
328     install -m 0644 ${SRCDIR}-${abi}/${i}.gz \
329     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
330     done
331     done
332     }
333    
334     ##
335     # multilib mbuild wrappers
336     ##
337     multilib_src_prepare()
338     {
339     munpack
340     }
341    
342     multilib_src_compile()
343     {
344     mconfigure
345     mmake
346     }
347    
348     multilib_src_install()
349     {
350     minstall_destdir
351    
352     local i
353     for abi in ${MULTILIB_ABIS}
354     do
355     cd ${SRCDIR}-${abi}
356     for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
357     FAQ LICENSE NEWS README TODO
358     do
359     if [ -f ${SRCDIR}-${abi}/${i} ]
360     then
361     minstalldocs ${i} || die
362     fi
363     done
364     done
365     }
366    
367     export_inherits multilib src_prepare src_compile src_install