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

Diff of /eclass/multilib.eclass

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

Revision 1.4 Revision 1.5
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.4 2005/01/12 20:27:30 eradicator Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/multilib.eclass,v 1.5 2005/01/12 22:39:44 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.
253 253
254 local dir 254 local dir
255 for dir in ${basedirs}; do 255 for dir in ${basedirs}; do
256 if [ -f "${D}/${dir}/${file}" ]; then 256 if [ -f "${D}/${dir}/${file}" ]; then
257 echo "#ifdef $(create_ml_includes-sym_for_dir ${dir} ${mlinfo})" 257 echo "#ifdef $(create_ml_includes-sym_for_dir ${dir} ${mlinfo})"
258 echo "#include \"$(create_ml_includes-relative_between ${dest} ${dir})/${file}\"" 258 echo "#include \"$(create_ml_includes-relative_between ${dest}/$(dirname ${file}) ${dir}/${file})\""
259 echo "#endif /* $(create_ml_includes-sym_for_dir ${dir} ${mlinfo}) */" 259 echo "#endif /* $(create_ml_includes-sym_for_dir ${dir} ${mlinfo}) */"
260 echo "" 260 echo ""
261 fi 261 fi
262 done 262 done
263 263
265 } > ${D}/${dest}/${file} 265 } > ${D}/${dest}/${file}
266 done 266 done
267} 267}
268 268
269# Helper function for create_ml_includes 269# Helper function for create_ml_includes
270# TODO: This needs to be updated to spit out relative paths...
271create_ml_includes-relative_between() { 270create_ml_includes-relative_between() {
271 local src="$(create_ml_includes-tidy_path ${1})"
272 local dst="$(create_ml_includes-tidy_path ${2})"
273
274 src=(${src//\// })
275 dst=(${dst//\// })
276
277 local i
278 for ((i=0; i<${#src[*]}; i++)); do
279 [ "${dst[i]}" != "${src[i]}" ] && break
280 done
281
282 local common=$i
283
284 for ((i=${#src[*]}; i>common; i--)); do
285 echo -n ../
286 done
287
288 for ((i=common; i<${#dst[*]}-1; i++)); do
289 echo -n ${dst[i]}/
290 done
291
292 echo -n ${dst[i]}
293}
294
295# Helper function for create_ml_includes
296create_ml_includes-tidy_path() {
272 local from=${1} 297 local removed="${1}"
273 local to=${2}
274
275 strip_duplicate_slashes "${ROOT}${to}"
276}
277 298
278# Helper function for create_ml_includes
279strip_duplicate_slashes () {
280 if [ -n "${1}" ]; then 299 if [ -n "${1}" ]; then
281 local removed=${1/\/\//\/} 300 # Remove multiple slashes
282 [ ${removed} != ${removed/\/\//\/} ] && removed=$(strip_duplicate_slashes "${removed}") 301 while [ "${removed}" != "${removed/\/\//\/}" ]; do
302 removed=${removed/\/\//\/}
303 done
304
305 # Remove . directories
306 while [ "${removed}" != "${removed//\/.\//\/}" ]; do
307 removed=${removed//\/.\//\/}
308 done
309 [ "${removed##*/}" = "." ] && removed=${removed%/*}
310
311 # Removed .. directories
312 # I wonder if there's a non-trivial bashism for this one...
313 while [ "${removed}" != "$(echo ${removed} | sed -e 's:[^/]*/\.\./::')" ]; do
314 removed=$(echo ${removed} | sed -e 's:[^/]*/\.\./::')
315 done
316
317 # Remove trailing ..
318 removed=$(echo ${removed} | sed -e 's:/[^/]*/\.\.$::')
319
320 # Remove trailing /
321 [ "${removed##*/}" = "" ] && removed=${removed%/*}
322
283 echo ${removed} 323 echo ${removed}
284 fi 324 fi
285} 325}
286 326
287# Helper function for create_ml_includes 327# Helper function for create_ml_includes

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.20