From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Bj=c3=b6rn_Lundin?= Newsgroups: comp.lang.ada Subject: Re: How to supply O/S linker arguments with gprbuild? Date: Tue, 23 Jun 2020 11:23:43 +0200 Organization: A noiseless patient Spider Message-ID: References: <3f234cce-c49f-40a4-83a4-f0c9860d8abfo@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 23 Jun 2020 09:23:44 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="c2a8d7197c9d47c55df82d0714facfda"; logging-data="28028"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/25gMTjQXy2L/5L9LOH4oG" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 Cancel-Lock: sha1:wzj3wgLfFPb4rBRaOFK64hGKyGY= In-Reply-To: <3f234cce-c49f-40a4-83a4-f0c9860d8abfo@googlegroups.com> Content-Language: sv Xref: reader01.eternal-september.org comp.lang.ada:59182 List-Id: 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