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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:aed:2846:: with SMTP id r64mr14486526qtd.55.1592848340581; Mon, 22 Jun 2020 10:52:20 -0700 (PDT) X-Received: by 2002:a05:6830:46:: with SMTP id d6mr15038990otp.178.1592848340343; Mon, 22 Jun 2020 10:52:20 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 22 Jun 2020 10:52:20 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=216.121.185.139; posting-account=ENgozAkAAACH-stq5yXctoDQeZQP2E6J NNTP-Posting-Host: 216.121.185.139 References: <3f234cce-c49f-40a4-83a4-f0c9860d8abfo@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <98843f83-9907-4bd4-9600-4bc67e41f883o@googlegroups.com> Subject: Re: How to supply O/S linker arguments with gprbuild? From: Warren Injection-Date: Mon, 22 Jun 2020 17:52:20 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader01.eternal-september.org comp.lang.ada:59164 List-Id: On Monday, 22 June 2020 12:39:05 UTC-4, Dmitry A. Kazakov wrote: > 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: > >=20 > > pragma Linker_Options("-L/usr/local/Cellar/readline/8.0.4/lib"); > > pragma Linker_Options("-lreadline"); > >=20 > > 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). > >=20 > > My project file looks something like this: > >=20 > > 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; > >=20 > > I've tried a variety of gpr things, but unsuccessfully. >=20 > There are many ways to do this. >=20 > Here I give one rarely used but most flexible and consistent with the=20 > idea of projects. >=20 > If you have an alien library like readline, you can pack it in a=20 > separate library project like this: >=20 > 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 >=20 > In your project or projects you would simply do >=20 > with "readline.gpr"; >=20 > and that is all. >=20 > Adjust the above using a scenario variable to select the target OS, e.g. >=20 > type OS_Type is > ( "Windows", "Windows_NT", > "Linux", > "UNIX", > "OSX", > "FreeBSD", > ... > ); > Target_OS : OS_Type :=3D external ("Target_OS", "MS-DOS"); >=20 > case Target_OS is > when "ms-dos" =3D> > for Library_Dir use "..."; > when "osx" =3D> > for Library_Dir use "..."; > ... The above might be useful for some projects, but I didn't want to define a = package for each and every library I link with. I have a simple Makefile th= at drives this project, and I simply wanted a central place to configure th= e pathnames.=20 So I managed to get this to work: project MyProject is =20 for Languages use ("ada", "c"); for Source_Dirs use ("src"); for Object_Dir use "obj"; for Main use ("main.adb"); package Linker is for Required_Switches use ( "-L/usr/local/Cellar/readline/8.0.4/lib", "= -lreadline" ); end Linker; end MyProject; =20 In the final version of the .gpr file, I'll put some sentinel text like and substitute it as required using sed from the Makefile. Cur= rently there is only one path I have to deal with but it might grow to seve= ral. I didn't want to define a package for each and every library reference= d. I find it amazing that there isn't a single instance of an example like thi= s that I could goggle. The gprbuild doc seems to expend a great deal explai= ning every other use case, including building of library packages. All I wa= nted to do was to link an executable. That said, it is possible that my fai= ling eyesight may have overlooked it. Thanks everyone, Warren