How do I get autotools to compile with the Intel compiler?
Asked Answered
G

4

10

I want my code to compile with the Intel compiler(s) or with gcc/g++ depending on a configure argument. Is this possible? What do I need to put in my configure.ac and Makefile.am files to make this happen?

Gatewood answered 14/8, 2009 at 21:56 Comment(0)
I
11

If you want to use a compiler other than gcc when you compile, pass 'CC=/path/to/compiler' as an argument to configure. (That is, run ./configure CC=/path. Do not use the form CC=/path ./configure.) If you want the default compiler to be something other than gcc, you can put

CC=${CC-/path/to/default/compiler}

in configure.ac before the invocation of AC_PROG_CC.

Intelligibility answered 15/8, 2009 at 12:18 Comment(1)
This is not a good approach. Use AC_PROG_CC as advised by freedrull instead.Intelligibility
T
16

I would do this:

AC_PROG_CC([icc gcc])

This will look for the compilers in the order specified, unless overridden with an argument to ./configure

$ ./confgure CC=gcc
Telemeter answered 24/2, 2011 at 5:47 Comment(0)
I
11

If you want to use a compiler other than gcc when you compile, pass 'CC=/path/to/compiler' as an argument to configure. (That is, run ./configure CC=/path. Do not use the form CC=/path ./configure.) If you want the default compiler to be something other than gcc, you can put

CC=${CC-/path/to/default/compiler}

in configure.ac before the invocation of AC_PROG_CC.

Intelligibility answered 15/8, 2009 at 12:18 Comment(1)
This is not a good approach. Use AC_PROG_CC as advised by freedrull instead.Intelligibility
E
4

Of course it is. You can configure a default compiler in configure.ac and if the user wants to use another compiler, he (or she) can pass it to the ./configure script.

You'll find more about it here: How to use autotools.

The part that might be interesting for you is at the middle of the page:

#if a compiler is not specified by the user use intel compilers
AC_PATH_PROG(CC_PATH, $CC, NO_PATH)
if test "$CC_PATH" = NO_PATH; then
 CC="icc"
fi
Epiphragm answered 14/8, 2009 at 23:15 Comment(2)
Can't you just do this as well:Telemeter
Under autoconf 2.69, what you suggested results in The usual way to define 'CC' is to add 'AC_PROG_CC' for me.Triturate
S
2

Usually you can just run

bash $ CC=icc ./configure

to use lcc, or any other compiler as the C compiler, provided the rest of the configure and build process doesn't use any gcc'ism.

Sharell answered 15/8, 2009 at 0:19 Comment(1)
It is better to use: $ ./configure CC=icc. If you pass CC as an argument to configure then re-configuring with config-status will work. If you set CC in the environment, then it will not.Intelligibility

© 2022 - 2024 — McMap. All rights reserved.