Annotation of /smage/trunk/include/multilib.sminc
Parent Directory | Revision Log
Revision 11529 -
(hide annotations)
(download)
Thu Dec 21 09:38:37 2017 UTC (6 years, 10 months ago) by niro
File size: 10304 byte(s)
Thu Dec 21 09:38:37 2017 UTC (6 years, 10 months ago) by niro
File size: 10304 byte(s)
-updated from upstream
1 | niro | 1665 | # $Id$ |
2 | # multilib abis | ||
3 | |||
4 | niro | 3573 | # 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 | # multilib should call all dependant includes, which gets overridden | ||
11 | sminclude mtools | ||
12 | |||
13 | niro | 1665 | # do not define EMUL_LINUX_32 after inherit of multlib !! |
14 | # it may break i*86 builds | ||
15 | |||
16 | # default ABIs to be build | ||
17 | case ${ARCH} in | ||
18 | x86_64) | ||
19 | : ${MULTILIB_ABIS="m32 m64"} | ||
20 | # default false | ||
21 | : ${EMUL_LINUX_32="false"} | ||
22 | |||
23 | # add linux32 to the dependencies | ||
24 | if [[ ${EMUL_LINUX_32} = true ]] | ||
25 | then | ||
26 | niro | 3573 | EMUL_LINUX_32_SDEPEND_x86_64=">= sys-apps/util-linux-2.19" |
27 | niro | 1665 | SPECIAL_VARS="${SPECIAL_VARS} EMUL_LINUX_32_SDEPEND_x86_64" |
28 | fi | ||
29 | ;; | ||
30 | i*86) | ||
31 | : ${MULTILIB_ABIS="m32"} | ||
32 | # always false | ||
33 | EMUL_LINUX_32="false" | ||
34 | ;; | ||
35 | esac | ||
36 | |||
37 | # add linux32 to the dependencies | ||
38 | if [[ ${EMUL_LINUX_32} = true ]] | ||
39 | then | ||
40 | # very dirty trick to get the dependencies right | ||
41 | # ; is the IFS, tr replaces ; with an crlfs | ||
42 | # the var ist decided with our common eval+echo magic | ||
43 | if [[ -z ${SDEPEND} ]] | ||
44 | then | ||
45 | niro | 5869 | SDEPEND="$(marchsdepend EMUL_LINUX_32_SDEPEND)" |
46 | niro | 1665 | else |
47 | SDEPEND="${SDEPEND} | ||
48 | niro | 5869 | $(marchsdepend EMUL_LINUX_32_SDEPEND)" |
49 | niro | 1665 | fi |
50 | fi | ||
51 | |||
52 | ## | ||
53 | # overide some defaults to respect ABI_LIBDIR | ||
54 | ## | ||
55 | mlibdir() | ||
56 | { | ||
57 | local libdir=lib | ||
58 | [[ ${ARCH} = x86_64 ]] && libdir=lib64 | ||
59 | [[ -n ${ABI_LIBDIR} ]] && libdir="${ABI_LIBDIR}" | ||
60 | |||
61 | echo "${libdir}" | ||
62 | } | ||
63 | |||
64 | ## | ||
65 | # multilib abi changers | ||
66 | ## | ||
67 | abi-m32() | ||
68 | { | ||
69 | export ABI="m32" | ||
70 | export CC="gcc -${ABI}" | ||
71 | export CXX="g++ -${ABI}" | ||
72 | export ABI_LIBDIR="lib" | ||
73 | if [[ ${EXPORT_ABI_LDFLAGS} != false ]] | ||
74 | then | ||
75 | niro | 3573 | local saved_ldflags="${LDFLAGS}" |
76 | export LDFLAGS="${LDFLAGS} -L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}" | ||
77 | niro | 1665 | fi |
78 | # keep pkgconfig clean | ||
79 | local orig_pkg_config_path="${PKG_CONFIG_PATH}" | ||
80 | export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}" | ||
81 | |||
82 | niro | 3573 | if [[ ${MULTILIB_VERBOSE} = true ]] |
83 | niro | 1665 | then |
84 | niro | 3573 | echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}" |
85 | echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'" | ||
86 | echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'" | ||
87 | echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'" | ||
88 | echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'" | ||
89 | if [[ ${EXPORT_ABI_LDFLAGS} != false ]] | ||
90 | then | ||
91 | echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'" | ||
92 | else | ||
93 | echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${COLYELLOW}not exported${COLDEFAULT}'" | ||
94 | fi | ||
95 | echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'" | ||
96 | echo -e "${COLBLUE}*** ${COLGREEN} SRCDIR${COLDEFAULT}='${SRCDIR}/${SRCSUBDIR}'" | ||
97 | echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'" | ||
98 | niro | 1665 | fi |
99 | |||
100 | # configure a linux32 emulated build | ||
101 | if [[ ${EMUL_LINUX_32} = true ]] | ||
102 | then | ||
103 | niro | 3573 | if [[ ${MULTILIB_VERBOSE} = true ]] |
104 | then | ||
105 | echo -e "${COLBLUE}*** ${COLGREEN} EMUL_LINUX_32${COLDEFAULT}='${EMUL_LINUX_32}'" | ||
106 | fi | ||
107 | niro | 1665 | uname(){ linux32 uname $@; } && export -f uname |
108 | niro | 3573 | local orig_chost="${CHOST}" && export CHOST="i686-pc-linux-gnu" |
109 | niro | 1665 | fi |
110 | niro | 3573 | if [[ ${MULTILIB_VERBOSE} = true ]] |
111 | then | ||
112 | echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'" | ||
113 | fi | ||
114 | niro | 1665 | |
115 | # run any given command | ||
116 | niro | 11529 | if [[ ${MULTILIB_VERBOSE} = true ]] |
117 | then | ||
118 | echo -e "${COLGREEN}Executing:${COLDEFAULT} '$@'" | ||
119 | fi | ||
120 | niro | 1665 | eval $@ || die |
121 | |||
122 | niro | 3573 | unset ABI CC CXX ABI_LIBDIR |
123 | niro | 1665 | # keep pkgconfig clean |
124 | export PKG_CONFIG_PATH="${orig_pkg_config_path}" | ||
125 | niro | 3573 | export LDFLAGS="${saved_ldflags}" |
126 | niro | 1665 | |
127 | # restore original settings | ||
128 | if [[ ${EMUL_LINUX_32} = true ]] | ||
129 | then | ||
130 | unset uname | ||
131 | niro | 3573 | export CHOST="${orig_chost}" && unset orig_chost |
132 | niro | 1665 | fi |
133 | } | ||
134 | |||
135 | abi-m64() | ||
136 | { | ||
137 | export ABI="m64" | ||
138 | export CC="gcc -${ABI}" | ||
139 | export CXX="g++ -${ABI}" | ||
140 | export ABI_LIBDIR="lib64" | ||
141 | if [[ ${EXPORT_ABI_LDFLAGS} != false ]] | ||
142 | then | ||
143 | niro | 3573 | local saved_ldflags="${LDFLAGS}" |
144 | niro | 1665 | export LDFLAGS="-L/${ABI_LIBDIR} -L/usr/${ABI_LIBDIR}" |
145 | fi | ||
146 | # keep pkgconfig clean | ||
147 | local orig_pkg_config_path="${PKG_CONFIG_PATH}" | ||
148 | export PKG_CONFIG_PATH="/usr/${ABI_LIBDIR}/pkgconfig:${PKG_CONFIG_PATH}" | ||
149 | |||
150 | niro | 3573 | if [[ ${MULTILIB_VERBOSE} = true ]] |
151 | niro | 1665 | then |
152 | niro | 3573 | echo -e "${COLBLUE}*** ${COLGREEN}running with -${ABI} ABI${COLDEFAULT}" |
153 | echo -e "${COLBLUE}*** ${COLGREEN} ABI${COLDEFAULT}='${ABI}'" | ||
154 | echo -e "${COLBLUE}*** ${COLGREEN} CC${COLDEFAULT}='${CC}'" | ||
155 | echo -e "${COLBLUE}*** ${COLGREEN} CXX${COLDEFAULT}='${CXX}'" | ||
156 | echo -e "${COLBLUE}*** ${COLGREEN} ABI_LIBDIR${COLDEFAULT}='${ABI_LIBDIR}'" | ||
157 | if [[ ${EXPORT_ABI_LDFLAGS} != false ]] | ||
158 | then | ||
159 | echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${LDFLAGS}'" | ||
160 | else | ||
161 | echo -e "${COLBLUE}*** ${COLGREEN} LDFLAGS${COLDEFAULT}='${COLYELLOW}not exported${COLDEFAULT}'" | ||
162 | fi | ||
163 | echo -e "${COLBLUE}*** ${COLGREEN} CHOST${COLDEFAULT}='${CHOST}'" | ||
164 | echo -e "${COLBLUE}*** ${COLGREEN} SRCDIR${COLDEFAULT}='${SRCDIR}/${SRCSUBDIR}'" | ||
165 | echo -e "${COLBLUE}*** ${COLGREEN} PKG_CONFIG_PATH${COLDEFAULT}='${PKG_CONFIG_PATH}'" | ||
166 | niro | 1665 | fi |
167 | |||
168 | # run any given command | ||
169 | niro | 11529 | if [[ ${MULTILIB_VERBOSE} = true ]] |
170 | then | ||
171 | echo -e "${COLGREEN}Executing:${COLDEFAULT} '$@'" | ||
172 | fi | ||
173 | niro | 1665 | eval $@ || die |
174 | |||
175 | niro | 3573 | unset ABI CC CXX ABI_LIBDIR |
176 | niro | 1665 | # keep pkgconfig clean |
177 | export PKG_CONFIG_PATH="${orig_pkg_config_path}" | ||
178 | niro | 3573 | export LDFLAGS="${saved_ldflags}" |
179 | niro | 1665 | } |
180 | |||
181 | only-m32() | ||
182 | { | ||
183 | local abi=m32 | ||
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 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
194 | niro | 1665 | abi-${abi} $@ || die |
195 | |||
196 | # unset this is very important | ||
197 | unset MULTILIB_ONLY_ABI | ||
198 | fi | ||
199 | done | ||
200 | } | ||
201 | |||
202 | only-m64() | ||
203 | { | ||
204 | local abi=m64 | ||
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 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
215 | niro | 1665 | abi-${abi} $@ || die |
216 | |||
217 | # unset this is very important | ||
218 | unset MULTILIB_ONLY_ABI | ||
219 | fi | ||
220 | done | ||
221 | } | ||
222 | |||
223 | all-abis() | ||
224 | { | ||
225 | local abi | ||
226 | for abi in ${MULTILIB_ABIS} | ||
227 | do | ||
228 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
229 | niro | 1665 | abi-${abi} $@ || die |
230 | done | ||
231 | } | ||
232 | |||
233 | mabi() | ||
234 | { | ||
235 | echo \${ABI} | ||
236 | } | ||
237 | |||
238 | niro | 3573 | mabi-cc() |
239 | { | ||
240 | niro | 5461 | echo "gcc -\${ABI}" |
241 | niro | 3573 | } |
242 | |||
243 | mabi-cxx() | ||
244 | { | ||
245 | niro | 5461 | echo "g++ -\${ABI}" |
246 | niro | 3573 | } |
247 | |||
248 | mabi-cflags() | ||
249 | { | ||
250 | niro | 5461 | echo "\${CFLAGS}" |
251 | niro | 3573 | } |
252 | |||
253 | mabi-cxxflags() | ||
254 | { | ||
255 | niro | 5461 | echo "\${CXXFLAGS}" |
256 | niro | 3573 | } |
257 | |||
258 | mabi-ldflags() | ||
259 | { | ||
260 | niro | 5461 | echo "\${LDFLAGS}" |
261 | niro | 3573 | } |
262 | |||
263 | niro | 1665 | ## |
264 | # multilib compile functions | ||
265 | ## | ||
266 | |||
267 | if [[ ! -z $(typeset -f mconfigure) ]] | ||
268 | then | ||
269 | # rename the old one | ||
270 | old_mconfigure=old$(typeset -f mconfigure) | ||
271 | eval "${old_mconfigure}" | ||
272 | niro | 5461 | |
273 | niro | 1665 | mconfigure() |
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 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
284 | niro | 1665 | abi-${abi} oldmconfigure $@ || die |
285 | done | ||
286 | } | ||
287 | niro | 5461 | fi |
288 | niro | 1665 | |
289 | if [[ ! -z $(typeset -f munpack) ]] | ||
290 | then | ||
291 | # rename the old one | ||
292 | old_munpack=old$(typeset -f munpack) | ||
293 | eval "${old_munpack}" | ||
294 | niro | 5461 | |
295 | niro | 1665 | munpack() |
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}unpacking for ABI -${abi}${COLDEFAULT}" | ||
306 | niro | 4031 | oldmunpack $@ || die |
307 | niro | 1665 | mv ${SRCDIR} ${SRCDIR}-${abi} || die |
308 | done | ||
309 | } | ||
310 | niro | 5461 | fi |
311 | niro | 1665 | |
312 | if [[ ! -z $(typeset -f mmake) ]] | ||
313 | then | ||
314 | # rename the old one | ||
315 | old_mmake=old$(typeset -f mmake) | ||
316 | eval "${old_mmake}" | ||
317 | niro | 5461 | |
318 | niro | 1665 | mmake() |
319 | { | ||
320 | local abi | ||
321 | local abis_to_run="${MULTILIB_ABIS}" | ||
322 | |||
323 | # respect MULTILIB_ONLY_ABI variable | ||
324 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
325 | |||
326 | for abi in ${abis_to_run} | ||
327 | do | ||
328 | echo -e "${COLBLUE}*** ${COLGREEN}compiling for ABI -${abi}${COLDEFAULT}" | ||
329 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
330 | niro | 1665 | abi-${abi} oldmmake $@ || die |
331 | done | ||
332 | } | ||
333 | niro | 5461 | fi |
334 | niro | 1665 | |
335 | if [[ ! -z $(typeset -f minstall) ]] | ||
336 | then | ||
337 | # rename the old one | ||
338 | old_minstall=old$(typeset -f minstall) | ||
339 | eval "${old_minstall}" | ||
340 | niro | 5461 | |
341 | niro | 1665 | minstall() |
342 | { | ||
343 | local abi | ||
344 | local abis_to_run="${MULTILIB_ABIS}" | ||
345 | |||
346 | # respect MULTILIB_ONLY_ABI variable | ||
347 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
348 | |||
349 | for abi in ${abis_to_run} | ||
350 | do | ||
351 | echo -e "${COLBLUE}*** ${COLGREEN}installing for ABI -${abi}${COLDEFAULT}" | ||
352 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
353 | niro | 1665 | abi-${abi} oldminstall $@ || die |
354 | done | ||
355 | } | ||
356 | niro | 5461 | fi |
357 | niro | 1665 | |
358 | minstall_destdir() | ||
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}installing for ABI -${abi}${COLDEFAULT}" | ||
369 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
370 | niro | 1665 | make DESTDIR=${BINDIR} $@ install || die |
371 | done | ||
372 | } | ||
373 | |||
374 | if [[ ! -z $(typeset -f mpatch) ]] | ||
375 | then | ||
376 | # rename the old one | ||
377 | old_mpatch=old$(typeset -f mpatch) | ||
378 | eval "${old_mpatch}" | ||
379 | niro | 5461 | |
380 | niro | 1665 | mpatch() |
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}appling patch for ABI -${abi}${COLDEFAULT}" | ||
391 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
392 | niro | 1665 | oldmpatch $@ || die |
393 | done | ||
394 | } | ||
395 | niro | 5461 | fi |
396 | niro | 1665 | |
397 | if [[ ! -z $(typeset -f mlibtoolize) ]] | ||
398 | then | ||
399 | # rename the old one | ||
400 | old_mlibtoolize=old$(typeset -f mlibtoolize) | ||
401 | eval "${old_mlibtoolize}" | ||
402 | niro | 5461 | |
403 | niro | 1665 | mlibtoolize() |
404 | { | ||
405 | local abi | ||
406 | local abis_to_run="${MULTILIB_ABIS}" | ||
407 | |||
408 | # respect MULTILIB_ONLY_ABI variable | ||
409 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
410 | |||
411 | for abi in ${abis_to_run} | ||
412 | do | ||
413 | echo -e "${COLBLUE}*** ${COLGREEN}running mlibtoolize for ABI -${abi}${COLDEFAULT}" | ||
414 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
415 | niro | 1665 | oldmlibtoolize $@ || die |
416 | done | ||
417 | } | ||
418 | niro | 5461 | fi |
419 | niro | 1665 | |
420 | niro | 3573 | if [[ ! -z $(typeset -f mautoreconf) ]] |
421 | then | ||
422 | # rename the old one | ||
423 | old_mautoreconf=old$(typeset -f mautoreconf) | ||
424 | eval "${old_mautoreconf}" | ||
425 | niro | 5461 | |
426 | niro | 3573 | mautoreconf() |
427 | { | ||
428 | local abi | ||
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 | echo -e "${COLBLUE}*** ${COLGREEN}running mautoreconf for ABI -${abi}${COLDEFAULT}" | ||
437 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} | ||
438 | oldmautoreconf $@ || die | ||
439 | done | ||
440 | } | ||
441 | niro | 5461 | fi |
442 | niro | 3573 | |
443 | if [[ ! -z $(typeset -f minstalldocs) ]] | ||
444 | then | ||
445 | # rename the old one | ||
446 | old_minstalldocs=old$(typeset -f minstalldocs) | ||
447 | eval "${old_minstalldocs}" | ||
448 | niro | 5461 | |
449 | niro | 1665 | minstalldocs() |
450 | { | ||
451 | local abi | ||
452 | local docfiles | ||
453 | |||
454 | local abis_to_run="${MULTILIB_ABIS}" | ||
455 | |||
456 | # respect MULTILIB_ONLY_ABI variable | ||
457 | [[ ! -z ${MULTILIB_ONLY_ABI} ]] && abis_to_run="${MULTILIB_ONLY_ABI}" | ||
458 | |||
459 | for abi in ${abis_to_run} | ||
460 | do | ||
461 | niro | 3573 | cd ${SRCDIR}-${abi}/${SRCSUBDIR} |
462 | oldminstalldocs $@ || die | ||
463 | niro | 1665 | done |
464 | } | ||
465 | niro | 5461 | fi |