Magellan Linux

Annotation of /trunk/include/multilib.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13972 - (hide annotations) (download)
Fri Nov 2 10:45:29 2012 UTC (12 years ago) by niro
File size: 11374 byte(s)
-enforce linux32 on request
1 niro 6346 # $Id$
2 niro 2 # multilib abis
3    
4 niro 11547 # tell the buildsystem that we are doing a multilib build
5     export MULTILIB_BUILD="true"
6 niro 11544
7 niro 8334 # be verbose or nor (true|false}
8     : ${MULTILIB_VERBOSE="true"}
9    
10 niro 11029 # multilib should call all dependant includes, which gets overridden
11 niro 11030 sminclude mtools
12 niro 11029
13 niro 2 # do not define EMUL_LINUX_32 after inherit of multlib !!
14     # it may break i*86 builds
15    
16     # default ABIs to be build
17     case ${ARCH} in
18     x86_64)
19     : ${MULTILIB_ABIS="m32 m64"}
20     # default false
21     : ${EMUL_LINUX_32="false"}
22    
23     # add linux32 to the dependencies
24     if [[ ${EMUL_LINUX_32} = true ]]
25     then
26 niro 7554 EMUL_LINUX_32_SDEPEND_x86_64=">= sys-apps/util-linux-2.19"
27 niro 6406 SPECIAL_VARS="${SPECIAL_VARS} EMUL_LINUX_32_SDEPEND_x86_64"
28 niro 2 fi
29     ;;
30     i*86)
31     : ${MULTILIB_ABIS="m32"}
32     # always false
33     EMUL_LINUX_32="false"
34     ;;
35     esac
36    
37     # add linux32 to the dependencies
38     if [[ ${EMUL_LINUX_32} = true ]]
39     then
40     # very dirty trick to get the dependencies right
41     # ; is the IFS, tr replaces ; with an crlfs
42     # the var ist decided with our common eval+echo magic
43     if [[ -z ${SDEPEND} ]]
44     then
45 niro 6406 SDEPEND="\$(eval echo \\\$EMUL_LINUX_32_SDEPEND_\${ARCH/i*86/x86} | tr ';' '\n')"
46 niro 2 else
47     SDEPEND="${SDEPEND}
48 niro 6406 \$(eval echo \\\$EMUL_LINUX_32_SDEPEND_\${ARCH/i*86/x86} | tr ';' '\n')"
49 niro 2 fi
50     fi
51    
52     ##
53     # overide some defaults to respect ABI_LIBDIR
54     ##
55     mlibdir()
56     {
57     local libdir=lib
58     [[ ${ARCH} = x86_64 ]] && libdir=lib64
59     [[ -n ${ABI_LIBDIR} ]] && libdir="${ABI_LIBDIR}"
60    
61     echo "${libdir}"
62     }
63    
64     ##
65     # multilib abi changers
66     ##
67     abi-m32()
68     {
69     export ABI="m32"
70     export CC="gcc -${ABI}"
71     export CXX="g++ -${ABI}"
72     export ABI_LIBDIR="lib"
73 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
74     then
75 niro 11300 local saved_ldflags="${LDFLAGS}"
76     export LDFLAGS="${LDFLAGS} -L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}"
77 niro 307 fi
78 niro 5371 # keep pkgconfig clean
79     local orig_pkg_config_path="${PKG_CONFIG_PATH}"
80     export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}"
81 niro 2
82 niro 8334 if [[ ${MULTILIB_VERBOSE} = true ]]
83 niro 307 then
84 niro 8334 echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}"
85     echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'"
86     echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'"
87     echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'"
88     echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'"
89     if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
90     then
91     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'"
92     else
93     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${COLYELLOW}not exported${COLDEFAULT}'"
94     fi
95 niro 11525 echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
96     echo -e "${COLBLUE}*** ${COLGREEN} SRCDIR${COLDEFAULT}='${SRCDIR}/${SRCSUBDIR}'"
97 niro 8334 echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'"
98 niro 307 fi
99 niro 2
100     # configure a linux32 emulated build
101 niro 13972 local linux32
102 niro 2 if [[ ${EMUL_LINUX_32} = true ]]
103     then
104 niro 8334 if [[ ${MULTILIB_VERBOSE} = true ]]
105     then
106     echo -e "${COLBLUE}*** ${COLGREEN} EMUL_LINUX_32${COLDEFAULT}='${EMUL_LINUX_32}'"
107     fi
108 niro 2 uname(){ linux32 uname $@; } && export -f uname
109 niro 11830 local orig_chost="${CHOST}" && export CHOST="i686-pc-linux-gnu"
110 niro 13972 linux32="linux32"
111 niro 2 fi
112 niro 8334 if [[ ${MULTILIB_VERBOSE} = true ]]
113     then
114     echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
115     fi
116 niro 2
117     # run any given command
118 niro 13972 eval ${linux32} $@ || die
119 niro 2
120 niro 11300 unset ABI CC CXX ABI_LIBDIR
121 niro 5371 # keep pkgconfig clean
122     export PKG_CONFIG_PATH="${orig_pkg_config_path}"
123 niro 11300 export LDFLAGS="${saved_ldflags}"
124 niro 2
125     # restore original settings
126     if [[ ${EMUL_LINUX_32} = true ]]
127     then
128     unset uname
129 niro 11830 export CHOST="${orig_chost}" && unset orig_chost
130 niro 13972 unset linux32
131 niro 2 fi
132     }
133    
134     abi-m64()
135     {
136     export ABI="m64"
137     export CC="gcc -${ABI}"
138     export CXX="g++ -${ABI}"
139     export ABI_LIBDIR="lib64"
140 niro 307 if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
141     then
142 niro 11300 local saved_ldflags="${LDFLAGS}"
143 niro 307 export LDFLAGS="-L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}"
144     fi
145 niro 5371 # keep pkgconfig clean
146     local orig_pkg_config_path="${PKG_CONFIG_PATH}"
147     export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}"
148 niro 2
149 niro 8334 if [[ ${MULTILIB_VERBOSE} = true ]]
150 niro 307 then
151 niro 8334 echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}"
152     echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'"
153     echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'"
154     echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'"
155     echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'"
156     if [[ ${EXPORT_ABI_LDFLAGS} != false ]]
157     then
158     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'"
159     else
160     echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${COLYELLOW}not exported${COLDEFAULT}'"
161     fi
162     echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'"
163 niro 11525 echo -e "${COLBLUE}*** ${COLGREEN} SRCDIR${COLDEFAULT}='${SRCDIR}/${SRCSUBDIR}'"
164 niro 8334 echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'"
165 niro 307 fi
166 niro 2
167     # run any given command
168     eval $@ || die
169    
170 niro 11300 unset ABI CC CXX ABI_LIBDIR
171 niro 5371 # keep pkgconfig clean
172     export PKG_CONFIG_PATH="${orig_pkg_config_path}"
173 niro 11300 export LDFLAGS="${saved_ldflags}"
174 niro 2 }
175    
176     only-m32()
177     {
178     local abi=m32
179     local i
180    
181     for i in ${MULTILIB_ABIS}
182     do
183     if [[ ${i} = ${abi} ]]
184     then
185     # export this for mpatch etc (to repect only-${abi})
186     export MULTILIB_ONLY_ABI=${abi}
187    
188 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
189 niro 2 abi-${abi} $@ || die
190    
191     # unset this is very important
192     unset MULTILIB_ONLY_ABI
193     fi
194     done
195     }
196    
197     only-m64()
198     {
199     local abi=m64
200     local i
201    
202     for i in ${MULTILIB_ABIS}
203     do
204     if [[ ${i} = ${abi} ]]
205     then
206     # export this for mpatch etc (to repect only-${abi})
207     export MULTILIB_ONLY_ABI=${abi}
208    
209 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
210 niro 2 abi-${abi} $@ || die
211    
212     # unset this is very important
213     unset MULTILIB_ONLY_ABI
214     fi
215     done
216     }
217    
218     all-abis()
219     {
220     local abi
221     for abi in ${MULTILIB_ABIS}
222     do
223 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
224 niro 2 abi-${abi} $@ || die
225     done
226     }
227    
228 niro 6346 mabi()
229     {
230     echo \${ABI}
231     }
232    
233 niro 11825 mabi-cc()
234     {
235 niro 11827 echo "\"gcc -\${ABI}\""
236 niro 11825 }
237    
238     mabi-cxx()
239     {
240 niro 11827 echo "\"g++ -\${ABI}\""
241 niro 11825 }
242    
243 niro 11828 mabi-cflags()
244     {
245     echo "\"\${CFLAGS}\""
246     }
247    
248     mabi-cxxflags()
249     {
250     echo "\"\${CXXFLAGS}\""
251     }
252    
253     mabi-ldflags()
254     {
255     echo "\"\${LDFLAGS}\""
256     }
257    
258 niro 2 ##
259     # multilib compile functions
260     ##
261    
262 niro 3671 if [[ ! -z $(typeset -f mconfigure) ]]
263     then
264     # rename the old one
265     old_mconfigure=old$(typeset -f mconfigure)
266 niro 4783 eval "${old_mconfigure}"
267 niro 3671 fi
268 niro 2 mconfigure()
269     {
270     local abi
271     local abis_to_run="${MULTILIB_ABIS}"
272    
273     # respect MULTILIB_ONLY_ABI variable
274     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
275    
276     for abi in ${abis_to_run}
277     do
278 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
279 niro 2 abi-${abi} oldmconfigure $@ || die
280     done
281     }
282    
283 niro 4780 if [[ ! -z $(typeset -f cmake_configure) ]]
284     then
285     # rename the old one
286     old_cmake_configure=old$(typeset -f cmake_configure)
287 niro 4783 eval "${old_cmake_configure}"
288 niro 4780 fi
289     cmake_configure()
290     {
291     local abi
292     local abis_to_run="${MULTILIB_ABIS}"
293    
294     # respect MULTILIB_ONLY_ABI variable
295     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
296    
297     local saved_SRCDIR="${SRCDIR}"
298     for abi in ${abis_to_run}
299     do
300     SRCDIR="${saved_SRCDIR}-${abi}"
301 niro 11531 cd ${SRCDIR}/${SRCSUBDIR}
302 niro 4780 abi-${abi} oldcmake_configure $@ || die
303     done
304 niro 9367 # restore SRCDIR
305     SRCDIR="${saved_SRCDIR}"
306 niro 4780 }
307    
308 niro 3671 if [[ ! -z $(typeset -f munpack) ]]
309     then
310     # rename the old one
311     old_munpack=old$(typeset -f munpack)
312     eval "${old_munpack}"
313     fi
314 niro 2 munpack()
315     {
316     local abi
317     local abis_to_run="${MULTILIB_ABIS}"
318    
319     # respect MULTILIB_ONLY_ABI variable
320     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
321    
322     for abi in ${abis_to_run}
323     do
324     echo -e "${COLBLUE}*** ${COLGREEN}unpacking for ABI -${abi}${COLDEFAULT}"
325 niro 13488 oldmunpack $@ || die
326 niro 2 mv ${SRCDIR} ${SRCDIR}-${abi} || die
327     done
328     }
329    
330 niro 3671 if [[ ! -z $(typeset -f mmake) ]]
331     then
332     # rename the old one
333     old_mmake=old$(typeset -f mmake)
334     eval "${old_mmake}"
335     fi
336 niro 2 mmake()
337     {
338     local abi
339     local abis_to_run="${MULTILIB_ABIS}"
340    
341     # respect MULTILIB_ONLY_ABI variable
342     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
343    
344     for abi in ${abis_to_run}
345     do
346     echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}"
347 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
348 niro 2 abi-${abi} oldmmake $@ || die
349     done
350     }
351    
352 niro 3671 if [[ ! -z $(typeset -f minstall) ]]
353     then
354     # rename the old one
355     old_minstall=old$(typeset -f minstall)
356     eval "${old_minstall}"
357     fi
358 niro 2 minstall()
359     {
360     local abi
361     local abis_to_run="${MULTILIB_ABIS}"
362    
363     # respect MULTILIB_ONLY_ABI variable
364     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
365    
366     for abi in ${abis_to_run}
367     do
368     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
369 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
370 niro 2 abi-${abi} oldminstall $@ || die
371     done
372     }
373    
374     minstall_destdir()
375     {
376     local abi
377     local abis_to_run="${MULTILIB_ABIS}"
378    
379     # respect MULTILIB_ONLY_ABI variable
380     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
381    
382     for abi in ${abis_to_run}
383     do
384     echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}"
385 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
386 niro 2 make DESTDIR=${BINDIR} $@ install || die
387     done
388     }
389    
390 niro 3671 if [[ ! -z $(typeset -f mpatch) ]]
391     then
392     # rename the old one
393     old_mpatch=old$(typeset -f mpatch)
394     eval "${old_mpatch}"
395     fi
396 niro 2 mpatch()
397     {
398     local abi
399     local abis_to_run="${MULTILIB_ABIS}"
400    
401     # respect MULTILIB_ONLY_ABI variable
402     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
403    
404     for abi in ${abis_to_run}
405     do
406     echo -e "${COLBLUE}*** ${COLGREEN}appling patch for ABI -${abi}${COLDEFAULT}"
407 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
408 niro 2 oldmpatch $@ || die
409     done
410     }
411    
412 niro 3671 if [[ ! -z $(typeset -f mlibtoolize) ]]
413     then
414     # rename the old one
415     old_mlibtoolize=old$(typeset -f mlibtoolize)
416     eval "${old_mlibtoolize}"
417     fi
418 niro 2 mlibtoolize()
419     {
420     local abi
421     local abis_to_run="${MULTILIB_ABIS}"
422    
423     # respect MULTILIB_ONLY_ABI variable
424     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
425    
426     for abi in ${abis_to_run}
427     do
428     echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}"
429 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
430 niro 2 oldmlibtoolize $@ || die
431     done
432     }
433    
434 niro 9334 if [[ ! -z $(typeset -f mautoreconf) ]]
435     then
436     # rename the old one
437     old_mautoreconf=old$(typeset -f mautoreconf)
438     eval "${old_mautoreconf}"
439     fi
440     mautoreconf()
441     {
442     local abi
443     local abis_to_run="${MULTILIB_ABIS}"
444    
445     # respect MULTILIB_ONLY_ABI variable
446     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
447    
448     for abi in ${abis_to_run}
449     do
450     echo -e "${COLBLUE}*** ${COLGREEN}running mautoreconf for ABI -${abi}${COLDEFAULT}"
451 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
452 niro 9334 oldmautoreconf $@ || die
453     done
454     }
455    
456 niro 9333 if [[ ! -z $(typeset -f minstalldocs) ]]
457     then
458     # rename the old one
459     old_minstalldocs=old$(typeset -f minstalldocs)
460     eval "${old_minstalldocs}"
461     fi
462 niro 2 minstalldocs()
463     {
464     local abi
465     local docfiles
466    
467     local abis_to_run="${MULTILIB_ABIS}"
468    
469     # respect MULTILIB_ONLY_ABI variable
470     [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}"
471    
472     for abi in ${abis_to_run}
473     do
474 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
475 niro 9756 oldminstalldocs $@ || die
476 niro 2 done
477     }
478    
479     ##
480     # multilib mbuild wrappers
481     ##
482     multilib_src_prepare()
483     {
484 niro 13526 munpack ${SRCFILE}
485 niro 2 }
486    
487     multilib_src_compile()
488     {
489     mconfigure
490     mmake
491     }
492    
493 niro 9902 multilib_src_check()
494     {
495 niro 9934 mmake -j1 -k check || die
496 niro 9902 }
497    
498 niro 2 multilib_src_install()
499     {
500     minstall_destdir
501    
502     local i
503     for abi in ${MULTILIB_ABIS}
504     do
505 niro 11522 cd ${SRCDIR}-${abi}/${SRCSUBDIR}
506 niro 2 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
507     FAQ LICENSE NEWS README TODO
508     do
509     if [ -f ${SRCDIR}-${abi}/${i} ]
510     then
511     minstalldocs ${i} || die
512     fi
513     done
514     done
515     }
516    
517 niro 9902 export_inherits multilib src_prepare src_compile src_check src_install