For reference.
---------- Forwarded message ---------- From: Giulio Paci <giuliop...@gmail.com> Date: Thu, Mar 14, 2013 at 3:04 AM Subject: Re: f2c and autotools To: Mathieu Malaterre <ma...@debian.org> Cc: Debian Mentors List <debian-ment...@lists.debian.org> Il 13/03/2013 16:01, Mathieu Malaterre ha scritto: > Hi there, > > I am trying to work on #702882 > > Upstream is basically doing: > > if test "$internal_f2c" = "no"; then > AC_CHECK_LIB([f2c], [f77_alloc_], [], > AC_CHECK_LIB([f2c], [f77_alloc], [], > AC_CHECK_LIB([f2c], [F77_ALLOC_], [], > AC_CHECK_LIB([f2c], [F77_ALLOC], [], > [AC_MSG_RESULT(not found, trying to use -lf2c anyway.)])))) > LDFLAGS="${LDFLAGS}" > else AC_DEFINE([INTERNAL_F2C], [1], [Define to 1 if you use the internal > F2C library]) > fi > > > As explained in #702882#5, this fails on debian system since one > cannot link to f2c without first defining a MAIN__ symbol. Has anyone > work on autotools and f2c issue on debian in the past ? How should one > use the autotools *F77* macros to handle this case ? As far as I can see there is no fortran code in the igraph package and as far as I know all the *F77* *FC* macros are useful only to detect proper setup for a specific fortran compiler. I do not think the check above is properly done. However to make it pass, you should (see the attached patch): 1) use C compiler in AC_CHECK_LIB (an AC_LANG_POP(C++) was missing) 2) force the AC_CHECK_LIB to create a MAIN__ function instead of main (the -Dmain=MAIN__ flags is used for that) 3) check for a function that is in libf2c (e.g., f_open) 4) use the -Dmain=MAIN__ flags wherever you are issuing checks that involves linking libf2c This however is only part of the problem: you still have to solve the issue of providing the correct flags/the correct source at compile time. I do not know what is the best way to deal with this kind of problems in Debian. Bests, Giulio.
--- a/configure.ac +++ b/configure.ac @@ -169,7 +169,7 @@ ]) ]) fi -AC_LANG_PUSH([C++]) +AC_LANG_POP([C++]) tls_support=no HAVE_TLS=0 @@ -211,40 +211,57 @@ [internal_glpk=no], [internal_glpk=yes]) +F2C_CPPFLAGS="" if test "$internal_f2c" = "no"; then AC_CHECK_LIB([f2c], [f77_alloc_], [], AC_CHECK_LIB([f2c], [f77_alloc], [], AC_CHECK_LIB([f2c], [F77_ALLOC_], [], AC_CHECK_LIB([f2c], [F77_ALLOC], [], - [AC_MSG_RESULT(not found, trying to use -lf2c anyway.)])))) + [ + + CPPFLAGS_TMP="$CPPFLAGS" + CPPFLAGS="-Dmain=MAIN__" + AC_CHECK_LIB([f2c], [f_open], [], + [AC_MSG_RESULT(not found, trying to use -lf2c anyway.)]) + CPPFLAGS="$CPPFLAGS_TMP" + F2C_CPPFLAGS="-Dmain=MAIN__" +])))) LDFLAGS="${LDFLAGS}" else AC_DEFINE([INTERNAL_F2C], [1], [Define to 1 if you use the internal F2C library]) fi if test "$internal_blas" = "no"; then + CPPFLAGS_TMP="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $F2C_CPPFLAGS" AC_CHECK_LIB([blas], [daxpy_], [], AC_CHECK_LIB([blas], [daxpy], [], AC_CHECK_LIB([blas], [DAXPY_], [], AC_CHECK_LIB([blas], [DAXPY], [], [AC_MSG_RESULT(not found, trying to use -lblas anyway.)])))) LDFLAGS="${LDFLAGS} -lblas" + CPPFLAGS="$CPPFLAGS_TMP" else AC_DEFINE([INTERNAL_BLAS], [1], [Define to 1 if you use the internal BLAS library]) fi if test "$internal_lapack" = "no"; then + CPPFLAGS_TMP="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $F2C_CPPFLAGS" AC_CHECK_LIB([lapack], [dlarnv_], [], AC_CHECK_LIB([lapack], [dlarnv], [], AC_CHECK_LIB([lapack], [DLARNV_], [], AC_CHECK_LIB([lapack], [DLARNV], [], [AC_MSG_RESULT(not found, trying to use -llapack anyway.)])))) LDFLAGS="${LDFLAGS} -llapack" + CPPFLAGS="$CPPFLAGS_TMP" else AC_DEFINE([INTERNAL_LAPACK], [1], [Define to 1 if you use the internal LAPACK library]) fi if test "$internal_arpack" = "no"; then + CPPFLAGS_TMP="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $F2C_CPPFLAGS" if test "$tls_support" = "yes"; then AC_MSG_ERROR([Thread-local storage only supported with internal ARPACK library]) fi @@ -254,12 +271,15 @@ AC_CHECK_LIB([arpack], [DSAUPD], [], [AC_MSG_RESULT(not found, trying to use -larpack anyway.)])))) LDFLAGS="${LDFLAGS} -larpack" + CPPFLAGS="$CPPFLAGS_TMP" else AC_DEFINE([INTERNAL_ARPACK], [1], [Define to 1 if you use the internal ARPACK library]) fi glpk_support=no if test "$internal_glpk" = "no"; then + CPPFLAGS_TMP="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $F2C_CPPFLAGS" AC_CHECK_LIB([glpk], [glp_read_mps], [ AC_CHECK_HEADER([glpk.h], [ AC_EGREP_CPP(yes, [ @@ -274,6 +294,7 @@ ]) ]) ]) + CPPFLAGS="$CPPFLAGS_TMP" else AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have the GLPK library]) AC_DEFINE([INTERNAL_GLPK], [1], [Define to 1 if you use the internal GLPK library])