Annotation of /trunk/include/multilib.sminc
Parent Directory | Revision Log
Revision 9334 -
(hide annotations)
(download)
Sat Nov 26 13:37:05 2011 UTC (12 years, 11 months ago) by niro
Original Path: branches/magellan-next/include/multilib.sminc
File size: 10644 byte(s)
Sat Nov 26 13:37:05 2011 UTC (12 years, 11 months ago) by niro
Original Path: branches/magellan-next/include/multilib.sminc
File size: 10644 byte(s)
-added missing mautoreconf wrapper
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 | } | ||
264 | |||
265 | niro | 3671 | if [[ ! -z $(typeset -f munpack) ]] |
266 | then | ||
267 | # rename the old one | ||
268 | old_munpack=old$(typeset -f munpack) | ||
269 | eval "${old_munpack}" | ||
270 | fi | ||
271 | niro | 2 | munpack() |
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}unpacking for ABI -${abi}${COLDEFAULT}" | ||
282 | niro | 5486 | oldmunpack ${SRCFILE} || die |
283 | niro | 2 | mv ${SRCDIR} ${SRCDIR}-${abi} || die |
284 | done | ||
285 | } | ||
286 | |||
287 | niro | 3671 | if [[ ! -z $(typeset -f mmake) ]] |
288 | then | ||
289 | # rename the old one | ||
290 | old_mmake=old$(typeset -f mmake) | ||
291 | eval "${old_mmake}" | ||
292 | fi | ||
293 | niro | 2 | mmake() |
294 | { | ||
295 | local abi | ||
296 | local abis_to_run="${MULTILIB_ABIS}" | ||
297 | |||
298 | # respect MULTILIB_ONLY_ABI variable | ||
299 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
300 | |||
301 | for abi in ${abis_to_run} | ||
302 | do | ||
303 | echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}" | ||
304 | cd ${SRCDIR}-${abi} | ||
305 | abi-${abi} oldmmake $@ || die | ||
306 | done | ||
307 | } | ||
308 | |||
309 | niro | 3671 | if [[ ! -z $(typeset -f minstall) ]] |
310 | then | ||
311 | # rename the old one | ||
312 | old_minstall=old$(typeset -f minstall) | ||
313 | eval "${old_minstall}" | ||
314 | fi | ||
315 | niro | 2 | minstall() |
316 | { | ||
317 | local abi | ||
318 | local abis_to_run="${MULTILIB_ABIS}" | ||
319 | |||
320 | # respect MULTILIB_ONLY_ABI variable | ||
321 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
322 | |||
323 | for abi in ${abis_to_run} | ||
324 | do | ||
325 | echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}" | ||
326 | cd ${SRCDIR}-${abi} | ||
327 | abi-${abi} oldminstall $@ || die | ||
328 | done | ||
329 | } | ||
330 | |||
331 | minstall_destdir() | ||
332 | { | ||
333 | local abi | ||
334 | local abis_to_run="${MULTILIB_ABIS}" | ||
335 | |||
336 | # respect MULTILIB_ONLY_ABI variable | ||
337 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
338 | |||
339 | for abi in ${abis_to_run} | ||
340 | do | ||
341 | echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}" | ||
342 | cd ${SRCDIR}-${abi} | ||
343 | make DESTDIR=${BINDIR} $@ install || die | ||
344 | done | ||
345 | } | ||
346 | |||
347 | niro | 3671 | if [[ ! -z $(typeset -f mpatch) ]] |
348 | then | ||
349 | # rename the old one | ||
350 | old_mpatch=old$(typeset -f mpatch) | ||
351 | eval "${old_mpatch}" | ||
352 | fi | ||
353 | niro | 2 | mpatch() |
354 | { | ||
355 | local abi | ||
356 | local abis_to_run="${MULTILIB_ABIS}" | ||
357 | |||
358 | # respect MULTILIB_ONLY_ABI variable | ||
359 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
360 | |||
361 | for abi in ${abis_to_run} | ||
362 | do | ||
363 | echo -e "${COLBLUE}*** ${COLGREEN}appling patch for ABI -${abi}${COLDEFAULT}" | ||
364 | cd ${SRCDIR}-${abi} | ||
365 | oldmpatch $@ || die | ||
366 | done | ||
367 | } | ||
368 | |||
369 | niro | 3671 | if [[ ! -z $(typeset -f mlibtoolize) ]] |
370 | then | ||
371 | # rename the old one | ||
372 | old_mlibtoolize=old$(typeset -f mlibtoolize) | ||
373 | eval "${old_mlibtoolize}" | ||
374 | fi | ||
375 | niro | 2 | mlibtoolize() |
376 | { | ||
377 | local abi | ||
378 | local abis_to_run="${MULTILIB_ABIS}" | ||
379 | |||
380 | # respect MULTILIB_ONLY_ABI variable | ||
381 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
382 | |||
383 | for abi in ${abis_to_run} | ||
384 | do | ||
385 | echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}" | ||
386 | cd ${SRCDIR}-${abi} | ||
387 | oldmlibtoolize $@ || die | ||
388 | done | ||
389 | } | ||
390 | |||
391 | niro | 9334 | if [[ ! -z $(typeset -f mautoreconf) ]] |
392 | then | ||
393 | # rename the old one | ||
394 | old_mautoreconf=old$(typeset -f mautoreconf) | ||
395 | eval "${old_mautoreconf}" | ||
396 | fi | ||
397 | mautoreconf() | ||
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}running mautoreconf for ABI -${abi}${COLDEFAULT}" | ||
408 | cd ${SRCDIR}-${abi} | ||
409 | oldmautoreconf $@ || die | ||
410 | done | ||
411 | } | ||
412 | |||
413 | niro | 9333 | if [[ ! -z $(typeset -f minstalldocs) ]] |
414 | then | ||
415 | # rename the old one | ||
416 | old_minstalldocs=old$(typeset -f minstalldocs) | ||
417 | eval "${old_minstalldocs}" | ||
418 | fi | ||
419 | niro | 2 | minstalldocs() |
420 | { | ||
421 | local abi | ||
422 | local docfiles | ||
423 | docfiles="$@" | ||
424 | |||
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 | cd ${SRCDIR}-${abi} | ||
433 | if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ] | ||
434 | then | ||
435 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." | ||
436 | fi | ||
437 | |||
438 | for i in ${docfiles} | ||
439 | do | ||
440 | cat ${SRCDIR}-${abi}/${i} | gzip -9c > ${SRCDIR}-${abi}/${i}.gz || die "gzipping docs." | ||
441 | install -m 0644 ${SRCDIR}-${abi}/${i}.gz \ | ||
442 | ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." | ||
443 | done | ||
444 | done | ||
445 | } | ||
446 | |||
447 | ## | ||
448 | # multilib mbuild wrappers | ||
449 | ## | ||
450 | multilib_src_prepare() | ||
451 | { | ||
452 | munpack | ||
453 | } | ||
454 | |||
455 | multilib_src_compile() | ||
456 | { | ||
457 | mconfigure | ||
458 | mmake | ||
459 | } | ||
460 | |||
461 | multilib_src_install() | ||
462 | { | ||
463 | minstall_destdir | ||
464 | |||
465 | local i | ||
466 | for abi in ${MULTILIB_ABIS} | ||
467 | do | ||
468 | cd ${SRCDIR}-${abi} | ||
469 | for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ | ||
470 | FAQ LICENSE NEWS README TODO | ||
471 | do | ||
472 | if [ -f ${SRCDIR}-${abi}/${i} ] | ||
473 | then | ||
474 | minstalldocs ${i} || die | ||
475 | fi | ||
476 | done | ||
477 | done | ||
478 | } | ||
479 | |||
480 | export_inherits multilib src_prepare src_compile src_install |