Changeset 3192


Ignore:
Timestamp:
Mar 8, 2014 1:50:58 PM (7 years ago)
Author:
stefan
Message:

put back some initialize/finalize and package searching functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/coin.m4

    r3128 r3192  
    330330]) #AC_COIN_EXAMPLE_FILES
    331331
     332
     333###########################################################################
     334#                          COIN_PROJECTVERSION                            #
     335###########################################################################
     336
     337# This macro is used by COIN_PROJECTDIR_INIT and sets up variables related
     338# to versioning numbers of the project.
     339
     340AC_DEFUN([AC_COIN_PROJECTVERSION],
     341[m4_ifvaln([$1],[
     342  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION), ["$PACKAGE_VERSION"],[Version number of project])
     343 
     344  [coin_majorver=`echo $PACKAGE_VERSION | sed -n -e 's/^\([0-9]*\).*/\1/gp'`]
     345  [coin_minorver=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.\([0-9]*\).*/\1/gp'`]
     346  [coin_releasever=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/gp'`]
     347  if test "x$coin_majorver" = x ; then coin_majorver=9999 ; fi
     348  if test "x$coin_minorver" = x ; then coin_minorver=9999 ; fi
     349  if test "x$coin_releasever" = x ; then coin_releasever=9999 ; fi
     350  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MAJOR),   [$coin_majorver],   [Major Version number of project])
     351  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MINOR),   [$coin_minorver],   [Minor Version number of project])
     352  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_RELEASE), [$coin_releasever], [Release Version number of project])
     353
     354  # We use the following variable to have a string with the upper case
     355  # version of the project name
     356  COIN_PRJCT=m4_toupper($1)
     357
     358  # Set the project's SVN revision number. The complicated sed expression
     359  # (made worse by quadrigraphs) ensures that things like 4123:4168MS end up
     360  # as a single number.
     361  AC_CHECK_PROG([have_svnversion],[svnversion],[yes],[no])
     362  if test "x$have_svnversion" = xyes; then
     363    AC_SUBST(m4_toupper($1_SVN_REV))
     364    svn_rev_tmp=`LANG=en_EN svnversion $srcdir 2>/dev/null`
     365    if test "x$svn_rev_tmp" != xexported -a "x$svn_rev_tmp" != x -a "x$svn_rev_tmp" != "xUnversioned directory"; then
     366      m4_toupper($1_SVN_REV)=`echo $svn_rev_tmp | sed -n -e 's/^@<:@0-9@:>@*://' -e 's/\(@<:@0-9@:>@\)@<:@^0-9@:>@*$/\1/p'`
     367      AC_DEFINE_UNQUOTED(m4_toupper($1_SVN_REV), $m4_toupper($1_SVN_REV), [SVN revision number of project])
     368    fi
     369  fi
     370 ])
     371 
     372# Capture libtool library version, if given.
     373 m4_ifvaln([$2],[coin_libversion=$2],[])
     374])
     375
     376###########################################################################
     377#                            COIN_INITALIZE                               #
     378###########################################################################
     379
     380# This macro does everything that is required in the early part in the
     381# configure script, such as defining a few variables.
     382# The first parameter is the project name.
     383# The second (optional) is the libtool library version (important for releases,
     384# less so for stable or trunk).
     385
     386AC_DEFUN([AC_COIN_INITIALIZE],
     387[
     388# figure out whether there is a base directory up from here
     389coin_base_directory=
     390if test -e ../coin_subdirs.txt ; then
     391  coin_base_directory=`cd ..; pwd`
     392elif test -e ../../coin_subdirs.txt ; then
     393  coin_base_directory=`cd ../..; pwd`
     394fi
     395
     396if test "x$coin_base_directory" != x ; then
     397  COIN_DESTDIR=$coin_base_directory/coinstash
     398fi
     399AC_SUBST(COIN_DESTDIR)
     400
     401# Set the project's version numbers
     402AC_COIN_PROJECTVERSION($1, $2)
     403])
     404
     405
     406###########################################################################
     407#                              COIN_FINALIZE                              #
     408###########################################################################
     409
     410# This macro should be called at the very end of the configure.ac file.
     411# It creates the output files (by using AC_OUTPUT), and might do some other
     412# things (such as generating links to data files in a VPATH configuration).
     413# It also prints the "success" message.
     414# Note: If the variable coin_skip_ac_output is set to yes, then no output
     415# files are written.
     416
     417AC_DEFUN([AC_COIN_FINALIZE],
     418[
     419# need to come before AC_OUTPUT
     420if test "x$coin_subdirs" != x; then
     421  # write coin_subdirs to a file so that project configuration knows where to find uninstalled projects
     422  echo $coin_subdirs > coin_subdirs.txt
     423else
     424  # substitute for OBJDIR, needed to setup .pc file for uninstalled project
     425  #ABSBUILDDIR="`pwd`"
     426  #AC_SUBST(ABSBUILDDIR)
     427  :
     428fi
     429 
     430AC_OUTPUT
     431
     432AC_MSG_NOTICE([In case of trouble, first consult the troubleshooting page at https://projects.coin-or.org/BuildTools/wiki/user-troubleshooting])
     433#if test x$coin_projectdir = xyes; then
     434  AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
     435#else
     436#  AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
     437#fi
     438
     439]) #AC_COIN_FINALIZE
     440
     441
     442###########################################################################
     443#                           COIN_HAS_PKGCONFIG                            #
     444###########################################################################
     445
     446# This macro checks whether a pkg-config tool with a minimal version number
     447# is available.  If so, then the variable PKGCONFIG is set to its path.
     448# If not, PKGCONFIG is set to "".  The minimal version number can be given
     449# as first parameter, by default it is 0.16.0, since COIN-OR .pc files now
     450# include an URL field, which breaks pkg-config version <= 0.15.
     451# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
     452# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
     453# AC_SUBST'ed.  Finally, if this setup belongs to a project directory, then
     454# the search path for .pc files is assembled from the value of
     455# $PKG_CONFIG_PATH and the directories named in a file
     456# $coin_base_directory/coin_subdirs.txt in a variable
     457# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed. For a path xxx given in the
     458# coin-subdirs.txt, also the directory xxx/pkgconfig is added, if existing.
     459
     460AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
     461[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
     462
     463AC_ARG_ENABLE([pkg-config],
     464  [AC_HELP_STRING([--disable-pkg-config],[disable use of pkg-config (if available)])],
     465  [use_pkgconfig="$enableval"],
     466  [#if test x$coin_cc_is_cl = xtrue; then
     467   #  use_pkgconfig=no
     468   #else
     469     use_pkgconfig=yes
     470   #fi
     471  ])
     472
     473if test $use_pkgconfig = yes ; then
     474  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
     475    AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
     476  fi
     477  if test -n "$PKG_CONFIG"; then
     478    _pkg_min_version=m4_default([$1], [0.16.0])
     479    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
     480    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
     481      AC_MSG_RESULT([yes])
     482    else
     483      AC_MSG_RESULT([no])
     484      PKG_CONFIG=""
     485    fi
     486  fi
     487
     488  # check if pkg-config supports the short-errors flag
     489  if test -n "$PKG_CONFIG" && \
     490    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
     491    pkg_short_errors=" --short-errors "
     492  else
     493    pkg_short_errors=""
     494  fi
     495fi
     496
     497AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
     498AC_SUBST(PKG_CONFIG)
     499
     500# assemble pkg-config search path to find projects under base directory
     501COIN_PKG_CONFIG_PATH=
     502if test "x$coin_base_directory" != x ; then
     503  if test -f $coin_base_directory/coin_subdirs.txt ; then
     504    for i in `cat $coin_base_directory/coin_subdirs.txt` ; do
     505      if test -d $coin_base_directory/$i ; then
     506        COIN_PKG_CONFIG_PATH="$coin_base_directory/$i:${COIN_PKG_CONFIG_PATH}"
     507      fi
     508      if test -d $coin_base_directory/$i/pkgconfig ; then
     509        COIN_PKG_CONFIG_PATH="$coin_base_directory/$i/pkgconfig:${COIN_PKG_CONFIG_PATH}"
     510      fi
     511    done
     512  fi
     513fi
     514AC_SUBST(COIN_PKG_CONFIG_PATH)
     515
     516])
     517
     518
     519###########################################################################
     520#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
     521###########################################################################
     522
     523# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     524#
     525# Check to see whether a particular set of packages exists.
     526# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
     527#
     528AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
     529[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     530if test -n "$PKG_CONFIG" ; then
     531  if $PKG_CONFIG --exists "$2"; then
     532    m4_toupper($1)[]_VERSIONS=`$PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`
     533    $3
     534  else
     535    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
     536    $4
     537  fi
     538else
     539  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
     540fi
     541])
     542
     543###########################################################################
     544#                            COIN_CHECK_PACKAGE                           #
     545###########################################################################
     546
     547AC_DEFUN([AC_COIN_CHECK_PACKAGE],
     548[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     549AC_MSG_CHECKING([for COIN-OR package $1])
     550
     551m4_tolower(coin_has_$1)=notGiven
     552
     553if test $m4_tolower(coin_has_$1) = notGiven; then
     554  if test -n "$PKG_CONFIG" ; then
     555    # set search path for pkg-config
     556    # need to export variable to be sure that the following pkg-config gets these values
     557    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     558    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$PKG_CONFIG_PATH"
     559    export PKG_CONFIG_PATH
     560   
     561    # let pkg-config do it's magic
     562    AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
     563      [ m4_tolower(coin_has_$1)=yes
     564        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
     565      ],
     566      [ m4_tolower(coin_has_$1)=notGiven
     567        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
     568      ])
     569
     570    # reset PKG_CONFIG_PATH variable
     571    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
     572    export PKG_CONFIG_PATH
     573
     574  else
     575    AC_MSG_ERROR([skipped check via pkg-config, redirect to fallback... -- oops, not there yet])
     576    # TODO
     577    #AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
     578  fi
     579
     580else
     581  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     582fi
     583
     584if test $m4_tolower(coin_has_$1) != skipping &&
     585   test $m4_tolower(coin_has_$1) != notGiven ; then
     586  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
     587fi
     588
     589# Define the Makefile conditional
     590AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     591               [test $m4_tolower(coin_has_$1) != notGiven &&
     592                test $m4_tolower(coin_has_$1) != skipping])
     593
     594])
     595
     596###########################################################################
     597#                           COIN_MAIN_PACKAGEDIR                          #
     598###########################################################################
     599
     600# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
     601#   If so, include this directory into the list of directories where configure and make recourse into.
     602# tolower(coin_has_$1) is set to "no" if the project source is not available or will not be compiled.
     603# Otherwise, it will be set to "yes".
     604
     605AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],[
     606AC_MSG_CHECKING([whether source of project $1 is available and should be compiled])
     607
     608m4_tolower(coin_has_$1)=notGiven
     609coin_reason=
     610
     611# check if project is available in present directory
     612if test "$m4_tolower(coin_has_$1)" = notGiven; then
     613  m4_tolower(coin_has_$1)=no
     614  if test -d $srcdir/m4_ifval($2,[$2/],)$1; then
     615    coin_reason="source in m4_ifval($2,[$2/],)$1"
     616    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
     617    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
     618    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
     619    m4_ifvaln([$3],
     620      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
     621         if test -r $i; then
     622           m4_tolower(coin_has_$1)="yes"
     623         else
     624           m4_tolower(coin_has_$1)="no"
     625           coin_reason="source file $i not available"
     626           break
     627         fi
     628       done],
     629      [ m4_tolower(coin_has_$1)="yes" ])
     630  fi
     631fi
     632
     633if test -z "$coin_reason" ; then
     634  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     635else
     636  AC_MSG_RESULT([$m4_tolower(coin_has_$1), $coin_reason])
     637fi
     638
     639if test "$m4_tolower(coin_has_$1)" = yes ; then
     640  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
     641    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
     642    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
     643  fi
     644fi
     645])
Note: See TracChangeset for help on using the changeset viewer.