comp.lang.ada
 help / color / mirror / Atom feed
From: Warren <ve3wwg@gmail.com>
Subject: Re: Autoconf & gnat Help Needed
Date: Thu, 22 Apr 2010 15:59:49 +0000 (UTC)
Date: 2010-04-22T15:59:49+00:00	[thread overview]
Message-ID: <Xns9D627A0ACB29EWarrensBlatherings@188.40.43.245> (raw)
In-Reply-To: Xns9D6274A3FCC0CWarrensBlatherings@188.40.43.245

Warren expounded in news:Xns9D6274A3FCC0CWarrensBlatherings@
188.40.43.245:

> Stephen Leake expounded in news:82sk6nn4vn.fsf@stephe-leake.org:
> 
>> Warren <ve3wwg@gmail.com> writes:
>> 
>>> Has anyone here had experience using GNAT with autoconf/automake?
...

Ok, I got this thang working together now, including
autoconf, automake and libtool. For anyone interested,
this is one way you can do it.

My executable is named z9. So in Makefile.am specify:

bin_PROGRAMS = z9

as per usual. I also build a static library containing 
all the related C/C++ modules (mine included a C++ main
program, thanks to ncurses).  So for the final target
specify something like:

z9$(EXEEXT): libz9.la 
   gnatmake $(AFLAGS) z9.adb
   gnatbind -n z9.ali
   libtool --mode=link --tag=CC gnatlink z9.ali --GCC=g++ \
       --LINK=g++ -L. -lz9 -lncurses -lpanel -o z9

The $(EXEEXT) is necessary for Cygwin builds.

File libz9.la is the surrogate for the static library of
C/C++ programs, which is listed as a dependency to
cause it to be created by libtool first. The
AFLAGS is just GNAT compile options, of the form:

DEBUG  = -g -O0
AFLAGS = $(DEBUG) -gnat05 -Wall -gnatwl ...

z9.adb was the starting point for my Ada code. It gets
invoked by the C++ main program. Specifying that, causes
all dependant Ada units to be compiled as usual by
gnatmake.

The libtool --mode=link is the tricky part:

You have to lie to libtool with --tag=CC (for C++) for 
a C++ build. 

I didn't try it, but presumably if you only have C 
modules, --tag=C will work (also remove "--GCC=g++" 
and "--LINK=g++" as well from the libtool command).

Then specify the entire rest of the gnatlink command line. 
libtool does however require that you explicitly specify 
the output file with the -o option ("-o z9", in this case).

Life is good, albeit a bit complex.

Warren



  reply	other threads:[~2010-04-22 15:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-21 19:54 Autoconf & gnat Help Needed Warren
2010-04-21 20:31 ` Charmed Snark
2010-04-22 10:23 ` Georg Bauhaus
2010-04-22 15:19   ` Warren
2010-04-22 10:44 ` Stephen Leake
2010-04-22 15:27   ` Warren
2010-04-22 15:59     ` Warren [this message]
2010-04-23  6:48     ` Stephen Leake
2010-04-23 13:44       ` Warren
2010-04-23 18:39         ` Vadim Godunko
2010-04-23 20:13           ` Warren
2010-04-24 11:18             ` Stephen Leake
2010-04-26 15:01               ` Warren
2010-04-27  6:57                 ` Alex R. Mosteo
2010-04-27 13:21                   ` Warren
2010-04-23 18:41 ` Vadim Godunko
2010-04-23 20:18   ` Warren
2010-04-24  0:11     ` Ludovic Brenta
2010-04-26 15:06       ` Charmed Snark
2010-04-26 18:30       ` Robert A Duff
2010-04-24 12:54     ` Vadim Godunko
2010-04-26 15:25       ` Warren
replies disabled

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