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