/[gentoo-x86]/eclass/multilib.eclass
Gentoo

Diff of /eclass/multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.14 Revision 1.28
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 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.14 2005/01/18 04:56:03 eradicator Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.28 2005/07/06 20:20:04 agriffis Exp $
4# 4#
5# Author: Jeremy Huddleston <eradicator@gentoo.org> 5# Author: Jeremy Huddleston <eradicator@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
10ECLASS=multilib
11INHERITED="$INHERITED $ECLASS" 10INHERITED="$INHERITED $ECLASS"
12 11
13DESCRIPTION="Based on the ${ECLASS} eclass" 12DESCRIPTION="Based on the ${ECLASS} eclass"
14 13
15# has_multilib_profile: 14# has_multilib_profile:
16# Return true if the current profile is a multilib profile. You might 15# Return true if the current profile is a multilib profile and lists more than
17# want to use this like 'use multilib || has_multilib_profile' until 16# one abi in ${MULTILIB_ABIS}. You might want to use this like
17# 'use multilib || has_multilib_profile' until all profiles utilizing the
18# all profiles utilizing the 'multilib' use flag are removed from portage 18# 'multilib' use flag are removed from portage
19 19
20# is_final_abi: 20# is_final_abi:
21# Return true if ${ABI} is the final abi to be installed (and thus we are 21# Return true if ${ABI} is the final abi to be installed (and thus we are
22# on our last run through a src_* function. 22# on our last run through a src_* function.
23 23
24# number_abis: 24# number_abis:
25# echo the number of ABIs we will be installing for 25# echo the number of ABIs we will be installing for
26 26
27# get_abi_order: 27# get_install_abis:
28# Return a list of the ABIs we want to install for with 28# Return a list of the ABIs we want to install for with
29# the last one in the list being the default. 29# the last one in the list being the default.
30 30
31# get_all_abis:
32# Return a list of the ABIs supported by this profile.
33# the last one in the list being the default.
34
31# get_all_libdir: 35# get_all_libdirs:
32# Returns a list of all the libdirs used by this profile. This includes 36# Returns a list of all the libdirs used by this profile. This includes
33# those that might not be touched by the current ebuild and always includes 37# those that might not be touched by the current ebuild and always includes
34# "lib". 38# "lib".
35 39
36# get_libdir: 40# get_libdir:
81# create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64 85# create_ml_includes /usr/include/asm __sparc__:/usr/include/asm-sparc __sparc64__:/usr/include/asm-sparc64
82# create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64 86# create_ml_includes /usr/include/asm __i386__:/usr/include/asm-i386 __x86_64__:/usr/include/asm-x86_64
83 87
84### END DOCUMENTATION ### 88### END DOCUMENTATION ###
85 89
90# Defaults:
91export MULTILIB_ABIS=${MULTILIB_ABIS:-"default"}
92export DEFAULT_ABI=${DEFAULT_ABI:-"default"}
93# This causes econf to set --libdir=/usr/lib where it didn't before
94#export ABI=${ABI:-"default"}
95export CFLAGS_default
96export LDFLAGS_default
97export CHOST_default=${CHOST_default:-${CHOST}}
98export LIBDIR_default=${CONF_LIBDIR:-"lib"}
99export CDEFINE_default="__unix__"
100
86# has_multilib_profile() 101# has_multilib_profile()
87# Return true if
88has_multilib_profile() { 102has_multilib_profile() {
89 [ -n "${MULTILIB_ABIS}" ] 103 [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
90} 104}
91 105
92# This function simply returns the desired lib directory. With portage 106# This function simply returns the desired lib directory. With portage
93# 2.0.51, we now have support for installing libraries to lib32/lib64 107# 2.0.51, we now have support for installing libraries to lib32/lib64
94# to accomidate the needs of multilib systems. It's no longer a good idea 108# to accomidate the needs of multilib systems. It's no longer a good idea
101# Added support for ${ABI} and ${DEFAULT_ABI}. If they're both not set, 115# Added support for ${ABI} and ${DEFAULT_ABI}. If they're both not set,
102# fall back on old behavior. Any profile that has these set should also 116# fall back on old behavior. Any profile that has these set should also
103# depend on a newer version of portage (not yet released) which uses these 117# depend on a newer version of portage (not yet released) which uses these
104# over CONF_LIBDIR in econf, dolib, etc... 118# over CONF_LIBDIR in econf, dolib, etc...
105get_libdir() { 119get_libdir() {
106 LIBDIR_TEST=$(type econf) 120 local CONF_LIBDIR
107 if [ ! -z "${CONF_LIBDIR_OVERRIDE}" ] ; then 121 if [ -n "${CONF_LIBDIR_OVERRIDE}" ] ; then
108 # if there is an override, we want to use that... always. 122 # if there is an override, we want to use that... always.
109 CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}" 123 echo ${CONF_LIBDIR_OVERRIDE}
110 elif [ -n "$(get_abi_LIBDIR)" ]; then 124 else
111 CONF_LIBDIR="$(get_abi_LIBDIR)" 125 get_abi_LIBDIR
112 elif [ "${LIBDIR_TEST/CONF_LIBDIR}" == "${LIBDIR_TEST}" ]; then # we don't have CONF_LIBDIR support
113 # will be <portage-2.0.51_pre20
114 CONF_LIBDIR="lib"
115 fi 126 fi
116 # and of course, default to lib if CONF_LIBDIR isnt set
117 echo ${CONF_LIBDIR:=lib}
118 unset LIBDIR_TEST
119} 127}
120 128
121get_multilibdir() { 129get_multilibdir() {
122 if [ -n "$(get_abi_LIBDIR)" ]; then 130 if has_multilib_profile; then
123 eerror "get_multilibdir called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org" 131 eerror "get_multilibdir called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org"
124 exit 1 132 exit 1
125 fi 133 fi
126 echo ${CONF_MULTILIBDIR:=lib32} 134 echo ${CONF_MULTILIBDIR:=lib32}
127} 135}
136# 144#
137# get_libdir_override lib64 145# get_libdir_override lib64
138# 146#
139# Travis Tilley <lv@gentoo.org> (31 Aug 2004) 147# Travis Tilley <lv@gentoo.org> (31 Aug 2004)
140get_libdir_override() { 148get_libdir_override() {
141 if [ -n "$(get_abi_LIBDIR)" ]; then 149 if has_multilib_profile; then
142 eerror "get_libdir_override called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org" 150 eerror "get_libdir_override called, but it shouldn't be needed with the new multilib approach. Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org"
143 exit 1 151 exit 1
144 fi 152 fi
145 CONF_LIBDIR="$1" 153 CONF_LIBDIR="$1"
146 CONF_LIBDIR_OVERRIDE="$1" 154 CONF_LIBDIR_OVERRIDE="$1"
155 LIBDIR_default="$1"
147} 156}
148 157
149# get_abi_var <VAR> [<ABI>] 158# get_abi_var <VAR> [<ABI>]
150# returns the value of ${<VAR>_<ABI>} which should be set in make.defaults 159# returns the value of ${<VAR>_<ABI>} which should be set in make.defaults
151# 160#
168 elif [ -n "${ABI}" ]; then 177 elif [ -n "${ABI}" ]; then
169 abi=${ABI} 178 abi=${ABI}
170 elif [ -n "${DEFAULT_ABI}" ]; then 179 elif [ -n "${DEFAULT_ABI}" ]; then
171 abi=${DEFAULT_ABI} 180 abi=${DEFAULT_ABI}
172 else 181 else
173 return 1 182 abi="default"
174 fi 183 fi
175 184
176 local var="${flag}_${abi}" 185 local var="${flag}_${abi}"
177 echo ${!var} 186 echo ${!var}
178} 187}
179 188
180get_abi_CFLAGS() { get_abi_var CFLAGS ${@}; } 189get_abi_CFLAGS() { get_abi_var CFLAGS "${@}"; }
190get_abi_LDFLAGS() { get_abi_var LDFLAGS "${@}"; }
191get_abi_CHOST() { get_abi_var CHOST "${@}"; }
192get_abi_FAKE_TARGETS() { get_abi_var FAKE_TARGETS "${@}"; }
181get_abi_CDEFINE() { get_abi_var CDEFINE ${@}; } 193get_abi_CDEFINE() { get_abi_var CDEFINE "${@}"; }
182get_abi_LIBDIR() { get_abi_var LIBDIR ${@}; } 194get_abi_LIBDIR() { get_abi_var LIBDIR "${@}"; }
183 195
184# Return a list of the ABIs we want to install for with 196# Return a list of the ABIs we want to install for with
185# the last one in the list being the default. 197# the last one in the list being the default.
186get_abi_order() { 198get_install_abis() {
187 local order="" 199 local order=""
188 200
189 if [ -z "${MULTILIB_ABIS}" ]; then 201 if [ -z "${MULTILIB_ABIS}" ]; then
190 echo "NOMULTILIB" 202 echo "default"
191 return 1 203 return 0
192 fi 204 fi
193 205
194 if hasq multilib-pkg-force ${RESTRICT} || 206 if hasq multilib-pkg-force ${RESTRICT} ||
195 { hasq multilib-pkg ${FEATURES} && hasq multilib-pkg ${RESTRICT}; }; then 207 { hasq multilib-pkg ${FEATURES} && hasq multilib-pkg ${RESTRICT}; }; then
196 for x in ${MULTILIB_ABIS}; do 208 for x in ${MULTILIB_ABIS}; do
219 231
220 echo ${order} 232 echo ${order}
221 return 0 233 return 0
222} 234}
223 235
236# Return a list of the ABIs supported by this profile.
237# the last one in the list being the default.
238get_all_abis() {
239 local order=""
240
241 if [ -z "${MULTILIB_ABIS}" ]; then
242 echo "default"
243 return 0
244 fi
245
246 for x in ${MULTILIB_ABIS}; do
247 if [ "${x}" != "${DEFAULT_ABI}" ]; then
248 order="${order:+${order }}${x}"
249 fi
250 done
251 order="${order:+${order} }${DEFAULT_ABI}"
252
253 echo ${order}
254 return 0
255}
256
224# get_all_libdir() 257# get_all_libdirs()
225# Returns a list of all the libdirs used by this profile. This includes 258# Returns a list of all the libdirs used by this profile. This includes
226# those that might not be touched by the current ebuild. 259# those that might not be touched by the current ebuild.
227get_all_libdirs() { 260get_all_libdirs() {
228 local libdirs="lib" 261 local libdirs="lib"
229 local abi 262 local abi
232 if has_multilib_profile; then 265 if has_multilib_profile; then
233 for abi in ${MULTILIB_ABIS}; do 266 for abi in ${MULTILIB_ABIS}; do
234 [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})" 267 [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})"
235 done 268 done
236 elif [ -n "${CONF_LIBDIR}" ]; then 269 elif [ -n "${CONF_LIBDIR}" ]; then
237 for dir in ${CONF_LIBDIR} ${CONF_MULTILIBDIR:=lib32}; do 270 for dir in ${CONF_LIBDIR} ${CONF_MULTILIBDIR:-lib32}; do
238 [ "${dir}" != "lib" ] && libdirs="${libdirs} ${dir}" 271 [ "${dir}" != "lib" ] && libdirs="${libdirs} ${dir}"
239 done 272 done
240 fi 273 fi
241 274
242 echo "${libdirs}" 275 echo "${libdirs}"
244 277
245# Return true if ${ABI} is the last ABI on our list (or if we're not 278# Return true if ${ABI} is the last ABI on our list (or if we're not
246# using the new multilib configuration. This can be used to determine 279# using the new multilib configuration. This can be used to determine
247# if we're in the last (or only) run through src_{unpack,compile,install} 280# if we're in the last (or only) run through src_{unpack,compile,install}
248is_final_abi() { 281is_final_abi() {
249 ! has_multilib_profile && return 0 282 has_multilib_profile || return 0
250 local ALL_ABIS=$(get_abi_order) 283 local ALL_ABIS=$(get_install_abis)
251 local LAST_ABI=${ALL_ABIS/* /} 284 local LAST_ABI=${ALL_ABIS/* /}
252 [ "${LAST_ABI}" = "${ABI}" ] 285 [[ ${LAST_ABI} == ${ABI} ]]
253} 286}
254 287
255# echo the number of ABIs we will be installing for 288# echo the number of ABIs we will be installing for
256number_abis() { 289number_abis() {
257 get_abi_order | wc -w 290 get_install_abis | wc -w
258} 291}
259 292
260# get_ml_incdir [<include dir> [<ABI>]] 293# get_ml_incdir [<include dir> [<ABI>]]
261# include dir defaults to /usr/include 294# include dir defaults to /usr/include
262# ABI defaults to ${ABI} or ${DEFAULT_ABI} 295# ABI defaults to ${ABI} or ${DEFAULT_ABI}
271 if [[ -z "${MULTILIB_ABIS}" ]]; then 304 if [[ -z "${MULTILIB_ABIS}" ]]; then
272 echo ${incdir} 305 echo ${incdir}
273 return 0 306 return 0
274 fi 307 fi
275 308
276 local abi=${ABI:-${DEFAULT_ABI}} 309 local abi=${ABI-${DEFAULT_ABI}}
277 if [[ ${#} -gt 0 ]]; then 310 if [[ ${#} -gt 0 ]]; then
278 abi=${1} 311 abi=${1}
279 shift 312 shift
280 fi 313 fi
281 314
321 done 354 done
322 355
323 if is_final_abi; then 356 if is_final_abi; then
324 base=${T}/gentoo-multilib 357 base=${T}/gentoo-multilib
325 pushd ${base} 358 pushd ${base}
326 find . | cpio -pmd --no-preserve-owner ${D} 359 find . | tar -c -T - -f - | tar -x --no-same-owner -f - -C ${D}
327 popd 360 popd
328 361
329 for dir in ${dirs}; do 362 for dir in ${dirs}; do
330 local args=${dir} 363 local args=${dir}
331 local abi 364 local abi
332 for abi in $(get_abi_order); do 365 for abi in $(get_install_abis); do
333 args="${args} $(get_abi_CDEFINE ${abi}):${dir}/gentoo-multilib/${abi}" 366 args="${args} $(get_abi_CDEFINE ${abi}):${dir}/gentoo-multilib/${abi}"
334 done 367 done
335 create_ml_includes ${args} 368 create_ml_includes ${args}
336 done 369 done
337 fi 370 fi
359 local file 392 local file
360 for file in $(create_ml_includes-allfiles ${basedirs}); do 393 for file in $(create_ml_includes-allfiles ${basedirs}); do
361 local name="$(echo $file | tr a-z A-Z | sed 's:[^A-Z]:_:g')" 394 local name="$(echo $file | tr a-z A-Z | sed 's:[^A-Z]:_:g')"
362 { 395 {
363 echo "/* Common header file autogenerated by create_ml_includes in multilib.eclass */" 396 echo "/* Common header file autogenerated by create_ml_includes in multilib.eclass */"
364 #echo "#ifndef __CREATE_ML_INCLUDES_STUB_${name}__"
365 #echo "#define __CREATE_ML_INCLUDES_STUB_${name}__"
366 #echo ""
367 397
368 local dir 398 local dir
369 for dir in ${basedirs}; do 399 for dir in ${basedirs}; do
370 if [ -f "${D}/${dir}/${file}" ]; then 400 if [ -f "${D}/${dir}/${file}" ]; then
371 echo "#ifdef $(create_ml_includes-sym_for_dir ${dir} ${mlinfo})" 401 local sym=$(create_ml_includes-sym_for_dir ${dir} ${mlinfo})
372 echo "#include \"$(create_ml_includes-relative_between ${dest}/$(dirname ${file}) ${dir}/${file})\"" 402 if [[ ${sym::1} == "!" ]]; then
373 echo "#endif /* $(create_ml_includes-sym_for_dir ${dir} ${mlinfo}) */" 403 echo "#ifndef ${sym:1}"
404 else
405 echo "#ifdef ${sym}"
406 fi
407 echo "#include <$(create_ml_includes-absolute ${dir}/${file})>"
408 echo "#endif /* ${sym} */"
374 echo "" 409 echo ""
375 fi 410 fi
376 done 411 done
377 412
378 #echo "#endif /* __CREATE_ML_INCLUDES_STUB_${name}__ */" 413 #echo "#endif /* __CREATE_ML_INCLUDES_STUB_${name}__ */"
379 } > ${D}/${dest}/${file} 414 } > ${D}/${dest}/${file}
380 done 415 done
381} 416}
382 417
383# Helper function for create_ml_includes 418# Helper function for create_ml_includes
384create_ml_includes-relative_between() { 419create_ml_includes-absolute() {
385 local src="$(create_ml_includes-tidy_path ${1})"
386 local dst="$(create_ml_includes-tidy_path ${2})" 420 local dst="$(create_ml_includes-tidy_path ${1})"
387 421
388 src=(${src//\// })
389 dst=(${dst//\// }) 422 dst=(${dst//\// })
390 423
391 local i 424 local i
392 for ((i=0; i<${#src[*]}; i++)); do 425 for ((i=0; i<${#dst[*]}; i++)); do
393 [ "${dst[i]}" != "${src[i]}" ] && break 426 [ "${dst[i]}" == "include" ] && break
394 done 427 done
395 428
396 local common=$i 429 local strip_upto=$i
397 430
398 for ((i=${#src[*]}; i>common; i--)); do
399 echo -n ../
400 done
401
402 for ((i=common; i<${#dst[*]}-1; i++)); do 431 for ((i=strip_upto+1; i<${#dst[*]}-1; i++)); do
403 echo -n ${dst[i]}/ 432 echo -n ${dst[i]}/
404 done 433 done
405 434
406 echo -n ${dst[i]} 435 echo -n ${dst[i]}
407} 436}

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20