Using ACX_BLAS before AX_PATH_GSL with gfortran 4.3.2
First I tried this in configure.ac:
ACX_BLAS([
export GSL_CBLAS_LIB="${BLAS_LIBS}"
AC_SUBST(GSL_CBLAS_LIB)
],AC_MSG_WARN([Will use gslcblas if it is present. Try --with-blas=<lib>.]))
AX_PATH_GSL(1.12,,AC_MSG_ERROR([Could not find required GSL version.]))
checking for GSL - version >= 1.12... nowith the linking problems in config.log looking like
*** Could not run GSL test program, checking why...
*** The test program failed to compile or link.
configure:7272: gcc -o conftest -I/org/centers/pecos/which a quick Google tells me is because -lgfortran isn't present in the linking line. I tried to obtain the required gfortran libraries in ${FLIBS} by using AC_FC_LIBRARY_LDFLAGS and then use them viaLIBRARIES/GSL/gsl-1.12-gcc-4. 3.1-ubuntu-amd64/include -I/h2/rhys/include -L/h2/rhys/lib conftest.c -L/org/centers/pecos/ LIBRARIES/GSL/gsl-1.12-gcc-4. 3.1-ubuntu-amd64/lib -lgsl -lcblas -lf77blas -latlas -lm >&5
/usr/lib/../lib64/libf77blas.so: undefined reference to `_gfortran_st_write_done'
export GSL_CBLAS_LIB="${BLAS_LIBS} ${FLIBS}"but later in the build I started hitting up against duplicate main issues because -lgfortranbegin winds up in ${FLIBS}.
More random Googling found the answer buried in lapack++'s configure script. The total solution looks like:
AC_PROG_SEDwhere there's an explicit hack to remove -lgfortranbegin from FLIBS. Not pretty, but it seems to work.
ACX_BLAS([
dnl Workaround for bogus FLIBS
FLIBS=`echo ${FLIBS} | ${SED} 's/-lgfortranbegin//'`
export GSL_CBLAS_LIB="${BLAS_LIBS} ${FLIBS}"
AC_SUBST(GSL_CBLAS_LIB)
],AC_MSG_WARN([Will use gslcblas if it is present. Try --with-blas=<lib>.]))
AX_PATH_GSL(1.12,,AC_MSG_ERROR([Could not find required GSL version.]))