Discussion:
no way to conditionally check for a C compiler?
Per Bothner
2014-01-19 23:58:51 UTC
Permalink
My problem: I use autoconf+automake for Kawa. (There is an option
to build using Ant, but it doesn't support running all the tests,
for example.) Most of Kawa is written in Java, but there is a
--enable-kawa-frontend option that builds a small C front-end wrapper
that uses readline.

This means I have to do AC_PROG_CC unconditionally, which means
you can't run configure unless a C compiler is available. This is
a shame, since you only need the C compiler if --enable-kawa-frontend
is selected.

I realize this is a highly unusual use-case, and autoconf can't
necessarily be all things to everyone. I thought I'd just ask if
there is a recommended solution.

I tried:

AC_CHECK_PROG(CC, gcc cc, missing-c-compiler)
AC_SUBST(CC)

But then automake complains:

/usr/share/automake-1.13/am/depend2.am: error: am__fastdepCC does not
appear in AM_CONDITIONAL
/usr/share/automake-1.13/am/depend2.am: The usual way to define
'am__fastdepCC' is to add 'AC_PROG_CC'
/usr/share/automake-1.13/am/depend2.am: to 'configure.ac' and run
'aclocal' and 'autoconf' again

I kludged this by adding:

AM_CONDITIONAL(AMDEP,false) dnl kludge
AM_CONDITIONAL(am__fastdepCC,false) dnl kludge

But then AC_OBJEXT is ignored.

So it all seems to be tied together: I can use autoconf+automake
as designed to compile C/C++ porgrams - but *only* if I do so
unconditionally. Otherwise I need to roll my own.

The advice "never perform tests conditionally: depend conditionally
on their output!" doesn't apply when the tests conditionally abort ...
--
--Per Bothner
***@bothner.com http://per.bothner.com/
Keith Marshall
2014-01-20 15:32:19 UTC
Permalink
Post by Per Bothner
This means I have to do AC_PROG_CC unconditionally, which means
you can't run configure unless a C compiler is available. This is
a shame, since you only need the C compiler if --enable-kawa-frontend
is selected.
I guess this is another facet of the issue I raised here:
http://thread.gmane.org/gmane.comp.sysutils.autoconf.general/15448

This has not (yet) elicited any response.
Post by Per Bothner
I realize this is a highly unusual use-case, and autoconf can't
necessarily be all things to everyone. I thought I'd just ask if
there is a recommended solution.
Not so unusual, surely, since building GCC itself requires some such
capability; (witness, the GCC_NO_EXECUTABLES macro).
--
Regards,
Keith.
Loading...