| 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.5 2005/01/12 22:39:44 eradicator Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.12 2005/01/17 04:17:53 eradicator 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 | |
| 10 | ECLASS=multilib |
10 | ECLASS=multilib |
| 11 | INHERITED="$INHERITED $ECLASS" |
11 | INHERITED="$INHERITED $ECLASS" |
| 12 | |
12 | |
| 13 | DESCRIPTION="Based on the ${ECLASS} eclass" |
13 | DESCRIPTION="Based on the ${ECLASS} eclass" |
| 14 | |
|
|
| 15 | DEPEND="!build? ( sys-apps/sed sys-apps/findutils sys-apps/coreutils )" |
|
|
| 16 | |
14 | |
| 17 | # This function simply returns the desired lib directory. With portage |
15 | # This function simply returns the desired lib directory. With portage |
| 18 | # 2.0.51, we now have support for installing libraries to lib32/lib64 |
16 | # 2.0.51, we now have support for installing libraries to lib32/lib64 |
| 19 | # to accomidate the needs of multilib systems. It's no longer a good idea |
17 | # to accomidate the needs of multilib systems. It's no longer a good idea |
| 20 | # to assume all libraries will end up in lib. Replace any (sane) instances |
18 | # to assume all libraries will end up in lib. Replace any (sane) instances |
| … | |
… | |
| 180 | # echo the number of ABIs we will be installing for |
178 | # echo the number of ABIs we will be installing for |
| 181 | number_abis() { |
179 | number_abis() { |
| 182 | get_abi_order | wc -w |
180 | get_abi_order | wc -w |
| 183 | } |
181 | } |
| 184 | |
182 | |
|
|
183 | # get_ml_incdir [<include dir> [<ABI>]] |
|
|
184 | # include dir defaults to /usr/include |
|
|
185 | # ABI defaults to ${ABI} or ${DEFAULT_ABI} |
|
|
186 | get_ml_incdir() { |
|
|
187 | local dir=/usr/include |
|
|
188 | |
|
|
189 | if [[ ${#} -gt 0 ]]; then |
|
|
190 | incdir=${1} |
|
|
191 | shift |
|
|
192 | fi |
|
|
193 | |
|
|
194 | if [[ -z "${MULTILIB_ABIS}" ]]; then |
|
|
195 | echo ${incdir} |
|
|
196 | return 0 |
|
|
197 | fi |
|
|
198 | |
|
|
199 | local abi=${ABI:-${DEFAULT_ABI}} |
|
|
200 | if [[ ${#} -gt 0 ]]; then |
|
|
201 | abi=${1} |
|
|
202 | shift |
|
|
203 | fi |
|
|
204 | |
|
|
205 | if [[ -d "${dir}/gentoo-multilib/${abi}" ]]; then |
|
|
206 | echo ${dir}/gentoo-multilib/${abi} |
|
|
207 | else |
|
|
208 | echo ${dir} |
|
|
209 | fi |
|
|
210 | } |
|
|
211 | |
| 185 | # prep_ml_includes: |
212 | # prep_ml_includes: |
| 186 | # |
213 | # |
| 187 | # Some includes (include/asm, glibc, etc) are ABI dependent. In this case, |
214 | # Some includes (include/asm, glibc, etc) are ABI dependent. In this case, |
| 188 | # We can install them in different locations for each ABI and create a common |
215 | # We can install them in different locations for each ABI and create a common |
| 189 | # header which includes the right one based on CDEFINE_${ABI}. If your |
216 | # header which includes the right one based on CDEFINE_${ABI}. If your |
| … | |
… | |
| 196 | # ... |
223 | # ... |
| 197 | # prep_ml_includes /usr/qt/3/include |
224 | # prep_ml_includes /usr/qt/3/include |
| 198 | # } |
225 | # } |
| 199 | |
226 | |
| 200 | prep_ml_includes() { |
227 | prep_ml_includes() { |
| 201 | local dirs |
|
|
| 202 | if [ ${#} -eq 0 ]; then |
|
|
| 203 | dirs="/usr/include" |
|
|
| 204 | else |
|
|
| 205 | dirs="${@}" |
|
|
| 206 | fi |
|
|
| 207 | |
|
|
| 208 | if [ $(number_abis) -gt 1 ]; then |
228 | if [ $(number_abis) -gt 1 ]; then |
| 209 | local dir |
229 | local dir |
|
|
230 | local dirs |
|
|
231 | local base |
|
|
232 | |
|
|
233 | if [ ${#} -eq 0 ]; then |
|
|
234 | dirs="/usr/include" |
|
|
235 | else |
|
|
236 | dirs="${@}" |
|
|
237 | fi |
|
|
238 | |
| 210 | for dir in ${dirs}; do |
239 | for dir in ${dirs}; do |
|
|
240 | base=${T}/gentoo-multilib/${dir}/gentoo-multilib |
|
|
241 | mkdir -p ${base} |
|
|
242 | [ -d ${base}/${ABI} ] && rm -rf ${base}/${ABI} |
| 211 | mv ${D}/${dir} ${D}/${dir}.${ABI} |
243 | mv ${D}/${dir} ${base}/${ABI} |
| 212 | done |
244 | done |
| 213 | |
245 | |
| 214 | if is_final_abi; then |
246 | if is_final_abi; then |
| 215 | for dir in ${dirs}; do |
247 | base=${T}/gentoo-multilib |
| 216 | local args="${dir}" |
248 | pushd ${base} |
|
|
249 | find . | cpio -pmd --no-preserve-owner ${D} |
|
|
250 | popd |
| 217 | local abi |
251 | local args |
| 218 | for abi in $(get_abi_order); do |
252 | for abi in $(get_abi_order); do |
| 219 | args="${args} $(get_abi_CDEFINE ${abi}):${dir}.${abi}" |
253 | args="${args} $(get_abi_CDEFINE ${abi}):${dir}/gentoo-multilib/${abi}" |
| 220 | done |
|
|
| 221 | create_ml_includes ${args} |
|
|
| 222 | done |
254 | done |
|
|
255 | create_ml_includes ${args} |
|
|
256 | |
| 223 | fi |
257 | fi |
| 224 | fi |
258 | fi |
| 225 | } |
259 | } |
| 226 | |
260 | |
| 227 | # If you need more control than prep_ml_includes can offer (like linux-headers |
261 | # If you need more control than prep_ml_includes can offer (like linux-headers |
| … | |
… | |
| 294 | |
328 | |
| 295 | # Helper function for create_ml_includes |
329 | # Helper function for create_ml_includes |
| 296 | create_ml_includes-tidy_path() { |
330 | create_ml_includes-tidy_path() { |
| 297 | local removed="${1}" |
331 | local removed="${1}" |
| 298 | |
332 | |
| 299 | if [ -n "${1}" ]; then |
333 | if [ -n "${removed}" ]; then |
| 300 | # Remove multiple slashes |
334 | # Remove multiple slashes |
| 301 | while [ "${removed}" != "${removed/\/\//\/}" ]; do |
335 | while [ "${removed}" != "${removed/\/\//\/}" ]; do |
| 302 | removed=${removed/\/\//\/} |
336 | removed=${removed/\/\//\/} |
| 303 | done |
337 | done |
| 304 | |
338 | |
| … | |
… | |
| 307 | removed=${removed//\/.\//\/} |
341 | removed=${removed//\/.\//\/} |
| 308 | done |
342 | done |
| 309 | [ "${removed##*/}" = "." ] && removed=${removed%/*} |
343 | [ "${removed##*/}" = "." ] && removed=${removed%/*} |
| 310 | |
344 | |
| 311 | # Removed .. directories |
345 | # Removed .. directories |
| 312 | # I wonder if there's a non-trivial bashism for this one... |
346 | while [ "${removed}" != "${removed//\/..\/}" ]; do |
| 313 | while [ "${removed}" != "$(echo ${removed} | sed -e 's:[^/]*/\.\./::')" ]; do |
347 | local p1="${removed%%\/..\/*}" |
| 314 | removed=$(echo ${removed} | sed -e 's:[^/]*/\.\./::') |
348 | local p2="${removed#*\/..\/}" |
|
|
349 | |
|
|
350 | removed="${p1%\/*}/${p2}" |
| 315 | done |
351 | done |
| 316 | |
352 | |
| 317 | # Remove trailing .. |
353 | # Remove trailing .. |
| 318 | removed=$(echo ${removed} | sed -e 's:/[^/]*/\.\.$::') |
354 | [ "${removed##*/}" = ".." ] && removed=${removed%/*/*} |
| 319 | |
355 | |
| 320 | # Remove trailing / |
356 | # Remove trailing / |
| 321 | [ "${removed##*/}" = "" ] && removed=${removed%/*} |
357 | [ "${removed##*/}" = "" ] && removed=${removed%/*} |
| 322 | |
358 | |
| 323 | echo ${removed} |
359 | echo ${removed} |
| … | |
… | |
| 353 | |
389 | |
| 354 | # Helper function for create_ml_includes |
390 | # Helper function for create_ml_includes |
| 355 | create_ml_includes-allfiles() { |
391 | create_ml_includes-allfiles() { |
| 356 | local basedirs=${@} |
392 | local basedirs=${@} |
| 357 | |
393 | |
| 358 | local files |
394 | local basedir |
| 359 | for basedir in ${basedirs}; do |
395 | for basedir in ${basedirs}; do |
| 360 | local file |
396 | local file |
| 361 | for file in $(find ${D}/${basedir} -type f); do |
397 | for file in $(find ${D}/${basedir} -type f); do |
| 362 | echo ${file/${D}\/${basedir}\//} |
398 | echo ${file/${D}\/${basedir}\//} |
| 363 | done |
399 | done |
| … | |
… | |
| 373 | if [ "${dir}" = "${data/*:/}" ]; then |
409 | if [ "${dir}" = "${data/*:/}" ]; then |
| 374 | echo ${data/:*/} |
410 | echo ${data/:*/} |
| 375 | return 0 |
411 | return 0 |
| 376 | fi |
412 | fi |
| 377 | done |
413 | done |
| 378 | echo "Should be here -- create_ml_includes-sym_for_dir ${1} ${@}" |
414 | echo "Shouldn't be here -- create_ml_includes-sym_for_dir ${1} ${@}" |
| 379 | # exit because we'll likely be called from a subshell |
415 | # exit because we'll likely be called from a subshell |
| 380 | exit 1 |
416 | exit 1 |
| 381 | } |
417 | } |