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)" > AC_SUBST(CCLD) > > 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 configure.ac files, and either override CC early in each of them, or in the $ac_configure_args variable in a higher-up configure.ac 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 CCLD = $(ALTER_CC) or so in dir2/Makefile.am I guess. > Alternatively, I've also tried this: > > configure.in: > AM_CONDITIONAL(USING_ALTERNATE_COMPILER, [test "$alternate_compiler" != ""]) > > dir2/Makefile.am: > If USING_ALTERNATE_COMPILER > CCLD=gcc-3.3.6 > endif > > But then I get this automake warning: > CCLD was already defined in condition TRUE, which includes condition USING_ALTERNATE_COMPILER â You can override that by using something like AUTOMAKE_OPTIONS = -Wno-syntax if USING_ALTERNATE_COMPILER CCLD = gcc-3.3.6 else CCLD = @CCLD@ endif but of course I should advise against using hard-coded names like that in a Makefile.am. 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 if USING_ALTERNATE_COMPILER CCLD = gcc-3.3.6 endif generates the wrong code: for me, the generated Makefile.in contains CCLD = $(CC) ... @USING_ALTERNATE_COMPILER_TRUE@CCLD = gcc-3.3.6 which amounts to exactly what you desire: override CCLD if and only if USING_ALTERNATE_COMPILER is true. Hope that helps. Cheers, Ralf _______________________________________________ Autoconf mailing list Autoconf@xxxxxxx http://lists.gnu.org/mailman/listinfo/autoconf