Discussion:
macro which returns found compiler for given language?
Diab Jerius
2015-05-11 15:59:03 UTC
Permalink
I'm trying to determine the version of GNU Fortran by parsing the
compiler's standard output when passed the --version option.

I cannot use AC_COMPILE_IFELSE, as the compiler doesn't generate an
object file when passed --version, and AC_COMPILE_IFELSE requires that
for success.

I've resorted to using the _AC_CC macro to get the name of the
compiler so that I can execute it directly, but that's not good
practice.

Is there a public macro which provides the compiler for a given language?

Thanks,

Diab
Daily, Jeff A
2015-05-11 16:40:53 UTC
Permalink
-----Original Message-----
Sent: Monday, May 11, 2015 8:59 AM
Subject: macro which returns found compiler for given language?
I'm trying to determine the version of GNU Fortran by parsing the
compiler's standard output when passed the --version option.
I cannot use AC_COMPILE_IFELSE, as the compiler doesn't generate an
object file when passed --version, and AC_COMPILE_IFELSE requires that
for success.
I've resorted to using the _AC_CC macro to get the name of the
compiler so that I can execute it directly, but that's not good
practice.
Is there a public macro which provides the compiler for a given language?
Why do you need an autoconf macro to provide this?

If a shell variable is sufficient, then use the following:

C -> $CC
C++ -> $CXX
Fortran77 -> $F77
Fortran -> $FC

These output variables are documented in the autoconf manual under AC_PROG_CC, AC_PROG_CXX, AC_PROG_F77, AC_PROG_FC, respectively.
Diab Jerius
2015-05-11 17:14:04 UTC
Permalink
Post by Daily, Jeff A
-----Original Message-----
Sent: Monday, May 11, 2015 8:59 AM
Subject: macro which returns found compiler for given language?
I'm trying to determine the version of GNU Fortran by parsing the
compiler's standard output when passed the --version option.
I cannot use AC_COMPILE_IFELSE, as the compiler doesn't generate an
object file when passed --version, and AC_COMPILE_IFELSE requires that
for success.
I've resorted to using the _AC_CC macro to get the name of the
compiler so that I can execute it directly, but that's not good
practice.
Is there a public macro which provides the compiler for a given language?
Why do you need an autoconf macro to provide this?
C -> $CC
C++ -> $CXX
Fortran77 -> $F77
Fortran -> $FC
These output variables are documented in the autoconf manual under AC_PROG_CC, AC_PROG_CXX, AC_PROG_F77, AC_PROG_FC, respectively.
D'oh! You know, I think I knew that once upon a time.

Thanks!.

Diab
Diab Jerius
2015-05-11 17:35:45 UTC
Permalink
Post by Diab Jerius
Post by Daily, Jeff A
-----Original Message-----
Sent: Monday, May 11, 2015 8:59 AM
Subject: macro which returns found compiler for given language?
I'm trying to determine the version of GNU Fortran by parsing the
compiler's standard output when passed the --version option.
I cannot use AC_COMPILE_IFELSE, as the compiler doesn't generate an
object file when passed --version, and AC_COMPILE_IFELSE requires that
for success.
I've resorted to using the _AC_CC macro to get the name of the
compiler so that I can execute it directly, but that's not good
practice.
Is there a public macro which provides the compiler for a given language?
Why do you need an autoconf macro to provide this?
C -> $CC
C++ -> $CXX
Fortran77 -> $F77
Fortran -> $FC
These output variables are documented in the autoconf manual under AC_PROG_CC, AC_PROG_CXX, AC_PROG_F77, AC_PROG_FC, respectively.
D'oh! You know, I think I knew that once upon a time.
Unfortunately, after further thought, the output variables aren't
sufficient for what I need.

As the code cannot assume which flavor of Fortran is being tested,
without more information it cannot choose between F77 or FC.

If the current language were known, the code could choose
appropriately, but the only macro available (AFAIK) to query the
current language is AC_LANG_ASSERT, which is inappropriate in this
context. It'd be much cleaner if one could get the compiler for the
current language, or have _AC_CC exposed as part of the public API.
Nick Bowler
2015-05-11 18:31:21 UTC
Permalink
Post by Diab Jerius
Post by Diab Jerius
Post by Daily, Jeff A
These output variables are documented in the autoconf manual under
AC_PROG_CC, AC_PROG_CXX, AC_PROG_F77, AC_PROG_FC, respectively.
D'oh! You know, I think I knew that once upon a time.
Unfortunately, after further thought, the output variables aren't
sufficient for what I need.
As the code cannot assume which flavor of Fortran is being tested,
without more information it cannot choose between F77 or FC.
If the current language were known, the code could choose
appropriately, but the only macro available (AFAIK) to query the
current language is AC_LANG_ASSERT, which is inappropriate in this
context. It'd be much cleaner if one could get the compiler for the
current language, or have _AC_CC exposed as part of the public API.
There is AC_LANG_CASE:

AC_LANG_CASE(
[Fortran], [...do stuff with $FC],
[Fortran 77], [...do stuff with $F77],
[neither option])

It seems this function is not documented in the manual, but it probably
should be.

Cheers,
--
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
Diab Jerius
2015-05-11 19:43:41 UTC
Permalink
Post by Nick Bowler
Post by Diab Jerius
Post by Diab Jerius
Post by Daily, Jeff A
These output variables are documented in the autoconf manual under
AC_PROG_CC, AC_PROG_CXX, AC_PROG_F77, AC_PROG_FC, respectively.
D'oh! You know, I think I knew that once upon a time.
Unfortunately, after further thought, the output variables aren't
sufficient for what I need.
As the code cannot assume which flavor of Fortran is being tested,
without more information it cannot choose between F77 or FC.
If the current language were known, the code could choose
appropriately, but the only macro available (AFAIK) to query the
current language is AC_LANG_ASSERT, which is inappropriate in this
context. It'd be much cleaner if one could get the compiler for the
current language, or have _AC_CC exposed as part of the public API.
AC_LANG_CASE(
[Fortran], [...do stuff with $FC],
[Fortran 77], [...do stuff with $F77],
[neither option])
It seems this function is not documented in the manual, but it probably
should be.
Thanks, that works nicely.

Diab

Loading...