I have a C library, GPTL, which is built with libtool. (https://github.com/jmrosinski/GPTL)
I have a Fortran wrapper library, GPTL-fortran, which calls the C library. (https://github.com/NOAA-GSD/GPTL-fortran)
I have a third github repo, GPTL-all. (https://github.com/NOAA-GSD/GPTL-all). I would like to use AC_CONFIG_SUBDIR to have GPTL-all build both the C and the fortran libraries.
The problem is that the Fortran library depends on the C library. When building separately, the C library is built and installed first, then the Fortran library is built with CPPFLAGS and LDFLAGS set to point to the location of the installed C library.
Is there a way to achieve this with a combined package that installs the C and Fortran libraries?
Here's what I have so far:
# This is the autoconf file for GPTL-all, a combined C and Fortran
# library distribution.
AC_PREREQ([2.69])
AC_INIT([GPTL-all], [1.0.0], [[email protected]])
# Find out about the host we're building on.
AC_CANONICAL_HOST
# Find out about the target we're building for.
AC_CANONICAL_TARGET
# Initialize automake.
AM_INIT_AUTOMAKE([foreign subdir-objects])
# Keep macros in an m4 directory.
AC_CONFIG_MACRO_DIR([m4])
# Set up libtool.
LT_PREREQ([2.4])
LT_INIT()
AC_CONFIG_FILES([Makefile])
AC_CONFIG_SUBDIRS([GPTL
GPTL-fortran])
AC_OUTPUT
But this fails. When I run configure, it runs the C library configure just fine. But the fortran library configure fails because it checks for the presence of the C library:
checking for GPTLinitialize in -lgptl... no
configure: error: Can't find or link to the GPTL C library.
configure: error: ./configure failed for GPTL-fortran
How can I get GPTL-fortran to depend on GPTL?