This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Position independence: $PREFIX-populate has absolute paths


Hello Michael!
Hello All!

On Tuesday 29 July 2008 16:28:09 Michael Abbott wrote:
> Just discovered that $PREFIX-populate has absolute paths.  I suggest
> changing tools/populate.in so that the lines:
> 
> CT_READELF="@@CT_READELF@@"
> CT_SYSROOT_DIR="@@CT_SYSROOT_DIR@@"
> 
> read something closer to:
> 
> CT_HERE="$(dirname "$0")"
> CT_READELF="$CT_HERE/@@CT_PREFIX@@-readelf"
> CT_SYSROOT_DIR="$CT_HERE/../@@CT_PREFIX@@/sys-root"

I think I understand what you mean: instead of harcoding the path to the
cross-readelf and the sysroot of the toolchain, I should detect them at
run time. So that the toolchain can be relocatable, right?

> (Here I'm assuming there's something like CT_PREFIX symbol to substitute
> here.)

In fact that's ${CT_TARGET}.

> Is it as simple as this?

Alas, tha't s not so easy:
 - I'm not sure that $0 always has the complete path
 - gcc -print-prog-name=readelf always yields 'readelf', and never the
   cross-readelf... :-(
 - gcc has no option to tell where the sysroot it uses is.

Maybe something like the following would work:

# Detect where the toolchain is:
case "${0}" in
  /*)   BIN_DIR="$(dirname "${0}")";;
  */*)  BIN_DIR="$(pwd)/$(dirname "${0}")";;
  *)    BIN_DIR="$(dirname $(which "${0}"))";;
esac
CT_READELF="${BIN_DIR}/@@CT_TARGET@@-readelf"
CT_SYSRROT_DIR="${BIN_DIR}/../@@CT_TARGET@@/sys-root"

> P.S. As a bash style I'd prefer to write
> 	(( ${still_needed} ))
> in preference to
> 	[ ${still_needed} -eq 1 ]
> on the grounds that it's an honest boolean test.

Granted.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< °_° >==-- °------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | * _ * | / \ HTML MAIL    |  """  conspiracy.  |
°------------------------------°-------°------------------°--------------------°


--
For unsubscribe information see http://sourceware.org/lists.html#faq


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]