comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: How to supply O/S linker arguments with gprbuild?
Date: Mon, 22 Jun 2020 18:39:02 +0200	[thread overview]
Message-ID: <rcqmr4$1rc9$1@gioia.aioe.org> (raw)
In-Reply-To: 3f234cce-c49f-40a4-83a4-f0c9860d8abfo@googlegroups.com

On 22/06/2020 17:51, Warren wrote:
> I have a GNAT project that has these pragma statements embedded to get the sucker to link. However, the directory is only valid for an instance on my Mac, so I need a better solution to replace:
> 
>     pragma Linker_Options("-L/usr/local/Cellar/readline/8.0.4/lib");
>     pragma Linker_Options("-lreadline");
> 
> I've tried to find the solution in the gnat documents but they seem to fall short of what I need to do (could not find an example nor direction in this -- perhaps I missed it).
> 
> My project file looks something like this:
> 
> project MyProject is
>      for Languages use ("ada", "c");
>      for Source_Dirs use ("src");
>      for Object_Dir use "obj";
>      for Main use ("main.adb");
> end MyProject;
> 
> I've tried a variety of gpr things, but unsuccessfully.

There are many ways to do this.

Here I give one rarely used but most flexible and consistent with the 
idea of projects.

If you have an alien library like readline, you can pack it in a 
separate library project like this:

project Readline is
    for Externally_Built use "true"; -- Do not build it
    for Source_Files use ();         -- No sources
    for Library_Dir use "/usr/local/Cellar/readline/8.0.4/lib";
    for Library_Name use "readline"; -- OS naming conventions applied
    for Library_Kind use "dynamic";  -- Or static,
end Readline;                       -- depending on what you have

In your project or projects you would simply do

with "readline.gpr";

and that is all.

Adjust the above using a scenario variable to select the target OS, e.g.

    type OS_Type is
         (  "Windows", "Windows_NT",
            "Linux",
            "UNIX",
            "OSX",
            "FreeBSD",
            ...
         );
    Target_OS : OS_Type := external ("Target_OS", "MS-DOS");

    case Target_OS is
       when "ms-dos" =>
          for Library_Dir use "...";
       when "osx" =>
          for Library_Dir use "...";
          ...

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  parent reply	other threads:[~2020-06-22 16:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-22 15:51 How to supply O/S linker arguments with gprbuild? Warren
2020-06-22 16:14 ` Mark Lorenzen
2020-06-22 16:30 ` Dennis Lee Bieber
2020-06-22 16:39 ` Dmitry A. Kazakov [this message]
2020-06-22 17:52   ` Warren
2020-06-22 20:07     ` Dmitry A. Kazakov
2020-06-22 20:43       ` Simon Wright
2020-06-22 20:59         ` Warren
2020-06-22 21:52           ` Simon Wright
2020-06-22 21:16         ` Dmitry A. Kazakov
2020-06-22 21:27           ` Warren
2020-06-22 21:47           ` Simon Wright
2020-06-22 22:08             ` Jeffrey R. Carter
2020-06-23  9:23 ` Björn Lundin
replies disabled

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