[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FCLINK with conditional fortran sources
From: |
Ralf Wildenhues |
Subject: |
Re: FCLINK with conditional fortran sources |
Date: |
Tue, 17 Apr 2007 20:30:47 +0200 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Hello Christopher,
* Christopher Hulbert wrote on Sun, Apr 15, 2007 at 03:58:10PM CEST:
> On 3/26/07, Ralf Wildenhues <address@hidden> wrote:
>> * Christopher Hulbert wrote on Fri, Mar 23, 2007 at 02:27:25AM CET:
>> > I have a library that has an optional fortran interface. I'd rather
>> > not separate this into two different libraries, but on systems without
>> > a fortran compiler, FCLD is empty and creating a libtool archive
>> > fails. Is there another way around this. My Makefile.am is something
>> > like
[...]
> Sorry it took so long to reply. No, automake gives an error. It also
> gives an error trying to redefine FCLINK and FC.
>
> address@hidden automake_error]$ cat Makefile.am && automake
> AUTOMAKE_OPTIONS = foreign no-dependencies
>
> lib_LTLIBRARIES = liba.la
> liba_la_SOURCES = a_c.c
>
> if ENABLE_FORTRAN
> liba_la_SOURCES += a_f.f90
> else
> FCLD=$(CCLD)
> endif
> automake: FCLD was already defined in condition !ENABLE_FORTRAN, which
> is included in condition TRUE ...
> Makefile.am:9: ... `FCLD' previously defined here
Try this:
# Makefile.am
lib_LTLIBRARIES = liba.la
liba_la_SOURCES = a_c.c
if ENABLE_FORTRAN
liba_la_SOURCES += a_f.f90
endif
# configure.ac
# ...
AC_PROG_CC
AC_PROG_FC
AC_PROG_LIBTOOL
AC_ARG_ENABLE([fortran], ... )
AM_CONDITIONAL([ENABLE_FORTRAN], [$enable_fortran])
if test "$enable_fortran" = yes; then
FCLD='$(FC)'
else
FCLD='$(CCLD)'
fi
AC_SUBST(FCLD)
It uses undocumented internals (CCLD and FCLD), but I think this case is
rather benign that way, CCLD is mentioned in the manual anyway.
Hope that helps.
Cheers,
Ralf