From: Dmitry A. Kazakov on
In the past we are used to link external libraries using package Linker and
Default_Switches ("ada") set to, e.g. "-lgdk_pixbuf-2.0". The problem with
this approach is that Linker package is not automatically inherited. There
exist different workarounds all more or less unpleasant.

Meanwhile there is IMO a cleaner and simpler way. Just create a gpr file
for the library(es) in use. For example:

project Gdk_Pixbuf is
for Externally_Built use "true";
for Source_Files use ();
for Library_Dir use "/usr/lib"; -- Where it resides
for Library_Name use "gdk_pixbuf-2.0"; -- Its name (no ".so" ending)
for Library_Kind use "dynamic"; -- Shared in this case
end Gdk_Pixbuf;

Then with it in your project:

with "gdk_pixbuf.gpr";
project My_Library is
... -- No linker package needed
end My_Library;

That is. gnatmake and gprbuild will add necessary linker options to all
projects referencing My_Library.

What about adding this as a requirement to the Debian policy?

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Ludovic Brenta on
"Dmitry A. Kazakov" <mailbox(a)dmitry-kazakov.de> writes:
> In the past we are used to link external libraries using package Linker and
> Default_Switches ("ada") set to, e.g. "-lgdk_pixbuf-2.0". The problem with
> this approach is that Linker package is not automatically inherited. There
> exist different workarounds all more or less unpleasant.
>
> Meanwhile there is IMO a cleaner and simpler way. Just create a gpr file
> for the library(es) in use. For example:
>
> project Gdk_Pixbuf is
> for Externally_Built use "true";
> for Source_Files use ();
> for Library_Dir use "/usr/lib"; -- Where it resides
> for Library_Name use "gdk_pixbuf-2.0"; -- Its name (no ".so" ending)
> for Library_Kind use "dynamic"; -- Shared in this case
> end Gdk_Pixbuf;
>
> Then with it in your project:
>
> with "gdk_pixbuf.gpr";
> project My_Library is
> ... -- No linker package needed
> end My_Library;
>
> That is. gnatmake and gprbuild will add necessary linker options to all
> projects referencing My_Library.
>
> What about adding this as a requirement to the Debian policy?

It seems you forgot to read §5.3.6 GNAT project file and §6 Using shared
libraries.

--
Ludovic Brenta.
From: Dmitry A. Kazakov on
On Sun, 16 May 2010 22:48:19 +0200, Ludovic Brenta wrote:

> "Dmitry A. Kazakov" <mailbox(a)dmitry-kazakov.de> writes:
>> In the past we are used to link external libraries using package Linker and
>> Default_Switches ("ada") set to, e.g. "-lgdk_pixbuf-2.0". The problem with
>> this approach is that Linker package is not automatically inherited. There
>> exist different workarounds all more or less unpleasant.
>>
>> Meanwhile there is IMO a cleaner and simpler way. Just create a gpr file
>> for the library(es) in use. For example:
>>
>> project Gdk_Pixbuf is
>> for Externally_Built use "true";
>> for Source_Files use ();
>> for Library_Dir use "/usr/lib"; -- Where it resides
>> for Library_Name use "gdk_pixbuf-2.0"; -- Its name (no ".so" ending)
>> for Library_Kind use "dynamic"; -- Shared in this case
>> end Gdk_Pixbuf;
>>
>> Then with it in your project:
>>
>> with "gdk_pixbuf.gpr";
>> project My_Library is
>> ... -- No linker package needed
>> end My_Library;
>>
>> That is. gnatmake and gprbuild will add necessary linker options to all
>> projects referencing My_Library.
>>
>> What about adding this as a requirement to the Debian policy?
>
> It seems you forgot to read �5.3.6 GNAT project file and �6 Using shared
> libraries.

5.3.6 seems to refer to the Ada library being packaged. What I mean is a
way to reference to an external C library, e.g. libgdk_pixbuf in the
example.

As for 6, it gives an example

with "LIBRARY";
project PROGRAM is
for Source_Dirs use (".");
for Object_Dir use "obj";
for Exec_Dir use ".";
for Main use ("PROGRAM");
package Linker is
for Default_Switches ("Ada") use ("/usr/lib/libLIBRARY.a");
end Linker;
end;

that uses Default_Switches. It were not necessary if the LIBRARY.gpr (in
5.3.6) described both static and dynamic builds controlled by Library_Type
variable. gnatmake is smart enough to choose either *.a or *.so for the
dependant library/application. E.g.

project LIBRARY is
type Library_Kind_Type is ("static", "relocatable");
Library_Kind : Library_Kind_Type :=
external ("Library_Type", "relocatable");
for Library_Kind use Library_Kind;
for Library_Name use "LIBRARY"; -- Valid for either choice
for Library_Dir use "/usr/lib"; -- Valid for either choice
...
for Externally_Built use "true";
end LIBRARY;

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Ludovic Brenta on
"Dmitry A. Kazakov" <mailbox(a)dmitry-kazakov.de> writes:
> On Sun, 16 May 2010 22:48:19 +0200, Ludovic Brenta wrote:
>
>> "Dmitry A. Kazakov" <mailbox(a)dmitry-kazakov.de> writes:
>>> In the past we are used to link external libraries using package Linker and
>>> Default_Switches ("ada") set to, e.g. "-lgdk_pixbuf-2.0". The problem with
>>> this approach is that Linker package is not automatically inherited. There
>>> exist different workarounds all more or less unpleasant.
>>>
>>> Meanwhile there is IMO a cleaner and simpler way. Just create a gpr file
>>> for the library(es) in use. For example:
>>>
>>> project Gdk_Pixbuf is
>>> for Externally_Built use "true";
>>> for Source_Files use ();
>>> for Library_Dir use "/usr/lib"; -- Where it resides
>>> for Library_Name use "gdk_pixbuf-2.0"; -- Its name (no ".so" ending)
>>> for Library_Kind use "dynamic"; -- Shared in this case
>>> end Gdk_Pixbuf;
>>>
>>> Then with it in your project:
>>>
>>> with "gdk_pixbuf.gpr";
>>> project My_Library is
>>> ... -- No linker package needed
>>> end My_Library;
>>>
>>> That is. gnatmake and gprbuild will add necessary linker options to all
>>> projects referencing My_Library.
>>>
>>> What about adding this as a requirement to the Debian policy?
>>
>> It seems you forgot to read §5.3.6 GNAT project file and §6 Using shared
>> libraries.
>
> 5.3.6 seems to refer to the Ada library being packaged. What I mean is a
> way to reference to an external C library, e.g. libgdk_pixbuf in the
> example.

Ah, I had not caught that subtlety. There are currently 2517 -dev
packages in the libdevel section of Debian unstable. Are you suggesting
that each -dev package for the C language should provide a GNAT Project
file? Or that each -dev package for an Ada library should provide an
individual project file for each C library referenced? That seems like
a *lot* of work.

> As for 6, it gives an example
>
> with "LIBRARY";
> project PROGRAM is
> for Source_Dirs use (".");
> for Object_Dir use "obj";
> for Exec_Dir use ".";
> for Main use ("PROGRAM");
> package Linker is
> for Default_Switches ("Ada") use ("/usr/lib/libLIBRARY.a");
> end Linker;
> end;
>
> that uses Default_Switches. It were not necessary if the LIBRARY.gpr (in
> 5.3.6) described both static and dynamic builds controlled by Library_Type
> variable. gnatmake is smart enough to choose either *.a or *.so for the
> dependant library/application. E.g.
>
> project LIBRARY is
> type Library_Kind_Type is ("static", "relocatable");
> Library_Kind : Library_Kind_Type :=
> external ("Library_Type", "relocatable");
> for Library_Kind use Library_Kind;
> for Library_Name use "LIBRARY"; -- Valid for either choice
> for Library_Dir use "/usr/lib"; -- Valid for either choice
> ...
> for Externally_Built use "true";
> end LIBRARY;

That's a nice suggestion. I'll try to implement that for the release
after Squeeze.

--
Ludovic Brenta.
From: Stephen Leake on
Ludovic Brenta <ludovic(a)ludovic-brenta.org> writes:

> "Dmitry A. Kazakov" <mailbox(a)dmitry-kazakov.de> writes:
>> On Sun, 16 May 2010 22:48:19 +0200, Ludovic Brenta wrote:
>>
>> 5.3.6 seems to refer to the Ada library being packaged. What I mean is a
>> way to reference to an external C library, e.g. libgdk_pixbuf in the
>> example.
>
> Ah, I had not caught that subtlety. There are currently 2517 -dev
> packages in the libdevel section of Debian unstable. Are you suggesting
> that each -dev package for the C language should provide a GNAT Project
> file?

That would be the best thing for Ada users :). But then Perl, Python etc
would demand equal treatment.

> Or that each -dev package for an Ada library should provide an
> individual project file for each C library referenced? That seems like
> a *lot* of work.

Perhaps 'gcc -fdump-ada-spec' could be enhanced to generate the
corresponding gpr file (or maybe it does that already?).

>> project LIBRARY is
>> type Library_Kind_Type is ("static", "relocatable");
>> Library_Kind : Library_Kind_Type :=
>> external ("Library_Type", "relocatable");
>> for Library_Kind use Library_Kind;
>> for Library_Name use "LIBRARY"; -- Valid for either choice
>> for Library_Dir use "/usr/lib"; -- Valid for either choice
>> ...
>> for Externally_Built use "true";
>> end LIBRARY;
>
> That's a nice suggestion. I'll try to implement that for the release
> after Squeeze.

We can do this now for individual packages; the only thing the policy
needs is a standard name for the "Library_Type" environment variable.

--
-- Stephe