autoconf
[Top][All Lists]
Advanced

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

Automatic conditional use of compilers (and how to conditionally use mac


From: Diab Jerius
Subject: Automatic conditional use of compilers (and how to conditionally use macros which REQUIRE them)
Date: Fri, 10 Feb 2023 16:36:44 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2

I have a library which can provides C, C++ and Fortran (F77) interfaces.

On systems without Fortran, I would like to have it (automatically) not build the Fortran interface.

The first obstacle I’ve run into is that

AC_PROG_F77

fails if no compiler is found, aborting the installation.  I’d like to turn that failure into something I can use in a conditional.

If it’s not possible to automatically move on from this failure, I can force the user to make a decision using something like this:

AC_PREREQ([2.57])
AC_INIT([cxcparam],[4.12.0.3],[yeah@yeah.yeah],[cxcparam])

AC_ARG_WITH([fortran],
        [AS_HELP_STRING([--with-fortran],[compile fortran interface library])],
        [use_fortran=$withval],
        [use_fortran=no])

AS_IF([test "x$with_fortran" != xno], [
    AC_PROG_F77
])
AC_OUTPUT

But then there are further obstacles; I would like to use the additional macros

  AC_F77_WRAPPERS
  AC_F77_LIBRARY_LDFLAGS
  AC_F77_FUNC(getarg,GETARG)

but they directly or indirectly REQUIRE AC_PROG_F77, so even if AC_PROG_F77 is wrapped in a conditional, e.g.:

AC_PREREQ([2.57])
AC_INIT([cxcparam],[4.12.0.3],[yeah@yeah.yeah],[cxcparam])

AC_ARG_WITH([fortran],
        [AS_HELP_STRING([--with-fortran],[compile fortran interface library])],
        [use_fortran=$withval],
        [use_fortran=yes])

AS_IF([test "x$with_fortran" != xno], [
    AC_PROG_F77
    AC_F77_WRAPPERS
    AC_F77_LIBRARY_LDFLAGS
    AC_F77_FUNC(getarg,GETARG)
])
AC_OUTPUT

AC_PROG_F77 will always be executed, regardless of the --without-fortran flag (and autoconf will warn

    configure.ac:11: warning: AC_REQUIRE: `AC_PROG_F77' was expanded before it was required
)

I must be missing something obvious.

Any ideas on where I’ve gone astray?

Thanks,

Diab




reply via email to

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