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