automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using two compilers


From: Juha Jäykkä
Subject: Using two compilers
Date: Mon, 07 Jun 2004 12:10:53 +0300

Hello! I found the following piece of conversation on how to compile parts
of a program with a non-standard CC. It is from the automake list
archives.

I have exactly the same situation: a set of source files must be compiled
with ordinary CC but some of them with mpicc (or AIX's mpxlc). Is the
reply below (at over a year old) still how things work today? At least
there does not seem to be a "AC_PROG_CC_FOR_BUILD" any more and having two
different configure.ac's seems horrible switching between two configures
all the time - not a major hassle when actually using the program, but
during development it sounds horrible.

To me it seems, the easiest way to accomplish this would be to be able to
define something like "program_CC = @MPICC@" and then just use AC_PROG_CC
and friends to find out the compiler, libraries etc and use AC_SUBST to
replace @MPICC@ from Makefile. Would this require tweaking automake itself
(which I cannot do) or can this be done with a m4 script?

Thanks for your time!


--snip--

Re: Can I select a different compiler ??

    * From: Ronald Landheer-Cieslak <ronald at landheer dot com>
    * To: "Dr. David Kirkby" <drkirkby at ntlworld dot com>
    * Cc: automake <automake at gnu dot org>
    * Cc: "autoconf at gnu dot org" <autoconf at gnu dot org>
    * Date: Wed, 16 Apr 2003 10:23:16 +0200 (CEST)
    * Subject: Re: Can I select a different compiler ??

The easiest way I know to do what you want, is to separate foo and foobar,

using two configure.ac files. The configure.ac file would contain an 
AC_PROG_CC invocation with the different "special" compilers, which would 
make the configure script search for those in stead of the standard list 
of compilers.

Failing that, you'll have to write your own m4 macro to scan for the 
compilers, much like AC_PROG_CC_FOR_BUILD does - but note that 
AC_PROG_CC_FOR_BUILD doesn't work for the current autoconf and I don't 
know why (yet) (apparently, the pushdefs don't get propagated correctly).

HTH

rlc


On Tue, 15 Apr 2003, Dr. David Kirkby wrote:
> Hi,
>       I'm using autoconf/automake on a set of programs (call them foo
>       and
> foobar) that are likely to use two different C compilers. foo is
> likely to be compiled with gcc or cc (as determined by the configure
> script) and will of course be set by the configure script to the
> variable CC.
> 
> The other compiler, needed to compile foobar, is a bit more
> specialised and might typically be be called mpicc,  hcc, mpcc, mpcc_r
> or whatever. This compiler is used for compiling code to run on a
> network of distributed computers. This compiler is set to the variable
> MPICC and the linker flags are set to MPILIBS. These are both set
> using an M4 macro called from the configure script. 
> 
> I want to compile+link foo with the $CC compiler and $LIBS, but foobar
> with the $MPICC compiler and $MPILIB + $LIBS libraries. I've sorted
> out how to do the libraries (see below), but I'm not sure how to
> enforce foobar to be compiled/linked using $MPICC rather than the
> normal $CC.
> 
> # This is part of the Makefile.am. 
> # foo needs no special treatment, as the default $CC compiler is fine. 
> bin_PROGRAMS = foo foobar
> foo_SOURCES = foo1.c foo2.c
> foo_LDADD = @LIBS@
> 
> # foobar needs to be compiled with the $MPICC compiler and linked with
> $MPILIBS.
> # the linker is easy to sort out, but how about the compiler ???????
> foobar_SOURCES = foobar1.c foobar2.c
> foobar_LDADD = @LIBS@ @MPILIB@



-- 
                 -----------------------------------------------
                | Juha Jäykkä, address@hidden                   |
                | Laboratory of Theoretical Physics             |
                | Department of Physics, University of Turku    |
                | home: http://www.utu.fi/~juolja/              |
                 -----------------------------------------------

Attachment: pgppBXPWDWQGo.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]