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