Changeset 3848 for trunk/coin_fortran.m4


Ignore:
Timestamp:
Oct 10, 2018 2:06:13 PM (14 months ago)
Author:
lou
Message:

Introduce CHK_HERE, {_CFLAGS,_LFLAGS}_NOPC for use in .pc files and remove
_PUB variables, rename a few variables, and generally clean up accumulation
of compiler and linker flags.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin_fortran.m4

    r3809 r3848  
    308308
    309309###########################################################################
    310 #                         COIN_CHK_PKG_BLAS                               #
    311 ###########################################################################
    312 
    313 # COIN_CHK_PKG_BLAS([client packages],[public],[nolinkcheck])
     310#                         COIN_CHK_BLAS                                   #
     311###########################################################################
     312
     313# COIN_CHK_BLAS([client packages],[nolinkcheck])
    314314
    315315# This macro checks for a BLAS library and adds the information necessary to
    316 # use it to the _LIBS, _CFLAGS, and _PCFILES variables of the client packages
     316# use it to the _LFLAGS, _CFLAGS, and _PCFILES variables of the client packages
    317317# passed as a space-separated list in parameter $1. These correspond to
    318318# Libs.private, Cflags.private, and Requires.private, respectively, in a .pc
    319 # file. To add to the public variables, specify 'public' as $2.
     319# file.
    320320
    321321# The algorithm first invokes FIND_PRIM_PKG. The parameters --with-blas,
    322 # --with-blas-libs, and --with-blas-cflags are interpreted there. If nothing
     322# --with-blas-lflags, and --with-blas-cflags are interpreted there. If nothing
    323323# is found, default locations are checked.
    324324
    325325# When checking default locations, the macro uses a link check because it's
    326 # the easiest way to decide if a guess is correct. But a link check is always
    327 # a good idea just in case FLIBS (Fortran intrinsic & runtime libraries) is
    328 # also necessary. You can suppress the link check for a library spec given on
    329 # the command line or obtained via a .pc file by adding `nolinkcheck' as $3.
    330 
    331 AC_DEFUN([AC_COIN_CHK_PKG_BLAS],
     326# really the only way to decide if a guess is correct. But a link check is
     327# always a good idea just in case FLIBS (Fortran intrinsic & runtime libraries)
     328# is also necessary. You can suppress the link check for a library spec given
     329# on the command line or obtained via a .pc file by adding `nolinkcheck' as $2.
     330
     331AC_DEFUN([AC_COIN_CHK_BLAS],
    332332[
    333333  AC_REQUIRE([AC_COIN_PROG_F77])
     
    337337# Make sure the necessary variables exist for each client package.
    338338
    339   pubpriv=m4_default([$2],[private])
    340339  m4_foreach_w([myvar],[$1],
    341     [AC_SUBST(m4_toupper(myvar)_LIBS)
     340    [AC_SUBST(m4_toupper(myvar)_LFLAGS)
    342341     AC_SUBST(m4_toupper(myvar)_CFLAGS)
    343      AC_SUBST(m4_toupper(myvar)_PCFILES)
    344      AC_SUBST(m4_toupper(myvar)_LIBS_PUB)
    345      AC_SUBST(m4_toupper(myvar)_CFLAGS_PUB)
    346      AC_SUBST(m4_toupper(myvar)_PCFILES_PUB)])
     342     AC_SUBST(m4_toupper(myvar)_PCFILES)])
    347343
    348344# Set up command line arguments with DEF_PRIM_ARGS and give FIND_PRIM_PKG
    349 # a chance. The result (coin_has_blas) will be one of yes (either the user
    350 # specified something or pkgconfig found something), no (user specified nothing
    351 # and pkgconfig found nothing) or skipping (user said do not use). We'll
    352 # also have variables blas_libs, blas_cflags, blas_data, and blas_pcfiles.
     345# a chance, just in case blas.pc exists. The result (coin_has_blas) will
     346# be one of yes (either the user specified something or pkgconfig found
     347# something), no (user specified nothing and pkgconfig found nothing) or
     348# skipping (user said do not use). We'll also have variables blas_lflags,
     349# blas_cflags, blas_data, and blas_pcfiles.
    353350
    354351  AC_COIN_DEF_PRIM_ARGS([blas],yes,yes,yes,no)
     
    361358    m4_if([$2],[nolinkcheck],[:],
    362359      [use_blas=
    363        AC_COIN_CHK_PKG_FLINK([use_blas],[daxpy],[$blas_libs])
     360       AC_COIN_CHK_PKG_FLINK([use_blas],[daxpy],[$blas_lflags])
    364361       if test -n "$use_blas" ; then
    365          blas_libs=$use_blas
     362         blas_lflags=$use_blas
    366363       else
    367          AC_MSG_WARN([BLAS failed to link with "$blas_libs"])
     364         AC_MSG_WARN([BLAS failed to link with "$blas_lflags"])
    368365       fi])
    369366
     
    377374      *-sgi-*)
    378375        AC_MSG_CHECKING([for BLAS in -lcomplib.sgimath])
    379         AC_COIN_CHK_PKG_FLINK([blas_libs],[daxpy],[-lcomplib.sgimath])
     376        AC_COIN_CHK_PKG_FLINK([blas_lflags],[daxpy],[-lcomplib.sgimath])
    380377        ;;
    381378
     
    389386        # can arrange that explicitly.
    390387        AC_MSG_CHECKING([for BLAS in -lsunperf])
    391         AC_COIN_CHK_PKG_FLINK([blas_libs],[daxpy],[-lsunperf])
     388        AC_COIN_CHK_PKG_FLINK([blas_lflags],[daxpy],[-lsunperf])
    392389        ;;
    393390       
     
    397394          cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
    398395            AC_MSG_CHECKING([for BLAS in MKL (32bit)])
    399             AC_COIN_CHK_PKG_FLINK([blas_libs],[daxpy],
     396            AC_COIN_CHK_PKG_FLINK([blas_lflags],[daxpy],
    400397              [mkl_intel_c.lib mkl_sequential.lib mkl_core.lib])
    401             if test -z "$blas_libs" ; then
     398            if test -z "$blas_lflags" ; then
    402399              AC_MSG_CHECKING([for BLAS in MKL (64bit)])
    403               AC_COIN_CHK_PKG_FLINK([blas_libs],[daxpy],
     400              AC_COIN_CHK_PKG_FLINK([blas_lflags],[daxpy],
    404401                [mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib])
    405402            fi
     
    410407       *-darwin*)
    411408        AC_MSG_CHECKING([for BLAS in Veclib])
    412         AC_COIN_CHK_PKG_FLINK([blas_libs],[daxpy],[-framework Accelerate])
     409        AC_COIN_CHK_PKG_FLINK([blas_lflags],[daxpy],[-framework Accelerate])
    413410        ;;
    414411    esac
    415     if test -z "$blas_libs" ; then
    416       AC_MSG_CHECKING([whether -lblas has BLAS])
    417       AC_COIN_CHK_PKG_FLINK([blas_libs],[daxpy],[-lblas])
     412    if test -z "$blas_lflags" ; then
     413      AC_MSG_CHECKING([for BLAS in -lblas])
     414      AC_COIN_CHK_PKG_FLINK([blas_lflags],[daxpy],[-lblas])
    418415    fi
    419     if test -n "$blas_libs" ; then
     416    if test -n "$blas_lflags" ; then
    420417      coin_has_blas=yes
    421418    fi
     
    432429  if test $coin_has_blas = yes ; then
    433430    AC_DEFINE(m4_toupper(COIN_HAS_BLAS),[1],
    434       [Define to 1 if the BLAS package is available])
    435     if test $pubpriv = private ; then
    436       m4_foreach_w([myvar],[$1],
    437         [m4_toupper(myvar)_PCFILES="$blas_pcfiles $m4_toupper(myvar)_PCFILES"
    438          m4_toupper(myvar)_LIBS="$blas_libs $m4_toupper(myvar)_LIBS"
    439          m4_toupper(myvar)_CFLAGS="$blas_cflags $m4_toupper(myvar)_CFLAGS"])
    440     else
    441       m4_foreach_w([myvar],[$1],
    442         [m4_toupper(myvar)_PCFILES_PUB="$blas_pcfiles $m4_toupper(myvar)_PCFILES"_PUB
    443          m4_toupper(myvar)_LIBS_PUB="$blas_libs $m4_toupper(myvar)_LIBS_PUB"
    444          m4_toupper(myvar)_CFLAGS_PUB="$blas_cflags $m4_toupper(myvar)_CFLAGS_PUB"])
    445     fi
     431      [Define to 1 if BLAS is available.])
     432    m4_foreach_w([myvar],[$1],
     433      [m4_toupper(myvar)_PCFILES="$blas_pcfiles $m4_toupper(myvar)_PCFILES"
     434       m4_toupper(myvar)_LFLAGS="$blas_lflags $m4_toupper(myvar)_LFLAGS"
     435       m4_toupper(myvar)_CFLAGS="$blas_cflags $m4_toupper(myvar)_CFLAGS"])
    446436  else
    447437    AC_MSG_RESULT([$coin_has_blas])
    448438  fi
    449439
    450 ]) # AC_COIN_CHK_PKG_BLAS
    451 
    452 
    453 ###########################################################################
    454 #                       COIN_CHK_PKG_LAPACK                               #
    455 ###########################################################################
    456 
    457 # COIN_CHK_PKG_LAPACK([client packages],[public],[nolinkcheck])
     440]) # AC_COIN_CHK_BLAS
     441
     442
     443###########################################################################
     444#                       COIN_CHK_LAPACK                                   #
     445###########################################################################
     446
     447# COIN_CHK_LAPACK([client packages],[nolinkcheck])
    458448
    459449# This macro checks for a LAPACK library and adds the information necessary to
    460 # use it to the _LIBS, _CFLAGS, and _PCFILES variables of the client packages
     450# use it to the _LFLAGS, _CFLAGS, and _PCFILES variables of the client packages
    461451# passed as a space-separated list in parameter $1. These correspond to
    462452# Libs.private, Cflags.private, and Requires.private, respectively, in a .pc
    463 # file. To add to the public variables, specify 'public' as $2.
     453# file.
    464454
    465455# The algorithm first invokes FIND_PRIM_PKG. The parameters --with-lapack,
    466 # --with-lapack-libs, and --with-lapack-cflags are interpreted there. If
     456# --with-lapack-lflags, and --with-lapack-cflags are interpreted there. If
    467457# nothing is found, default locations are checked.
    468458
    469459# When checking default locations, the macro uses a link check because it's
    470 # the easiest way to decide if a guess is correct. But a link check is always
    471 # a good idea just in case FLIBS (Fortran intrinsic & runtime libraries) is
    472 # also necessary. You can suppress the link check for a library spec given on
    473 # the command line or obtained via a .pc file by adding `nolinkcheck' as $3.
    474 
    475 AC_DEFUN([AC_COIN_CHK_PKG_LAPACK],
     460# really the only way to decide if a guess is correct. But a link check is
     461# always a good idea just in case FLIBS (Fortran intrinsic & runtime libraries)
     462# is also necessary. You can suppress the link check for a library spec given
     463# on the command line or obtained via a .pc file by adding `nolinkcheck' as $2.
     464
     465AC_DEFUN([AC_COIN_CHK_LAPACK],
    476466[
    477467  AC_REQUIRE([AC_COIN_PROG_F77])
     
    481471# Make sure the necessary variables exist for each client package.
    482472
    483   pubpriv=m4_default([$2],[private])
    484473  m4_foreach_w([myvar],[$1],
    485474    [AC_SUBST(m4_toupper(myvar)_LIBS)
    486475     AC_SUBST(m4_toupper(myvar)_CFLAGS)
    487      AC_SUBST(m4_toupper(myvar)_PCFILES)
    488      AC_SUBST(m4_toupper(myvar)_LIBS_PUB)
    489      AC_SUBST(m4_toupper(myvar)_CFLAGS_PUB)
    490      AC_SUBST(m4_toupper(myvar)_PCFILES_PUB)])
     476     AC_SUBST(m4_toupper(myvar)_PCFILES)])
    491477
    492478# Set up command line arguments with DEF_PRIM_ARGS and give FIND_PRIM_PKG
    493 # a chance. The result (coin_has_blas) will be one of yes (either the user
    494 # specified something or pkgconfig found something), no (user specified nothing
    495 # and pkgconfig found nothing) or skipping (user said do not use). We'll
    496 # also have variables blas_libs, blas_cflags, blas_data, and blas_pcfiles.
     479# a chance, just in case lapack.pc exists. The result (coin_has_lapack)
     480# will be one of yes (either the user specified something or pkgconfig
     481# found something), no (user specified nothing and pkgconfig found nothing)
     482# or skipping (user said do not use). We'll also have variables lapack_lflags,
     483# lapack_cflags, lapack_data, and lapack_pcfiles.
    497484
    498485  AC_COIN_DEF_PRIM_ARGS([lapack],yes,yes,yes,no)
     
    500487
    501488# If FIND_PRIM_PKG found something and the user wants a link check, do it. For
    502 # a successful link check, update lapack_libs just in case FLIBS was added.
     489# a successful link check, update lapack_lflags just in case FLIBS was added.
    503490
    504491  if test "$coin_has_lapack" = yes ; then
    505492    m4_if([$2],[nolinkcheck],[:],
    506493      [use_lapack=
    507        AC_COIN_CHK_PKG_FLINK([use_lapack],[daxpy],[$lapack_libs])
     494       AC_COIN_CHK_PKG_FLINK([use_lapack],[daxpy],[$lapack_lflags])
    508495       if test -n "$use_lapack" ; then
    509          lapack_libs=$use_lapack
     496         lapack_lflags=$use_lapack
    510497       else
    511          AC_MSG_WARN([LAPACK failed to link with "$lapack_libs"])
     498         AC_MSG_WARN([LAPACK failed to link with "$lapack_lflags"])
    512499       fi])
    513500
    514 # If FIND_PRIM_PKG didn't find anything, try a few guesses. First, check if
    515 # the library for BLAS already includes LAPACK. Then try some specialised
    516 # checks based on the host system type first.  If none of them are applicable,
    517 # or the applicable one fails, try the generic -llapack.
     501# If FIND_PRIM_PKG didn't find anything, try a few guesses. First, try some
     502# specialised checks based on the host system type. If none of them are
     503# applicable, or the applicable one fails, try the generic -llapack.
    518504
    519505  elif test "$coin_has_lapack" = no ; then
    520506    AC_MSG_RESULT([nothing yet])
    521     if test x"$coin_has_blas" = xyes ; then
    522       AC_MSG_CHECKING([whether LAPACK is available in the BLAS library])
    523       AC_COIN_CHK_PKG_FLINK([lapack_libs],[dsyev],[$BLAS_LIBS])
     507    case $build in
     508      *-sgi-*)
     509        AC_MSG_CHECKING([for LAPACK in -lcomplib.sgimath])
     510        AC_COIN_CHK_PKG_FLINK([lapack_lflags],[dsyev],[-lcomplib.sgimath])
     511        ;;
     512
     513      *-*-solaris*)
     514        # See comments in COIN_CHK_PKG_BLAS.
     515        AC_MSG_CHECKING([for LAPACK in -lsunperf])
     516        AC_COIN_CHK_PKG_FLINK([lapack_lflags],[dsyev],[-lsunperf])
     517        ;;
     518
     519        # On cygwin, do this check only if doscompile is disabled. The
     520        # prebuilt library will want to link with cygwin, hence won't run
     521        # standalone in DOS.
     522
     523    esac
     524    if test -z "$lapack_lflags" ; then
     525      AC_MSG_CHECKING([for LAPACK in -llapack])
     526      AC_COIN_CHK_PKG_FLINK([lapack_lflags],[dsyev],[-llapack])
    524527    fi
    525 
    526 # 171116 (lh) Note that the libraries tested for SGI and Solaris are the same
    527 # ones we tested for BLAS. Since LAPACK needs BLAS, we should have already
    528 # performed those tests, hence the tests here are repetitive. I've left them
    529 # in on the sole justification that rechecking is robust against changes in
    530 # library content.
    531 
    532     if test -z "$lapack_libs" ; then
    533       case $build in
    534         *-sgi-*)
    535           AC_MSG_CHECKING([for LAPACK in -lcomplib.sgimath])
    536           AC_COIN_CHK_PKG_FLINK([lapack_libs],[dsyev],[-lcomplib.sgimath])
    537           ;;
    538 
    539         *-*-solaris*)
    540           # See comments in COIN_CHK_PKG_BLAS.
    541           AC_MSG_CHECKING([for LAPACK in -lsunperf])
    542           AC_COIN_CHK_PKG_FLINK([lapack_libs],[dsyev],[-lsunperf])
    543           ;;
    544 
    545           # On cygwin, do this check only if doscompile is disabled. The
    546           # prebuilt library will want to link with cygwin, hence won't run
    547           # standalone in DOS.
    548 
    549       esac
    550     fi
    551     if test -z "$lapack_libs" ; then
    552       AC_MSG_CHECKING([whether -llapack has LAPACK])
    553       AC_COIN_CHK_PKG_FLINK([lapack_libs],[dsyev],[-llapack])
    554     fi
    555     if test -n "$lapack_libs" ; then
     528    if test -n "$lapack_lflags" ; then
    556529      coin_has_lapack=yes
    557530    fi
     
    569542    AC_DEFINE(m4_toupper(COIN_HAS_LAPACK),[1],
    570543      [Define to 1 if the LAPACK package is available])
    571     if test $pubpriv = private ; then
    572       m4_foreach_w([myvar],[$1],
    573         [m4_toupper(myvar)_PCFILES="$lapack_pcfiles $m4_toupper(myvar)_PCFILES"
    574          m4_toupper(myvar)_LIBS="$lapack_libs $m4_toupper(myvar)_LIBS"
    575          m4_toupper(myvar)_CFLAGS="$lapack_cflags $m4_toupper(myvar)_CFLAGS"])
    576     else
    577       m4_foreach_w([myvar],[$1],
    578         [m4_toupper(myvar)_PCFILES_PUB="$lapack_pcfiles $m4_toupper(myvar)_PCFILES"_PUB
    579          m4_toupper(myvar)_LIBS_PUB="$lapack_libs $m4_toupper(myvar)_LIBS_PUB"
    580          m4_toupper(myvar)_CFLAGS_PUB="$lapack_cflags $m4_toupper(myvar)_CFLAGS_PUB"])
    581     fi
     544    m4_foreach_w([myvar],[$1],
     545      [m4_toupper(myvar)_PCFILES="$lapack_pcfiles $m4_toupper(myvar)_PCFILES"
     546       m4_toupper(myvar)_LFLAGS="$lapack_lflags $m4_toupper(myvar)_LFLAGS"
     547       m4_toupper(myvar)_CFLAGS="$lapack_cflags $m4_toupper(myvar)_CFLAGS"])
    582548  else
    583549    AC_MSG_RESULT([$coin_has_lapack])
    584550  fi
    585551
    586 ]) # AC_COIN_CHK_PKG_LAPACK
    587 
     552]) # AC_COIN_CHK_LAPACK
     553
Note: See TracChangeset for help on using the changeset viewer.