[Top][All Lists]

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


From: Ralf Wildenhues
Subject: Re: AC_SUBST(CCLD)
Date: Sun, 13 Feb 2011 09:06:44 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

Hello Justin,

* Too, Justin A. wrote on Wed, Feb 09, 2011 at 10:50:00PM CET:
> Currently, I have CCLD set to $(CC). Using AC_SUBST, all Makefile's
> will contain this variable.
> Config:
> CC=gcc
> CCLD="$(CC)"
> Generated Makefiles:
> CCLD = gcc
> The problem, however, is that I use different compilers for certain 
> directories. So, for example:
> $ cd dir1/
> $ gcc-4.1.2 –c –o helloworld.o helloworld.c
> $ libtool --tag=CC —mode=link $(CCLD) -o helloworld.out helloworld.o
> $ cd dir2/
> $ gcc-3.3.6 –c –o helloworld.o helloworld.c
> $ libtool —tag=CC —mode=link $(CCLD) -o helloworld.out helloworld.o
> Then, the same $(CCLD) linker is being used for both directories, but
> I need to use the appropriate linkers for each directory, i.e.
> gcc-4.1.2 and gcc-3.3.6.

Autoconf and Libtool don't really have good support for using more than
one compiler (per language) in the same project.  To be really clean
you'd have to have two separate files, and either override
CC early in each of them, or in the $ac_configure_args variable in a
higher-up script before calling the sub configure scripts.

As long as you're using very similar compilers (and for that matter, two
GCC versions are probably eligible), you may be able to get around this
unless at the time you're creating shared libraries.  Point is, libtool
--mode=link completely ignores what compiler you list on the command
line, when you are creating a shared library; when creating a program,
things can work as expected.

> Then, my question is: how can I set CCLD appropriately for different
> Makefiles so autoconf will generate the
> appropriate Libtool link rules for my Makefiles? Or any other suggestions?

You should be able to set

or so in dir2/ I guess.

> Alternatively, I've also tried this:
> AM_CONDITIONAL(USING_ALTERNATE_COMPILER, [test "$alternate_compiler" != ""])
> dir2/
> CCLD=gcc-3.3.6
> endif
> But then I get this automake warning:
> CCLD was already defined in condition TRUE, which includes condition 

You can override that by using something like

CCLD = gcc-3.3.6

but of course I should advise against using hard-coded names like that
in a  If your package has any users at all, where you don't
know their system environment completely yet, such names may simply not
be valid there.

Hmm, how come this needs -Wno-syntax and not -Wno-override?

> And the generated Makefile contains:
> CCLD = gcc-3.3.6
> CCLD = gcc

Which automake version does this come from?  The order should be
reversed.  If you are using a version older than 1.10, please upgrade
and retry.

> So, autoconf put its CCLD into the generated Makefile, basically
> ignoring my declaration of CCLD. Omitting the "if..endif" yields the
> correct result, I.e. One declaration of CCLD.

I don't see how even

CCLD = gcc-3.3.6

generates the wrong code: for me, the generated contains

CCLD = $(CC)
@address@hidden = gcc-3.3.6

which amounts to exactly what you desire: override CCLD if and only if

Hope that helps.


reply via email to

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