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