| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2007 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.22 2005/02/14 11:33:11 eradicator Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.63 2007/07/01 23:14:58 peper Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Jeremy Huddleston <eradicator@gentoo.org> |
5 | # Maintainer: amd64@gentoo.org / toolchain@gentoo.org |
| 6 | # |
6 | # |
| 7 | # This eclass is for all functions pertaining to handling multilib. |
7 | # This eclass is for all functions pertaining to handling multilib. |
| 8 | # configurations. |
8 | # configurations. |
| 9 | |
9 | |
| 10 | ECLASS=multilib |
10 | ___ECLASS_RECUR_MULTILIB="yes" |
| 11 | INHERITED="$INHERITED $ECLASS" |
11 | [[ -z ${___ECLASS_RECUR_TOOLCHAIN_FUNCS} ]] && inherit toolchain-funcs |
| 12 | |
|
|
| 13 | DESCRIPTION="Based on the ${ECLASS} eclass" |
|
|
| 14 | |
12 | |
| 15 | # has_multilib_profile: |
13 | # has_multilib_profile: |
| 16 | # Return true if the current profile is a multilib profile and lists more than |
14 | # Return true if the current profile is a multilib profile and lists more than |
| 17 | # one abi in ${MULTILIB_ABIS}. You might want to use this like |
15 | # one abi in ${MULTILIB_ABIS}. When has_multilib_profile returns true, that |
| 18 | # 'use multilib || has_multilib_profile' until all profiles utilizing the |
16 | # profile should enable the 'multilib' use flag. This is so you can DEPEND on |
| 19 | # 'multilib' use flag are removed from portage |
17 | # a package only for multilib or not multilib. |
| 20 | |
18 | |
| 21 | # is_final_abi: |
19 | # is_final_abi: |
| 22 | # Return true if ${ABI} is the final abi to be installed (and thus we are |
20 | # Return true if ${ABI} is the final abi to be installed (and thus we are |
| 23 | # on our last run through a src_* function. |
21 | # on our last run through a src_* function. |
| 24 | |
22 | |
| … | |
… | |
| 84 | # |
82 | # |
| 85 | # Example: |
83 | # Example: |
| 86 | # create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64 |
84 | # create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64 |
| 87 | # create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64 |
85 | # create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64 |
| 88 | |
86 | |
|
|
87 | # get_libname [version] |
|
|
88 | # returns libname with proper suffix {.so,.dylib} and optionally supplied version |
|
|
89 | # for ELF/MACH-O shared objects |
|
|
90 | # |
|
|
91 | # Example: |
|
|
92 | # get_libname libfoo ${PV} |
|
|
93 | # Returns: libfoo.so.${PV} (ELF) || libfoo.${PV}.dylib (MACH) |
|
|
94 | |
| 89 | ### END DOCUMENTATION ### |
95 | ### END DOCUMENTATION ### |
| 90 | |
96 | |
| 91 | # Defaults: |
97 | # Defaults: |
| 92 | export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"} |
98 | export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"} |
| 93 | export DEFAULT_ABI=${DEFAULT_ABI:-"default"} |
99 | export DEFAULT_ABI=${DEFAULT_ABI:-"default"} |
| 94 | export ABI=${ABI:-"default"} |
|
|
| 95 | export CFLAGS_default="" |
100 | export CFLAGS_default |
| 96 | export LDFLAGS_default="" |
101 | export LDFLAGS_default |
| 97 | export CHOST_default=${CHOST} |
102 | export CHOST_default=${CHOST_default:-${CHOST}} |
|
|
103 | export CTARGET_default=${CTARGET_default:-${CTARGET:-${CHOST_default}}} |
| 98 | export LIBDIR_default=${CONF_LIBDIR:-"lib"} |
104 | export LIBDIR_default=${CONF_LIBDIR:-"lib"} |
| 99 | export CDEFINE_default="__unix__" |
105 | export CDEFINE_default="__unix__" |
|
|
106 | export KERNEL_ABI=${KERNEL_ABI:-${DEFAULT_ABI}} |
| 100 | |
107 | |
| 101 | # has_multilib_profile() |
108 | # has_multilib_profile() |
| 102 | has_multilib_profile() { |
109 | has_multilib_profile() { |
| 103 | [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ] |
110 | [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ] |
| 104 | } |
111 | } |
| … | |
… | |
| 168 | # If <ABI> is not specified and ${ABI} is not defined, ${DEFAULT_ABI} is used. |
175 | # If <ABI> is not specified and ${ABI} is not defined, ${DEFAULT_ABI} is used. |
| 169 | # If <ABI> is not specified and ${ABI} and ${DEFAULT_ABI} are not defined, we return an empty string. |
176 | # If <ABI> is not specified and ${ABI} and ${DEFAULT_ABI} are not defined, we return an empty string. |
| 170 | # |
177 | # |
| 171 | # Jeremy Huddleston <eradicator@gentoo.org> |
178 | # Jeremy Huddleston <eradicator@gentoo.org> |
| 172 | get_abi_var() { |
179 | get_abi_var() { |
| 173 | local flag=${1} |
180 | local flag=$1 |
| 174 | local abi |
181 | local abi |
| 175 | if [ $# -gt 1 ]; then |
182 | if [ $# -gt 1 ]; then |
| 176 | abi=${2} |
183 | abi=${2} |
| 177 | elif [ -n "${ABI}" ]; then |
184 | elif [ -n "${ABI}" ]; then |
| 178 | abi=${ABI} |
185 | abi=${ABI} |
| … | |
… | |
| 184 | |
191 | |
| 185 | local var="${flag}_${abi}" |
192 | local var="${flag}_${abi}" |
| 186 | echo ${!var} |
193 | echo ${!var} |
| 187 | } |
194 | } |
| 188 | |
195 | |
| 189 | get_abi_CFLAGS() { get_abi_var CFLAGS "${@}"; } |
196 | get_abi_CFLAGS() { get_abi_var CFLAGS "$@"; } |
|
|
197 | get_abi_ASFLAGS() { get_abi_var ASFLAGS "$@"; } |
| 190 | get_abi_LDFLAGS() { get_abi_var LDFLAGS "${@}"; } |
198 | get_abi_LDFLAGS() { get_abi_var LDFLAGS "$@"; } |
| 191 | get_abi_CHOST() { get_abi_var CHOST "${@}"; } |
199 | get_abi_CHOST() { get_abi_var CHOST "$@"; } |
|
|
200 | get_abi_CTARGET() { get_abi_var CTARGET "$@"; } |
|
|
201 | get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "$@"; } |
| 192 | get_abi_CDEFINE() { get_abi_var CDEFINE "${@}"; } |
202 | get_abi_CDEFINE() { get_abi_var CDEFINE "$@"; } |
| 193 | get_abi_LIBDIR() { get_abi_var LIBDIR "${@}"; } |
203 | get_abi_LIBDIR() { get_abi_var LIBDIR "$@"; } |
| 194 | |
204 | |
| 195 | # Return a list of the ABIs we want to install for with |
205 | # Return a list of the ABIs we want to install for with |
| 196 | # the last one in the list being the default. |
206 | # the last one in the list being the default. |
| 197 | get_install_abis() { |
207 | get_install_abis() { |
| 198 | local order="" |
208 | local order="" |
| 199 | |
209 | |
| 200 | if [ -z "${MULTILIB_ABIS}" ]; then |
210 | if [[ -z ${MULTILIB_ABIS} ]] ; then |
| 201 | echo "default" |
211 | echo "default" |
| 202 | return 0 |
212 | return 0 |
| 203 | fi |
213 | fi |
| 204 | |
214 | |
| 205 | if hasq multilib-pkg-force ${RESTRICT} || |
215 | if [[ ${EMULTILIB_PKG} == "true" ]] ; then |
| 206 | { hasq multilib-pkg ${FEATURES} && hasq multilib-pkg ${RESTRICT}; }; then |
|
|
| 207 | for x in ${MULTILIB_ABIS}; do |
216 | for x in ${MULTILIB_ABIS} ; do |
| 208 | if [ "${x}" != "${DEFAULT_ABI}" ]; then |
217 | if [[ ${x} != "${DEFAULT_ABI}" ]] ; then |
| 209 | hasq ${x} ${ABI_DENY} || ordera="${ordera} ${x}" |
218 | hasq ${x} ${ABI_DENY} || ordera="${ordera} ${x}" |
| 210 | fi |
219 | fi |
| 211 | done |
220 | done |
| 212 | hasq ${DEFAULT_ABI} ${ABI_DENY} || order="${ordera} ${DEFAULT_ABI}" |
221 | hasq ${DEFAULT_ABI} ${ABI_DENY} || order="${ordera} ${DEFAULT_ABI}" |
| 213 | |
222 | |
| 214 | if [ -n "${ABI_ALLOW}" ]; then |
223 | if [[ -n ${ABI_ALLOW} ]] ; then |
| 215 | local ordera="" |
224 | local ordera="" |
| 216 | for x in ${order}; do |
225 | for x in ${order} ; do |
| 217 | if hasq ${x} ${ABI_ALLOW}; then |
226 | if hasq ${x} ${ABI_ALLOW} ; then |
| 218 | ordera="${ordera} ${x}" |
227 | ordera="${ordera} ${x}" |
| 219 | fi |
228 | fi |
| 220 | done |
229 | done |
| 221 | order="${ordera}" |
230 | order=${ordera} |
| 222 | fi |
231 | fi |
| 223 | else |
232 | else |
| 224 | order="${DEFAULT_ABI}" |
233 | order=${DEFAULT_ABI} |
| 225 | fi |
234 | fi |
| 226 | |
235 | |
| 227 | if [ -z "${order}" ]; then |
236 | if [[ -z ${order} ]] ; then |
| 228 | die "The ABI list is empty. Are you using a proper multilib profile? Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package." |
237 | die "The ABI list is empty. Are you using a proper multilib profile? Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package." |
| 229 | fi |
238 | fi |
| 230 | |
239 | |
| 231 | echo ${order} |
240 | echo ${order} |
| 232 | return 0 |
241 | return 0 |
| … | |
… | |
| 235 | # Return a list of the ABIs supported by this profile. |
244 | # Return a list of the ABIs supported by this profile. |
| 236 | # the last one in the list being the default. |
245 | # the last one in the list being the default. |
| 237 | get_all_abis() { |
246 | get_all_abis() { |
| 238 | local order="" |
247 | local order="" |
| 239 | |
248 | |
| 240 | if [ -z "${MULTILIB_ABIS}" ]; then |
249 | if [[ -z ${MULTILIB_ABIS} ]] ; then |
| 241 | echo "default" |
250 | echo "default" |
| 242 | return 0 |
251 | return 0 |
| 243 | fi |
252 | fi |
| 244 | |
253 | |
| 245 | for x in ${MULTILIB_ABIS}; do |
254 | for x in ${MULTILIB_ABIS}; do |
| 246 | if [ "${x}" != "${DEFAULT_ABI}" ]; then |
255 | if [[ ${x} != ${DEFAULT_ABI} ]] ; then |
| 247 | order="${order:+${order }}${x}" |
256 | order="${order:+${order} }${x}" |
| 248 | fi |
257 | fi |
| 249 | done |
258 | done |
| 250 | order="${order:+${order} }${DEFAULT_ABI}" |
259 | order="${order:+${order} }${DEFAULT_ABI}" |
| 251 | |
260 | |
| 252 | echo ${order} |
261 | echo ${order} |
| … | |
… | |
| 259 | get_all_libdirs() { |
268 | get_all_libdirs() { |
| 260 | local libdirs="lib" |
269 | local libdirs="lib" |
| 261 | local abi |
270 | local abi |
| 262 | local dir |
271 | local dir |
| 263 | |
272 | |
| 264 | if has_multilib_profile; then |
|
|
| 265 | for abi in ${MULTILIB_ABIS}; do |
273 | for abi in ${MULTILIB_ABIS}; do |
| 266 | [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})" |
274 | [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})" |
| 267 | done |
275 | done |
| 268 | elif [ -n "${CONF_LIBDIR}" ]; then |
|
|
| 269 | for dir in ${CONF_LIBDIR} ${CONF_MULTILIBDIR:-lib32}; do |
|
|
| 270 | [ "${dir}" != "lib" ] && libdirs="${libdirs} ${dir}" |
|
|
| 271 | done |
|
|
| 272 | fi |
|
|
| 273 | |
276 | |
| 274 | echo "${libdirs}" |
277 | echo "${libdirs}" |
| 275 | } |
278 | } |
| 276 | |
279 | |
| 277 | # Return true if ${ABI} is the last ABI on our list (or if we're not |
280 | # Return true if ${ABI} is the last ABI on our list (or if we're not |
| 278 | # using the new multilib configuration. This can be used to determine |
281 | # using the new multilib configuration. This can be used to determine |
| 279 | # if we're in the last (or only) run through src_{unpack,compile,install} |
282 | # if we're in the last (or only) run through src_{unpack,compile,install} |
| 280 | is_final_abi() { |
283 | is_final_abi() { |
| 281 | ! has_multilib_profile && return 0 |
284 | has_multilib_profile || return 0 |
| 282 | local ALL_ABIS=$(get_install_abis) |
285 | local ALL_ABIS=$(get_install_abis) |
| 283 | local LAST_ABI=${ALL_ABIS/* /} |
286 | local LAST_ABI=${ALL_ABIS/* /} |
| 284 | [ "${LAST_ABI}" = "${ABI}" ] |
287 | [[ ${LAST_ABI} == ${ABI} ]] |
| 285 | } |
288 | } |
| 286 | |
289 | |
| 287 | # echo the number of ABIs we will be installing for |
290 | # echo the number of ABIs we will be installing for |
| 288 | number_abis() { |
291 | number_abis() { |
| 289 | get_install_abis | wc -w |
292 | get_install_abis | wc -w |
| … | |
… | |
| 293 | # include dir defaults to /usr/include |
296 | # include dir defaults to /usr/include |
| 294 | # ABI defaults to ${ABI} or ${DEFAULT_ABI} |
297 | # ABI defaults to ${ABI} or ${DEFAULT_ABI} |
| 295 | get_ml_incdir() { |
298 | get_ml_incdir() { |
| 296 | local dir=/usr/include |
299 | local dir=/usr/include |
| 297 | |
300 | |
| 298 | if [[ ${#} -gt 0 ]]; then |
301 | if [[ $# -gt 0 ]]; then |
| 299 | incdir=${1} |
302 | incdir=$1 |
| 300 | shift |
303 | shift |
| 301 | fi |
304 | fi |
| 302 | |
305 | |
| 303 | if [[ -z "${MULTILIB_ABIS}" ]]; then |
306 | if [[ -z "${MULTILIB_ABIS}" ]]; then |
| 304 | echo ${incdir} |
307 | echo ${incdir} |
| 305 | return 0 |
308 | return 0 |
| 306 | fi |
309 | fi |
| 307 | |
310 | |
| 308 | local abi=${ABI:-${DEFAULT_ABI}} |
311 | local abi=${ABI-${DEFAULT_ABI}} |
| 309 | if [[ ${#} -gt 0 ]]; then |
312 | if [[ $# -gt 0 ]]; then |
| 310 | abi=${1} |
313 | abi=$1 |
| 311 | shift |
314 | shift |
| 312 | fi |
315 | fi |
| 313 | |
316 | |
| 314 | if [[ -d "${dir}/gentoo-multilib/${abi}" ]]; then |
317 | if [[ -d "${dir}/gentoo-multilib/${abi}" ]]; then |
| 315 | echo ${dir}/gentoo-multilib/${abi} |
318 | echo ${dir}/gentoo-multilib/${abi} |
| … | |
… | |
| 332 | # ... |
335 | # ... |
| 333 | # prep_ml_includes /usr/qt/3/include |
336 | # prep_ml_includes /usr/qt/3/include |
| 334 | # } |
337 | # } |
| 335 | |
338 | |
| 336 | prep_ml_includes() { |
339 | prep_ml_includes() { |
| 337 | if [ $(number_abis) -gt 1 ]; then |
340 | if [[ $(number_abis) -gt 1 ]] ; then |
| 338 | local dir |
341 | local dir |
| 339 | local dirs |
342 | local dirs |
| 340 | local base |
343 | local base |
| 341 | |
344 | |
| 342 | if [ ${#} -eq 0 ]; then |
345 | if [[ $# -eq 0 ]] ; then |
| 343 | dirs="/usr/include" |
346 | dirs=/usr/include |
| 344 | else |
347 | else |
| 345 | dirs="${@}" |
348 | dirs="$@" |
| 346 | fi |
349 | fi |
| 347 | |
350 | |
| 348 | for dir in ${dirs}; do |
351 | for dir in ${dirs} ; do |
| 349 | base=${T}/gentoo-multilib/${dir}/gentoo-multilib |
352 | base=${T}/gentoo-multilib/${dir}/gentoo-multilib |
| 350 | mkdir -p ${base} |
353 | mkdir -p "${base}" |
| 351 | [ -d ${base}/${ABI} ] && rm -rf ${base}/${ABI} |
354 | [[ -d ${base}/${ABI} ]] && rm -rf "${base}/${ABI}" |
| 352 | mv ${D}/${dir} ${base}/${ABI} |
355 | mv "${D}/${dir}" "${base}/${ABI}" |
| 353 | done |
356 | done |
| 354 | |
357 | |
| 355 | if is_final_abi; then |
358 | if is_final_abi; then |
| 356 | base=${T}/gentoo-multilib |
359 | base=${T}/gentoo-multilib |
| 357 | pushd ${base} |
360 | pushd "${base}" |
| 358 | find . | tar -c -T - -f - | tar -x --no-same-owner -f - -C ${D} |
361 | find . | tar -c -T - -f - | tar -x --no-same-owner -f - -C ${D} |
| 359 | popd |
362 | popd |
| 360 | |
363 | |
|
|
364 | # This 'set' stuff is required by mips profiles to properly pass |
|
|
365 | # CDEFINE's (which have spaces) to sub-functions |
|
|
366 | set -- |
| 361 | for dir in ${dirs}; do |
367 | for dir in ${dirs} ; do |
| 362 | local args=${dir} |
368 | set -- "$@" "${dir}" |
| 363 | local abi |
369 | local abi |
| 364 | for abi in $(get_install_abis); do |
370 | for abi in $(get_install_abis); do |
| 365 | args="${args} $(get_abi_CDEFINE ${abi}):${dir}/gentoo-multilib/${abi}" |
371 | set -- "$@" "$(get_abi_CDEFINE ${abi}):${dir}/gentoo-multilib/${abi}" |
| 366 | done |
372 | done |
| 367 | create_ml_includes ${args} |
373 | create_ml_includes "$@" |
| 368 | done |
374 | done |
| 369 | fi |
375 | fi |
| 370 | fi |
376 | fi |
| 371 | } |
377 | } |
| 372 | |
378 | |
| … | |
… | |
| 378 | # Ideas for this code came from debian's sparc-linux headers package. |
384 | # Ideas for this code came from debian's sparc-linux headers package. |
| 379 | # |
385 | # |
| 380 | # Example: |
386 | # Example: |
| 381 | # create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64 |
387 | # create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64 |
| 382 | # create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64 |
388 | # create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64 |
|
|
389 | # |
|
|
390 | # Warning: Be careful with the ordering here. The default ABI has to be the |
|
|
391 | # last, because it is always defined (by GCC) |
| 383 | create_ml_includes() { |
392 | create_ml_includes() { |
| 384 | local dest="${1}" |
393 | local dest=$1 |
| 385 | shift |
394 | shift |
| 386 | local mlinfo="${@}" |
|
|
| 387 | local basedirs=$(create_ml_includes-listdirs ${mlinfo}) |
395 | local basedirs=$(create_ml_includes-listdirs "$@") |
| 388 | |
396 | |
| 389 | create_ml_includes-makedestdirs ${dest} ${basedirs} |
397 | create_ml_includes-makedestdirs ${dest} ${basedirs} |
| 390 | |
398 | |
| 391 | local file |
399 | local file |
| 392 | for file in $(create_ml_includes-allfiles ${basedirs}); do |
400 | for file in $(create_ml_includes-allfiles ${basedirs}) ; do |
| 393 | local name="$(echo $file | tr a-z A-Z | sed 's:[^A-Z]:_:g')" |
401 | #local name=$(echo ${file} | tr '[:lower:]' '[:upper:]' | sed 's:[^[:upper:]]:_:g') |
| 394 | { |
402 | ( |
| 395 | echo "/* Common header file autogenerated by create_ml_includes in multilib.eclass */" |
403 | echo "/* Autogenerated by create_ml_includes() in multilib.eclass */" |
| 396 | |
404 | |
| 397 | local dir |
405 | local dir |
| 398 | for dir in ${basedirs}; do |
406 | for dir in ${basedirs}; do |
| 399 | if [ -f "${D}/${dir}/${file}" ]; then |
407 | if [[ -f ${D}/${dir}/${file} ]] ; then |
|
|
408 | echo "" |
| 400 | local sym=$(create_ml_includes-sym_for_dir ${dir} ${mlinfo}) |
409 | local sym=$(create_ml_includes-sym_for_dir ${dir} "$@") |
|
|
410 | if [[ ${sym/=} != "${sym}" ]] ; then |
|
|
411 | echo "#if ${sym}" |
| 401 | if [[ ${sym::1} == "!" ]]; then |
412 | elif [[ ${sym::1} == "!" ]] ; then |
| 402 | echo "#ifndef ${sym:1}" |
413 | echo "#ifndef ${sym:1}" |
| 403 | else |
414 | else |
| 404 | echo "#ifdef ${sym}" |
415 | echo "#ifdef ${sym}" |
| 405 | fi |
416 | fi |
| 406 | echo "#include \"$(create_ml_includes-relative_between ${dest}/$(dirname ${file}) ${dir}/${file})\"" |
417 | echo "# include <$(create_ml_includes-absolute ${dir}/${file})>" |
| 407 | echo "#endif /* ${sym} */" |
418 | echo "#endif /* ${sym} */" |
| 408 | echo "" |
|
|
| 409 | fi |
419 | fi |
| 410 | done |
420 | done |
| 411 | |
421 | |
| 412 | #echo "#endif /* __CREATE_ML_INCLUDES_STUB_${name}__ */" |
422 | #echo "#endif /* __CREATE_ML_INCLUDES_STUB_${name}__ */" |
| 413 | } > ${D}/${dest}/${file} |
423 | ) > "${D}/${dest}/${file}" |
| 414 | done |
424 | done |
| 415 | } |
425 | } |
| 416 | |
426 | |
| 417 | # Helper function for create_ml_includes |
427 | # Helper function for create_ml_includes |
| 418 | create_ml_includes-relative_between() { |
428 | create_ml_includes-absolute() { |
| 419 | local src="$(create_ml_includes-tidy_path ${1})" |
|
|
| 420 | local dst="$(create_ml_includes-tidy_path ${2})" |
429 | local dst="$(create_ml_includes-tidy_path $1)" |
| 421 | |
430 | |
| 422 | src=(${src//\// }) |
|
|
| 423 | dst=(${dst//\// }) |
431 | dst=(${dst//\// }) |
| 424 | |
432 | |
| 425 | local i |
433 | local i |
| 426 | for ((i=0; i<${#src[*]}; i++)); do |
434 | for ((i=0; i<${#dst[*]}; i++)); do |
| 427 | [ "${dst[i]}" != "${src[i]}" ] && break |
435 | [ "${dst[i]}" == "include" ] && break |
| 428 | done |
436 | done |
| 429 | |
437 | |
| 430 | local common=$i |
438 | local strip_upto=$i |
| 431 | |
439 | |
| 432 | for ((i=${#src[*]}; i>common; i--)); do |
|
|
| 433 | echo -n ../ |
|
|
| 434 | done |
|
|
| 435 | |
|
|
| 436 | for ((i=common; i<${#dst[*]}-1; i++)); do |
440 | for ((i=strip_upto+1; i<${#dst[*]}-1; i++)); do |
| 437 | echo -n ${dst[i]}/ |
441 | echo -n ${dst[i]}/ |
| 438 | done |
442 | done |
| 439 | |
443 | |
| 440 | echo -n ${dst[i]} |
444 | echo -n ${dst[i]} |
| 441 | } |
445 | } |
| 442 | |
446 | |
| 443 | # Helper function for create_ml_includes |
447 | # Helper function for create_ml_includes |
| 444 | create_ml_includes-tidy_path() { |
448 | create_ml_includes-tidy_path() { |
| 445 | local removed="${1}" |
449 | local removed=$1 |
| 446 | |
450 | |
| 447 | if [ -n "${removed}" ]; then |
451 | if [ -n "${removed}" ]; then |
| 448 | # Remove multiple slashes |
452 | # Remove multiple slashes |
| 449 | while [ "${removed}" != "${removed/\/\//\/}" ]; do |
453 | while [ "${removed}" != "${removed/\/\//\/}" ]; do |
| 450 | removed=${removed/\/\//\/} |
454 | removed=${removed/\/\//\/} |
| … | |
… | |
| 467 | # Remove trailing .. |
471 | # Remove trailing .. |
| 468 | [ "${removed##*/}" = ".." ] && removed=${removed%/*/*} |
472 | [ "${removed##*/}" = ".." ] && removed=${removed%/*/*} |
| 469 | |
473 | |
| 470 | # Remove trailing / |
474 | # Remove trailing / |
| 471 | [ "${removed##*/}" = "" ] && removed=${removed%/*} |
475 | [ "${removed##*/}" = "" ] && removed=${removed%/*} |
| 472 | |
476 | |
| 473 | echo ${removed} |
477 | echo ${removed} |
| 474 | fi |
478 | fi |
| 475 | } |
479 | } |
| 476 | |
480 | |
| 477 | # Helper function for create_ml_includes |
481 | # Helper function for create_ml_includes |
| 478 | create_ml_includes-listdirs() { |
482 | create_ml_includes-listdirs() { |
| 479 | local dirs |
483 | local dirs |
| 480 | local data |
484 | local data |
| 481 | for data in ${@}; do |
485 | for data in "$@"; do |
| 482 | dirs="${dirs} ${data/*:/}" |
486 | dirs="${dirs} ${data/*:/}" |
| 483 | done |
487 | done |
| 484 | echo ${dirs:1} |
488 | echo ${dirs:1} |
| 485 | } |
489 | } |
| 486 | |
490 | |
| 487 | # Helper function for create_ml_includes |
491 | # Helper function for create_ml_includes |
| 488 | create_ml_includes-makedestdirs() { |
492 | create_ml_includes-makedestdirs() { |
| 489 | local dest=${1} |
493 | local dest=$1 |
| 490 | shift |
494 | shift |
| 491 | local basedirs=${@} |
495 | local basedirs=$@ |
| 492 | |
496 | |
| 493 | dodir ${dest} |
497 | dodir ${dest} |
| 494 | |
498 | |
| 495 | local basedir |
499 | local basedir |
| 496 | for basedir in ${basedirs}; do |
500 | for basedir in ${basedirs}; do |
| … | |
… | |
| 501 | done |
505 | done |
| 502 | } |
506 | } |
| 503 | |
507 | |
| 504 | # Helper function for create_ml_includes |
508 | # Helper function for create_ml_includes |
| 505 | create_ml_includes-allfiles() { |
509 | create_ml_includes-allfiles() { |
| 506 | local basedirs=${@} |
|
|
| 507 | |
|
|
| 508 | local basedir |
510 | local basedir file |
| 509 | for basedir in ${basedirs}; do |
511 | for basedir in "$@" ; do |
| 510 | local file |
|
|
| 511 | for file in $(find ${D}/${basedir} -type f); do |
512 | for file in $(find "${D}"/${basedir} -type f); do |
| 512 | echo ${file/${D}\/${basedir}\//} |
513 | echo ${file/${D}\/${basedir}\//} |
| 513 | done |
514 | done |
| 514 | done | sort | uniq |
515 | done | sort | uniq |
| 515 | } |
516 | } |
| 516 | |
517 | |
| 517 | # Helper function for create_ml_includes |
518 | # Helper function for create_ml_includes |
| 518 | create_ml_includes-sym_for_dir() { |
519 | create_ml_includes-sym_for_dir() { |
| 519 | local dir="${1}" |
520 | local dir=$1 |
| 520 | shift |
521 | shift |
| 521 | local data |
522 | local data |
| 522 | for data in ${@}; do |
523 | for data in "$@"; do |
| 523 | if [ "${dir}" = "${data/*:/}" ]; then |
524 | if [[ ${data} == *:${dir} ]] ; then |
| 524 | echo ${data/:*/} |
525 | echo ${data/:*/} |
| 525 | return 0 |
526 | return 0 |
| 526 | fi |
527 | fi |
| 527 | done |
528 | done |
| 528 | echo "Shouldn't be here -- create_ml_includes-sym_for_dir ${1} ${@}" |
529 | echo "Shouldn't be here -- create_ml_includes-sym_for_dir $1 $@" |
| 529 | # exit because we'll likely be called from a subshell |
530 | # exit because we'll likely be called from a subshell |
| 530 | exit 1 |
531 | exit 1 |
| 531 | } |
532 | } |
|
|
533 | |
|
|
534 | get_libname() { |
|
|
535 | local libname |
|
|
536 | local ver=$1 |
|
|
537 | case ${CHOST} in |
|
|
538 | *-darwin*) libname="dylib";; |
|
|
539 | *) libname="so";; |
|
|
540 | esac |
|
|
541 | |
|
|
542 | if [[ -z $@ ]] ; then |
|
|
543 | echo ".${libname}" |
|
|
544 | else |
|
|
545 | for ver in "$@" ; do |
|
|
546 | case ${CHOST} in |
|
|
547 | *-darwin*) echo ".${ver}.${libname}";; |
|
|
548 | *) echo ".${libname}.${ver}";; |
|
|
549 | esac |
|
|
550 | done |
|
|
551 | fi |
|
|
552 | } |
|
|
553 | |
|
|
554 | # This is for the toolchain to setup profile variables when pulling in |
|
|
555 | # a crosscompiler (and thus they aren't set in the profile) |
|
|
556 | multilib_env() { |
|
|
557 | local CTARGET=${1:-${CTARGET}} |
|
|
558 | |
|
|
559 | case ${CTARGET} in |
|
|
560 | x86_64*) |
|
|
561 | export CFLAGS_x86=${CFLAGS_x86--m32} |
|
|
562 | export CHOST_x86=${CTARGET/x86_64/i686} |
|
|
563 | export CTARGET_x86=${CHOST_x86} |
|
|
564 | export CDEFINE_x86="__i386__" |
|
|
565 | export LIBDIR_x86="lib" |
|
|
566 | |
|
|
567 | export CFLAGS_amd64=${CFLAGS_amd64--m64} |
|
|
568 | export CHOST_amd64=${CTARGET} |
|
|
569 | export CTARGET_amd64=${CHOST_amd64} |
|
|
570 | export CDEFINE_amd64="__x86_64__" |
|
|
571 | export LIBDIR_amd64="lib64" |
|
|
572 | |
|
|
573 | export MULTILIB_ABIS="amd64 x86" |
|
|
574 | export DEFAULT_ABI="amd64" |
|
|
575 | ;; |
|
|
576 | mips64*) |
|
|
577 | export CFLAGS_o32=${CFLAGS_o32--mabi=32} |
|
|
578 | export CHOST_o32=${CTARGET/mips64/mips} |
|
|
579 | export CTARGET_o32=${CHOST_o32} |
|
|
580 | export CDEFINE_o32="_MIPS_SIM == _ABIO32" |
|
|
581 | export LIBDIR_o32="lib" |
|
|
582 | |
|
|
583 | export CFLAGS_n32=${CFLAGS_n32--mabi=n32} |
|
|
584 | export CHOST_n32=${CTARGET} |
|
|
585 | export CTARGET_n32=${CHOST_n32} |
|
|
586 | export CDEFINE_n32="_MIPS_SIM == _ABIN32" |
|
|
587 | export LIBDIR_n32="lib32" |
|
|
588 | |
|
|
589 | export CFLAGS_n64=${CFLAGS_n64--mabi=64} |
|
|
590 | export CHOST_n64=${CTARGET} |
|
|
591 | export CTARGET_n64=${CHOST_n64} |
|
|
592 | export CDEFINE_n64="_MIPS_SIM == _ABI64" |
|
|
593 | export LIBDIR_n64="lib64" |
|
|
594 | |
|
|
595 | export MULTILIB_ABIS="n64 n32 o32" |
|
|
596 | export DEFAULT_ABI="n32" |
|
|
597 | ;; |
|
|
598 | powerpc64*) |
|
|
599 | export CFLAGS_ppc=${CFLAGS_ppc--m32} |
|
|
600 | export CHOST_ppc=${CTARGET/powerpc64/powerpc} |
|
|
601 | export CTARGET_ppc=${CHOST_ppc} |
|
|
602 | export CDEFINE_ppc="!__powerpc64__" |
|
|
603 | export LIBDIR_ppc="lib" |
|
|
604 | |
|
|
605 | export CFLAGS_ppc64=${CFLAGS_ppc64--m64} |
|
|
606 | export CHOST_ppc64=${CTARGET} |
|
|
607 | export CTARGET_ppc64=${CHOST_ppc64} |
|
|
608 | export CDEFINE_ppc64="__powerpc64__" |
|
|
609 | export LIBDIR_ppc64="lib64" |
|
|
610 | |
|
|
611 | export MULTILIB_ABIS="ppc64 ppc" |
|
|
612 | export DEFAULT_ABI="ppc64" |
|
|
613 | ;; |
|
|
614 | s390x*) |
|
|
615 | export CFLAGS_s390=${CFLAGS_s390--m31} # the 31 is not a typo |
|
|
616 | export CHOST_s390=${CTARGET/s390x/s390} |
|
|
617 | export CTARGET_s390=${CHOST_s390} |
|
|
618 | export CDEFINE_s390="!__s390x__" |
|
|
619 | export LIBDIR_s390="lib" |
|
|
620 | |
|
|
621 | export CFLAGS_s390x=${CFLAGS_s390x--m64} |
|
|
622 | export CHOST_s390x=${CTARGET} |
|
|
623 | export CTARGET_s390x=${CHOST_s390x} |
|
|
624 | export CDEFINE_s390x="__s390x__" |
|
|
625 | export LIBDIR_s390x="lib64" |
|
|
626 | |
|
|
627 | export MULTILIB_ABIS="s390x s390" |
|
|
628 | export DEFAULT_ABI="s390x" |
|
|
629 | ;; |
|
|
630 | sparc64*) |
|
|
631 | export CFLAGS_sparc32=${CFLAGS_sparc32--m32} |
|
|
632 | export CHOST_sparc32=${CTARGET/sparc64/sparc} |
|
|
633 | export CTARGET_sparc32=${CHOST_sparc32} |
|
|
634 | export CDEFINE_sparc32="!__arch64__" |
|
|
635 | export LIBDIR_sparc32="lib" |
|
|
636 | |
|
|
637 | export CFLAGS_sparc64=${CFLAGS_sparc64--m64} |
|
|
638 | export CHOST_sparc64=${CTARGET} |
|
|
639 | export CTARGET_sparc64=${CHOST_sparc64} |
|
|
640 | export CDEFINE_sparc64="__arch64__" |
|
|
641 | export LIBDIR_sparc64="lib64" |
|
|
642 | |
|
|
643 | export MULTILIB_ABIS="sparc64 sparc32" |
|
|
644 | export DEFAULT_ABI="sparc64" |
|
|
645 | ;; |
|
|
646 | *) |
|
|
647 | export MULTILIB_ABIS="default" |
|
|
648 | export DEFAULT_ABI="default" |
|
|
649 | ;; |
|
|
650 | esac |
|
|
651 | } |
|
|
652 | |
|
|
653 | # Hide multilib details here for packages which are forced to be compiled for a |
|
|
654 | # specific ABI when run on another ABI (like x86-specific packages on amd64) |
|
|
655 | multilib_toolchain_setup() { |
|
|
656 | export ABI=$1 |
|
|
657 | |
|
|
658 | if has_version app-admin/eselect-compiler ; then |
|
|
659 | # Binutils doesn't have wrappers for ld and as (yet). Eventually it |
|
|
660 | # will, and all this can just be handled with CHOST. |
|
|
661 | export LD="ld $(get_abi_LDFLAGS $1)" |
|
|
662 | export AS="as $(get_abi_ASFLAGS $1)" |
|
|
663 | |
|
|
664 | export CHOST=$(get_abi_CHOST $1) |
|
|
665 | export CBUILD=$(get_abi_CHOST $1) |
|
|
666 | else |
|
|
667 | tc-export CC |
|
|
668 | fi |
|
|
669 | } |