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