From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: How to supply O/S linker arguments with gprbuild?
Date: Tue, 23 Jun 2020 11:23:43 +0200 [thread overview]
Message-ID: <rcshn0$rbs$1@dont-email.me> (raw)
In-Reply-To: <3f234cce-c49f-40a4-83a4-f0c9860d8abfo@googlegroups.com>
Den 2020-06-22 kl. 17:51, skrev Warren:
> 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.
>
> Warren
>
This was just (basically) discussed recently in thread
'Checking for OS in gnatstudio project file(.gpr)'
I replied with scnenario/environment variables does the trick
db_libs := ();
case db is
when Oracle => db_libs := db_lib1;
when Postgresql => db_libs := db_lib2;
when sqlserver => db_libs := db_lib3;
end case
then you can use db_libs and fill it up and use it like
ORACLE_HOME := external ("ORACLE_HOME", "ORACLE_HOME_not_set");
ORACLE_CLIENT := external ("ORACLE_CLIENT", "ORACLE_CLIENT_not_set");
ORA_INST := external ("ORACLE_INST", "ORACLE_INST_not_set");
LIB_SATTMATE := external ("SATTMATE_A", "SATTMATE_A_not_set");
....
there is also
Target_Machine : Environment.OS_Version_Type := Environment.Os_Version;
Compiler_Version : Environment.Compiler_Version_Type :=
Environment.Compiler_Version;
Data_Base : Environment.Database_Type := Environment.Database;
then it comes down to casing the correct combinations
case Target_Machine is
when "AIX_7.1" =>
case Database is
when "oracle_11" => db_libs :=
(SMT & "/global/sqlifc_oracle.o",
ORACLE_CLIENT & "/lib/libclntsh.a");
when "oci" => Data_Base_Libs :=
(ORACLE_CLIENT & "/lib/libclntsh.a",
SATTMATE_OCILIB & "/lib/libocilib.a");
when others => null;
end case;
Platform_Dependent_Compiler_Switches := ("-mminimal-toc") ;
Platform_Dependent_Linker_Switches := ("-L" & SMT & "/global",
LIB_SATTMATE,
"-Xlinker",
"-bhalt:5") & db_libs;
when "windows_6.2" =>
case Database is
when "oracle_11" => db_libs :=
(SMT & "/global/sqlifc_oracle.o",
ORA_INST & "/precomp/lib/oraSQL11.LIB");
when "oci" => db_libs :=
("-L" & ORACLE_CLIENT & "/bin",
"-loci",
"-L" & SATTMATE_OCILIB,
"-lociliba");
when "sqlserver" => db_libs := ("-lodbc32");
when others => null;
end case;
Platform_Dependent_Compiler_Switches := ("-gnatP");
Platform_Dependent_Linker_Switches :=
("-L" & SMT & "/global",
"-lsattmate") & db_libs;
when "linux-x64" => ....
when "linux-arm32" => ...
end case;
then use it like (the not previously shown varibles get values in other
case statemets)
package Compiler is
for Default_Switches ("Ada") use
Platform_Independent_Compiler_Switches &
Compiler_Dependent_Compiler_Switches &
Platform_Dependent_Compiler_Switches;
end Compiler;
package Linker is
for Default_Switches ("Ada") use Platform_Dependent_Linker_Switches;
end Linker;
Scenario variables are useful too to include a certain directory among
sources or not, like having common specs but os/db depedent bodies.
make directories win_x86, winx64,Linux_x64/mac/aix/whaterever and
include the correct one in Sources_dir
for Source_Dirs use common_dirs & (../win_x86);
--
Björn
prev parent reply other threads:[~2020-06-23 9:23 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
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 [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox