comp.lang.ada
 help / color / mirror / Atom feed
* GNAT library directory - how to detect it at build time?
@ 2012-10-29 13:42 Maciej Sobczak
  2012-10-29 15:08 ` Simon Wright
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej Sobczak @ 2012-10-29 13:42 UTC (permalink / raw)


Hi,

I have two Linux systems. On one GNAT keeps its library files in the following directory:

   /usr/lib/gcc/i486-linux-gnu/4.4

but on the other the directory is:

   /usr/lib/gcc/x86_64-linux-gnu/4.6

Normally I do not need to name these directories during compilation and linking, because GNAT is smart enough to use them when needed. Except for files that are directly in these directories and can that be needed for linking. GNAT is not smart enough to find these files automatically and project files have to be carefully crafted to work around that.

Is there a way to obtain these paths in the automatic way (say, via standard GPR variables or something like that) or to abstract them away with a link that is perhaps installed by GNAT always in the same place but that I have not yet discovered?

In short: I don't want to make ugly workarounds in GPR or Makefiles to tell GNAT something that it knows already.

-- 
Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT library directory - how to detect it at build time?
  2012-10-29 13:42 GNAT library directory - how to detect it at build time? Maciej Sobczak
@ 2012-10-29 15:08 ` Simon Wright
  2012-10-30  9:02   ` Maciej Sobczak
  0 siblings, 1 reply; 5+ messages in thread
From: Simon Wright @ 2012-10-29 15:08 UTC (permalink / raw)


Maciej Sobczak <see.my.homepage@gmail.com> writes:

> Hi,
>
> I have two Linux systems. On one GNAT keeps its library files in the
> following directory:
>
>    /usr/lib/gcc/i486-linux-gnu/4.4
>
> but on the other the directory is:
>
>    /usr/lib/gcc/x86_64-linux-gnu/4.6
>
> Normally I do not need to name these directories during compilation
> and linking, because GNAT is smart enough to use them when
> needed. Except for files that are directly in these directories and
> can that be needed for linking. GNAT is not smart enough to find these
> files automatically and project files have to be carefully crafted to
> work around that.
>
> Is there a way to obtain these paths in the automatic way (say, via
> standard GPR variables or something like that) or to abstract them
> away with a link that is perhaps installed by GNAT always in the same
> place but that I have not yet discovered?

Not sure these will help ...

$ gnatgcc --print-libgcc-file-name
/opt/gcc-4.7.0/lib/gcc/x86_64-apple-darwin11/4.7.0/libgcc.a

or

$ gnatgcc --print-file-name=libgcc.a
/opt/gcc-4.7.0/lib/gcc/x86_64-apple-darwin11/4.7.0/libgcc.a

or the surprising

$ gnatgcc --print-file-name=adalib/libgnat.a
/opt/gcc-4.7.0/lib/gcc/x86_64-apple-darwin11/4.7.0/adalib/libgnat.a



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT library directory - how to detect it at build time?
  2012-10-29 15:08 ` Simon Wright
@ 2012-10-30  9:02   ` Maciej Sobczak
  2012-11-08 22:05     ` rugxulo
  0 siblings, 1 reply; 5+ messages in thread
From: Maciej Sobczak @ 2012-10-30  9:02 UTC (permalink / raw)


W dniu poniedziałek, 29 października 2012 16:08:25 UTC+1 użytkownik Simon Wright napisał:

> Not sure these will help ...
> 
> $ gnatgcc --print-libgcc-file-name
[...]

Yes, it helped. Not directly, but I have followed this idea and finally ended up with this:

$ gnatgcc --print-search-dirs | grep 'install: ' | grep -o '/.*'

The above command extracts the name of GNAT installation directory, which I can then inject into the GNAT project manager and use to portably link the final program. I hope the above will help others as well.

-- 
Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT library directory - how to detect it at build time?
  2012-10-30  9:02   ` Maciej Sobczak
@ 2012-11-08 22:05     ` rugxulo
  2012-11-09  8:07       ` Simon Wright
  0 siblings, 1 reply; 5+ messages in thread
From: rugxulo @ 2012-11-08 22:05 UTC (permalink / raw)


Hi,

On Tuesday, October 30, 2012 4:02:31 AM UTC-5, Maciej Sobczak wrote:
> 
> Yes, it helped. Not directly, but I have followed this idea and finally ended up with this:
> 
> $ gnatgcc --print-search-dirs | grep 'install: ' | grep -o '/.*'
> 
> The above command extracts the name of GNAT installation
> directory, which I can then inject into the GNAT project
> manager and use to portably link the final program. I
> hope the above will help others as well.

While I'm extremely noobish in all these things, I couldn't help but think you're doing it incorrectly. But my first instinct (basename or dirname) wouldn't work here (and I forgot I had GNAT installed on this machine, so I can actually test).

Just for the record, a quick search shows that POSIX grep doesn't support '-o', so you may wish to avoid that (though further searches show some *BSDs do support it). The easier solution seems to be to just use AWK:

(Thu Nov 08, 03:54 PM) /tmp/doydoy # gnatgcc --print-search-dirs | awk '/install:/ { print $2 }'
/usr/lib/gcc/i486-linux-gnu/4.4.3/

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/grep.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GNAT library directory - how to detect it at build time?
  2012-11-08 22:05     ` rugxulo
@ 2012-11-09  8:07       ` Simon Wright
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Wright @ 2012-11-09  8:07 UTC (permalink / raw)


rugxulo@gmail.com writes:

> Just for the record, a quick search shows that POSIX grep doesn't
> support '-o', so you may wish to avoid that (though further searches
> show some *BSDs do support it). The easier solution seems to be to
> just use AWK:

Or replace the "grep -o" component by "cut -d' ' -f2".

But "grep -o" works fine on Mac OS X...



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-16  9:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-29 13:42 GNAT library directory - how to detect it at build time? Maciej Sobczak
2012-10-29 15:08 ` Simon Wright
2012-10-30  9:02   ` Maciej Sobczak
2012-11-08 22:05     ` rugxulo
2012-11-09  8:07       ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox