Changeset 3867


Ignore:
Timestamp:
Feb 20, 2020, 4:43:31 AM (16 months ago)
Author:
Peter
Message:

allow user to override values from pkg-config

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/m4/yat_plplot.m4

    r3866 r3867  
    11## $Id$
    22#
    3 # serial 1
     3# serial 2
    44#
    55# see http://www.gnu.org/software/automake/manual/automake.html#Serials
     
    1515#   pkg-config. Otherwise try linking against plplot-c++ and
    1616#   plplotd-c++ to set PLPLOT_LIBS to what the library is called on
    17 #   this system.
     17#   this system. If PLPLOT_* variable above are already set, the
     18#   values from pkg-config is ignored.
    1819#
    1920# COPYLEFT
     
    8687
    8788
     89  AC_ARG_VAR([PLPLOT_CPPFLAGS],
     90             [preprocessor flags for plplot, overriding pkg-config])
     91  AC_ARG_VAR([PLPLOT_CXXFLAGS],
     92             [compiler flags for plplot, overriding pkg-config])
     93  AC_ARG_VAR([PLPLOT_LDFLAGS],
     94             [linker flags for plplot, overriding pkg-config])
     95  AC_ARG_VAR([PLPLOT_LIBS], [libraries for plplot, overriding pkg-config])
     96
    8897  AS_VAR_IF([yat_plplot_pkg], [no], [], [
    8998    # pkg-config typically returns <prefix>/include/plplot because plplot
     
    92101    # trailing '/plplot'. Space is included in sed expression to avoid
    93102    # substituting potential '/plplot' in PREFIX.
    94     PLPLOT_CPPFLAGS=`$PKG_CONFIG --cflags-only-I $yat_plplot_pkg | sed 's|/plplot | |g'`
    95     PLPLOT_CXXFLAGS=`$PKG_CONFIG --cflags-only-other $yat_plplot_pkg`
    96     PLPLOT_LDFLAGS=`$PKG_CONFIG --libs-only-other --libs-only-L $yat_plplot_pkg`
    97     PLPLOT_LIBS=`$PKG_CONFIG --libs-only-l $yat_plplot_pkg`
     103
     104    # only set flags if not already set, to allow user to override
     105    AS_VAR_SET_IF([PLPLOT_CPPFLAGS], [], [
     106      PLPLOT_CPPFLAGS=`$PKG_CONFIG --cflags-only-I $yat_plplot_pkg | sed 's|/plplot | |g'`])
     107
     108    AS_VAR_SET_IF([PLPLOT_CXXFLAGS], [], [
     109      PLPLOT_CXXFLAGS=`$PKG_CONFIG --cflags-only-other $yat_plplot_pkg`])
     110
     111    AS_VAR_SET_IF([PLPLOT_LDFLAGS], [], [
     112      PLPLOT_LDFLAGS=`$PKG_CONFIG --libs-only-other --libs-only-L $yat_plplot_pkg`])
     113
     114    AS_VAR_SET_IF([PLPLOT_LIBS], [], [
     115      PLPLOT_LIBS=`$PKG_CONFIG --libs-only-l $yat_plplot_pkg`])
    98116  ])
    99117])
     
    123141AC_REQUIRE([YAT_CHECK_PKG_CONFIG_PLPLOT])
    124142
     143save_CPPFLAGS=$CPPFLAGS
     144save_CXXFLAGS=$CXXFLAGS
     145save_LDFLAGS=$LDFLAGS
    125146save_LIBS=$LIBS
    126 AS_VAR_IF([yat_plplot_pkg], [no], [
    127    YAT_CHECK_LIBS([for library that contains plstream], [yat_cv_plplot_lib],
    128                   [plplotcxx plplotcxxd],
    129                   [AC_LANG_PROGRAM([@%:@ include <plplot/plstream.h>],
    130                                    [plstream pls])],
    131                   [PLPLOT_LIBS="$yat_cv_plplot_lib"
    132 dnl restore LIBS here so user can set it in $1
    133                    LIBS=$save_LIBS
    134                    $1],
    135                   [$2])
    136 ], [
    137   save_LDFLAGS=$LDFLAGS
     147AS_VAR_SET_IF([PLPLOT_LIBS], [
    138148  LDFLAGS="$LDFLAGS $PLPLOT_LDFLAGS"
    139149  LIBS="$LIBS $PLPLOT_LIBS"
     
    141151  AC_LINK_IFELSE([AC_LANG_PROGRAM()], [
    142152    AC_MSG_RESULT([ok])
    143 dnl restore variables already here so user can set these variables (in $1)
     153    dnl restore variables already here so user can set these variables (in $1)
    144154    LDFLAGS=$save_LDFLAGS
    145155    LIBS=$save_LIBS
     
    147157  ], [
    148158    AC_MSG_RESULT([failed])
    149 dnl restore variables already here so user can set these variables (in $2)
     159    dnl restore variables already here so user can set these variables (in $2)
    150160    LDFLAGS=$save_LDFLAGS
    151161    LIBS=$save_LIBS
    152162    $2
    153163  ])
    154 ])
    155 ])
     164], [ dnl else
     165  CPPFLAGS="$CPPFLAGS $PLPLOT_CPPFLAGS"
     166  CXXFLAGS="$CXXFLAGS $PLPLOT_CXXFLAGS"
     167  LDFLAGS="$LDFLAGS $PLPLOT_LDFLAGS"
     168  YAT_CHECK_LIBS([for library that contains plstream], [yat_cv_plplot_lib],
     169                 [plplotcxx plplotcxxd],
     170                 [AC_LANG_PROGRAM([@%:@ include <plplot/plstream.h>],
     171                                  [plstream pls])],
     172                 [PLPLOT_LIBS="$yat_cv_plplot_lib"
     173                  dnl restore variables here so user can set it in $1
     174                  CPPFLAGS=$save_CPPFLAGS
     175                  CXXFLAGS=$save_CXXFLAGS
     176                  LDFLAGS=$save_LDFLAGS
     177                  LIBS=$save_LIBS
     178                  $1],
     179                 [$2])
     180]) # end VAR_SET_IF
     181]) # YAT_CHECK_PLPLOT_LIB
Note: See TracChangeset for help on using the changeset viewer.