Changeset 1695


Ignore:
Timestamp:
Oct 30, 2010 6:24:42 PM (9 years ago)
Author:
tkr
Message:

Syncing stable/0.6 with trunk

Location:
stable/0.6
Files:
9 edited
8 copied

Legend:

Unmodified
Added
Removed
  • stable/0.6

  • stable/0.6/Makemain.inc

    r1363 r1695  
    1212
    1313DocFiles =  README AUTHORS LICENSE
    14 DocInstallDir = $(prefix)/share/doc/coin/$(PACKAGE_NAME)
     14DocInstallDir = $(datadir)/coin/doc/$(PACKAGE_NAME)
    1515
    1616install-doc: $(DocFiles)
  • stable/0.6/coin.m4

    r1694 r1695  
    1212# Check requirements
    1313AC_PREREQ(2.59)
     14
     15###########################################################################
     16#                           coin_foreach_w                                #
     17###########################################################################
     18
     19# the autoconf version used by COIN-OR is so old that it does not have the M4 macro foreach_w.
     20# thus, we define our own one which applies the foreach macro to the same arguments but with
     21# all spaces replaced by ',' in the second argument.
     22# further, we run the loop only if the second argument is not empty
     23AC_DEFUN([coin_foreach_w], [m4_ifval([$2], [m4_foreach([$1], [m4_bpatsubsts([$2],[[     ]+],[, ])], [$3])])])
    1424
    1525###########################################################################
     
    270280# This macro sets the variable coin_vpath_config to true if this is a
    271281# VPATH configuration, otherwise it sets it to false.
     282
    272283AC_DEFUN([AC_COIN_CHECK_VPATH],
    273 [AC_MSG_CHECKING(whether this is a VPATH configuration)
     284[
     285AC_MSG_CHECKING(whether this is a VPATH configuration)
    274286if test `cd $srcdir; pwd` != `pwd`; then
    275287  coin_vpath_config=yes;
     
    285297
    286298# This macro does everything that is required in the early part in the
    287 # configure script, such as defining a few variables.  This should only
    288 # be used in the main directory of a project directory (the one under
    289 # which src is)
     299# configure script, such as defining a few variables.  This should only be used
     300# in the main directory of a project directory (the one which holds the src
     301# directory for the project). The first parameter is the project name. The
     302# second (optional) is the libtool library version (important for releases,
     303# less so for stable or trunk).
    290304
    291305AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
     
    294308AC_SUBST(ADDLIBS)
    295309
     310# Initialize the PCADDLIBS variable.
     311# This variable is used to setup library flags for the "Libs:" section in a .pc file.
     312# In certain cases, it may contain more flags than the ADDLIBS variable.
     313PCADDLIBS=""
     314AC_SUBST(PCADDLIBS)
     315
    296316# As backup, we make sure we don't loose an FLIBS if it has been set
    297317# by the user
     
    310330coin_projectdir=yes
    311331
    312 # Check if a library version is set for libtool
    313 m4_ifvaln([$1],[coin_libversion=$1],[])
     332# Set the project's version number
     333if test "x$1" != x; then
     334  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION), ["$PACKAGE_VERSION"],
     335                     [Version number of project])
     336fi
     337
     338# Set the project's SVN revision number. The complicated sed expression
     339# (made worse by quadrigraphs) ensures that things like 4123:4168MS end up
     340# as a single number.
     341AC_CHECK_PROG([have_svnversion],[svnversion],[yes],[no])
     342if test "x$have_svnversion" = xyes && test "x$1" != x; then
     343  AC_SUBST(m4_toupper($1_SVN_REV))
     344  svn_rev_tmp=`cd $srcdir/$m4_tolower(coin_has_$1) ; svnversion`
     345  m4_toupper($1_SVN_REV)=`echo $svn_rev_tmp | sed -n -e 's/^@<:@0-9@:>@*://' -e 's/\(@<:@0-9@:>@\)@<:@^0-9@:>@*$/\1/p'`
     346  if test $m4_toupper($1_SVN_REV) != exported; then
     347    AC_DEFINE_UNQUOTED(m4_toupper($1_SVN_REV), $m4_toupper($1_SVN_REV),
     348                       [SVN revision number of project])
     349  fi
     350fi
     351
     352# Capture libtool library version, if given.
     353m4_ifvaln([$2],[coin_libversion=$2],[])
    314354]) # AC_COIN_PROJECTDIR_INIT
    315355
     
    587627      *)
    588628# ToDo decide about unroll-loops
    589         coin_opt_cxxflags="-O3 -fomit-frame-pointer"
     629        coin_opt_cxxflags="-O3"
    590630        coin_add_cxxflags="-pipe"
    591631        coin_dbg_cxxflags="-g"
     
    9721012        ;;
    9731013      *)
    974         coin_opt_cflags="-O3 -fomit-frame-pointer"
     1014        coin_opt_cflags="-O3"
    9751015        coin_add_cflags="-pipe"
    9761016        coin_dbg_cflags="-g"
     
    11981238
    11991239  if test "$G77" = "yes"; then
    1200     coin_opt_fflags="-O3 -fomit-frame-pointer"
     1240    coin_opt_fflags="-O3"
    12011241    coin_add_fflags="-pipe"
    12021242    coin_dbg_fflags="-g"
     
    13901430  # However, this seem to create a dependency on libifcorert.dll (or libifcorertd.dll) in the executables.
    13911431  # This is seem to be unnecessary, libifcorert(d).lib has been removed from the link line.
     1432  # Further, excluding libc.lib from the default libs seemed to be necessary only for VS < 8.
     1433  # Since the corresponding flag seems to make more trouble that it avoid, it has been removed now.
    13921434     *-cygwin* | *-mingw*)
    13931435       case "$F77" in
    1394          ifort* | */ifort* | IFORT* | */IFORT*)
    1395            FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib"
     1436#         ifort* | */ifort* | IFORT* | */IFORT*)
     1437#           FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib"
    13961438#           if "$coin_debug_compile" = true ; then
    13971439#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib"
     
    13991441#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib"
    14001442#           fi
    1401            ;;
     1443#           ;;
    14021444         compile_f2c*)
    14031445           FLIBS=`$F77 -FLIBS` ;;
     
    14111453         pgf77* | */pgf77* | pgf90* | */pgf90*)
    14121454# ask linker to go through the archives multiple times
    1413 # (the Fortran compiler seems to do that automatically...
     1455# (the Fortran compiler seems to do that automatically...)
    14141456           FLIBS="-Wl,--start-group $FLIBS -Wl,--end-group" ;;
    14151457       esac
     
    16621704full_prefix=`cd $full_prefix ; pwd`
    16631705AC_SUBST(abs_lib_dir)
    1664 abs_lib_dir=$full_prefix/lib
     1706abs_lib_dir=$full_prefix/lib/coin
    16651707AC_SUBST(abs_include_dir)
    16661708abs_include_dir=$full_prefix/include
     
    17861828  # set RPATH_FLAGS to the compiler link flags required to hardcode location
    17871829  # of the shared objects
    1788   AC_COIN_RPATH_FLAGS($abs_lib_dir)
     1830  AC_COIN_RPATH_FLAGS([$abs_lib_dir $abs_lib_dir/ThirdParty])
    17891831
    17901832else
     
    18521894#END
    18531895}])
    1854 
    18551896
    18561897###########################################################################
     
    21272168    ADDLIBS="$ADDLIBS $FLIBS"
    21282169  fi
     2170  PCADDLIBS="$PCADDLIBS $ADDLIBS"
    21292171
    21302172  # library extension
     
    21592201  fi
    21602202
     2203  # need to come before AC_OUTPUT
     2204  if test x$coin_projectdir != xyes; then
     2205    # write coin_subdirs to a file so that project configuration knows where to find uninstalled projects
     2206    echo $coin_subdirs > coin_subdirs.txt
     2207  else
     2208    # substitute for OBJDIR, needed to setup .pc file for uninstalled project
     2209    ABSBUILDDIR="`pwd`"
     2210    AC_SUBST(ABSBUILDDIR)
     2211  fi
     2212 
    21612213  AC_OUTPUT
    21622214
     
    21932245###########################################################################
    21942246
    2195 # This macro makes sure that a symbolic link is created to a file in
    2196 # the source code directory tree if we are in a VPATH compilation, and
    2197 # if this package is the main package to be installed
     2247# This macro queues source files that need to be available in the build
     2248# directory. In a VPATH configuration, the files will be made available by
     2249# symbolic link or copy (when the platform does not support links). The list
     2250# is processed by COIN_FINALIZE. The parameter is a whitespace-separated
     2251# list of files.
    21982252
    21992253AC_DEFUN([AC_COIN_VPATH_LINK],
    2200 [AC_REQUIRE([AC_COIN_CHECK_VPATH])
     2254[
     2255AC_REQUIRE([AC_COIN_CHECK_VPATH])
     2256# Allow for newlines in the parameter
    22012257if test $coin_vpath_config = yes; then
    2202   coin_vpath_link_files="$coin_vpath_link_files $1"
     2258  cvl_tmp="$1"
     2259  for file in $cvl_tmp ; do
     2260    coin_vpath_link_files="$coin_vpath_link_files $file"
     2261  done
    22032262fi
    22042263]) #AC_COIN_VPATH_LINK
     
    22212280]) # AC_COIN_ENABLE_GNU_PACKAGES
    22222281
     2282#######################################################################
     2283#                           COIN_CHECK_LIBM                           #
     2284#######################################################################
     2285
     2286# For a (space separated) list of arguments X, this macro adds the flags
     2287# for linking against the math library to a X_LIBS and X_PCLIBS.
     2288
     2289AC_DEFUN([AC_COIN_CHECK_LIBM],
     2290[AC_BEFORE([AC_COIN_PROG_CC],[$0])
     2291
     2292case "$CC" in
     2293  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
     2294    ;;
     2295  *)
     2296    coin_foreach_w([myvar], [$1], [
     2297      m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"
     2298      m4_toupper(myvar)_PCLIBS="-lm $m4_toupper(myvar)_PCLIBS"
     2299    ])
     2300  ;;
     2301esac
     2302
     2303]) # AC_COIN_CHECK_LIBM
     2304
    22232305###########################################################################
    22242306#                           COIN_CHECK_GNU_ZLIB                           #
     
    22262308
    22272309# This macro checks for the libz library.
     2310# If found, it sets the automake conditional COIN_HAS_ZLIB and defines the C preprocessor variable COIN_HAS_ZLIB.
     2311# Further, for a (space separated) list of arguments X, it adds the linker flag to the variables X_LIBS and X_PCLIBS.
    22282312
    22292313AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
     
    22402324  if test $coin_has_zlib = yes; then
    22412325    AC_CHECK_LIB([z],[gzopen],
    2242                  [ADDLIBS="-lz $ADDLIBS"],
     2326                 [ADDLIBS="-lz $ADDLIBS"
     2327                  coin_foreach_w([myvar], [$1], [
     2328                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
     2329                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
     2330                  ])
     2331                 ],
    22432332                 [coin_has_zlib=no])
    22442333  fi
     
    22582347
    22592348# This macro checks for the libbz2 library.
     2349# If found, it defines the C preprocessor variable COIN_HAS_BZLIB.
     2350# Further, for a (space separated) list of arguments X, it adds the linker flag to the variables X_LIBS and X_PCLIBS.
    22602351
    22612352AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
     
    22722363  if test $coin_has_bzlib = yes; then
    22732364    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
    2274                  [ADDLIBS="-lbz2 $ADDLIBS"],
     2365                 [ADDLIBS="-lbz2 $ADDLIBS"
     2366                  coin_foreach_w([myvar], [$1], [
     2367                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
     2368                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
     2369                  ])
     2370                 ],
    22752371                 [coin_has_bzlib=no])
    22762372  fi
     
    22912387# contains "readline".  It is assumed that #include <stdio.h> is included
    22922388# in the source file before the #include<readline/readline.h>
     2389# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
     2390# Further, for a (space separated) list of arguments X, it adds the linker flag to the variable X_LIBS and X_PCLIBS.
    22932391
    22942392AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
     
    23162414  if test $coin_has_readline = yes; then
    23172415    AC_CHECK_LIB([readline],[readline],
    2318                  [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
     2416                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"
     2417                  coin_foreach_w([myvar], [$1], [
     2418                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
     2419                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
     2420                  ])
     2421                 ],
    23192422                 [coin_has_readline=no])
    23202423  fi
     
    24342537[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
    24352538AC_REQUIRE([AC_COIN_CHECK_VPATH])
     2539AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
     2540AC_REQUIRE([AC_PROG_LN_S])
     2541
    24362542files=`cd $srcdir; ls $1`
    24372543# We need to do the following loop to make sure that are no newlines
     
    24492555      lnkcmd=cp ;;
    24502556  esac
    2451   if test "$lnkcmd" = cp; then
     2557  if test "x$lnkcmd" = xcp; then
    24522558    AC_MSG_NOTICE([Copying example files ($1)])
    24532559  else
    2454     AC_PROG_LN_S
    24552560    AC_MSG_NOTICE([Creating links to the example files ($1)])
    24562561    lnkcmd="$LN_S"
     
    24822587
    24832588###########################################################################
    2484 #                            COIN_HAS_PROJECT                             #
    2485 ###########################################################################
    2486 
    2487 # This macro sets up usage of a Coin package.  It defines the
    2488 # PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
    2489 # object directory of the package, respectively.  It also defines
    2490 # a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
    2491 # argument should be the name (Pkg) of the project (in correct lower
    2492 # and upper case)
     2589#                            COIN_HAS_PROJECT (deprecated)                #
     2590###########################################################################
     2591
     2592# This macro sets up usage of a Coin package.  It defines the PKGSRCDIR,
     2593# PKGOBJDIR, and PKGDOCDIR variables, referring to the main source, object, and
     2594# documentation directories of the package, respectively.  It also defines a
     2595# COIN_HAS_PKG preprocessor macro and makefile conditional.  The argument
     2596# should be the name (Pkg) of the project (in correct lower and upper case)
    24932597
    24942598AC_DEFUN([AC_COIN_HAS_PROJECT],
     
    25282632  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
    25292633  AC_SUBST(m4_toupper($1DOCDIR))
    2530   m4_toupper($1DOCDIR)=$abs_lib_dir/../share/doc/coin/$1
     2634  m4_toupper($1DOCDIR)=$abs_lib_dir/../../share/doc/coin/$1
    25312635fi
    25322636
     
    25792683# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
    25802684# name.
     2685# A fifth argument can be specified to include linker flags that may be required
     2686# to sucessfully perform the linking check.
     2687#
     2688# An optional sixth argument can be given to specify a list of targets.
     2689# For each target X, the variables X_LIBS and X_PCLIBS will be extended by $LBRYLIB,
     2690# if the library has been found and seems to work.
    25812691
    25822692AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
     
    26422752        [if test x"$m4_tolower($1)_libcheck" != xno; then
    26432753           coin_save_LIBS="$LIBS"
    2644            LIBS="$$2LIB $ADDLIBS"
     2754           LIBS="$$2LIB $ADDLIBS $5"
    26452755           coin_$2_link=no
    26462756           AC_LANG_PUSH(C)
     
    26542764           done
    26552765           AC_LANG_POP(C)
    2656            if test x"$coin_$2_link" = xyes ; then
    2657              LIBS="$coin_save_LIBS"
    2658            else
     2766           LIBS="$coin_save_LIBS"
     2767           if test x"$coin_$2_link" != xyes ; then
    26592768             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
    26602769           fi
     
    26622771
    26632772# If we make it this far, we've verified the file and linked the function. Add
    2664 # the necessary link flags to ADDLIBS and define the preprocessor symbol
     2773# the necessary link flags to ADDLIBS and $6_{PC}LIBS and define the preprocessor symbol
    26652774# COIN_HAS_LBRY.
    26662775
    26672776    ADDLIBS="$$2LIB $ADDLIBS"
     2777    coin_foreach_w([myvar], [$6], [
     2778      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
     2779      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
     2780    ])
     2781   
    26682782    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
    26692783  fi
     
    33493463
    33503464]) # AC_COIN_HAS_GLPK
     3465
     3466
     3467###########################################################################
     3468#                           COIN_DOXYGEN                                  #
     3469###########################################################################
     3470#
     3471# This macro determines the configuration information for doxygen, the tool
     3472# used to generate online documentation of COIN code. It takes one parameter,
     3473# a list of projects (mixed-case, to match the directory names) that should
     3474# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
     3475#
     3476# This macro will define the following variables:
     3477#  coin_have_doxygen    Yes if doxygen is found, no otherwise
     3478#  coin_doxy_usedot     Defaults to `yes'; --with-dot will still check to see
     3479#                       if dot is available
     3480#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
     3481#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
     3482#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
     3483#                       doxygen documentation
     3484#  coin_doxy_excludes   Directories to exclude from doxygen processing
     3485
     3486AC_DEFUN([AC_COIN_DOXYGEN],
     3487[
     3488
     3489AC_MSG_NOTICE([configuring doxygen documentation options])
     3490
     3491# Check to see if doxygen is available.
     3492
     3493AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
     3494
     3495# Look for the dot tool from the graphviz package, unless the user has
     3496# disabled it.
     3497
     3498AC_ARG_WITH([dot],
     3499  AS_HELP_STRING([--with-dot],
     3500                 [use dot (from graphviz) when creating documentation with
     3501                  doxygen if available; --without-dot to disable]),
     3502  [],[withval=yes])
     3503if test x"$withval" = xno ; then
     3504  coin_doxy_usedot=NO
     3505  AC_MSG_CHECKING([for dot ])
     3506  AC_MSG_RESULT([disabled])
     3507else
     3508  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
     3509fi
     3510
     3511# Generate a tag file name and a log file name
     3512
     3513AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
     3514AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
     3515
     3516# Process the list of project names and massage them into possible doxygen
     3517# doc'n directories. Prefer 1) classic external, source processed using
     3518# a project-specific doxygen.conf, we use the tag file; 2) classic
     3519# external, source processed using package doxygen.conf; 3) installed
     3520# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
     3521# configured, which we can't know unless this is the package base configure,
     3522# since coin_subdirs is only set there. Hence it's sufficient to check for
     3523# membership. If we use a tag file from a classic external, exclude the
     3524# source from doxygen processing when doxygen runs in the base directory.
     3525
     3526coin_doxy_tagfiles=
     3527coin_doxy_excludes=
     3528tmp="$1"
     3529for proj in $tmp ; do
     3530  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
     3531  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
     3532  doxytag=${lc_proj}_doxy.tag
     3533  doxyfound=no
     3534  for chkProj in $coin_subdirs ; do
     3535    if test "$chkProj" = "$proj" ; then
     3536      # proj will be configured, hence doxydoc present in build tree
     3537      doxysrcdir="${srcdir}/${proj}"
     3538      # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
     3539      if test -d "$doxysrcdir" ; then
     3540        # with a doxydoc directory?
     3541        doxydir="$doxysrcdir/doxydoc"
     3542        # AC_MSG_NOTICE([Considering $doxydir (base)])
     3543        # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
     3544        if test -d "$doxydir" ; then
     3545          # use tag file; don't process source
     3546          eval doxydir="`pwd`/${proj}/doxydoc"
     3547          coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
     3548          AC_MSG_RESULT([$doxydir (tag)])
     3549          coin_doxy_excludes="$coin_doxy_excludes */${proj}*"
     3550        else
     3551          # will process the source -- nothing further to be done here
     3552          AC_MSG_RESULT([$doxysrcdir (src)])
     3553        fi
     3554        doxyfound=yes
     3555      fi
     3556    fi
     3557  done
     3558  # Not built, fall back to installed tag file
     3559  if test $doxyfound = no ; then
     3560    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
     3561    # AC_MSG_NOTICE([Considering $doxydir (install)])
     3562    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
     3563    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
     3564    AC_MSG_RESULT([$doxydir (tag)])
     3565  fi
     3566done
     3567AC_SUBST([coin_doxy_tagfiles])
     3568AC_SUBST([coin_doxy_excludes])
     3569
     3570]) # AC_COIN_DOXYGEN
     3571
     3572
     3573###########################################################################
     3574#                           COIN_HAS_PKGCONFIG                            #
     3575###########################################################################
     3576
     3577# This macro checks whether a pkg-config tool with a minimal version number is available.
     3578# If so, then the variable PKGCONFIG is set to its path.
     3579# If not, PKGCONFIG is set to "".
     3580# The minimal version number can be given as first parameter, by default it is 0.9.0.
     3581# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4
     3582#
     3583# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is AC_SUBST'ed.
     3584# Finally, if this setup belongs to a project directory, then the search path for .pc files
     3585# is assembled from the value of $PKG_CONFIG_PATH, the values of --prefix, --coin-instdir,
     3586# and the directory named in a file ../coin_subdirs.txt or ../../coin_subdirs.txt in a variable
     3587# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed.
     3588
     3589AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
     3590[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
     3591
     3592AC_ARG_ENABLE([pkg-config],
     3593  [AC_HELP_STRING([--enable-pkg-config],[use pkg-config if available (default is yes)])],
     3594  [use_pkgconfig="$enableval"],
     3595  [use_pkgconfig=yes])
     3596
     3597if test $use_pkgconfig = yes ; then
     3598  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
     3599    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
     3600  fi
     3601  if test -n "$PKG_CONFIG"; then
     3602    _pkg_min_version=m4_default([$1], [0.9.0])
     3603    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
     3604    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
     3605      AC_MSG_RESULT([yes])
     3606    else
     3607      AC_MSG_RESULT([no])
     3608      PKG_CONFIG=""
     3609    fi
     3610  fi
     3611
     3612  # check if pkg-config supports the short-errors flag
     3613  if test -n "$PKG_CONFIG" && \
     3614    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
     3615    pkg_short_errors=" --short-errors "
     3616  else
     3617    pkg_short_errors=""
     3618  fi
     3619fi
     3620
     3621AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
     3622AC_SUBST(PKG_CONFIG)
     3623
     3624# assemble pkg-config search path for installed projects
     3625COIN_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     3626
     3627# let's assume that when installing into $prefix, then the user may have installed some other coin projects there before, so it's worth to have a look into there
     3628# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
     3629# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
     3630COIN_PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:${COIN_PKG_CONFIG_PATH}"
     3631
     3632AC_ARG_WITH([coin-instdir],
     3633  AC_HELP_STRING([--with-coin-instdir],
     3634                 [prefix of installation directory for precompiled COIN packages]),
     3635  [if test -d "$withval"; then : ; else
     3636     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
     3637   fi
     3638   COIN_PKG_CONFIG_PATH="$withval/lib/pkgconfig:${COIN_PKG_CONFIG_PATH}"
     3639  ],[])
     3640
     3641AC_SUBST(COIN_PKG_CONFIG_PATH)
     3642
     3643# assemble additional pkg-config search paths for uninstalled projects
     3644if test x$coin_projectdir = xyes ; then
     3645  # if we are in a project setup, then in a classic setup, we want to find uninstalled projects
     3646  # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
     3647  # unfortunately, if the user set prefix, then we do not know where the project base directory is located
     3648  # but it is likely to be either .. (if we are a usual coin project) or ../.. (if we are a unusual coin project like ThirdParty or Data)
     3649  COIN_PKG_CONFIG_PATH_UNINSTALLED=
     3650  if test -e ../coin_subdirs.txt ; then
     3651    for i in `cat ../coin_subdirs.txt` ; do
     3652      if test -d ../$i ; then
     3653        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
     3654      fi
     3655    done
     3656  fi
     3657
     3658  if test -e ../../coin_subdirs.txt ; then
     3659    for i in `cat ../../coin_subdirs.txt` ; do
     3660      if test -d ../../$i ; then
     3661        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
     3662      fi
     3663    done
     3664  fi
     3665
     3666  AC_SUBST(COIN_PKG_CONFIG_PATH_UNINSTALLED)
     3667fi
     3668
     3669])
     3670
     3671###########################################################################
     3672#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
     3673###########################################################################
     3674
     3675# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     3676#
     3677# Check to see whether a particular project exists.  Similar
     3678# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
     3679#
     3680AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
     3681[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3682if test -n "$PKG_CONFIG" ; then
     3683  if $PKG_CONFIG --exists "m4_tolower($1)"; then
     3684    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
     3685    m4_ifval([$2], [$2], [:])
     3686  else
     3687    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
     3688    $3
     3689  fi
     3690else
     3691  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
     3692fi
     3693])
     3694
     3695###########################################################################
     3696#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
     3697###########################################################################
     3698
     3699# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     3700#
     3701# Check to see whether a particular set of packages exists.
     3702# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
     3703#
     3704AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
     3705[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3706if test -n "$PKG_CONFIG" ; then
     3707  if $PKG_CONFIG --exists "$2"; then
     3708    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion $2 2>/dev/null`"
     3709    $3
     3710  else
     3711    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors $2`
     3712    $4
     3713  fi
     3714else
     3715  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
     3716fi
     3717])
     3718
     3719###########################################################################
     3720#                           COIN_PKG_HAS_MODULE                           #
     3721###########################################################################
     3722
     3723# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
     3724#
     3725# Checks whether pkg-config files for a given set of packages is available.
     3726# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
     3727# If not, then ACTION-IF-NOT-FOUND is executed.
     3728# A reason for not finding a package is stored in MODULE_PKG_ERRORS
     3729#
     3730# --------------------------------------------------------------
     3731AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
     3732[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3733
     3734AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
     3735  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
     3736    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
     3737        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
     3738        # but only do this if is not trivial
     3739    if test "$CYGPATH_W" != "echo" ; then
     3740      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
     3741          [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
     3742        fi
     3743    m4_toupper($1)[]_CFLAGS="$cflags"
     3744    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
     3745    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
     3746    $3
     3747  ],
     3748  [ $4 ])
     3749
     3750])# PKG_CHECK_MODULES
     3751
     3752###########################################################################
     3753#                           COIN_MAIN_PACKAGEDIR                          #
     3754###########################################################################
     3755
     3756# This macro substitutes COIN_MAIN_SUBDIR.
     3757# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
     3758# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
     3759# Otherwise, if pkg-config is available, use it to check whether the package is available.
     3760#   If $4 is given, then pkg-config is asked for the existance of $4, otherwise tolower($1) is used.
     3761# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
     3762#   If so, include this directory into the list of directories where configure and make recourse into.
     3763# tolower(coin_has_$1) is set to notGiven, skipping, installed, the version of an installed project, or the projects main directory (if uninstalled).
     3764
     3765AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],
     3766[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3767AC_MSG_CHECKING([whether project $1 is available])
     3768
     3769m4_tolower(coin_has_$1)=notGiven
     3770coin_have_project_dir=no
     3771
     3772# check if user wants to skip project in any case
     3773AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
     3774if test x"$COIN_SKIP_PROJECTS" != x; then
     3775  for dir in $COIN_SKIP_PROJECTS; do
     3776    if test $dir = "$1"; then
     3777      m4_tolower(coin_has_$1)=skipping
     3778    fi
     3779    if test $dir = "$2/$1"; then
     3780      m4_tolower(coin_has_$1)=skipping
     3781    fi
     3782  done
     3783fi
     3784
     3785if test $m4_tolower(coin_has_$1) != skipping; then
     3786  if test $PACKAGE_TARNAME = m4_tolower($1); then
     3787    m4_tolower(coin_has_$1)=.
     3788    coin_have_project_dir=yes
     3789  fi
     3790
     3791  AC_ARG_WITH([m4_tolower($1)-lib],
     3792    AC_HELP_STRING([--with-m4_tolower($1)-lib],
     3793                   [linker flags for using project $1]),
     3794      [m4_tolower(coin_has_$1)=installed],
     3795      [])
     3796
     3797  AC_ARG_WITH([m4_tolower($1)-incdir],
     3798    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
     3799                   [directory with header files for using project $1]),
     3800    [m4_tolower(coin_has_$1)=installed],
     3801    [])
     3802
     3803  AC_ARG_WITH([m4_tolower($1)-datadir],
     3804    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
     3805                   [directory with data files for using project $1]),
     3806    [m4_tolower(coin_has_$1)=installed],
     3807    [])
     3808
     3809  m4_if(m4_tolower($1), blas, [
     3810    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
     3811    AC_ARG_WITH([blas],
     3812      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD for compilation)]),
     3813        [if test x"$withval" = "xBUILD" ; then
     3814           coin_has_blas=notGiven
     3815         else
     3816           coin_has_blas=installed
     3817         fi],
     3818        [])])
     3819
     3820  m4_if(m4_tolower($1), lapack, [
     3821    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
     3822    AC_ARG_WITH([lapack],
     3823      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD for compilation)]),
     3824        [if test x"$withval" = "xBUILD" ; then
     3825           coin_has_lapack=notGiven
     3826         else
     3827           coin_has_lapack=installed
     3828         fi],
     3829        [])])
     3830
     3831fi
     3832
     3833if test $m4_tolower(coin_has_$1) = notGiven; then
     3834  #check for project by using pkg-config, if pkg-config is available
     3835  #we are only interested in installed packages here, so we do not search in $COIN_PKG_CONFIG_PATH_UNINSTALLED
     3836  if test -n "$PKG_CONFIG" ; then
     3837    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     3838    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" ; export PKG_CONFIG_PATH
     3839      m4_ifval([$4],
     3840        [AC_COIN_PKG_CHECK_PROJECT_EXISTS([$4],
     3841                [m4_tolower(coin_has_$1)="$m4_toupper([$4])_VERSION"])],
     3842              [AC_COIN_PKG_CHECK_PROJECT_EXISTS([$1],
     3843                [m4_tolower(coin_has_$1)="$m4_toupper([$1])_VERSION"])])
     3844    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
     3845    export PKG_CONFIG_PATH
     3846  fi
     3847fi
     3848
     3849# if not found yet, check if project is available in present directory
     3850if test "$m4_tolower(coin_has_$1)" = notGiven; then
     3851  if test -d $srcdir/$2/$1; then
     3852    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
     3853    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
     3854    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
     3855    m4_ifvaln([$3],
     3856      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
     3857         if test -r $i; then
     3858           coin_have_project_dir=yes
     3859         fi
     3860       done],
     3861      [ coin_have_project_dir=yes ])
     3862    if test $coin_have_project_dir = yes; then
     3863      m4_tolower(coin_has_$1)=m4_ifval($2,[$2/],)$1
     3864    fi
     3865  fi
     3866fi
     3867
     3868AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     3869
     3870AC_MSG_CHECKING(whether project $1 need to be configured)
     3871if test "$coin_have_project_dir" = yes ; then
     3872
     3873  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
     3874    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
     3875    AC_MSG_RESULT(yes)
     3876    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
     3877  else
     3878    AC_MSG_RESULT(no)
     3879  fi
     3880else
     3881  AC_MSG_RESULT(no)
     3882fi
     3883])
     3884
     3885###########################################################################
     3886#                            COIN_HAS_MODULE                              #
     3887###########################################################################
     3888
     3889# This macro sets up a COIN-OR module.
     3890# A module consists of one or more COIN-OR packages.
     3891# It defines the MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA variables, referring to the compiler and linker
     3892# flags to use when linking against this module and the directories where the module data resists.
     3893# It also defines a COIN_HAS_MODULE preprocessor macro and makefile conditional.
     3894# Further, tolower(coin_has_$1) is set to "yes".
     3895# If the flag 'required' is set (which is on by default), then the packages of the module are added to
     3896# the REQUIREDPACKAGES variable, which can be used to setup a .pc file.
     3897# The first argument should be the name (MODULE) of the module (in correct lower
     3898# and upper case).
     3899# The second argument should be a (space separated) list of projects which this
     3900# module consists of. Optionally, required version numbers can be added.
     3901# The optional third argument can be used to overwrite default values for flags like 'required'.
     3902#
     3903# It is also possible to specify a preinstalled version of this module
     3904# or to specify only the linker and compiler flags and data directory.
     3905# If the flag 'required' (which is on by default) is set, then user-given linker flags are added to
     3906# the PCADDLIBS variable, which can be used to setup a .pc file.
     3907#
     3908# If the user did not specify --with-$1-... flags and pkg-config is not available,
     3909# COIN_HAS_MODULE_FALLBACK($1, $2, $3) is called.
     3910
     3911AC_DEFUN([AC_COIN_HAS_MODULE],
     3912[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     3913AC_MSG_CHECKING([for COIN-OR module $1])
     3914
     3915m4_tolower(coin_has_$1)=notGiven
     3916
     3917# check if user wants to skip module in any case
     3918if test x"$COIN_SKIP_PROJECTS" != x; then
     3919  for dir in $COIN_SKIP_PROJECTS; do
     3920    if test $dir = "$1"; then
     3921      m4_tolower(coin_has_$1)=skipping
     3922    fi
     3923  done
     3924fi
     3925
     3926m4_toupper($1_LIBS)=
     3927m4_toupper($1_CFLAGS)=
     3928m4_toupper($1_DATA)=
     3929AC_SUBST(m4_toupper($1_LIBS))
     3930AC_SUBST(m4_toupper($1_CFLAGS))
     3931AC_SUBST(m4_toupper($1_DATA))
     3932AC_SUBST(REQUIREDPACKAGES)
     3933
     3934#check if user provided LIBS, CFLAGS, or DATA for module
     3935if test $m4_tolower(coin_has_$1) != skipping; then
     3936
     3937  AC_ARG_WITH([m4_tolower($1)-lib],
     3938    AC_HELP_STRING([--with-m4_tolower($1)-lib],
     3939                   [linker flags for using module $1]),
     3940      [m4_tolower(coin_has_$1)=yes
     3941       m4_toupper($1_LIBS)="$withval"
     3942       m4_bmatch($3, [required=0], [], [PCADDLIBS="$withval $PCADDLIBS"])
     3943      ],
     3944      [])
     3945
     3946  AC_ARG_WITH([m4_tolower($1)-incdir],
     3947    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
     3948                   [directory with header files for using module $1]),
     3949    [m4_tolower(coin_has_$1)=yes
     3950     m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"],
     3951    [])
     3952
     3953  AC_ARG_WITH([m4_tolower($1)-datadir],
     3954    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
     3955                   [directory with data files for using module $1]),
     3956    [m4_tolower(coin_has_$1)=yes
     3957     m4_toupper($1_DATA)="$withval"],
     3958    [])
     3959fi
     3960
     3961if test $m4_tolower(coin_has_$1) = notGiven; then
     3962  if test -n "$PKG_CONFIG" ; then
     3963    # set search path for pkg-config
     3964    # need to export variable to be sure that the following pkg-config gets these values
     3965    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     3966    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
     3967    export PKG_CONFIG_PATH
     3968   
     3969    # let pkg-config do it's magic
     3970    AC_COIN_PKG_HAS_MODULE([$1],[$2],
     3971      [ m4_tolower(coin_has_$1)=yes
     3972        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
     3973        m4_bmatch($3, [required=0], [], [REQUIREDPACKAGES="$2 $REQUIREDPACKAGES"])
     3974      ],
     3975      [ m4_tolower(coin_has_$1)=notGiven
     3976        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
     3977      ])
     3978
     3979    # reset PKG_CONFIG_PATH variable
     3980    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
     3981    export PKG_CONFIG_PATH
     3982  else
     3983    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
     3984    AC_COIN_HAS_MODULE_FALLBACK([$1], [$2], [$3])
     3985  fi
     3986
     3987else
     3988  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     3989fi
     3990
     3991if test $m4_tolower(coin_has_$1) != skipping &&
     3992   test $m4_tolower(coin_has_$1) != notGiven ; then
     3993  if test 0 = 1 ; then  #change this test to enable a bit of debugging output
     3994  if test -n "$m4_toupper($1)_CFLAGS" ; then
     3995    AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     3996  fi
     3997  if test -n "$m4_toupper($1)_LIBS" ; then
     3998    AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     3999  fi
     4000  if test -n "$m4_toupper($1)_DATA" ; then
     4001    AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     4002  fi
     4003  fi
     4004  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
     4005fi
     4006
     4007# Define the Makefile conditional
     4008AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     4009               [test $m4_tolower(coin_has_$1) != notGiven &&
     4010                test $m4_tolower(coin_has_$1) != skipping])
     4011
     4012]) # AC_COIN_HAS_MODULE
     4013
     4014###########################################################################
     4015#                       COIN_HAS_MODULE_FALLBACK                          #
     4016###########################################################################
     4017
     4018# This macro is used if COIN_HAS_MODULE fails to find a module because pkg-config was disabled or is not available.
     4019#
     4020# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc file in the directories specified in
     4021# $COIN_PKG_CONFIG_PATH_UNINSTALLED. The latter variable is setup by COIN_HAS_PKGCONFIG and
     4022# consists of the content of the coin_subdirs.txt file which has been created by configure in the base directory.
     4023# The content of xxx-uninstalled.pc is parsed in order to defines the variables MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA,
     4024# referring to the compiler and linker flags to use when linking against this module
     4025# and the directory where the module data resists.
     4026# Further, the Required field of each .pc file is parsed and -uninstalled.pc files for these projects are searched for.
     4027# The MODULE_CFLAGS and MODULE_LIBS variables are augmented with the information from these .pc files.
     4028# Thus, the macros checks also dependencies of $2.
     4029# Note that the MODULE_DATA variable is set to the content of datadir of the first .pc file that is parsed.
     4030#
     4031# If .pc files for all projects in $2 and their dependencies is found, tolower(coin_has_$1) is set to "yes".
     4032# Otherwise, if some dependency is not found, tolower(coin_has_$1) is set to no.
     4033# Further, a COIN_HAS_MODULE preprocessor macro and a makefile conditional are defined.
     4034# If the flag 'required' is set (which is on by default), then the module package is added to
     4035# the REQUIREDPACKAGES variable, which can be used to setup a .pc file.
     4036#
     4037# The first argument should be the name (MODULE) of the module (in correct lower and upper case).
     4038# The second argument should be the base names of the projects .pc file which define this module.
     4039# The optional third argument can be used to overwrite default values for flags like 'required'.
     4040
     4041# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into $COIN_PKG_CONFIG_PATH_UNINSTALLED.
     4042# When the content of this variable was setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
     4043
     4044AC_DEFUN([AC_COIN_HAS_MODULE_FALLBACK],
     4045[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     4046AC_MSG_CHECKING([for COIN-OR module $1 (fallback)])
     4047
     4048m4_tolower(coin_has_$1)=notGiven
     4049m4_toupper($1_LIBS)=
     4050m4_toupper($1_CFLAGS)=
     4051m4_toupper($1_DATA)=
     4052AC_SUBST(REQUIREDPACKAGES)
     4053
     4054# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x)
     4055projtoprocess="m4_bpatsubsts([$2], [<?>?=[      ]*[^    ]+])"
     4056projprocessed=""
     4057
     4058while test $m4_tolower(coin_has_$1) = notGiven ; do
     4059  # setup list of projects that need to be processed in the next round
     4060  nextprojtoprocess=""
     4061
     4062  for proj in $projtoprocess ; do
     4063    # if $proj has been processed already, skip this round
     4064    if test "x$projprocessed" != x ; then
     4065      for projdone in $projprocessed ; do
     4066        if test $projdone = $proj ; then
     4067          continue 2
     4068        fi
     4069      done
     4070    fi
     4071
     4072    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
     4073    pcfile=""
     4074    save_IFS="$IFS"
     4075    IFS=":"
     4076    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
     4077      # the base directory configure should have setup coin_subdirs.txt in a way that it does not contain projects that should be skipped, so we do not need to test this here again
     4078      if test -r "$dir/$proj-uninstalled.pc" ; then
     4079        pcfile="$dir/$proj-uninstalled.pc"
     4080        pcfiledir="$dir"
     4081        break
     4082      fi
     4083    done
     4084    IFS="$save_IFS"
     4085
     4086    if test "x$pcfile" != x ; then
     4087      # read CFLAGS from $pcfile and add CYGPATH_W cludge into include flags
     4088      projcflags=`sed -n -e 's/Cflags://p' "$pcfile"`
     4089      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
     4090      m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
     4091     
     4092      # read LIBS from $pcfile and replace -L${libdir} by absolute path to build directory in linker flags
     4093      # we assume that the build directory is $pcfiledir/src if this directory exists, otherwise we assume that it is $pcfiledir
     4094      projlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' "$pcfile"`
     4095      if test "x$projlibs" != x ; then
     4096        if test -d "${pcfiledir}/src" ; then
     4097          projlibs="-L`cd "${pcfiledir}/src"; pwd` $projlibs"
     4098        else
     4099          projlibs="-L`cd "$pcfiledir"; pwd` $projlibs"
     4100        fi
     4101      else
     4102        projlibs=`sed -n -e 's/Libs://p' "$pcfile"`
     4103      fi
     4104      m4_toupper($1_LIBS)="$m4_toupper($1_LIBS) $projlibs"
     4105     
     4106      # read DATA from $pcfile, if this is the first .pc file we are processing (so assume that its the main one)
     4107      if test "x$projprocessed" = x ; then
     4108        m4_toupper($1_DATA)=`sed -n -e 's/datadir=//gp' "$pcfile"`
     4109      fi
     4110     
     4111      # read dependencies from $pcfile, filter it, and add to list of projects that need to be processed next
     4112      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\?>\?=[         ]*[^    ]\+//g'`]
     4113      nextprojtoprocess="$nextprojtoprocess $projrequires"
     4114     
     4115      # remember that we have processed $proj
     4116      projprocessed="$projprocessed $proj"
     4117     
     4118    else
     4119      AC_MSG_RESULT([no, dependency $proj not available])
     4120      break 2
     4121    fi
     4122
     4123  done
     4124 
     4125  projtoprocess="$nextprojtoprocess"
     4126 
     4127  if test "x$projtoprocess" = x ; then
     4128    m4_tolower(coin_has_$1)=yes
     4129    AC_MSG_RESULT([yes, dependencies are$projprocessed])
     4130   
     4131    m4_bmatch($3, [required=0], [], [REQUIREDPACKAGES="$2 $REQUIREDPACKAGES"])
     4132    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
     4133   
     4134    if test 1 = 0 ; then  #change this test to enable a bit of debugging output
     4135    if test -n "$m4_toupper($1)_CFLAGS" ; then
     4136      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     4137    fi
     4138    if test -n "$m4_toupper($1)_LIBS" ; then
     4139      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     4140    fi
     4141    if test -n "$m4_toupper($1)_DATA" ; then
     4142      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     4143    fi
     4144    fi
     4145  fi
     4146done
     4147
     4148AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     4149               [test $m4_tolower(coin_has_$1) != notGiven &&
     4150                test $m4_tolower(coin_has_$1) != skipping])
     4151
     4152]) # AC_COIN_HAS_MODULE_FALLBACK
     4153
     4154###########################################################################
     4155#                         COIN_HAS_MODULE_BLAS                            #
     4156###########################################################################
     4157
     4158# This macro checks for a library containing the BLAS library.  It
     4159# 1. checks the --with-blas argument
     4160# 2. if --with-blas=BUILD has been specified goes to point 5
     4161# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS to its value
     4162# 4. tries standard libraries
     4163# 5. calls COIN_HAS_MODULE(Blas, [coinblas]) to check for ThirdParty/Blas
     4164# 6. calls COIN_HAS_MODULE_FALLBACK(Blas, [coinblas], [../ThirdParty/Blas or ../Blas])
     4165# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
     4166# BLAS_LIBS is set to the flags required to link with a Blas library.
     4167# In case 3 and 4, the flags to link to Blas are added to PCADDLIBS too.
     4168# In case 5, Blas is added to REQUIREDPACKAGES
     4169
     4170AC_DEFUN([AC_COIN_HAS_MODULE_BLAS],
     4171[
     4172AC_ARG_WITH([blas],
     4173            AC_HELP_STRING([--with-blas],
     4174                           [specify BLAS library (or BUILD for compilation)]),
     4175            [use_blas="$withval"], [use_blas=])
     4176
     4177#if user specified --with-blas-lib, then we should give COIN_HAS_MODULE preference
     4178AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
     4179
     4180# Check if user supplied option makes sense
     4181if test x"$use_blas" != x; then
     4182  if test "$use_blas" = "BUILD"; then
     4183    # we come to this later
     4184    :
     4185  elif test "$use_blas" != "no"; then
     4186    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
     4187    coin_save_LIBS="$LIBS"
     4188    LIBS="$use_blas $LIBS"
     4189    AC_COIN_TRY_FLINK([daxpy],
     4190                      [AC_MSG_RESULT([yes])],
     4191                      [AC_MSG_RESULT([no])
     4192                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
     4193    LIBS="$coin_save_LIBS"
     4194  fi
     4195else
     4196# Try to autodetect the library for blas based on build system
     4197  #AC_MSG_CHECKING([default locations for BLAS])
     4198  skip_lblas_check=no
     4199  case $build in
     4200    *-sgi-*)
     4201      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
     4202      SAVE_LIBS="$LIBS"
     4203      LIBS="-lcomplib.sgimath $LIBS"
     4204      AC_COIN_TRY_FLINK([daxpy],
     4205                        [AC_MSG_RESULT([yes])
     4206                         use_blas="-lcomplib.sgimath"],
     4207                        [AC_MSG_RESULT([no])
     4208                         SAVE_LIBS="$LIBS"])
     4209      ;;
     4210
     4211# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
     4212# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
     4213# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
     4214# that CC and cc will understand -library in Studio 13. The main extra
     4215# function of -xlic_lib and -library is to arrange for the Fortran run-time
     4216# libraries to be linked for C++ and C. We can arrange that explicitly.
     4217    *-*-solaris*)
     4218      SAVE_LIBS="$LIBS"
     4219      AC_MSG_CHECKING([for BLAS in libsunperf])
     4220      LIBS="-lsunperf $FLIBS $LIBS"
     4221      AC_COIN_TRY_FLINK([daxpy],
     4222                        [AC_MSG_RESULT([yes])
     4223                         use_blas='-lsunperf'
     4224                         coin_need_flibs=yes],
     4225                        [AC_MSG_RESULT([no])
     4226                         LIBS="$SAVE_LIBS"])
     4227      ;;
     4228    *-cygwin* | *-mingw*)
     4229# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
     4230# library will want to link with cygwin, hence won't run standalone in DOS.
     4231      if test "$enable_doscompile" = mingw; then
     4232        skip_lblas_check=yes
     4233      fi
     4234      case "$CC" in
     4235        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
     4236          SAVE_LIBS="$LIBS"
     4237          AC_MSG_CHECKING([for BLAS in MKL])
     4238          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
     4239          AC_COIN_TRY_FLINK([daxpy],
     4240                            [AC_MSG_RESULT([yes])
     4241                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'],
     4242                            [AC_MSG_RESULT([no])
     4243                             LIBS="$SAVE_LIBS"])
     4244          ;;
     4245      esac
     4246      ;;
     4247  esac
     4248
     4249  if test -z "$use_blas" && test $skip_lblas_check = no; then
     4250    SAVE_LIBS="$LIBS"
     4251    AC_MSG_CHECKING([whether -lblas has BLAS])
     4252    LIBS="-lblas $LIBS"
     4253    AC_COIN_TRY_FLINK([daxpy],
     4254                      [AC_MSG_RESULT([yes])
     4255                       use_blas='-lblas'],
     4256                      [AC_MSG_RESULT([no])
     4257                       LIBS="$SAVE_LIBS"])
     4258  fi
     4259  LIBS="$SAVE_LIBS"
     4260 
     4261  # If we have no other ideas, consider building BLAS.
     4262  if test -z "$use_blas" ; then
     4263    use_blas=BUILD
     4264  fi
     4265fi
     4266
     4267if test "x$use_blas" = xBUILD ; then
     4268  AC_COIN_HAS_MODULE(Blas, [coinblas])
     4269 
     4270elif test "x$use_blas" != x && test "$use_blas" != no; then
     4271  coin_has_blas=yes
     4272  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
     4273  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
     4274  BLAS_LIBS="$use_blas"
     4275  BLAS_CFLAGS=
     4276  BLAS_DATA=
     4277  AC_SUBST(BLAS_LIBS)
     4278  AC_SUBST(BLAS_CFLAGS)
     4279  AC_SUBST(BLAS_DATA)
     4280  PCADDLIBS="$use_blas $PCADDLIBS"
     4281 
     4282else
     4283  coin_has_blas=no
     4284  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
     4285fi
     4286
     4287]) # AC_COIN_HAS_MODULE_BLAS
     4288
     4289###########################################################################
     4290#                       COIN_HAS_MODULE_LAPACK                            #
     4291###########################################################################
     4292
     4293# This macro checks for a library containing the LAPACK library.  It
     4294# 1. checks the --with-lapack argument
     4295# 2. if --with-lapack=BUILD has been specified goes to point 5
     4296# 3. if --with-lapack has been specified to a working library, sets LAPACK_LIBS to its value
     4297# 4. tries standard libraries
     4298# 5. calls COIN_HAS_MODULE(Lapack, [lapack]) to check for ThirdParty/Lapack
     4299# 6. calls COIN_HAS_MODULE_FALLBACK(Lapack, [coinlapack], [../ThirdParty/Lapack or ../Lapack])
     4300# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
     4301# LAPACK_LIBS is set to the flags required to link with a Lapack library.
     4302# In case 3 and 4, the flags to link to Lapack are added to PCADDLIBS too.
     4303# In case 5, Lapack is added to REQUIREDPACKAGES
     4304
     4305AC_DEFUN([AC_COIN_HAS_MODULE_LAPACK],
     4306[
     4307AC_ARG_WITH([lapack],
     4308            AC_HELP_STRING([--with-lapack],
     4309                           [specify LAPACK library (or BUILD for compilation)]),
     4310            [use_lapack=$withval], [use_lapack=])
     4311           
     4312#if user specified --with-lapack-lib, then we should give COIN_HAS_MODULE preference
     4313AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
     4314
     4315# Check if user supplied option makes sense
     4316if test x"$use_lapack" != x; then
     4317  if test "$use_lapack" = "BUILD"; then
     4318    # we come to this later
     4319    :
     4320  elif test "$use_lapack" != no; then
     4321    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
     4322    coin_save_LIBS="$LIBS"
     4323    LIBS="$use_lapack $LIBS"
     4324    AC_COIN_TRY_FLINK([dsyev],
     4325                      [AC_MSG_RESULT([yes])],
     4326                      [AC_MSG_RESULT([no])
     4327                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
     4328    LIBS="$coin_save_LIBS"
     4329  fi
     4330else
     4331  if test x$coin_has_blas = xyes; then
     4332    # First try to see if LAPACK is already available with BLAS library
     4333    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
     4334    coin_save_LIBS="$LIBS"
     4335    LIBS="$BLAS_LIBS $LIBS"
     4336    AC_COIN_TRY_FLINK([dsyev],
     4337                      [AC_MSG_RESULT([yes]); use_lapack="$BLAS_LIBS"],
     4338                      [AC_MSG_RESULT([no])])
     4339    LIBS="$coin_save_LIBS"
     4340  fi
     4341  skip_llapack_check=no
     4342  if test -z "$use_lapack"; then
     4343    # Try to autodetect the library for lapack based on build system
     4344    case $build in
     4345      *-sgi-*)
     4346        SAVE_LIBS="$LIBS"
     4347        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
     4348        LIBS="-lcomplib.sgimath $LIBS"
     4349        AC_COIN_TRY_FLINK([dsyev],
     4350                          [AC_MSG_RESULT([yes])
     4351                           use_lapack="-lcomplib.sgimath;"],
     4352                          [AC_MSG_RESULT([no])
     4353                           SAVE_LIBS="$LIBS"])
     4354        ;;
     4355
     4356# See comments in COIN_HAS_BLAS.
     4357      *-*-solaris*)
     4358      SAVE_LIBS="$LIBS"
     4359      AC_MSG_CHECKING([for LAPACK in libsunperf])
     4360      LIBS="-lsunperf $FLIBS $LIBS"
     4361      AC_COIN_TRY_FLINK([dsyev],
     4362                        [AC_MSG_RESULT([yes])
     4363                         use_lapack='-lsunperf'
     4364                         coin_need_flibs=yes],
     4365                        [AC_MSG_RESULT([no])
     4366                         LIBS="$SAVE_LIBS"])
     4367        ;;
     4368# On cygwin, do this check only if doscompile is disabled. The prebuilt library
     4369# will want to link with cygwin, hence won't run standalone in DOS.
     4370      *-cygwin*)
     4371        if test "$enable_doscompile" = mingw; then
     4372          skip_llapack_check=yes
     4373        fi
     4374        ;;
     4375    esac
     4376  fi
     4377
     4378  if test -z "$use_lapack" && test $skip_llapack_check = no; then
     4379    SAVE_LIBS="$LIBS"
     4380    AC_MSG_CHECKING([whether -llapack has LAPACK])
     4381    LIBS="-llapack $LIBS"
     4382    AC_COIN_TRY_FLINK([dsyev],
     4383                      [AC_MSG_RESULT([yes])
     4384                       use_lapack='-llapack'],
     4385                      [AC_MSG_RESULT([no])
     4386                       LIBS="$SAVE_LIBS"])
     4387  fi
     4388 
     4389  LIBS="$SAVE_LIBS"
     4390
     4391  # If we have no other ideas, consider building LAPACK.
     4392  if test -z "$use_lapack" ; then
     4393    use_lapack=BUILD
     4394  fi
     4395fi
     4396
     4397if test "x$use_lapack" = xBUILD ; then
     4398  AC_COIN_HAS_MODULE(Lapack, [coinlapack])
     4399 
     4400elif test "x$use_lapack" != x && test "$use_lapack" != no; then
     4401  coin_has_lapack=yes
     4402  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
     4403  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
     4404  LAPACK_LIBS="$use_lapack"
     4405  LAPACK_CFLAGS=
     4406  LAPACK_DATA=
     4407  AC_SUBST(LAPACK_LIBS)
     4408  AC_SUBST(LAPACK_CFLAGS)
     4409  AC_SUBST(LAPACK_DATA)
     4410  if test "x$LAPACK_LIBS" != "x$BLAS_LIBS"; then
     4411    PCADDLIBS="$LAPACK_LIBS $PCADDLIBS"
     4412  fi
     4413 
     4414else
     4415  coin_has_lapack=no
     4416  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
     4417fi
     4418
     4419]) # AC_COIN_HAS_MODULE_LAPACK
     4420
     4421###########################################################################
     4422#                            COIN_HAS_PACKAGE                             #
     4423###########################################################################
     4424
     4425# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
     4426# A package can consists of one or more COIN-OR or other projects.
     4427# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA variables, referring to the compiler and linker
     4428# flags to use when linking against this module and the directories where the module data resists.
     4429# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
     4430# Further, tolower(coin_has_$1) is set to "yes".
     4431# If a list of build targets using this projects is given in the third argument,
     4432# then the compiler and linker variables and .pc file setup variable corresponding to this build target
     4433# are extended with the values for this package.
     4434# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_PCLIBS, X_PCREQUIRES are setup,
     4435# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
     4436#
     4437# The first argument should be the name (PACKAGE) of the package (in correct lower
     4438# and upper case).
     4439# The second argument should be a (space separated) list of projects which this
     4440# package consists of. Optionally, required version numbers can be added.
     4441# The optional third argument should be a (space separated) list of build targets
     4442# which use this package, if available.
     4443#
     4444# It is also possible to specify a preinstalled version of this package
     4445# or to specify only the linker and compiler flags and data directory.
     4446#
     4447# If the user did not specify --with-$1-... flags and pkg-config is not available,
     4448# COIN_HAS_PACKAGE_FALLBACK($1, $2, $3) is called.
     4449
     4450AC_DEFUN([AC_COIN_HAS_PACKAGE],
     4451[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     4452AC_MSG_CHECKING([for COIN-OR package $1])
     4453
     4454m4_tolower(coin_has_$1)=notGiven
     4455
     4456# check if user wants to skip package in any case
     4457if test x"$COIN_SKIP_PROJECTS" != x; then
     4458  for dir in $COIN_SKIP_PROJECTS; do
     4459    if test $dir = "$1"; then
     4460      m4_tolower(coin_has_$1)=skipping
     4461    fi
     4462  done
     4463fi
     4464
     4465m4_toupper($1_LIBS)=
     4466m4_toupper($1_CFLAGS)=
     4467m4_toupper($1_DATA)=
     4468AC_SUBST(m4_toupper($1_LIBS))
     4469AC_SUBST(m4_toupper($1_CFLAGS))
     4470AC_SUBST(m4_toupper($1_DATA))
     4471coin_foreach_w([myvar], [$3], [
     4472  AC_SUBST(m4_toupper(myvar)_CFLAGS)
     4473  AC_SUBST(m4_toupper(myvar)_LIBS)
     4474  AC_SUBST(m4_toupper(myvar)_PCLIBS)
     4475  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
     4476])
     4477
     4478#check if user provided LIBS, CFLAGS, or DATA for module
     4479if test $m4_tolower(coin_has_$1) != skipping; then
     4480
     4481  AC_ARG_WITH([m4_tolower($1)-lib],
     4482    AC_HELP_STRING([--with-m4_tolower($1)-lib],
     4483                   [linker flags for using package $1]),
     4484      [m4_tolower(coin_has_$1)=yes
     4485       m4_toupper($1_LIBS)="$withval"
     4486       coin_foreach_w([myvar], [$3], [
     4487         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
     4488         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
     4489       ])
     4490      ],
     4491      [])
     4492
     4493  AC_ARG_WITH([m4_tolower($1)-incdir],
     4494    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
     4495                   [directory with header files for using package $1]),
     4496    [m4_tolower(coin_has_$1)=yes
     4497     m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
     4498     coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="$withval $m4_toupper(myvar)_CFLAGS"
     4499     ])
     4500    ],
     4501    [])
     4502
     4503  AC_ARG_WITH([m4_tolower($1)-datadir],
     4504    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
     4505                   [directory with data files for using package $1]),
     4506    [m4_tolower(coin_has_$1)=yes
     4507     m4_toupper($1_DATA)="$withval"],
     4508    [])
     4509fi
     4510
     4511if test $m4_tolower(coin_has_$1) = notGiven; then
     4512  if test -n "$PKG_CONFIG" ; then
     4513    # set search path for pkg-config
     4514    # need to export variable to be sure that the following pkg-config gets these values
     4515    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
     4516    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
     4517    export PKG_CONFIG_PATH
     4518   
     4519    # let pkg-config do it's magic
     4520    AC_COIN_PKG_HAS_MODULE([$1],[$2],
     4521      [ m4_tolower(coin_has_$1)=yes
     4522        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
     4523        coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
     4524        ])
     4525      ],
     4526      [ m4_tolower(coin_has_$1)=notGiven
     4527        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
     4528      ])
     4529
     4530    # reset PKG_CONFIG_PATH variable
     4531    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
     4532    export PKG_CONFIG_PATH
     4533   
     4534    # augment X_CFLAGS and X_LIBS for each build target X in $3
     4535    coin_foreach_w([myvar], [$3], [
     4536      m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
     4537      m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
     4538    ])
     4539  else
     4540    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
     4541    AC_COIN_HAS_PACKAGE_FALLBACK([$1], [$2], [$3])
     4542  fi
     4543
     4544else
     4545  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
     4546fi
     4547
     4548if test $m4_tolower(coin_has_$1) != skipping &&
     4549   test $m4_tolower(coin_has_$1) != notGiven ; then
     4550  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
     4551   
     4552  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
     4553    if test -n "$m4_toupper($1)_CFLAGS" ; then
     4554      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     4555    fi
     4556    if test -n "$m4_toupper($1)_LIBS" ; then
     4557      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     4558    fi
     4559    if test -n "$m4_toupper($1)_DATA" ; then
     4560      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     4561    fi
     4562    if test -n "$m4_toupper($1)_CFLAGS" ; then
     4563      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     4564    fi
     4565    coin_foreach_w([myvar], [$3], [
     4566      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
     4567      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
     4568    ])
     4569  fi
     4570fi
     4571
     4572# Define the Makefile conditional
     4573AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     4574               [test $m4_tolower(coin_has_$1) != notGiven &&
     4575                test $m4_tolower(coin_has_$1) != skipping])
     4576
     4577]) # AC_COIN_HAS_MODULE
     4578
     4579###########################################################################
     4580#                       COIN_HAS_PACKAGE_FALLBACK                         #
     4581###########################################################################
     4582
     4583# This macro is used if COIN_HAS_PACKAGE fails to find a module because pkg-config was disabled or is not available.
     4584#
     4585# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc file in the directories specified in
     4586# $COIN_PKG_CONFIG_PATH_UNINSTALLED. The latter variable is setup by COIN_HAS_PKGCONFIG and
     4587# consists of the content of the coin_subdirs.txt file which has been created by configure in the base directory.
     4588# The content of xxx-uninstalled.pc is parsed in order to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
     4589# referring to the compiler and linker flags to use when linking against this package
     4590# and the directory where the package data resists.
     4591# Further, for each build target X specified in the third argument, the variables X_CFLAGS and X_LIBS are
     4592# extended with the compiler and linker flags of this package and the variables X_PCLIBS and X_PCREQUIRES are extended by the list
     4593# of linker flags and dependent projects as needed to setup a .pc file.
     4594# The macros checks also dependencies of $2.
     4595# Note that the PACKAGE_DATA variable is set to the content of datadir of the first .pc file that is parsed.
     4596#
     4597# If .pc files for all projects in $2 and their dependencies is found, tolower(coin_has_$1) is set to "yes".
     4598# Otherwise, if some dependency is not found, tolower(coin_has_$1) is set to "notGiven".
     4599# Further, a COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
     4600#
     4601# The first argument should be the name (PACKAGE) of the package (in correct lower and upper case).
     4602# The second argument should be the base names of the projects .pc file which define this package.
     4603# The optional third argument should be a (space separated) list of build targets
     4604# which use this package, if available.
     4605
     4606# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into $COIN_PKG_CONFIG_PATH_UNINSTALLED.
     4607# When the content of this variable was setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
     4608
     4609AC_DEFUN([AC_COIN_HAS_PACKAGE_FALLBACK],
     4610[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
     4611AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
     4612
     4613m4_tolower(coin_has_$1)=notGiven
     4614m4_toupper($1_LIBS)=
     4615m4_toupper($1_CFLAGS)=
     4616m4_toupper($1_DATA)=
     4617
     4618# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x)
     4619projtoprocess="m4_bpatsubsts([$2], [<?>?=[      ]*[^    ]+])"
     4620projprocessed=""
     4621
     4622while test $m4_tolower(coin_has_$1) = notGiven ; do
     4623  # setup list of projects that need to be processed in the next round
     4624  nextprojtoprocess=""
     4625
     4626  for proj in $projtoprocess ; do
     4627    # if $proj has been processed already, skip this round
     4628    if test "x$projprocessed" != x ; then
     4629      for projdone in $projprocessed ; do
     4630        if test $projdone = $proj ; then
     4631          continue 2
     4632        fi
     4633      done
     4634    fi
     4635
     4636    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
     4637    pcfile=""
     4638    save_IFS="$IFS"
     4639    IFS=":"
     4640    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
     4641      # the base directory configure should have setup coin_subdirs.txt in a way that it does not contain projects that should be skipped, so we do not need to test this here again
     4642      if test -r "$dir/$proj-uninstalled.pc" ; then
     4643        pcfile="$dir/$proj-uninstalled.pc"
     4644        pcfiledir="$dir"
     4645        break
     4646      fi
     4647    done
     4648    IFS="$save_IFS"
     4649
     4650    if test "x$pcfile" != x ; then
     4651      # read CFLAGS from $pcfile and add CYGPATH_W cludge into include flags
     4652      projcflags=`sed -n -e 's/Cflags://p' "$pcfile"`
     4653      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
     4654      m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
     4655     
     4656      # read LIBS from $pcfile and replace -L${libdir} by absolute path to build directory in linker flags
     4657      # we assume that the build directory is $pcfiledir/src if this directory exists, otherwise we assume that it is $pcfiledir
     4658      projlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' "$pcfile"`
     4659      if test "x$projlibs" != x ; then
     4660        if test -d "${pcfiledir}/src" ; then
     4661          projlibs="-L`cd "${pcfiledir}/src"; pwd` $projlibs"
     4662        else
     4663          projlibs="-L`cd "$pcfiledir"; pwd` $projlibs"
     4664        fi
     4665      else
     4666        projlibs=`sed -n -e 's/Libs://p' "$pcfile"`
     4667      fi
     4668      m4_toupper($1_LIBS)="$m4_toupper($1_LIBS) $projlibs"
     4669     
     4670      # read DATA from $pcfile, if this is the first .pc file we are processing (so assume that its the main one)
     4671      if test "x$projprocessed" = x ; then
     4672        m4_toupper($1_DATA)=`sed -n -e 's/datadir=//gp' "$pcfile"`
     4673      fi
     4674     
     4675      # read dependencies from $pcfile, filter it, and add to list of projects that need to be processed next
     4676      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\?>\?=[         ]*[^    ]\+//g'`]
     4677      nextprojtoprocess="$nextprojtoprocess $projrequires"
     4678     
     4679      # remember that we have processed $proj
     4680      projprocessed="$projprocessed $proj"
     4681     
     4682    else
     4683      AC_MSG_RESULT([no, dependency $proj not available])
     4684      break 2
     4685    fi
     4686
     4687  done
     4688 
     4689  projtoprocess="$nextprojtoprocess"
     4690 
     4691  # if there are no more projects to search for, finish up
     4692  if test "x$projtoprocess" = x ; then
     4693    m4_tolower(coin_has_$1)=yes
     4694    AC_MSG_RESULT([yes, dependencies are$projprocessed])
     4695    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
     4696   
     4697    coin_foreach_w([myvar], [$3], [
     4698      m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
     4699      m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
     4700      m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
     4701    ])
     4702   
     4703    if test 1 = 0 ; then  #change this test to enable a bit of debugging output
     4704      if test -n "$m4_toupper($1)_CFLAGS" ; then
     4705        AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
     4706      fi
     4707      if test -n "$m4_toupper($1)_LIBS" ; then
     4708        AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
     4709      fi
     4710      if test -n "$m4_toupper($1)_DATA" ; then
     4711        AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
     4712      fi
     4713      coin_foreach_w([myvar], [$3], [
     4714        AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
     4715        AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
     4716      ])
     4717    fi
     4718  fi
     4719done
     4720
     4721AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
     4722               [test $m4_tolower(coin_has_$1) != notGiven &&
     4723                test $m4_tolower(coin_has_$1) != skipping])
     4724
     4725]) # AC_COIN_HAS_PACKAGE_FALLBACK
     4726
     4727###########################################################################
     4728#                         COIN_HAS_PACKAGE_BLAS                           #
     4729###########################################################################
     4730
     4731# This macro checks for a library containing the BLAS library.  It
     4732# 1. checks the --with-blas argument
     4733# 2. if --with-blas=BUILD has been specified goes to point 5
     4734# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS to its value
     4735# 4. tries standard libraries
     4736# 5. calls COIN_HAS_PACKAGE(Blas, [coinblas], [$1]) to check for ThirdParty/Blas
     4737# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
     4738# BLAS_LIBS is set to the flags required to link with a Blas library.
     4739# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
     4740# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
     4741# In case 5, Blas is added to X_PCREQUIRES.
     4742
     4743AC_DEFUN([AC_COIN_HAS_PACKAGE_BLAS],
     4744[
     4745AC_ARG_WITH([blas],
     4746            AC_HELP_STRING([--with-blas],
     4747                           [specify BLAS library (or BUILD for compilation)]),
     4748            [use_blas="$withval"], [use_blas=])
     4749
     4750#if user specified --with-blas-lib, then we should give COIN_HAS_PACKAGE preference
     4751AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
     4752
     4753# Check if user supplied option makes sense
     4754if test x"$use_blas" != x; then
     4755  if test "$use_blas" = "BUILD"; then
     4756    # we come to this later
     4757    :
     4758  elif test "$use_blas" != "no"; then
     4759    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
     4760    coin_save_LIBS="$LIBS"
     4761    LIBS="$use_blas $LIBS"
     4762    AC_COIN_TRY_FLINK([daxpy],
     4763                      [AC_MSG_RESULT([yes])],
     4764                      [AC_MSG_RESULT([no])
     4765                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
     4766    LIBS="$coin_save_LIBS"
     4767  fi
     4768else
     4769# Try to autodetect the library for blas based on build system
     4770  #AC_MSG_CHECKING([default locations for BLAS])
     4771  skip_lblas_check=no
     4772  case $build in
     4773    *-sgi-*)
     4774      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
     4775      coin_save_LIBS="$LIBS"
     4776      LIBS="-lcomplib.sgimath $LIBS"
     4777      AC_COIN_TRY_FLINK([daxpy],
     4778                        [AC_MSG_RESULT([yes])
     4779                         use_blas="-lcomplib.sgimath"],
     4780                        [AC_MSG_RESULT([no])])
     4781      LIBS="$coin_save_LIBS"
     4782      ;;
     4783
     4784# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
     4785# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
     4786# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
     4787# that CC and cc will understand -library in Studio 13. The main extra
     4788# function of -xlic_lib and -library is to arrange for the Fortran run-time
     4789# libraries to be linked for C++ and C. We can arrange that explicitly.
     4790    *-*-solaris*)
     4791      AC_MSG_CHECKING([for BLAS in libsunperf])
     4792      coin_save_LIBS="$LIBS"
     4793      LIBS="-lsunperf $FLIBS $LIBS"
     4794      AC_COIN_TRY_FLINK([daxpy],
     4795                        [AC_MSG_RESULT([yes])
     4796                         use_blas='-lsunperf'
     4797                         coin_need_flibs=yes],
     4798                        [AC_MSG_RESULT([no])])
     4799      LIBS="$coin_save_LIBS"
     4800      ;;
     4801    *-cygwin* | *-mingw*)
     4802# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
     4803# library will want to link with cygwin, hence won't run standalone in DOS.
     4804      if test "$enable_doscompile" = mingw; then
     4805        skip_lblas_check=yes
     4806      fi
     4807      case "$CC" in
     4808        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
     4809          AC_MSG_CHECKING([for BLAS in MKL])
     4810          coin_save_LIBS="$LIBS"
     4811          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
     4812          AC_COIN_TRY_FLINK([daxpy],
     4813                            [AC_MSG_RESULT([yes])
     4814                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'],
     4815                            [AC_MSG_RESULT([no])])
     4816          LIBS="$coin_save_LIBS"
     4817          ;;
     4818      esac
     4819      ;;
     4820  esac
     4821
     4822  if test -z "$use_blas" && test $skip_lblas_check = no; then
     4823    AC_MSG_CHECKING([whether -lblas has BLAS])
     4824    coin_save_LIBS="$LIBS"
     4825    LIBS="-lblas $LIBS"
     4826    AC_COIN_TRY_FLINK([daxpy],
     4827                      [AC_MSG_RESULT([yes])
     4828                       use_blas='-lblas'],
     4829                      [AC_MSG_RESULT([no])])
     4830    LIBS="$coin_save_LIBS"
     4831  fi
     4832 
     4833  # If we have no other ideas, consider building BLAS.
     4834  if test -z "$use_blas" ; then
     4835    use_blas=BUILD
     4836  fi
     4837fi
     4838
     4839if test "x$use_blas" = xBUILD ; then
     4840  AC_COIN_HAS_PACKAGE(Blas, [coinblas], [$1])
     4841 
     4842elif test "x$use_blas" != x && test "$use_blas" != no; then
     4843  coin_has_blas=yes
     4844  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
     4845  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
     4846  BLAS_LIBS="$use_blas"
     4847  BLAS_CFLAGS=
     4848  BLAS_DATA=
     4849  AC_SUBST(BLAS_LIBS)
     4850  AC_SUBST(BLAS_CFLAGS)
     4851  AC_SUBST(BLAS_DATA)
     4852  coin_foreach_w([myvar], [$1], [
     4853    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
     4854    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
     4855  ])
     4856 
     4857else
     4858  coin_has_blas=no
     4859  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
     4860fi
     4861
     4862coin_foreach_w([myvar], [$1], [
     4863  AC_SUBST(m4_toupper(myvar)_PCLIBS)
     4864  AC_SUBST(m4_toupper(myvar)_LIBS)
     4865])
     4866
     4867]) # AC_COIN_HAS_PACKAGE_BLAS
     4868
     4869###########################################################################
     4870#                       COIN_HAS_PACKAGE_LAPACK                           #
     4871###########################################################################
     4872
     4873# This macro checks for a library containing the LAPACK library.  It
     4874# 1. checks the --with-lapack argument
     4875# 2. if --with-lapack=BUILD has been specified goes to point 5
     4876# 3. if --with-lapack has been specified to a working library, sets LAPACK_LIBS to its value
     4877# 4. tries standard libraries
     4878# 5. calls COIN_HAS_PACKAGE(Lapack, [lapack], [$1]) to check for ThirdParty/Lapack
     4879# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
     4880# LAPACK_LIBS is set to the flags required to link with a Lapack library.
     4881# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
     4882# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
     4883# In case 5, Lapack is added to X_PCREQUIRES.
     4884
     4885AC_DEFUN([AC_COIN_HAS_PACKAGE_LAPACK],
     4886[
     4887AC_ARG_WITH([lapack],
     4888            AC_HELP_STRING([--with-lapack],
     4889                           [specify LAPACK library (or BUILD for compilation)]),
     4890            [use_lapack=$withval], [use_lapack=])
     4891           
     4892#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
     4893AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
     4894
     4895# Check if user supplied option makes sense
     4896if test x"$use_lapack" != x; then
     4897  if test "$use_lapack" = "BUILD"; then
     4898    # we come to this later
     4899    :
     4900  elif test "$use_lapack" != no; then
     4901    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
     4902    coin_save_LIBS="$LIBS"
     4903    LIBS="$use_lapack $LIBS"
     4904    AC_COIN_TRY_FLINK([dsyev],
     4905                      [AC_MSG_RESULT([yes])],
     4906                      [AC_MSG_RESULT([no])
     4907                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
     4908    LIBS="$coin_save_LIBS"
     4909  fi
     4910else
     4911  if test x$coin_has_blas = xyes; then
     4912    # First try to see if LAPACK is already available with BLAS library
     4913    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
     4914    coin_save_LIBS="$LIBS"
     4915    LIBS="$BLAS_LIBS $LIBS"
     4916    AC_COIN_TRY_FLINK([dsyev],
     4917                      [AC_MSG_RESULT([yes]); use_lapack="$BLAS_LIBS"],
     4918                      [AC_MSG_RESULT([no])])
     4919    LIBS="$coin_save_LIBS"
     4920  fi
     4921  skip_llapack_check=no
     4922  if test -z "$use_lapack"; then
     4923    # Try to autodetect the library for lapack based on build system
     4924    case $build in
     4925      *-sgi-*)
     4926        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
     4927        coin_save_LIBS="$LIBS"
     4928        LIBS="-lcomplib.sgimath $LIBS"
     4929        AC_COIN_TRY_FLINK([dsyev],
     4930                          [AC_MSG_RESULT([yes])
     4931                           use_lapack="-lcomplib.sgimath;"],
     4932                          [AC_MSG_RESULT([no])])
     4933        LIBS="$coin_save_LIBS"
     4934        ;;
     4935
     4936      # See comments in COIN_HAS_BLAS.
     4937      *-*-solaris*)
     4938        AC_MSG_CHECKING([for LAPACK in libsunperf])
     4939        coin_save_LIBS="$LIBS"
     4940        LIBS="-lsunperf $FLIBS $LIBS"
     4941        AC_COIN_TRY_FLINK([dsyev],
     4942                          [AC_MSG_RESULT([yes])
     4943                           use_lapack='-lsunperf'
     4944                           coin_need_flibs=yes],
     4945                          [AC_MSG_RESULT([no])])
     4946        LIBS="$coin_save_LIBS"
     4947        ;;
     4948        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
     4949        # will want to link with cygwin, hence won't run standalone in DOS.
     4950      *-cygwin*)
     4951        if test "$enable_doscompile" = mingw; then
     4952          skip_llapack_check=yes
     4953        fi
     4954        ;;
     4955    esac
     4956  fi
     4957
     4958  if test -z "$use_lapack" && test $skip_llapack_check = no; then
     4959    AC_MSG_CHECKING([whether -llapack has LAPACK])
     4960    coin_save_LIBS="$LIBS"
     4961    LIBS="-llapack $LIBS"
     4962    AC_COIN_TRY_FLINK([dsyev],
     4963                      [AC_MSG_RESULT([yes])
     4964                       use_lapack='-llapack'],
     4965                      [AC_MSG_RESULT([no])])
     4966    LIBS="$coin_save_LIBS"
     4967  fi
     4968
     4969  # If we have no other ideas, consider building LAPACK.
     4970  if test -z "$use_lapack" ; then
     4971    use_lapack=BUILD
     4972  fi
     4973fi
     4974
     4975if test "x$use_lapack" = xBUILD ; then
     4976  AC_COIN_HAS_PACKAGE(Lapack, [coinlapack], [$1])
     4977 
     4978elif test "x$use_lapack" != x && test "$use_lapack" != no; then
     4979  coin_has_lapack=yes
     4980  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
     4981  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
     4982  LAPACK_LIBS="$use_lapack"
     4983  LAPACK_CFLAGS=
     4984  LAPACK_DATA=
     4985  AC_SUBST(LAPACK_LIBS)
     4986  AC_SUBST(LAPACK_CFLAGS)
     4987  AC_SUBST(LAPACK_DATA)
     4988  coin_foreach_w([myvar], [$1], [
     4989    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
     4990    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
     4991  ])
     4992 
     4993else
     4994  coin_has_lapack=no
     4995  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
     4996fi
     4997
     4998coin_foreach_w([myvar], [$1], [
     4999  AC_SUBST(m4_toupper(myvar)_PCLIBS)
     5000  AC_SUBST(m4_toupper(myvar)_LIBS)
     5001])
     5002
     5003]) # AC_COIN_HAS_PACKAGE_LAPACK
  • stable/0.6/commit_new_release

    r1363 r1695  
    11#!/bin/sh
    22
    3 # Copyright (C) 2007  International Business Machines.
     3# Copyright (C) 2010  International Business Machines and others.
    44# All Rights Reserved.
    55# This file is distributed under the Common Public License.
    66# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
    77#
    8 ## $Id$
     8# $Id$
    99#
    1010# Author: Andreas Waechter     IBM      2007-06-21
    1111# Modified by: Lou Hafer       SFU      2008-04-17
     12#              Lou Hafer       SFU      2010-06-29      major rewrite
    1213
    1314#set -x -v
     
    1516set -e
    1617
    17 # Remember what was done during release generation.
    18 
    19 if test -r .new_release_data; then
    20   . .new_release_data
    21 else
    22   echo ''
    23   echo 'Error: You need to run prepare_new_release first.'
    24   echo ''
    25   exit -1;
    26 fi
     18# Know thy self. If there are no '/' chars in the command name, we're running
     19# in the current directory. Otherwise, strip the command name, leaving the
     20# prefix.  Coin-functions is expected to live in the same directory.  As of
     21# the original version (100602), this script doesn't need coin-functions,
     22# but this still has some value as a consistency check.
     23
     24if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
     25  cmdDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
     26else
     27  cmdDir='.'
     28fi
     29cmdDir=`cd $cmdDir ; pwd`
     30if test -r $cmdDir/coin-functions ; then
     31  . $cmdDir/coin-functions
     32else
     33  echo "Cannot find utility functions file coin-functions; exiting."
     34fi
     35
     36# We need at least one parameter. The default is a dry run (dryRun = 1).
     37
     38printHelp=0
     39dryRun=1
     40dirToCommit=
     41
     42if test "$#" -eq 0; then
     43  printHelp=1
     44else
     45
     46# Process the parameters. A parameter without an opening `-' is assumed to be
     47# the spec for the directory to be committed.
     48
     49  while test $# -gt 0 && test $printHelp = 0 ; do
     50    case "$1" in
     51      -h* | --h*)
     52           printHelp=1
     53           ;;
     54      -c* | --c*)
     55           dryRun=0
     56           ;;
     57       -*) echo "$0: unrecognised command line switch '"$1"'."
     58           printHelp=1
     59           ;;
     60        *) dirToCommit="$1"
     61           ;;
     62    esac
     63    shift
     64  done
     65fi
     66
     67# What are we committing?
     68
     69if test -z "$dirToCommit" ; then
     70  printHelp=1
     71fi
     72
     73if test $printHelp = 1 ; then
     74  cat <<EOF
     75usage: commit_new_release [-c] <directory_to_commit>
     76
     77  By default, commit_new_release is a dry run, printing the commands that
     78  will be executed. When you're confident that everything looks right, use
     79  the -c (--commit) flag to commit the release.
     80EOF
     81  exit 1
     82fi
     83
     84# Remember what was done during generation of the new release.
     85
     86if test -r $dirToCommit/.new_release_data; then
     87  . $dirToCommit/.new_release_data
     88else
     89  echo ''
     90  echo "Error: the file .new_release_data is not present in $dirToCommit."
     91  echo 'Are you running commit_new_release in the same directory where you'
     92  echo 'ran prepare_new_release?'
     93  echo ''
     94  exit 1
     95fi
     96
     97# Confirm that we're in the proper directory.
     98
     99currDir=`pwd`
     100if test "$currDir/$dirToCommit" != "$topBuildDir" ; then
     101  echo "According to $dirToCommit/.new_release_data, the release candidate was assembled"
     102  echo "in $topBuildDir."
     103  echo "You have asked to commit $currDir/$dirToCommit."
     104  echo "There is some confusion. Repository is unchanged."
     105  exit 1
     106fi
     107
     108if test $dryRun = 1 ; then
     109  echo "Dry run; testing commit of $dirToCommit."
     110else
     111  echo "Committing $dirToCommit."
     112fi
     113
     114# Change to the checkout directory.
     115
     116cd $coDir
     117
     118# If there are externals set on this directory, confirm that
     119# .Externals.original is present so that we can restore them later.
     120
     121releaseExternals=`svn propget svn:externals .`
     122if test -n "$releaseExternals" ; then
     123  if test -r .Externals.original ; then
     124    :
     125  else
     126    echo "This project has externals, but no .Externals.original file"
     127    echo "is present to restore them. Repository is unchanged."
     128    exit 1
     129  fi
     130fi
     131
     132# Make some short-form URLs by stripping the COIN URL base.
     133
     134stableURLshort=`echo $stableURL | sed -e "s,$coinURL/\(.*\),\1,"`
     135releaseURLshort=`echo $releaseURL | sed -e "s,$coinURL/\(.*\),\1,"`
     136
     137# Do we have to svn add Dependencies? If this query comes up with a leading
     138# `?', the answer is yes. If Dependencies is entirely absent or unchanged,
     139# we'll get a null string. If it's modified, we'll have a leading `M'.
     140
     141dependStatus=`svn status Dependencies`
     142if expr "$dependStatus" : '?.*Dependencies.*' >/dev/null 2>&1 ; then
     143  cmd='svn add Dependencies'
     144  echo $cmd
     145  if test $dryRun = 0 ; then
     146    eval $cmd
     147  fi
     148fi
     149
     150# Now, do we really need to to a temporary commit? BuildTools is the poster
     151# child, there are no changes at time of writing (100629). Do an svn status
     152# on the checkout directory and see if anything comes up as modified.
     153
     154if svn status $coDir | egrep '^M' 2>&1 >/dev/null ; then
     155  doCommit=yes
     156else
     157  doCommit=no
     158fi
     159
     160if test $doCommit = yes ; then
    27161
    28162# Commit the release to stable so we can do a repository-side copy to create
    29163# the release.
    30164
    31 echo ''
    32 echo '===> Temporarily committing changed version of stable...'
    33 echo ''
    34 
    35 rev_num_before=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
    36 echo "Revision number before commit: $rev_num_before"
    37 
    38 cmd="svn ci -m \"temporarily committing release candidate to stable\""
     165  echo ''
     166  echo "===> Temporarily committing release candidate to $stableURLshort ..."
     167  echo ''
     168
     169  rev_num_before=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
     170  echo "Revision number before commit: $rev_num_before"
     171
     172  cmd="svn ci -m \"temporarily committing release candidate\""
     173  echo $cmd
     174  if test $dryRun = 0 ; then
     175    eval $cmd
     176  fi
     177
     178# Update to confirm the commit. Avoid pulling in externals --- if we're doing
     179# multiple commits of new releases, they may not exist. As it stands, the
     180# main purpose of this call is to allow us to easily obtain the current
     181# revision.
     182# It might be useful to strengthen this and check that the value
     183# is what we're expecting --- one greater than the revision before
     184# commit. `--ignore-externals' could be made provisional on the existence
     185# of all externals by passing a boolean through .new_release_data. This
     186# would strengthen the update, in that the update would confirm existence
     187# of the externals.
     188
     189  cmd='svn update --ignore-externals'
     190  echo $cmd
     191  if test $dryRun = 0 ; then
     192    eval $cmd
     193  fi
     194
     195  rev_num=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
     196  echo "Current revision number is: $rev_num"
     197
     198fi
     199
     200# End preparatory commit.
     201
     202# Create the release with a repository-side copy.
     203
     204echo ''
     205echo "===> Creating new release $releaseURLshort from $stableURLshort (rev $rev_num) ..."
     206echo ''
     207
     208cmd="svn copy -m \"creating $releaseURLshort from $stableURLshort (rev $rev_num)\" $stableURL $releaseURL"
    39209echo $cmd
    40 eval $cmd
    41 
    42 # Update to confirm the commit. Avoid pulling in externals --- if we're doing
    43 # circular dependencies, they may not exist. As it stands, the main purpose of
    44 # this call is to allow us to easily obtain the current revision. It might be
    45 # useful to strengthen this and check that the value is what we're expecting
    46 # --- one greater than the revision before commit. `--ignore-externals' could
    47 # be made provisional on the existence of circular dependency by passing a
    48 # boolean through .new_release_data. This would strengthen the update, in that
    49 # the update would confirm existence of the externals.
    50 
    51 cmd='svn update --ignore-externals'
    52 echo $cmd
    53 eval $cmd
    54 
    55 rev_num=`svn info . | grep -E '^Revision:' | sed -e 's|Revision: ||'`
    56 echo "Current revision number is: $rev_num"
    57 
    58 # Create the release with a repository-side copy.
    59 
    60 echo ''
    61 echo "===> Creating new release $new_ver from stable $stableBranch (rev $rev_num)..."
    62 echo ''
    63 
    64 cmd="svn copy -m \"creating releases/$new_ver from stable/$stableBranch (rev $rev_num)\" $stableURL $releaseURL"
    65 echo $cmd
    66 eval $cmd
    67 
    68 # And restore the stable branch to it's original condition. Start by reverting
     210if test $dryRun = 0 ; then
     211  eval $cmd
     212fi
     213
     214# Restore the original stable branch.
     215
     216if test $doCommit = yes ; then
     217
     218# And restore the stable branch to its original condition. Start by reverting
    69219# to the original externals.
    70220
    71 if test -r Externals; then
    72   echo ''
    73   echo '===> Restoring original externals...'
    74   echo ''
    75 
    76   mv Externals.bak Externals
    77   svn pset svn:externals -F Externals .
    78 fi
    79 
    80 # Revert the package id in configure.ac and propagate with run_autotools.  Note
    81 # that this does not exclude configure.ac for externals in the normal place.
    82 # But since changes to externals are not swept up by the commit, it doesn't
    83 # matter. On the other hand, if this whole checkout is a temporary for the
    84 # purpose of release generation, I'm not entirely convinced we need to bother
    85 # to exclude configure.ac in the actual ThirdParty code base. Comments from
    86 # ThirdParty maintainers welcome.
    87 
    88 conf_ac_files=`find . -name 'configure.ac' | grep -v -E 'ThirdParty/.*/.*/configure.ac'`
    89 
    90 echo ''
    91 echo "===> Restoring version number (${stableBranch}stable) in configure.ac files"
    92 for i in $conf_ac_files; do
    93   sed -e "s|AC_INIT\(.*\)\[[0-9\.]*\],\(.*\)|AC_INIT\1[${stableBranch}stable],\2|" $i > bla
    94   mv bla $i
    95   svn di $i
    96 done
    97 
    98 echo ''
    99 echo '===> Running the autotools'
    100 echo ''
    101 curdir=`pwd`
    102 cd $buildBase
    103 BuildTools/run_autotools
    104 cd "$curdir"
     221  if test -r .Externals.original ; then
     222    echo ''
     223    echo '===> Restoring original externals ...'
     224    echo ''
     225    cmd="svn propset -F .Externals.original svn:externals ."
     226    echo $cmd
     227    if test $dryRun = 0 ; then
     228      eval $cmd
     229      rm .Externals.original
     230    fi
     231  fi
     232
     233# For every .bak file that we created, revert it.
     234
     235  if test -n "$bak_files" ; then
     236    echo ''
     237    echo '===> Restoring modified files ...'
     238    echo ''
     239    for i in $bak_files; do
     240      cmd="cp $i.bak $i ; rm $i.bak"
     241      if test $dryRun = 1 ; then
     242        echo "$cmd"
     243      else
     244        eval $cmd
     245      fi
     246    done
     247  fi
     248
     249# Rebuild configure and Makefile.in files.
     250
     251  echo ''
     252  echo '===> Executing run_autotools to restore configuration files ...'
     253  echo ''
     254  curdir=`pwd`
     255  cd $topBuildDir
     256  cmd="./BuildTools/run_autotools"
     257  echo $cmd
     258  if test $dryRun = 0 ; then
     259    eval $cmd
     260  fi
     261  cd "$curdir"
    105262
    106263# Commit the restored stable branch.
    107264
    108 echo ''
    109 echo '===> Committing restored stable...'
    110 echo ''
    111 
    112 cmd="svn ci -m \"restoring stable/$stableBranch\""
    113 echo $cmd
    114 eval $cmd
    115 
    116 echo ''
    117 echo "Done, new release $releaseURL created"
    118 echo ''
    119 echo "You can now delete the directory $buildBase including subdirectories"
    120 
    121 rm .new_release_data
     265  echo ''
     266  echo "===> Committing restored $stableURLshort ..."
     267  echo ''
     268
     269  cmd="svn ci -m \"restoring $stableURLshort\""
     270  echo $cmd
     271  if test $dryRun = 0 ; then
     272    eval $cmd
     273  fi
     274
     275fi
     276
     277# End restorative commit.
     278
     279cd $topBuildDir
     280cmd="rm .new_release_data"
     281if test $dryRun = 0 ; then
     282  eval $cmd
     283fi
     284
     285cd $startDir
     286echo ''
     287echo "Done, new release $releaseURLshort created."
     288echo ''
     289echo "You can now delete the directory $topBuildDir including subdirectories"
     290
  • stable/0.6/compile_f2c

  • stable/0.6/headers/configall_system_msc.h

    r1187 r1695  
    22 * system and compiler dependent configuration macros */
    33
    4 /* Define to 64bit integer types */
    5 #if _MSC_VER==1200
    6 #define COIN_INT64_T __int64
    7 #define COIN_UINT64_T __uint64
     4/*
     5  Microsoft defines types in BaseTsd.h, part of the Windows SDK. Given
     6  that this file only gets used in the Visual Studio environment, it
     7  seems to me we'll be better off simply including it and using the
     8  types MS defines. But since I have no idea of history here, I'll leave
     9  all of this inside the guard for MSC_VER >= 1200. If you're reading this
     10  and have been developing in MSVS long enough to know, fix it.  -- lh, 100915 --
     11*/
     12#if _MSC_VER >= 1200
     13# include <BaseTsd.h>
     14#endif
     15
     16/* Define to 64bit integer types. Note that MS does not provide __uint64. */
     17#if _MSC_VER >= 1200
     18# define COIN_INT64_T INT64
     19# define COIN_UINT64_T UINT64
    820#else
    9 #define COIN_INT64_T long long
    10 #define COIN_UINT64_T unsigned long long
     21# define COIN_INT64_T long long
     22# define COIN_UINT64_T unsigned long long
    1123#endif
    1224
    1325/* Define to integer type capturing pointer */
    14 #define COIN_INTPTR_T long
     26#define COIN_INTPTR_T ULONG_PTR
    1527
    1628/* Define to dummy `main' function (if any) required to link to the Fortran
  • stable/0.6/prepare_new_release

    r1367 r1695  
    66# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
    77#
    8 ## $Id$
     8# $Id$
    99#
    1010# Author: Andreas Waechter     IBM      2007-06-21
     
    1414# Modified: Ted Ralphs         Lehigh University 2009-07-10
    1515#       Set libtool version info automatically
     16# Modified: Lou Hafer          SFU      2010-06-02
     17#       Adapt to new script architecture pioneered in *_new_stable; major
     18#       rewrite.
    1619
    1720#set -x -v
    1821set -e
    1922
    20 # You can think of this script as having three sections: first, the following
    21 # function definition, then parameter parsing and validation, and finally the
    22 # actual generation of the release candidate. See the help message for a good
    23 # description of the actions taken to generate the release candidate.
    24 
    25 # Utility function to determine current or next release for a given stable
    26 # branch. Call is determine_release(stableURL,next). Replace next with 1 for
    27 # the next release, 0 for the current release. This code is needed in three
    28 # separate places, so it really deserves to be a function. We can hope that
    29 # maintainers will have a reasonably modern version of standard sh.
    30 
    31 # Data is a real pain in the **** and should be converted to the standard
    32 # nomenclature.
    33 
    34 #Determine revision number (patch release number--third digit in release
    35 # version number
    36 
    37 determine_revision ()
    38 {
    39   if test $isData = no ; then
    40 
    41     drtmp_stableBranch=`echo $1 | sed -e 's|.*/stable/||'`
    42     drtmp_baseURL=`echo $1 | sed -e 's|/stable/[0-9.]*||'`
    43 
    44     # List the existing releases and screen for releases matching stableBranch.
    45 
    46     drtmp_svnlst=`svn list $drtmp_baseURL/releases/`
    47 
    48     drtmp_release_vers=
    49     for drtmp_i in $drtmp_svnlst ; do
    50       case $drtmp_i in
    51         $drtmp_stableBranch.*)
    52           drtmp_i=`echo $drtmp_i | sed -e 's|/$||'`
    53           drtmp_release_vers="$drtmp_release_vers $drtmp_i";;
    54       esac;
    55     done
    56 
    57     # Are there any existing releases? If not, and the user didn't ask for the
    58     # next release, we have an error.
    59 
    60     if test -z "$drtmp_release_vers" ; then
    61       if test $2 = 1 ; then
    62         drtmp_revision=0
    63       else
    64         drtmp_revision="Error"
    65       fi
    66     else
    67 
    68     # There are releases. If we don't have one after the loop, we're confused.
    69 
    70       drtmp_revision=-10000
    71       for drtmp_i in $drtmp_release_vers; do
    72         drtmp_old_revision=`echo $drtmp_i | sed -e "s|^$drtmp_stableBranch.||"`
    73         if test $drtmp_old_revision -gt $drtmp_revision; then
    74           drtmp_revision=$drtmp_old_revision
    75         fi
    76       done
    77 
    78       if test $drtmp_revision = -10000; then
    79         drtmp_revision="Error"
    80       elif test $2 = 1 ; then
    81         drtmp_revision=`expr $drtmp_revision + 1`
    82       fi
    83     fi
    84    
    85     # determine current and age for the purposes of libtool versioning
    86 
    87   else  # end normal and ThirdParty, begin Data
    88 
    89     drtmp_stableBranch=`echo $1 | sed -e 's|.*/stable/\([0-9.]*\)/.*|\1|'`
    90     drtmp_baseURL=`echo $1 | sed -e 's|\(.*\)/stable/[0-9.]*/.*|\1|'`
    91     drtmp_proj=`echo $1 | sed -e 's|.*/stable/[0-9.]*/||'`
    92 
    93     # Screen for releases that match the stable branch and contain the project
    94     # of interest. First, check for releases that match the stable branch. If
    95     # there are none, we're release 0 for this stable branch. It's an error if
    96     # there are no releases and the user did not ask for the next release. Sort
    97     # by release number here, while we have newlines in the list from svn.
    98 
    99     drtmp_svnlst=`svn list $drtmp_baseURL/releases | sort -nr -t. -k3,3`
    100 
    101     drtmp_release_vers=
    102     for drtmp_i in $drtmp_svnlst ; do
    103       case $drtmp_i in
    104         $drtmp_stableBranch.*)
    105           drtmp_i=`echo $drtmp_i | sed -e 's|/$||'`
    106           drtmp_release_vers="$drtmp_release_vers $drtmp_i";;
    107       esac;
    108     done
    109 
    110     # Do we have releases that match the stable branch?
    111 
    112     if test -z "$drtmp_release_vers" ; then
    113       if test $2 = 1 ; then
    114         drtmp_revision=0
    115       else
    116         drtmp_revision="Error"
    117       fi
    118     else
    119 
    120     # Releases exist that match stable; do any contain our project? Because
    121     # we presorted by release, we can break here at the first success.
    122 
    123       drtmp_svnlst=`echo $drtmp_release_vers`
    124       drtmp_release_vers=
    125       for drtmp_i in $drtmp_svnlst ; do
    126         case $drtmp_i in
    127           $drtmp_stableBranch.*)
    128             drtmp_i=`echo $drtmp_i | sed -e 's|/$||'`
    129             drtmp_projlst=`2>&1 svn list $drtmp_baseURL/releases/$drtmp_i/$drtmp_proj`
    130             if expr "$drtmp_projlst" : '.*non-existent.*' 2>&1 >/dev/null ; then
    131               :
    132             else
    133               drtmp_release_vers="$drtmp_i"
    134               break
    135             fi
    136             ;;
    137         esac;
    138       done
    139 
    140       # Are there any existing releases? If no, and the user didn't ask for
    141       # the next release, it's an error. Otherwise, go for release 0 of
    142       # proj in the current stable branch. If there are existing releases,
    143       # return either the current or +1.
    144 
    145       if test -z "$drtmp_release_vers" ; then
    146         if test $2 = 0 ; then
    147           drtmp_revision="Error"
    148         else
    149           drtmp_revision=0
    150         fi
    151       else
    152         drtmp_revision=-10000
    153         for drtmp_i in $drtmp_release_vers; do
    154           drtmp_old_revision=`echo $drtmp_i | sed -e "s|^$drtmp_stableBranch.||"`
    155           if test $drtmp_old_revision -gt $drtmp_revision; then
    156             drtmp_revision=$drtmp_old_revision
    157           fi
    158         done
    159         drtmp_revision=`expr $drtmp_revision + 1`
    160       fi
    161 
    162     fi  # for releases matching stable branch
    163 
    164   fi    # for normal/Data
    165 
    166   echo $drtmp_revision
    167 }
    168 
    169 # Determine current (the total number of stable releases over all time)
    170 
    171 determine_current ()
    172 {
    173   if test $isData = no ; then
    174 
    175     dctmp_stableBranch=`echo $1 | sed -e 's|.*/stable/||'`
    176     dctmp_baseURL=`echo $1 | sed -e 's|/stable/[0-9.]*||'`
    177 
    178     dctmp_current=`svn list $dctmp_baseURL/stable | wc -w`
    179 
    180   else
    181 
    182     dctmp_current=0
    183 
    184   fi
    185 
    186   echo $dctmp_current
    187 }
    188 
    189 # Determine age (the number of backwards compatible stable releases (second
    190 # number in stable version)
    191 
    192 determine_age ()
    193 {
    194   if test $isData = no ; then
    195 
    196     datmp_stableBranch=`echo $1 | sed -e 's|.*/stable/||'`
    197     datmp_baseURL=`echo $1 | sed -e 's|/stable/[0-9.]*||'`
    198 
    199     datmp_age=`echo $datmp_stableBranch | sed -e 's|[0-9].||'`
    200 
    201   else
    202 
    203     datmp_age=0
    204 
    205   fi
    206 
    207   echo $datmp_age
    208 }
     23# You can think of this script as having two sections: parameter parsing and
     24# validation, followed by generation of the release candidate. See the help
     25# message for a good description of the actions taken to generate the release
     26# candidate.
     27
     28# Know thy self. If there are no '/' chars in the command name, we're running
     29# in the currrent directory. Otherwise, strip the command name, leaving the
     30# prefix.  Coin-functions is expected to live in the same directory.
     31
     32if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
     33  cmdDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
     34else
     35  cmdDir='.'
     36fi
     37cmdDir=`cd $cmdDir ; pwd`
     38if test -r $cmdDir/coin-functions ; then
     39  . $cmdDir/coin-functions
     40else
     41  echo "Cannot find utility functions file coin-functions; exiting."
     42fi
     43
     44# Note that plain sh does not accept negative exit values
     45
     46exitValue=0
    20947
    21048# Specify the COIN URL base for convenience.
     
    21553
    21654printHelp=0
    217 exitValue=0
    21855ignoreBuildToolsMismatch=0
     56suppressCheckout=0
    21957
    22058# stableURL will be the stable branch that is the parent for the release we
    22159# are building. We'll need to be able to distinguish ThirdParty and Data
    222 # builds; they require special handling.
    223 # buildToolsURL is required when stableURL specifies a ThirdParty or Data
    224 # project --- we'll need to assemble a temporary package while creating the
    225 # release candidate.
     60# builds, and BuildTools itself; they require special handling. If a project
     61# is not BuildTools, ThirdParty, or Data, it's `normal'.
    22662
    22763stableURL=
    22864isThirdParty=no
    22965isData=no
    230 buildToolsURL=
    231 
    232 # stableExternals, on the other hand, specifies externals for which we are
    233 # doing simultaneous releases. We will use the stable branch of the external
    234 # while preparing and testing this release candidate, changing the Dependencies
    235 # file to specify a (nonexistent) release of the external at the last moment.
     66isBuildTools=no
     67isNormal=yes
     68
     69# cmdBTURL is required when stableURL specifies a ThirdParty or Data
     70# project --- we'll need to assemble a temporary package while creating the
     71# release candidate.
     72
     73cmdBTURL=
     74
     75# stableExternals specifies externals for which we are doing simultaneous
     76# releases. We will use the stable branch of the external while preparing and
     77# testing this release candidate, changing the Dependencies file to specify a
     78# (nonexistent) release of the external at the last moment.
    23679
    23780stableExternals=
     81
     82# exciseExternals specifies externals that should be removed when creating the
     83# new release.
     84
     85exciseExternals=
    23886
    23987# We need at least one parameter.
     
    25098      -h* | --h*) printHelp=1 ;;
    25199      -i* | --i*) ignoreBuildToolsMismatch=1 ;;
     100      -p* | --p*) suppressCheckout=1 ;;
    252101      -s* | --s*)
    253102           if expr "$1" : '.*-s.*=.*' 2>&1 >/dev/null ; then
     
    258107           fi
    259108           ;;
     109      -x* | --x*)
     110           if expr "$1" : '.*-x.*=.*' 2>&1 >/dev/null ; then
     111             exciseExternals=`echo $1 | sed -n -e 's/[^=]*=\(.*\)/\1/p'`
     112           else
     113             shift
     114             exciseExternals=$1
     115           fi
     116           ;;
    260117       -b* | --b*)
    261118           if expr "$1" : '.*-b.*=.*' 2>&1 >/dev/null ; then
    262              buildToolsURL=`echo $1 | sed -n -e 's/[^=]*=\(.*\)/\1/p'`
     119             cmdBTURL=`echo $1 | sed -n -e 's/[^=]*=\(.*\)/\1/p'`
    263120           else
    264121             shift
    265              buildToolsURL=$1
     122             cmdBTURL=$1
    266123           fi
    267            if expr "$buildToolsURL" : '.*BuildTools.*' 2>&1 >/dev/null ; then
    268              case $buildToolsURL in
     124           if expr "$cmdBTURL" : '.*BuildTools.*' 2>&1 >/dev/null ; then
     125             case $cmdBTURL in
    269126               http*) ;;
    270                    *) buildToolsURL=${coinURL}/$buildToolsURL
     127                   *) cmdBTURL=${coinURL}/$cmdBTURL
    271128                      ;;
    272129             esac
    273130           else
    274131             echo ''
    275              echo "URL $buildToolsURL does not point to BuildTools."
     132             echo "URL $cmdBTURL does not point to BuildTools."
    276133             echo ''
    277134             printHelp=1
    278              exitValue=-3
     135             exitValue=3
    279136            fi
    280137           ;;
     
    282139       -*) echo "$0: unrecognised command line switch '"$1"'."
    283140           printHelp=1
    284            exitValue=-1
     141           exitValue=1
    285142           ;;
    286143        *) stableURL=$1
     
    288145             case $stableURL in
    289146               http*) ;;
    290                    *) stableURL=${coinURL}/$stableURL
    291                       ;;
     147               BuildTools/ThirdParty/* )
     148                 stableURL=${coinURL}/$stableURL
     149                 ;;
     150               ThirdParty/* )
     151                 stableURL=${coinURL}/BuildTools/$stableURL
     152                 ;;
     153               CoinAll/* )
     154                 stableURL=${coinURL}/CoinBinary/$stableURL
     155                 ;;
     156               *) stableURL=${coinURL}/$stableURL
     157                 ;;
    292158             esac
    293159           else
     
    296162             echo ''
    297163             printHelp=1
    298              exitValue=-2
     164             exitValue=2
    299165           fi
    300166           ;;
     
    312178      echo "Stable URL $stableURL does not seem to exist."
    313179      printHelp=1
    314       exitValue=-5
     180      exitValue=5
    315181    fi
    316182  fi
     
    319185      *ThirdParty/* )
    320186        isThirdParty=yes
     187        isNormal=no
    321188        ;;
    322189      *Data/* )
    323190        isData=yes
     191        isNormal=no
     192        ;;
     193      *BuildTools/* )
     194        isBuildTools=yes
     195        isNormal=no
    324196        ;;
    325197      *)
     
    327199    esac
    328200    if test $isThirdParty = yes || test $isData = yes ; then
    329       if test -z $buildToolsURL ; then
     201      if test -z $cmdBTURL ; then
    330202        echo "You must provide a BuildTools URL to build a ThirdParty or Data project."
    331203        printHelp=1
    332         exitValue=-4
     204        exitValue=4
    333205      else
    334         if svn list $buildToolsURL 2>&1 >/dev/null ; then
     206        if svn list $cmdBTURL 2>&1 >/dev/null ; then
    335207          :
    336208        else
    337           echo "BuildTools URL $buildToolsURL does not seem to exist."
     209          echo "BuildTools URL $cmdBTURL does not seem to exist."
    338210          printHelp=1
    339           exitValue=-6
     211          exitValue=6
    340212        fi
    341213      fi
    342214    fi
    343215  fi
    344 fi
     216fi  # if "$#" .eq 0
    345217
    346218if test $printHelp = 1 ; then
    347219  cat <<EOF
    348 Usage: prepare_new_release <stableBranch> [options]
     220Usage: prepare_new_release <stableVer> [options]
    349221
    350222COIN standard practice is to generate periodic releases by taking a snapshot
     
    352224a new release based on the specified stable branch.
    353225
    354 Stable_branch specifies the stable branch of your project to be used to
     226<stableVer> specifies the stable branch of your project to be used to
    355227create the new release.  You can specify the entire URL, or you just enter
    356228what comes after "https://projects.coin-or.org/svn".  A typical example is
     
    361233  -b <BuildToolsURL>    URL for BuildTools; required to generate a release
    362234                        for a ThirdParty or Data project.
    363   -s <projectlist>      Comma-separated list of projects with circular
    364                         dependencies on this project. The stable branch of
    365                         projects in this list will be used while testing, on
    366                         the assumption that simultaneous releases will be
    367                         created as the release candidates are committed.
    368235  -i                    Ignore BuildTools version mismatches in externals.
     236  -p                    Suppress checkout (useful for testing)
     237  -s <projectlist>      Suppress conversion from stable to release for the
     238                        listed externals (comma-separated list of project
     239                        names, e.g., -s Osi,Cbc).
     240  -x <projectlist>      Remove the listed projects from the list of externals
     241                        (comma-separated list of project names).
    369242
    370243This script will do the following:
     
    374247    release)
    375248  - Check out a clean copy of the specified stable branch, without externals
    376   - Make sure that the svn:externals property points to releases
     249  - Make sure that the svn:externals property points to releases, with the
     250    exception of projects in the list specified with -s.
    377251  - Create a new package configure.ac file with the release version number
    378252    specified in the AC_INIT macro.
     
    381255    the most recent release of BuildTools.
    382256  - Run the configure script, compile the code, and run the unit test.
    383   - Replace any stable branches in externals (specified with -s) with the
     257  - Replace stable externals for projects specified with -s with the
    384258    appropriate (yet to be committed) release.
    385259
     
    406280
    407281stableURL=`echo $stableURL | sed -e 's|/$||'`
    408 if test $isData = yes ; then
    409   stableProj=`echo $stableURL | sed -n -e 's|.*/[^/]*/stable/[0-9.]*/\(.*\)|\1|p'`
    410   baseURL=`echo $stableURL | sed -e 's|\(.*\)/stable/[0-9.]*/\(.*\)|\1/_BB_/_RR_/\2|'`
    411   stableBranch=`echo $stableURL | sed -e 's|.*/stable/\([0-9.]*\)/.*|\1|'`
     282stableProj=`extractProjFromURL $stableURL`
     283majVer=`extractMajorFromURL $stableURL`
     284minVer=`extractMinorFromURL $stableURL`
     285stableVer=$majVer.$minVer
     286echo "Stable URL..........: $stableURL"
     287echo "Stable project......: $stableProj"
     288echo "Stable branch.......: $stableVer"
     289if test -n "$stableExternals" ; then
     290  echo "Stable externals....: $stableExternals."
     291fi
     292
     293# Find out the most recent release (if any) for the stable branch, then
     294# construct the revision number of the new release. If there are existing
     295# releases, it's a matter of bumping the revision number and inserting the
     296# new revision in the URL. Otherwise, we know the new revision is 0 and we
     297# can simply tweak the stable URL.
     298
     299releaseURL=`bestRelease $stableURL $majVer $minVer | sed -e 's|/$||'`
     300if test -n "$releaseURL" ; then
     301  curRel=`extractReleaseFromURL $releaseURL`
     302  existingURL=$releaseURL
     303  newRel=`expr $curRel + 1`
    412304else
    413   stableProj=`echo $stableURL | sed -n -e 's|.*/\([^/]*\)/stable/.*|\1|p'`
    414   baseURL=`echo $stableURL | sed -e 's|/stable/[0-9.]*||'`
    415   stableBranch=`echo $stableURL | sed -e 's|.*/stable/||'`
    416 fi
    417 echo "StableProj: $stableProj"
    418 echo "Base URL..........: $baseURL"
    419 echo "Stable URL........: $stableURL"
    420 echo "Stable branch.....: $stableBranch"
    421 if test -n "$stableExternals" ; then
    422   echo "Stable externals..: $stableExternals."
    423 fi
    424 
    425 # Find out the most recent release (if any) for the stable branch. List the
    426 # existing releases and screen for releases matching stableBranch. The new
    427 # release should be one greater than any existing release, or 0 if the stable
    428 # branch has no releases.
    429 
    430 echo ''
    431 echo "===> Checking releases for stable branch $stableBranch ..."
    432 
    433 echo $stableURL
    434 new_current=`determine_current "$stableURL" 1`
    435 new_revision=`determine_revision "$stableURL" 1`
    436 new_age=`determine_age "$stableURL" 1`
    437 new_ver="$stableBranch.$new_revision"
    438 
    439 echo ''
    440 echo "New current.......: $new_current"
    441 echo "New revision......: $new_revision"
    442 echo "New age...........: $new_age"
    443 echo "New release.......: $new_ver"
    444 buildBase="${stableProj}-$new_ver"
    445 echo "Build directory...: $buildBase"
    446 if test $isData = yes ; then
    447   releaseURL=`echo $baseURL | sed -e s/_BB_/releases/ -e s/_RR_/$new_ver/`
     305  curRel=-1
     306  releaseURL=`echo $stableURL | sed -e s/stable/releases/`
     307  existingURL="none"
     308  newRel=0
     309fi
     310newVer=$majVer.$minVer.$newRel
     311releaseURL=`replaceVersionInURL $releaseURL $majVer $minVer $newRel`
     312
     313echo "Top release URL.....: $existingURL"
     314echo "New release URL.....: $releaseURL"
     315
     316# Relevant only if we're building ThirdParty or Data
     317
     318if test $isThirdParty = yes || test $isData = yes ; then
     319  echo "BuildTools URL......: $cmdBTURL"
     320fi
     321
     322# We need a libtool version number only for normal projects
     323
     324if test $isNormal = yes ; then
     325  newLTCurrent=`calcLibtoolAge $stableURL -1`
     326  newLTRevision=$newRel
     327  newLTAge=`calcLibtoolAge $stableURL $majVer`
     328  newLTVer=${newLTCurrent}:${newLTRevision}:${newLTAge}
     329  echo "Libtool version.....: $newLTVer"
     330fi
     331
     332# Now decide where to build and check out code. If the stable project name
     333# contains a '/', strip it out to make the build and checkout directories.
     334
     335topBuildDir=`echo $stableProj | sed -e 's|.*/\([^/]*\)$|\1|'`
     336topBuildDir="${topBuildDir}-${newVer}"
     337if test $isThirdParty = yes; then
     338  coDir=$topBuildDir/Thirdparty/$stableProj
     339elif test $isData = yes; then
     340  coDir=$topBuildDir/Data/$stableProj
    448341else
    449   releaseURL="$baseURL/releases/$new_ver"
    450 fi
    451 echo "Release URL.......: $releaseURL"
     342  coDir=$topBuildDir
     343fi
     344echo "Build directory.....: $topBuildDir"
     345echo "Checkout directory..: $coDir"
    452346
    453347# Check out the stable branch that'll be the base of the new release. No
     
    457351
    458352echo ''
    459 echo "===> Checking out stable release $stableBranch without externals..."
     353echo "===> Checking out stable release $stableVer without externals..."
    460354echo ''
    461355
    462 if test $isThirdParty = yes; then
    463   coDir=$buildBase/a/b
    464 elif test $isData = yes; then
    465   coDir=$buildBase/a/b
     356rm -rf $topBuildDir
     357cmd="svn co --ignore-externals $stableURL $coDir"
     358if test $suppressCheckout = 1 ; then
     359  echo "Pretending to do: $cmd"
    466360else
    467   coDir=$buildBase
    468 fi
    469 echo "Checkout directory: $coDir"
    470 
    471 rm -rf $buildBase
    472 cmd="svn co --ignore-externals $stableURL $coDir"
    473 echo $cmd
    474 eval $cmd
    475 
    476 if test $isThirdParty = yes || test $isData = yes; then
    477   echo ''
    478   echo '===> Checking out BuildTools for ThirdParty project...'
    479   echo ''
    480   cmd="svn co $buildToolsURL $buildBase/BuildTools"
     361  rm -rf $topBuildDir
    481362  echo $cmd
    482363  eval $cmd
    483364fi
    484365
     366if test $isThirdParty = yes || test $isData = yes; then
     367  echo ''
     368  echo '===> Checking out BuildTools (Data or ThirdParty) ...'
     369  echo ''
     370  cmd="svn co $cmdBTURL $topBuildDir/BuildTools"
     371  if test $suppressCheckout = 1 ; then
     372    echo "Pretending to do: $cmd"
     373  else
     374    echo $cmd
     375    eval $cmd
     376  fi
     377fi
     378
     379startDir=`pwd`
    485380coDir=`cd $coDir; pwd`
    486 buildBase=`cd $buildBase; pwd`
     381topBuildDir=`cd $topBuildDir; pwd`
    487382
    488383cd $coDir
    489384
    490385# Find configure.ac files for the package and project and update the version.
    491 # We have no externals at this point, so there will be two files for a
    492 # standard project, one for a ThirdParty project, and none for a Data project.
     386# We have no externals or third-party code at this point, so there will be
     387# two files for a normal project, one for a ThirdParty or Data project, and
     388# none for BuildTools.
    493389
    494390echo ''
    495 conf_ac_files=`find . -name 'configure.ac' | grep -v -E 'ThirdParty/.*/.*/configure.ac'`
    496 echo "===> Creating backup (.bak) for configure.ac files..."
    497 for i in $conf_ac_files; do
    498   cp $i $i.bak
     391echo "===> Checking for configure.ac files ..."
     392bak_files=`find . -name 'configure.ac'`
     393
     394if test -n "$bak_files" ; then
     395  for i in $bak_files; do
     396    cp $i $i.bak
     397  done
     398
     399# Take the attitude that [] around parameters in AC_INIT is optional,
     400# it's the commas that count. This does make for a surpassing ugly regular
     401# expression.  A comma in the version string will cause a spectacular failure.
     402# In AC_COIN_PROJECTDIR_INIT, take the attitude that the existing parameters
     403# don't matter, we know what the release parameters should be.
     404
     405  echo ''
     406  echo "===> Updating version numbers in configure.ac files ..."
     407  for i in $bak_files; do
     408    sed -e "s|AC_INIT\(.*\),\(\[*\)[^],]*\(\]*\),\(.*\)|AC_INIT\1,\2$newVer\3,\4|" $i > bla
     409    mv bla $i
     410    sed -e "s|AC_COIN_PROJECTDIR_INIT(.*)|AC_COIN_PROJECTDIR_INIT\($stableProj,$newLTCurrent:$newLTRevision:$newLTAge\)|" $i > bla
     411    mv bla $i
     412    svn diff $i
     413  done
     414else
     415  echo "    ... none to process."
     416fi
     417
     418# Find ProjConfig.h. If there's a definition for PROJ_VERSION, adjust it and
     419# add ProjConfig.h.bak to the list of files to be restored.
     420
     421stableProjUC=`echo $stableProj | tr '[a-z]' '[A-Z]'`
     422configFileLoc=`find . -name '*Config.h' -print`
     423if test -n "$configFileLoc" ; then
     424  versionSym=${stableProjUC}_VERSION
     425  echo ''
     426  echo "===> Updating $versionSym in $configFileLoc (if present)"
     427  echo ''
     428  mv $configFileLoc $configFileLoc.bak
     429  bak_files="$bak_files $configFileLoc"
     430  sed -e "s/# *define $versionSym.*\$/#define $versionSym \"$newVer\"/" <$configFileLoc.bak >$configFileLoc
     431  svn diff $configFileLoc
     432fi
     433
     434# Look for a file specifying externals.
     435
     436srcDepFile=
     437for file in Dependencies Externals ; do
     438  if test -r $file ; then
     439    srcDepFile=$file
     440    break
     441  fi
    499442done
    500443
    501 echo ''
    502 echo "===> Updating version numbers in configure.ac files"
    503 for i in $conf_ac_files; do
    504   sed -e "s|AC_INIT\(.*\)\[[0-9A-Za-z\.]*\],\(.*\)|AC_INIT\1[$new_ver],\2|" $i > bla
    505   mv bla $i
    506   sed -e "s|AC_COIN_PROJECTDIR_INIT\(.*\)|AC_COIN_PROJECTDIR_INIT\($new_current:$new_revision:$new_age\)|" $i > bla
    507   mv bla $i
    508   svn di $i
    509 done
    510 
    511 # Now fix up the Dependencies file, if it exists. References to stable branches
    512 # will be converted to references to releases unless the reference is to a
    513 # project in the stableExternals list. Each line in a Dependencies file has the
    514 # format <ext_name> <ext_url>. The reference must be to a stable branch.
    515 
    516 if test -r Dependencies; then
    517 
    518   echo ''
    519   echo '===> Checking externals for releases and buildtools version...'
    520   echo ''
    521 
    522   buildtools_stable=`svn pget svn:externals $stableURL | grep -e "BuildTools/releases" | sed -e 's|.*/releases/\([0-9]*.[0-9]*\).[0-9]*|\1|'`
    523 
    524   echo "$stableProj uses build tools stable version $buildtools_stable"
    525   echo ''
    526 
    527   rm -f Externals.releases
     444# Now generate a proper Dependencies file for the release.  Each line
     445# in a Dependencies file has the format <ext_name> <ext_url>.  Normally,
     446# each <ext_url> should be a stable branch.  References to stable branches
     447# will be converted to references to releases unless the reference is to
     448# a project in the stableExternals list (in which case it'll be converted
     449# at the very end). References to releases are not changed. References to
     450# trunk are an error. Failure to find a release for an external not in the
     451# stableExternals list is an error. Save the existing externals and srcDepFile,
     452# as we'll probably change both.
     453
     454if test -n "$srcDepFile" ; then
     455
     456  svn propget svn:externals . > .Externals.original
     457  bak_files="$bak_files $srcDepFile"
     458  cp $srcDepFile $srcDepFile.bak
     459
     460  echo ''
     461  echo "===> Checking externals in $srcDepFile ..."
     462  echo ''
     463
     464# Because we're working directly from command output, the regular expression
     465# must check for lines.
     466
     467  ourBTURL=`svn propget svn:externals . | \
     468            sed -n -e 's/^BuildTools *https:\([^ ]*\)$/https:\1/p'`
     469  if test -z "$ourBTURL" ; then
     470    ourBTURL=none
     471  fi
     472  echo "Our BuildTools...:    $ourBTURL"
     473
     474  rm -f Dependencies
    528475  ext_name=
    529476  ext_url=
    530   for i in `cat Dependencies`; do
     477  buildtoolsMismatch=0
     478  for i in `cat $srcDepFile.bak`; do
    531479    if test "$ext_name" = ""; then
    532480      ext_name="$i"
    533481    else
    534       echo "Now checking $ext_name..."
    535       echo ''
    536482      ext_url=$i
    537       if (echo $ext_name | grep -E '^#' >/dev/null); then
    538         echo "===> Skip $ext_name $ext_url."
     483      if expr "$ext_name" : '#.*' 2>&1 >/dev/null ; then
     484        echo "    $ext_name $ext_url ==> skipped"
    539485        ext_name=
    540486        continue
    541       fi                                   
    542       if (echo $ext_url | grep -E 'stable/|releases/' >/dev/null); then
    543         :;
    544       else
     487      fi
     488      ext_urltype=`extractTypeFromURL $ext_url`
     489      ext_proj=`extractProjFromURL $ext_url`
     490
     491# See if this external should be dropped.
     492
     493      if expr "$exciseExternals" : '.*'$ext_proj'.*' 2>&1 > /dev/null ; then
     494        echo "    $ext_name $ext_url ==> excised"
     495        ext_name=
     496        continue
     497      fi
     498
     499# External must be a stable or a release.
     500
     501      if test $ext_urltype != stable && test $ext_urltype != release ; then
    545502        echo ''
    546503        echo "===> The external URL $ext_url is not a stable branch or release. Exiting."
    547504        echo ''
    548         exit -2
     505        exit 2
    549506      fi
    550507
    551 #      buildtools_version=`svn pget svn:externals $ext_url | grep -e "BuildTools/releases" | sed -e 's|.*/releases/\([0-9]*.[0-9]*\).[0-9]*|\1|'`
    552       ext_stable=`echo $ext_url | sed -e 's|\(.*/stable/[0-9]*.[0-9]*/\).*|\1|'`
    553       buildtools_version=`svn pget svn:externals $ext_stable | grep -e "BuildTools/stable" | sed -e 's|.*/stable/\([0-9]*.[0-9]*\)|\1|'`
    554 
    555       if test "$buildtools_stable" = "$buildtools_version"; then
    556         echo '===> Build tools consistency check OK'
    557       elif test "$buildtools_version" = ""; then
    558         echo "===> Skipping build tools version check for $ext_name"
     508      ext_isNormal=`isNormalURL $ext_url`
     509
     510# Convert stable branches to releases unless listed in stableExternals.
     511# Existing releases are unchanged.
     512
     513      if test $ext_urltype = stable ; then
     514        if expr "$stableExternals" : '.*'"$ext_proj"'.*' 2>&1 >/dev/null ; then
     515          echo "    $ext_name $ext_url unchanged"
     516          ext_rel_url=$ext_url
     517        else
     518          ext_majVer=`extractMajorFromURL $ext_url`
     519          ext_minVer=`extractMinorFromURL $ext_url`
     520          ext_rel_url=`bestRelease $ext_url $ext_majVer $ext_minVer`
     521          if test -z "$ext_rel_url" ; then
     522            echo ''
     523            echo "===> No release for $ext_url. Exiting."
     524            echo ''
     525            exit 2
     526          fi
     527          # Normal (not BuildTools/ThirdParty/Data) need a directory name,
     528          # and it may differ from the project name. Carefully preserve it.
     529          if test $ext_isNormal = yes ; then
     530            ext_tail=`extractTailFromExt $ext_url`
     531            ext_rel_url=${ext_rel_url}${ext_tail}
     532          fi
     533          echo "    $ext_name $ext_url ==> $ext_rel_url"
     534        fi
    559535      else
    560         echo $ext_name >>problems.ext
     536        ext_rel_url=$ext_url
     537        echo "    $ext_name $ext_url ==> unchanged"
    561538      fi
    562539
    563       if test -r problems.ext; then
    564         echo ''
    565         echo 'PROBLEM DURING CONSISTENCY CHECK:'
    566         echo ''
    567         echo ''
    568         echo "External $ext_name uses stable version $buildtools_version of the build tools"
    569         echo "$stableProj uses stable version $buildtools_stable of the build tools"
    570         echo ''
    571         cat problems.ext
    572         echo ''
    573         rm -f problems.ext
    574         if test $ignoreBuildToolsMismatch = 0 ; then
    575            exit -2
    576         else
    577           echo "Continuing in spite of BuildTools mismatch."
    578         fi
    579       fi
    580 
    581       ext_base_front=`echo $ext_url | sed -e 's|/stable/.*||'`
    582       ext_proj=`echo $ext_base_front | sed -e 's|.*/\([^/]*\)|\1|'`
    583 
    584       if expr "$stableExternals" : '.*'"$ext_proj"'.*' 2>&1 >/dev/null ; then
    585         echo "===> Using stable reference for $ext_name."
    586         ext_rel_url=$ext_url
    587       elif expr "$ext_url" : '.*releases/.*' 2>&1 >/dev/null ; then
    588         echo "===> Using specified release for $ext_name."
    589         ext_rel_url=$ext_url
    590       else
    591         ext_stable=`echo $ext_url | sed -e 's|\(.*/stable/[0-9\.]*\).*|\1|'`
    592         ext_base_end=`echo $ext_url | sed -e 's|.*/stable/[0-9\.]*||'`
    593         ext_stable_branch=`echo $ext_stable | sed -e 's|.*/stable/||'`
    594 
    595         echo "===> Determining release replacement for $ext_name:"
    596         ext_latest=$ext_stable_branch.`determine_revision $ext_stable 0`
    597 
    598         if test "$ext_base_end" = ""; then
    599           ext_rel_url=$ext_base_front/releases/$ext_latest
    600         else
    601           ext_rel_url=$ext_base_front/releases/$ext_latest$ext_base_end
     540# Get the BuildTools URL for the external and compare to the BuildTools URL
     541# for the source, assuming we have one and the external has one. We only need
     542# to do this for normal URLs, and we need to strip the tail.
     543
     544      if test $ext_isNormal = yes &&
     545         test $ext_proj != BuildTools && test $ourBTURL != none ; then
     546        ext_rel_url_notail=`echo $ext_rel_url | sed -e 's,/[^/]*$,,'`
     547        extBTURL=`svn propget svn:externals $ext_rel_url_notail`
     548        extBTURL=`echo $extBTURL | \
     549          sed -n -e 's/.*BuildTools https:\([^ ]*\) .*/https:\1/p'`
     550        if test -n "$extBTURL" ; then
     551          testResult=`compareURLVersions "$ourBTURL" "$extBTURL"`
     552          if test $testResult = no ; then
     553            echo "    WARNING: BuildTools mismatch: $ext_rel_url_notail uses $extBTURL"
     554            if test $ignoreBuildToolsMismatch = 0 ; then
     555               buildtoolsMismatch=1
     556            fi
     557          fi
    602558        fi
    603559      fi
    604560
    605       echo "     $ext_rel_url"
    606       echo "$ext_name  $ext_rel_url" >>Externals.releases
     561      echo "$ext_name  $ext_rel_url" >>Dependencies
    607562      ext_name=
    608563      echo ''
     
    610565  done
    611566
    612   echo ''
    613   echo '===> Updating svn:externals properties, and checking out externals...'
    614   echo ''
    615 
    616   svn pset svn:externals -F Externals.releases .
    617 
     567# If we have a BuildTools mismatch, and mismatch is not permitted, exit.
     568
     569  if test $buildtoolsMismatch -gt $ignoreBuildToolsMismatch ; then
     570    echo "Exiting due to BuildTools mismatches; use -i to ignore."
     571    exit 2
     572  fi
     573
     574  echo ''
     575  echo '===> Updating svn:externals property and checking out externals ...'
     576  echo ''
     577
     578  svn propset svn:externals -F Dependencies .
    618579  svn update
    619580
    620   echo ''
    621   echo '===> If there are ThirdParty externals, run the download scripts...'
    622   echo ''
    623 
    624   ext_name=
    625   ext_url=
    626   for i in `cat Externals.releases`; do
    627     if test "$ext_name" = ""; then
    628       ext_name="$i"
    629     else
    630       ext_url=$i
    631 
    632       case $ext_name in
    633         ThirdParty/*)
    634           pkg=`echo $ext_name | sed -e 's|ThirdParty/||' -e 's|/||g'`
    635           getfile=get.$pkg
    636           if test -r $ext_name/$getfile; then
    637             curdir=`pwd`
    638             cd $ext_name
    639             echo "Running $getfile -patch in `pwd`"
    640             eval ./$getfile -patch
    641             cd "$curdir"
    642           fi
    643           ;;
    644       esac
    645       ext_name=
    646     fi
    647   done
    648 fi # if test -r Externals.releases
    649 
    650 if test $isThirdParty = yes; then
    651   pkg=`echo $baseURL | sed -e 's|.*/||g'`
    652   if test -r get.$pkg; then
     581  if test -d ThirdParty ; then
    653582    echo ''
    654     echo '===> Download third party code...'
     583    echo '===> Downloading ThirdParty code ...'
    655584    echo ''
    656     ./get.$pkg
    657   fi
    658 fi
    659 
    660 echo ''
    661 echo '===> Running the autotools...'
    662 echo ''
    663 
    664 if test $isThirdParty = yes; then
    665   curdir=`pwd`
    666   cd ../..
    667   BuildTools/run_autotools
    668   cd "$curdir"
    669 elif test $isData = yes; then
    670   curdir=`pwd`
    671   cd ../..
    672   BuildTools/run_autotools
    673   cd "$curdir"
    674 else
    675   BuildTools/run_autotools
    676 fi
    677 
    678 if test $isThirdParty != yes && test $isData != yes; then
     585
     586    ext_name=
     587    ext_url=
     588    for i in `svn propget svn:externals .` ; do
     589      if test -z "$ext_name" ; then
     590        ext_name="$i"
     591      else
     592        ext_url=$i
     593        if expr "$ext_name" : 'ThirdParty/.*' 2>&1 >/dev/null ; then
     594          cd $ext_name
     595          ext_proj=`extractProjFromURL $ext_url`
     596          getScript=get.$ext_proj
     597          if test -x "$getScript" ; then
     598            ./$getScript -patch
     599          fi
     600          cd $coDir
     601        fi
     602        ext_name=
     603      fi
     604    done
     605  fi
     606fi
     607
     608# Finally! Done processing externals. If this is a ThirdParty project, we
     609# still have to run the get script.
     610
     611if test $isThirdParty = yes ; then
     612  if test -x get.$stableProj ; then
     613    echo ''
     614    echo '===> Downloading third party code ...'
     615    echo ''
     616    ./get.$stableProj
     617  fi
     618fi
     619
     620# Don't run run_autotools for BuildTools!
     621
     622if test $isBuildTools = no ; then
     623  echo ''
     624  echo '===> Running BuildTools/run_autotools ...'
     625  echo ''
     626  if test $isThirdParty = yes || test $isData = yes ; then
     627    cd ../..
     628    ./BuildTools/run_autotools
     629    cd "$coDir"
     630  elif test $isNormal = yes ; then
     631    ./BuildTools/run_autotools
     632  fi
     633fi
     634
     635# Let's see if it works. We only run tests for normal projects. DO NOT turn
     636# on --enable-maintainer-mode in the initial configure command. At the least,
     637# it's not needed. At the worst, as of 100526, it'll undo all the careful
     638# work above to set externals.
     639
     640if test $isNormal = yes ; then
    679641  (set -e
    680642   echo ''
     
    683645   mkdir build
    684646   cd build
    685    cmd="$coDir/configure -C --enable-maintainer-mode"
     647   cmd="$coDir/configure -C"
    686648   echo $cmd
    687649   eval $cmd
     
    715677    echo 'Error during build or test'
    716678    echo ''
    717     exit -3
    718   fi
     679    exit 3
     680  fi
     681  echo ''
     682  echo '===> ALL TESTS PASSED'
    719683fi
    720684
    721685echo ''
    722 echo '===> ALL TESTS PASSED'
    723 if test $isThirdParty != yes && test $isData != yes; then
    724   echo ''
    725   echo 'Please review the output above, particularly the one of make test'
    726 fi
     686if test $isNormal = yes ; then
     687  echo 'Please review the output above, particularly the one of make test.'
     688else
     689  echo 'Please review the output above.'
     690fi
     691echo ''
    727692
    728693# Do we need to plug in nonexistent releases for circular dependencies tested
    729 # with the stable versions? If so, generate a new Externals.release. This is
    730 # the only reason stable references should appear in the Externals file for a
    731 # release, so we don't need to check further before removing them.
     694# with the stable versions? If so, generate a new Dependencies. This is the
     695# only reason stable references should appear in the externals for a release,
     696# so we don't need to check further before removing them.
    732697
    733698if test -n "$stableExternals" ; then
    734   echo "Grooming Externals to remove stable references used for testing."
    735   mv Externals.releases Externals
     699  echo "===> Grooming externals to remove stable externals used for testing ..."
     700  mv Dependencies Dependencies.temp.$$
    736701  ext_name=
    737702  ext_url=
    738   for i in `cat Externals`; do
     703  for i in `cat Dependencies.temp.$$`; do
    739704    if test "$ext_name" = ""; then
    740705      ext_name="$i"
    741706    else
    742707      ext_url=$i
    743       if (echo $ext_url | grep -E 'stable/' >/dev/null); then
    744         echo "Determining release replacement for $ext_name:"
    745         ext_stable=`echo $ext_url | sed -e 's|\(.*/stable/[0-9\.]*\).*|\1|'`
    746         ext_latest=`determine_release $ext_stable 1`
    747         ext_rel_url=`echo $ext_url | sed -e "s|stable/[0-9.]*|releases/$ext_latest|"`
    748         echo "  $ext_rel_url"
     708      ext_urltype=`extractTypeFromURL $ext_url`
     709      ext_proj=`extractProjFromURL $ext_url`
     710      if test $ext_urltype = stable ; then
     711        ext_rel_url=$ext_url
     712        ext_majVer=`extractMajorFromURL $ext_url`
     713        ext_minVer=`extractMinorFromURL $ext_url`
     714        ext_rel_url=`echo $ext_url | sed -e 's,/stable/,/releases/,'`
     715        ext_rel_url=`replaceVersionInURL $ext_rel_url $ext_majVer $ext_minVer 0`
     716        echo "    $ext_name $ext_url ==> $ext_rel_url"
    749717      else
    750718        ext_rel_url=$ext_url
    751719      fi
    752       echo "$ext_name  $ext_rel_url" >>Externals.releases
     720      echo "$ext_name  $ext_rel_url" >>Dependencies
    753721      ext_name=
    754722    fi
    755723  done
    756   svn propset -F Externals.releases svn:externals .
    757   rm -rf Externals
    758 fi
    759 
    760 
    761 if test -r Externals.releases; then
    762   echo ''
    763   echo 'Also, please confirm the Externals are correct:'
     724  rm -f Dependencies.temp.$$
     725  svn propset -F Dependencies svn:externals .
     726  echo ''
     727fi
     728
     729if test -r Dependencies ; then
     730  echo 'Also, please confirm the externals are correct:'
    764731  svn propget svn:externals
    765732fi
     
    769736echo 'the directory'
    770737echo ''
    771 echo "          $coDir"
     738echo "          $startDir"
    772739echo ''
    773740echo "and run the commit_new_release script"
    774741
    775 rm -rf Externals.releases
     742cd $topBuildDir
    776743
    777744cat >.new_release_data <<EOF
    778 isData=$isData
     745coinURL=$coinURL
     746startDir=$startDir
     747topBuildDir=$topBuildDir
    779748coDir=$coDir
    780 buildBase=$buildBase
    781749releaseURL=$releaseURL
    782750stableURL=$stableURL
    783 new_ver=$new_ver
    784 stableBranch=$stableBranch
     751newVer=$newVer
     752bak_files="$bak_files"
    785753EOF
  • stable/0.6/run_autotools

    r1363 r1695  
    11#!/bin/sh
    22
    3 # Copyright (C) 2006, 2007  International Business Machines.
     3# Copyright (C) 2006, 2007, 2008, 2009, 2010  International Business Machines
     4# and others.
    45# All Rights Reserved.
    56# This file is distributed under the Common Public License.
     
    910#
    1011# Author: Andreas Waechter     IBM      2006-04-14
     12# Modified: Lou Hafer          SFU      2010-06-11
     13#      Mods to allow variations from standard package structure. Decision to
     14#      process a configure.ac file is based on presence of COIN macros.
     15#      Directories specified on the command line are recursively searched
     16#      for configure.ac files. Install-sh signals an independent unit.
     17# Modified: Lou Hafer          SFU      2010-07-08
     18#      More mods to maintain flexibility but be a bit less aggressive about
     19#      forcing installation of autotools auxilliary scripts. Also add some
     20#      command line options and restore ability to specify individual
     21#      directories on the command line.
     22
     23# run_autotools takes care of running the autotools (automake, autoconf,
     24# and helpers) and also makes a few arrangements for when configure and
     25# libtool execute at configuration, build, and installation.
     26
     27# Run_autotools can be given a set of directories on the command line; if none
     28# are specified, it assumes the current directory (`,').  Subdirectories are
     29# searched for configure.ac files unless suppressed with the -nr option.
     30# Autotools will consider a directory for processing if any AC_COIN_ macro is
     31# present in the configure.ac file. Should it be necessary to fool this script
     32# into processing a file that otherwise contains no COIN macros, just add a
     33# line with AC_COIN_.  The resulting list is winnowed to remove directories
     34# specified in COIN_SKIP_PROJECTS.
     35
     36# Each directory processed gets a temporary link to BuildTools, unless a
     37# BuildTools subdirectory is already present. Mostly this is a convenience, but
     38# one thing makes it mandatory: Many Makefile.am files in COIN use an include
     39# directive to pull in BuildTools/Makemain.inc. There's no way I (lh) can see
     40# to alter the path that's hardcoded in the include directive. Just to make it
     41# more interesting, COIN projects are generally constructed with the assumption
     42# that BuildTools will be one or two directories up, so you'll see things like
     43# `include ../BuildTools/Makemain.inc'. run_autotools doesn't understand this
     44# hierarchy, so it keeps all those temporary BuildTools links until the very
     45# end. That way, it works with the old-style COIN organisation where a
     46# BuildTools directory is pulled in as an external in the top directory of a
     47# package, and with the new-style independent organisation, where there may be
     48# only a single copy of BuildTools out there somewhere.
     49
     50# If any subdirectory queued for processing is found to contain an install-sh
     51# script, it is treated as an independent unit (i.e., you can run `make
     52# install' from this directory) and the set of auxilliary scripts is refreshed
     53# from BuildTools.  You can force installation of install-sh and associated
     54# scripts with the -i option. It's good to read the autoconf documentation for
     55# AC_CONFIG_AUX_DIR if this doesn't make sense to you.
    1156
    1257# Make sure we bail out if there is an error
    1358set -e
     59
     60# Define a cleanup function. We'll set a trap below, just before we start to
     61# do actual work.
     62
     63cleanupOnErrorExit ()
     64{ for link in $buildtoolsLinks; do
     65    echo Trap: removing $link
     66    rm -f $link
     67  done
     68  cd $startDir
     69}
     70
     71# Note that vanilla sh doesn't like negative exit values.
     72
     73# Determine the location of run_autotools.  If there are no '/' chars in
     74# the command name, we're running in the current directory (almost certainly
     75# not what's wanted). Otherwise, strip the command name, leaving the prefix.
     76# Convert the prefix to an absolute path, if needed, and clean it up, removing
     77# `XXX/..', '/./', '//' sequences.
     78
     79startDir=`pwd`
     80if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
     81  runautotoolDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
     82else
     83  runautotoolDir='.'
     84fi
     85if  expr "$runautotoolDir" : '/.*' >/dev/null 2>&1 ; then
     86  :
     87else
     88  runautotoolDir=$startDir/$runautotoolDir
     89fi
     90while expr "$runautotoolDir" : '.*/\.\./.*' >/dev/null 2>&1 ; do
     91  runautotoolDir=`echo $runautotoolDir | sed -e 's,/[^/][^/]*/\.\./,/,'`
     92done
     93runautotoolDir=`echo $runautotoolDir | sed -e 's,/\./,/,g' -e 's,//,/,g'`
     94
     95# Make sure we're using the correct versions of the autotools. Failure to
     96# satisfy this requirement is a fatal error.
    1497
    1598ver_autoconf='2.59'
     
    28111  echo You are not using the correct version of autoconf
    29112  rm -f confauto.out
    30   exit -2
     113  exit 2
    31114fi
    32115rm -f confauto.out
     
    35118if test $autoconf_dir = `cd $AUTOTOOLS_DIR/bin; pwd`; then :; else
    36119  echo autoconf is not picked up from the correct location
    37   exit -2
     120  exit 2
    38121fi
    39122
     
    43126  echo You are not using the correct version of automake
    44127  rm -f confauto.out
    45   exit -2
     128  exit 2
    46129fi
    47130rm -f confauto.out
     
    50133if test $autoconf_dir = `cd $AUTOTOOLS_DIR/bin; pwd`; then :; else
    51134  echo automake is not picked up from the correct location
    52   exit -2
    53 fi
     135  exit 2
     136fi
     137
     138# Failure to find the correct version of libtool isn't fatal here, but
     139# the user should be warned.
    54140
    55141grep_version=`echo  $ver_libtool | sed -e 's/\\./\\\\\\./g'`
    56142ltfile=$AUTOTOOLS_DIR/share/libtool/ltmain.sh
    57143if test -r $ltfile; then :; else
    58   echo Cannot file $ltfile
     144  echo WARNING: Cannot file libtool shell $ltfile
    59145fi
    60146if $EGREP $grep_version $ltfile >/dev/null 2>&1; then :; else
    61   echo You are not using the correct verion of libtool
    62 fi
    63 
    64 # Find directories which contain a file configure.ac. When all is said and
    65 # done, each entry in dirs will be of the form `./path/to/directory'
    66 
    67 if test $# != 0; then
    68   dirs="$*"
     147  echo WARNING: You are not using the correct version of libtool
     148fi
     149
     150# Set up to process parameters. No parameters is the default.
     151
     152printHelp=0
     153doRecurse=1
     154forceScripts=0
     155userSpecifiedDirs=0
     156dirsToProcess=
     157
     158# Process the parameters. A parameter without an opening `-' is assumed to be
     159# a spec for a directory to be processed.
     160
     161while test $# -gt 0 && test $printHelp = 0 ; do
     162  case "$1" in
     163    -h* | --h* )
     164         printHelp=1
     165         ;;
     166    -nr* | --no-recursion )
     167         doRecurse=0
     168         ;;
     169    -i | --independent )
     170         forceScripts=1
     171         doRecurse=0
     172         ;;
     173    -* ) echo "$0: unrecognised command line switch '"$1"'."
     174         printHelp=1
     175         ;;
     176     * ) dirsToProcess="$dirsToProcess $1"
     177         userSpecifiedDirs=1
     178         ;;
     179  esac
     180  shift
     181done
     182
     183# Help?
     184
     185if test $printHelp = 1 ; then
     186  cat <<EOF
     187usage: run_autotools [-h] [-nr] [ directory directory ... ]
     188
     189  -h  | --help           print help message and exit
     190  -nr | --no-recursion   do not do recursive search for configure.ac files
     191  -i  | --independent    install scripts necessary for an independent unit
     192
     193  If no directories are specified, the tree rooted at the current directory
     194  is searched recursively for directories with configure.ac files containing
     195  COIN configuration macros (AC_COIN_*) and autotools is run in those
     196  directories. Directories listed in COIN_SKIP_PROJECTS are skipped.
     197  If directories are specified on the command line, the search for configure.ac
     198  files is restricted to the specified directories.
     199
     200  If directories are specified on the command line *and* --no-recursion is
     201  given, the specified directories are processed with no checks.
     202
     203  The --independent option will force installation of install-sh and other
     204  scripts necessary for a unit that is installed independently. This will
     205  be forced in *all* directories processed. Most often what is desired is
     206  to install these scripts in the top-level directory of a unit, so -i
     207  forces -nr. It's a good idea to explicitly specify the directories you want
     208  to process.
     209EOF
     210  exit
     211fi
     212
     213# Did the user give directories on the command line? If not, assume the current
     214# directory.
     215
     216if test -z "$dirsToProcess" ; then
     217  dirsToProcess='.'
     218fi
     219
     220# If recursion is permitted, find directories which contain a file
     221# configure.ac. When all is said and done, each entry in dirs will be of the
     222# form `./path/to/directory'
     223
     224candDirs=
     225if test $doRecurse = 1 ; then
     226  for dir in $dirsToProcess ; do
     227    tmp=`find $dir -name configure.ac | sed -e s%/configure.ac%%g`
     228    case "$candDirs" in
     229      *"$tmp"* )
     230          ;;
     231      * )
     232          candDirs="$candDirs $tmp"
     233          ;;
     234      esac
     235  done
    69236else
    70   pos_dirs=`find . -name configure.ac | sed -e s%/configure.ac%%g | grep -v 'ThirdParty/[^/]*/[^/]*'`
     237  candDirs=$dirsToProcess
     238fi
     239
     240# Did the user specify these directories *and* forbid recursion? In that case,
     241# use the directories exactly as given. If not, winnow the candidates.
     242# Process a directory only if the configure.ac file contains at least one
     243# macro that starts with AC_COIN_, and it's not listed in COIN_SKIP_PROJECTS.
     244
     245if test $userSpecifiedDirs = 1 && test $doRecurse = 0 ; then
     246  dirs=$candDirs
     247else
    71248  dirs=
    72   for dir in $pos_dirs; do
    73     if test -r $dir/configure.ac; then
     249  for dir in $candDirs; do
     250    if grep AC_COIN_ $dir/configure.ac >/dev/null 2>&1 ; then
    74251      dirs="$dirs $dir"
    75252    else
    76       echo "$dir/configure.ac doesn't appear to be a regular file; skipping."
     253      echo "  Skipping foreign configure.ac in $dir."
    77254    fi
    78255  done
    79 fi
    80256
    81257# Now compare against the skip entries in COIN_SKIP_PROJECTS. To match the
    82258# entries we just collected, add `./' to the front of each skip entry.
    83259
    84 pos_dirs=$dirs
    85 if test x${COIN_SKIP_PROJECTS+set} = xset ; then
    86   dirs=
    87   for dir in $COIN_SKIP_PROJECTS ; do
    88     skip_dirs="$skip_dirs ./$dir"
    89   done
    90   for dir in $pos_dirs ; do
    91     skip=0
    92     for skipdir in $skip_dirs ; do
    93       if test $dir = $skipdir ; then
    94         skip=1
    95         break
    96       fi
     260  candDirs=$dirs
     261  if test x${COIN_SKIP_PROJECTS+set} = xset ; then
     262    dirs=
     263    for dir in $COIN_SKIP_PROJECTS ; do
     264      skip_dirs="$skip_dirs ./$dir"
    97265    done
    98     if test $skip = 0 ; then
    99       dirs="$dirs $dir"
     266    for dir in $candDirs ; do
     267      skip=0
     268      for skipdir in $skip_dirs ; do
     269        if test $dir = $skipdir ; then
     270          skip=1
     271          break
     272        fi
     273      done
     274      if test $skip = 0 ; then
     275        dirs="$dirs $dir"
     276      else
     277        echo "  Skipping $dir listed in COIN_SKIP_PROJECTS."
     278      fi
     279    done
     280  fi
     281fi
     282
     283# Set a trap so that we'll clean up any links on exit, for whatever reason.
     284# Note that this executes on normal exit, too, so don't do anything rash.
     285
     286topLink=
     287subLink=
     288trap 'exit_status=$?
     289  cleanupOnErrorExit
     290  exit $exit_status' 0
     291
     292# And now the main event. Process each directory.
     293
     294echo "Running autotools in $dirs"
     295
     296autotoolsFiles="config.guess config.sub depcomp install-sh ltmain.sh missing"
     297m4Files="$AUTOTOOLS_DIR/share/aclocal/libtool.m4"
     298buildtoolsLinks=
     299
     300for dir in $dirs; do
     301  if test -r $dir/configure.ac; then
     302    cd $dir
     303    echo "Processing $dir ..."
     304
     305# Do we need a BuildTools subdirectory here? The criteria is that install-sh
     306# already exists, or Makefile.am (which may include Makemain.inc), or we're
     307# forcing installation of the configure scripts.  Assuming we need BuildTools,
     308# what BuildTools should we use? If a BuildTools is already present, that's
     309# it.  Otherwise, assume that runautotooldDir is BuildTools. Allow that the
     310# user may have linked to a BuildTools.
     311
     312    needScripts=0
     313    if test -f install-sh || test $forceScripts = 1 ; then
     314      needScripts=1
     315    fi
     316    if test -f Makefile.am || test $needScripts = 1 ; then
     317      if test -d BuildTools || test -L BuildTools ; then
     318        createLink=0
     319        toolsDir=`pwd`/BuildTools
     320      else
     321        createLink=1
     322        toolsDir=$runautotoolDir
     323      fi
     324      echo "  BuildTools directory: $toolsDir"
     325
     326# Test to be sure that run_autotools is coming from the BuildTools directory.
     327
     328      if test $createLink = 0 && test "$toolsDir" != "$runautotoolDir" ; then
     329        echo "WARNING: using run_autotools from $runautotoolDir"
     330        echo "         but BuildTools is $toolsDir."
     331        echo "         Consider carefully if this is what you wanted to do."
     332      fi
     333
     334# coin.m4 should live in the same directory; failure is fatal.
     335
     336      if test ! -r $toolsDir/coin.m4 ; then
     337        echo "Cannot find Coin autotools macro file $toolsDir/coin.m4."
     338        echo "It should be in the BuildTools directory."
     339        exit 1
     340      fi
     341
     342# Install a link, if needed.
     343
     344      if test $createLink = 1 ; then
     345        ln -s $toolsDir BuildTools
     346        buildtoolsLinks="$buildtoolsLinks `pwd`/BuildTools"
     347        echo "  creating temporary link for ./BuildTools -> $toolsDir"
     348      fi
     349
     350# And refresh the autotools scripts, if needed.
     351
     352      if test $needScripts = 1 ; then
     353        echo "  refreshing autotools scripts in this directory."
     354        for file in $autotoolsFiles ; do
     355          cp BuildTools/$file .
     356        done
     357      fi
     358
     359    fi
     360
     361# Get on with running the autotools.
     362
     363    echo "  creating acinclude.m4 in $dir"
     364    cat $m4Files $toolsDir/coin.m4 > acinclude.m4
     365    echo "  running aclocal in $dir"
     366    if test -d m4; then
     367      aclocal -I m4 || exit 1
    100368    else
    101       echo "$dir listed in COIN_SKIP_PROJECTS; skipping."
    102     fi
    103   done
    104 fi
    105 
    106 echo Running autotools in $dirs
    107 
    108 currdir=`pwd`
    109 if test -r $currdir/BuildTools/coin.m4; then
    110   toolsdir=$currdir/BuildTools
    111 else
    112   echo Cannot find BuildTools directory.
    113   exit
    114 fi
    115 
    116 echo Copying autotools scripts into this directory
    117 cp $toolsdir/config.guess $toolsdir/config.sub $toolsdir/depcomp $toolsdir/install-sh $toolsdir/ltmain.sh $toolsdir/missing .
    118 
    119 if test x$AUTOTOOLS_DIR = x; then
    120   AUTOTOOLS_DIR=$HOME
    121 fi
    122 
    123 for dir in $dirs; do
    124   (if test -r $dir/configure.ac; then
    125      cd $dir
    126      echo creating acinclude.m4 in $dir
    127      cat $AUTOTOOLS_DIR/share/aclocal/libtool.m4 $toolsdir/coin.m4> acinclude.m4
    128      echo running aclocal in $dir
    129      if test -d m4; then
    130        aclocal -I m4 || exit -1
    131      else
    132        aclocal || exit -1
    133      fi
    134      if grep AC_CONFIG_HEADER configure.ac >/dev/null 2>&1; then
    135        echo running autoheader in $dir
    136        autoheader || exit -1
    137      fi
    138      echo running automake in $dir
    139      automake || exit -1
    140      echo running autoconf in $dir
    141      autoconf || exit -1
    142    else
    143      echo "*** No configure.ac file in $dir - SKIPPING! ***"
    144    fi
    145   )
    146   if test $? -ne 0; then
    147     exit -2;
     369      aclocal || exit 1
     370    fi
     371    if grep AC_CONFIG_HEADER configure.ac >/dev/null 2>&1; then
     372      echo "  running autoheader in $dir"
     373      autoheader || exit 1
     374    fi
     375    echo "  running automake in $dir"
     376    automake || exit 1
     377    echo "  running autoconf in $dir"
     378    autoconf || exit 1
     379    cd $startDir
     380  else
     381    # Serious confusion! Should not reach here.
     382    echo "*** No configure.ac file in $dir - SKIPPING! ***"
    148383  fi
    149384done
     385
     386# Remove the links. Yeah, the trap will do this, but it never hurts to clean
     387# up properly.
     388
     389if test -n "$buildtoolsLinks" ; then
     390  echo "Removing temporary links to BuildTools."
     391  for link in $buildtoolsLinks ; do
     392    # echo "  removing temporary link for BuildTools: $link"
     393    rm $link
     394  done
     395  buildtoolsLinks=
     396fi
     397
     398exit
     399
  • stable/0.6/set_externals

    r1370 r1695  
    77# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
    88#
    9 ## $Id: prepare_new_release 1302 2009-06-07 18:17:53Z stefan $
     9# $Id$
    1010#
    11 # This script is based on prepare_new_release, which is authored by
    12 # Author: Andreas Waechter     IBM      2007-06-21
    13 # Modified: Lou Hafer          SFU      2008-01-20
    14 #
    15 # The modifications to set_externals were made by
    16 # Ted Ralphs Lehigh University          2009-07-07
    17 #
     11
     12# Adapted from prepare_new_release by Ted Ralphs, Lehigh Univ., 2009-07-07
     13# Modified:     Lou Hafer    SFU    2010-06-02
    1814
    1915#set -x -v
    2016set -e
    2117
    22 determine_release ()
    23 {
    24   drtmp_stableBranch=`echo $1 | sed -e 's|.*/stable/||'`
    25   drtmp_baseURL=`echo $1 | sed -e 's|/stable/[0-9.]*||'`
    26   drtmp_returnVal=
     18# Know thy self. If there are no '/' chars in the command name, we're running
     19# in the currrent directory. Otherwise, strip the command name, leaving the
     20# prefix.  Coin-functions is expected to live in the same directory.
    2721
    28   # List the existing releases and screen for releases matching stableBranch.
     22if expr "$0" : '.*/.*' >/dev/null 2>&1 ; then
     23  cmdDir=`echo $0 | sed -e 's,\(.*\)/[^/]*,\1,'`
     24else
     25  cmdDir='.'
     26fi
     27if test -r $cmdDir/coin-functions ; then
     28  . $cmdDir/coin-functions
     29else
     30  echo "Cannot find utility functions file coin-functions; exiting."
     31fi
    2932
    30   drtmp_svnlst=`svn list $drtmp_baseURL/releases/`
    31 
    32   drtmp_release_vers=
    33   for drtmp_i in $drtmp_svnlst ; do
    34     case $drtmp_i in
    35       $drtmp_stableBranch.*)
    36         drtmp_i=`echo $drtmp_i | sed -e 's|/$||'`
    37         drtmp_release_vers="$drtmp_release_vers $drtmp_i";;
    38     esac;
    39   done
    40 
    41   # Are there any existing releases? If not, and the user didn't ask for the
    42   # next release, we have an error.
    43 
    44   if test -z "$drtmp_release_vers" ; then
    45     if test $2 = 1 ; then
    46       drtmp_returnVal="$drtmp_stableBranch.0"
    47     else
    48       drtmp_returnVal="Error"
    49     fi
    50   else
    51 
    52   # There are releases. If we don't have one after the loop, we're confused.
    53 
    54     drtmp_new_rel=-10000
    55     for drtmp_i in $drtmp_release_vers; do
    56       drtmp_rel=`echo $drtmp_i | sed -e "s|^$drtmp_stableBranch.||"`
    57       if test $drtmp_rel -gt $drtmp_new_rel; then
    58         drtmp_new_rel=$drtmp_rel
    59       fi
    60     done
    61 
    62     if test $drtmp_new_rel = -10000; then
    63       drtmp_new_rel="Error"
    64     elif test $2 = 1 ; then
    65       drtmp_new_rel=`expr $drtmp_new_rel + 1`
    66     fi
    67       drtmp_returnVal="$drtmp_stableBranch.$drtmp_new_rel"
    68   fi
    69 
    70   echo $drtmp_returnVal
    71 }
    7233
    7334printHelp=0
    7435exitValue=0
    75 Dependencies=
     36depFile=
    7637
    7738if test "$#" -eq 0; then
     
    8041
    8142# Process the parameters. A parameter without an opening `-' is assumed to be
    82 # the spec for the stable branch.
     43# the dependency file.
    8344
    8445  while test $# -gt 0 && test $exitValue = 0 && test $printHelp = 0 ; do
     
    8849       -*) echo "$0: unrecognised command line switch '"$1"'."
    8950           printHelp=1
    90            exitValue=-1
     51           exitValue=1
    9152           ;;
    92         *) Dependencies=$1
     53        *) depFile=$1
    9354           ;;
    9455    esac
     
    9758fi
    9859
    99 # End of parameter parsing. We have a stable URL to work with.  Tell the
    100 # user what we've seen.
    101 
    102 # Find out the most recent release (if any) for the stable branch. List the
    103 # existing releases and screen for releases matching stableBranch. The new
    104 # release should be one greater than any existing release, or 0 if the stable
    105 # branch has no releases.
     60# Find the most recent release for each stable external. Allow for the
     61# possibility that a stable branch has no associated release.
    10662
    10763if test $printHelp = 0 && test $exitValue = 0; then
    108   if test -r $Dependencies; then
     64  if test -r $depFile; then
    10965
    11066    rm -f Externals.releases
    11167
    11268    echo ''
    113     echo '===> Creating new externals file with pointers to releases...'
     69    echo '===> Converting stable externals to releases ...'
    11470    echo ''
    11571
    11672    ext_name=
    11773    ext_url=
    118     for i in `cat $Dependencies`; do
     74    for i in `cat $depFile`; do
    11975      if test "$ext_name" = ""; then
    12076        ext_name="$i"
    12177      else
    12278        ext_url=$i
    123         if (echo $ext_name | grep -E '^#' >/dev/null); then
    124           echo "Skip $ext_name."
     79        if expr "$ext_name" : '#.*' >/dev/null 2>&1 ; then
     80          echo "Skipping $ext_name."
    12581          ext_name=
    12682          continue
    12783        fi                                   
    128         if (echo $ext_url | grep -E 'trunk|stable/|releases/' >/dev/null); then
    129           :;
    130         else
     84        extType=`extractTypeFromURL $ext_url`
     85        if test "$extType" = invalid ; then
    13186          echo ''
    132           echo "The external URL $ext_url is not valid. Exiting."
     87          echo "The external URL $ext_url appears to be invalid. Exiting."
    13388          echo ''
    134           exit -2
     89          exit 3
    13590        fi
    13691
    137         ext_base_front=`echo $ext_url | sed -e 's|/stable/.*||'`
    138         ext_proj=`echo $ext_base_front | sed -e 's|.*/\([^/]*\)|\1|'`
     92        if test "$extType" = stable ; then
     93          ext_majVer=`extractMajorFromURL $ext_url`
     94          ext_minVer=`extractMinorFromURL $ext_url`
     95          ext_rel_url=`bestRelease $ext_url $ext_majVer $ext_minVer`
     96          if test -z "$ext_rel_url" ; then
     97            echo "There is no release for $ext_url"
     98            echo "Keeping $ext_url"
     99          else
     100            # Normal (not BuildTools/ThirdParty/Data) need a directory name,
     101            # and it may differ from the project name. Carefully preserve it.
     102            # ThirdParty URLs include BuildTools ; both named for emphasis
     103            case $ext_rel_url in
     104              */BuildTools/* | */ThirdParty/* | */Data/* ) ;;
     105              *) ext_tail=`extractTailFromExt $ext_url`
     106                 ext_rel_url=${ext_rel_url}${ext_tail}
     107                 ;;
     108            esac
     109            echo "Replacing $ext_url with $ext_rel_url"
     110            ext_url=$ext_rel_url
     111          fi
     112        else
     113          echo "Keeping $ext_url"
     114        fi
    139115
    140         if expr "$ext_url" : '.*releases/.*' 2>&1 >/dev/null ; then
    141           echo "Using specified release for $ext_name."
    142           ext_rel_url=$ext_url
    143         elif expr "$ext_url" : '.*trunk.*' 2>&1 >/dev/null; then
    144           echo "Using specified trunk for $ext_name."
    145           ext_rel_url=$ext_url
    146         else
    147           ext_stable=`echo $ext_url | sed -e 's|\(.*/stable/[0-9\.]*\).*|\1|'`
    148           ext_base_end=`echo $ext_url | sed -e 's|.*/stable/[0-9\.]*||'`
    149 
    150           echo "Determining release for $ext_name:"
    151           ext_latest=`determine_release $ext_stable 0`
    152  
    153           if test "$ext_base_end" = ""; then
    154             ext_rel_url=$ext_base_front/releases/$ext_latest
    155           else
    156             ext_rel_url=$ext_base_front/releases/$ext_latest$ext_base_end
    157           fi
    158         fi
    159 
    160         echo "  $ext_rel_url"
    161         echo "$ext_name  $ext_rel_url" >>Externals.releases
     116        echo "$ext_name  $ext_url" >>Externals.releases
    162117        ext_name=
    163118      fi
     
    168123    echo ''
    169124
    170     svn pset svn:externals -F Externals.releases .
     125    svn propset svn:externals -F Externals.releases .
     126    svn propget svn:externals .
    171127   
    172128    rm Externals.releases
    173129
    174   else # if test -r Dependencies
     130  else # if test -r depFile
    175131    echo ""
    176132    echo "Dependency file does not exist or is unspecified..."
    177133    echo ""
    178134    printHelp=1
    179     exitvalue=-2
     135    exitvalue=2
    180136  fi
    181137fi
     
    190146 <name> <URL of stable version>
    191147
    192 Recommended practice is to keep this list in a file called "Dendencies" in the
    193 project's root directory. A temporary file called "Externals.releases" in the
    194 same form, but with the URL of each stable version replaced by the URL of the
    195 latest associated release is produced. From this file, the script will set the
    196 svn:externals variable. It does not do an update or commit the change. After
    197 the script runs, do an update and test build, then commit the change if you
    198 are happy.
     148Recommended practice is to keep this list in a file called "Dependencies" in
     149the project's root directory. A temporary file called "Externals.releases" in
     150the same form, but with the URL of each stable version replaced by the URL of
     151the latest associated release is produced. From this file, the script will
     152set the svn:externals variable. It does not do an update or commit the
     153change. After the script runs, do an update and test build, then commit the
     154change if you are happy.
    199155
    200156EOF
Note: See TracChangeset for help on using the changeset viewer.