Discussion:
Configure for non-gcc compiler
A.P. Horst
2013-04-18 18:06:12 UTC
Permalink
Hi,

been trying my way in autotools land for a short while now, and I must
say, it works like a charm.
But there is one thing I've been breaking my head on for a while now.
Many of my projects use GCC, some use a totally different compiler and
worse, some are mixed. How do I go about that with autoconf? Is there an
easy way to 'add' a compiler to check for? Or a hard way?
If somebody could give me some handles to work with, I would be very
thankful. My searches on the internet have turned up squat, bit might be
I didn't use the magic combo of keywords.

Arie
Mike Frysinger
2013-04-18 18:20:22 UTC
Permalink
Post by A.P. Horst
been trying my way in autotools land for a short while now, and I must
say, it works like a charm.
But there is one thing I've been breaking my head on for a while now.
Many of my projects use GCC, some use a totally different compiler and
worse, some are mixed. How do I go about that with autoconf? Is there an
easy way to 'add' a compiler to check for? Or a hard way?
If somebody could give me some handles to work with, I would be very
thankful. My searches on the internet have turned up squat, bit might be
I didn't use the magic combo of keywords.
check out this project:
http://www.gnu.org/software/autoconf-archive/
it includes a lot of macros like doing compiler/linker checks

if you want to be lazy, there is a $GCC var that autoconf sets up so it's not
uncommon for packages to do:
AS_IF([test "$GCC" = "yes"], [dnl
...
])
-mike
Eric Blake
2013-04-18 19:23:09 UTC
Permalink
Post by A.P. Horst
Hi,
been trying my way in autotools land for a short while now, and I must
say, it works like a charm.
But there is one thing I've been breaking my head on for a while now.
Many of my projects use GCC, some use a totally different compiler and
worse, some are mixed. How do I go about that with autoconf? Is there an
easy way to 'add' a compiler to check for? Or a hard way?
What do you mean by adding a compiler? Your user can already do:

./configure CC=/path/to/weird/cc

to get whatever compiler they want, without you as the configure.ac
author even having to know about their weird compiler name. As long as
you correctly wrote your configure.ac to do feature tests (such as "does
$CC -Wall work?") rather than hard-coded tests ("is $CC named GCC?" or
"is the compiler newer than version 1.5?"), then your configure script
should already just work.

Using AC_PROG_CC without arguments already provides your configure
script with a rather long list of compiler names to try, but it you are
absolutely certain that you want to make an even longer list of default
compiler names to try by default, you can call AC_PROG_CC([gcc cc ...])
to populate the list with your set of default names. See
https://www.gnu.org/software/autoconf/manual/autoconf.html#C-Compiler
for details.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Paul Eggert
2013-04-18 19:27:06 UTC
Permalink
Post by A.P. Horst
worse, some are mixed
Autoconf doesn't work very well if you use different C compilers
to compile different bits of C code. If the compilers are compatible
with each other it'll work, but if not, you could be in trouble.
If you have that sort of trouble,
my suggestion is to segregate the code by directory, and
to have separate 'configure' scripts in each directory.
As long as you use only one C compiler per directory you
should be OK.
A.P. Horst
2013-04-19 08:24:59 UTC
Permalink
Post by Eric Blake
Using AC_PROG_CC without arguments already provides your configure
script with a rather long list of compiler names to try, but it you are
absolutely certain that you want to make an even longer list of default
compiler names to try by default, you can call AC_PROG_CC([gcc cc ...])
to populate the list with your set of default names.
And here I was thinking this was only to change the default order.
Now I tried this and what I was afraid of is also happening: AC_PROG_CC
tries all kinds of things the compiler doesn't understand. It gets a
long way but then fails with 'cannot compute suffix of object files'
because the compiler doesn't understand the option '-c'.
Do you think it is viable (or even possible) of modifying AC_PROG_CC to
my specific needs? Or should I write a custom macro mimicking AC_PROG_CC
as an exception for this compiler? I know this violates the philosophy
behind autotools, but I see no other way when dealing with embedded targets.
Post by Eric Blake
Autoconf doesn't work very well if you use different C compilers
to compile different bits of C code. If the compilers are compatible
with each other it'll work, but if not, you could be in trouble.
It is not mixed like this file need this compiler and another needs that
compiler, rather I need the complete source tree to be configurable for
different target platforms, of which some require a specific (obscure)
embedded compiler.

Arie
Miles Bader
2013-04-19 09:36:31 UTC
Permalink
Might it be easier to write simple shell script wrappers for these
weird compilers, which export a more conventional interface and
translate the arguments as necessary?

Then you could specify the shell-scripts as CC when invoking the
configure script.

-miles
--
Politics, n. A strife of interests masquerading as a contest of
principles. The conduct of public affairs for private advantage.
Bastien ROUCARIES
2013-04-19 09:51:56 UTC
Permalink
Post by Miles Bader
Might it be easier to write simple shell script wrappers for these
weird compilers, which export a more conventional interface and
translate the arguments as necessary?
Then you could specify the shell-scripts as CC when invoking the
configure script.
compile script exist and is used for visual studio
Post by Miles Bader
-miles
--
Politics, n. A strife of interests masquerading as a contest of
principles. The conduct of public affairs for private advantage.
_______________________________________________
Autoconf mailing list
https://lists.gnu.org/mailman/listinfo/autoconf
A.P. Horst
2013-04-19 09:57:46 UTC
Permalink
Post by Bastien ROUCARIES
Post by Miles Bader
Might it be easier to write simple shell script wrappers for these
weird compilers, which export a more conventional interface and
translate the arguments as necessary?
Then you could specify the shell-scripts as CC when invoking the
configure script.
compile script exist and is used for visual studio
I thought about that, but solving it in the configure script seemed like
a cleaner solution to me.
I will take that lead for now, but please keep me advised if anyone
knows of a cleaner solution.

Arie

Loading...