source: branches/autotools-update/coin.m4 @ 2553

Last change on this file since 2553 was 2553, checked in by stefan, 8 years ago
  • remove macros that workaround problems with old autotools/libtool version in the hope that these issues are fixed with a current version
  • remove own setting of compiler flags in favor of autoconf wisdom
  • Property svn:keywords set to Author Date Id Revision
File size: 108.6 KB
Line 
1# Copyright (C) 2006, 2009 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Eclipse Public License.
4#
5## $Id: coin.m4 2553 2012-05-16 18:13:24Z stefan $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_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])])])
24
25###########################################################################
26#                            COIN_CHECK_FILE                              #
27###########################################################################
28
29# A simple replacement for AC_CHECK_FILE that works for cross compilation
30
31AC_DEFUN([AC_COIN_CHECK_FILE],
32[if test -r $1; then
33  $2
34  :
35else
36  $3
37  :
38fi
39])
40
41###########################################################################
42#                           COIN_CHECK_VPATH                              #
43###########################################################################
44
45# This macro sets the variable coin_vpath_config to true if this is a
46# VPATH configuration, otherwise it sets it to false.
47
48AC_DEFUN([AC_COIN_CHECK_VPATH],
49[
50AC_MSG_CHECKING(whether this is a VPATH configuration)
51if test `cd $srcdir; pwd` != `pwd`; then
52  coin_vpath_config=yes;
53else
54  coin_vpath_config=no;
55fi
56AC_MSG_RESULT($coin_vpath_config)
57]) # AC_COIN_CHECK_VPATH
58
59###########################################################################
60#                         COIN_PROJECTDIR_INIT                            #
61###########################################################################
62
63# This macro does everything that is required in the early part in the
64# configure script, such as defining a few variables.  This should only be used
65# in the main directory of a project directory (the one which holds the src
66# directory for the project). The first parameter is the project name. The
67# second (optional) is the libtool library version (important for releases,
68# less so for stable or trunk).
69
70AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
71[
72# As backup, we make sure we don't loose an FLIBS if it has been set
73# by the user
74save_FLIBS="$FLIBS"
75
76# A useful makefile conditional that is always false
77AM_CONDITIONAL(ALWAYS_FALSE, false)
78
79# We set the following variable so that we know later in AC_COIN_FINALIZE
80# that we are in a project main directory
81coin_projectdir=yes
82
83# Set the project's version numbers
84m4_ifvaln([$1],[
85  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION), ["$PACKAGE_VERSION"],[Version number of project])
86 
87  [coin_majorver=`echo $PACKAGE_VERSION | sed -n -e 's/^\([0-9]*\).*/\1/gp'`]
88  [coin_minorver=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.\([0-9]*\).*/\1/gp'`]
89  [coin_releasever=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/gp'`]
90  if test "x$coin_majorver" = x ; then coin_majorver=9999 ; fi
91  if test "x$coin_minorver" = x ; then coin_minorver=9999 ; fi
92  if test "x$coin_releasever" = x ; then coin_releasever=9999 ; fi
93  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MAJOR),   [$coin_majorver],   [Major Version number of project])
94  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MINOR),   [$coin_minorver],   [Minor Version number of project])
95  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_RELEASE), [$coin_releasever], [Release Version number of project])
96
97  # We use the following variable to have a string with the upper case
98  # version of the project name
99  COIN_PRJCT=m4_toupper($1)
100
101  # Set the project's SVN revision number. The complicated sed expression
102  # (made worse by quadrigraphs) ensures that things like 4123:4168MS end up
103  # as a single number.
104  AC_CHECK_PROG([have_svnversion],[svnversion],[yes],[no])
105  if test "x$have_svnversion" = xyes; then
106    AC_SUBST(m4_toupper($1_SVN_REV))
107    svn_rev_tmp=`LANG=en_EN svnversion $srcdir 2>/dev/null`
108    if test "x$svn_rev_tmp" != xexported -a "x$svn_rev_tmp" != x; then
109      m4_toupper($1_SVN_REV)=`echo $svn_rev_tmp | sed -n -e 's/^@<:@0-9@:>@*://' -e 's/\(@<:@0-9@:>@\)@<:@^0-9@:>@*$/\1/p'`
110      AC_DEFINE_UNQUOTED(m4_toupper($1_SVN_REV), $m4_toupper($1_SVN_REV), [SVN revision number of project])
111    fi
112  fi
113 ])
114
115# Capture libtool library version, if given.
116m4_ifvaln([$2],[coin_libversion=$2],[])
117
118]) # AC_COIN_PROJECTDIR_INIT
119
120###########################################################################
121#                          COIN_DEBUG_COMPILE                             #
122###########################################################################
123
124# enable the configure flags --enable-debug and --enable-debug-prjct
125# (where prcjt is the name of the project in lower case) and set the
126# variable coin_debug_compile to true or false This is used by
127# COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77 to determine the
128# compilation flags.  This macro also makes the switches
129# --with-prjct-verbosity and --with-prjct-checklevel available, which
130# define the preprocessor macros COIN_PRJCT_VERBOSITY and
131# COIN_PRJCT_CHECKLEVEL to the specified value (default is 0).
132#
133# The project specific flags are only made available, if one gives the
134# name of the project as first argument to this macro.
135
136AC_DEFUN([AC_COIN_DEBUG_COMPILE],
137[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
138AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
139AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
140
141AC_MSG_CHECKING([whether we want to compile in debug mode])
142
143AC_ARG_ENABLE([debug],
144[AC_HELP_STRING([--enable-debug],
145                [compile all projects with debug options tests (implies --disable-shared)])],
146[case "${enableval}" in
147   yes) coin_debug_compile=true
148        if test "${enable_shared+set}" = set; then :; else
149          enable_shared=no
150        fi
151        ;;
152   no)  coin_debug_compile=false
153        ;;
154   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
155        ;;
156esac],
157[coin_debug_compile=false])
158
159m4_ifvaln([$1],
160[AC_ARG_ENABLE(debug-m4_tolower($1),
161 [AC_HELP_STRING([--enable-debug-m4_tolower($1)],
162                 [compile project $1 with debug compiler flags])],
163 [case "${enableval}" in
164    yes) coin_debug_compile=true
165         ;;
166    no)  coin_debug_compile=false
167         ;;
168    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
169         ;;
170 esac],[:])
171]) # m4_ifvaln([$1],
172
173if test $coin_debug_compile = true; then
174  AC_MSG_RESULT([yes])
175else
176  AC_MSG_RESULT([no])
177fi
178
179m4_ifvaln([$1],
180[AC_ARG_WITH(m4_tolower($1)-verbosity,
181             AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
182                            [specify the debug verbosity level for project $1]),
183             [if test "$withval" = yes; then
184                withval=1
185              fi
186              m4_tolower(coin_$1_verbosity)=$withval],
187             [m4_tolower(coin_$1_verbosity)=0])
188 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
189                    m4_tolower($coin_$1_verbosity),
190                    [Define to the debug verbosity level (0 is no output)])
191
192 AC_ARG_WITH(m4_tolower($1)-checklevel,
193             AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
194                            [specify the sanity check level for project $1]),
195             [if test "$withval" = yes; then
196                withval=1
197              fi
198              m4_tolower(coin_$1_checklevel)=$withval],
199             [m4_tolower(coin_$1_checklevel)=0])
200 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
201                    m4_tolower($coin_$1_checklevel),
202                    [Define to the debug sanity check level (0 is no test)])
203]) # m4_ifvaln([$1],
204 
205]) # AC_COIN_DEBUG_COMPILE
206
207###########################################################################
208#                             COIN_PROG_CXX                               #
209###########################################################################
210
211AC_DEFUN([AC_COIN_PROG_CXX],
212[AC_REQUIRE([AC_PROG_CXX])
213
214# add automake conditional so we can recognize cl compiler in makefile
215coin_cxx_is_cl=false
216case "$CXX" in
217  clang* ) ;;
218  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
219    coin_cxx_is_cl=true
220    ;;
221esac
222AM_CONDITIONAL(COIN_CXX_IS_CL, [test $coin_cxx_is_cl = true])
223
224# add -DPROJECT_BUILD to signal compiler preprocessor which config header file to include
225if test x$COIN_PRJCT != x; then
226  CXXFLAGS="$CXXFLAGS -D${COIN_PRJCT}_BUILD"
227fi
228
229AC_MSG_NOTICE([C++ compiler options are: $CXXFLAGS])
230
231]) # AC_COIN_PROG_CXX
232
233
234###########################################################################
235#                           COIN_CHECK_HEADER                             #
236###########################################################################
237
238AC_DEFUN([AC_COIN_CHECK_HEADER],[AC_CHECK_HEADERS([$1],[$2],[$3],[$4])])
239
240###########################################################################
241#                       COIN_CHECK_CXX_CHEADER                            #
242###########################################################################
243
244# This macro checks for C header files that are used from C++.  For a given
245# stub (e.g., math), it first checks if the C++ library (cmath) is available.
246# If it is, it defines HAVE_CMATH (or whatever the stub is).  If it is not
247# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
248# if that one exists.
249
250AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
251[AC_LANG_PUSH(C++)
252AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
253if test "$ac_cv_header_c$1" != "yes"; then
254  AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
255fi
256AC_LANG_POP(C++)
257]) # AC_COIN_CHECK_CXX_CHEADER
258
259###########################################################################
260#                             COIN_PROG_CC                                #
261###########################################################################
262
263AC_DEFUN([AC_COIN_PROG_CC],
264[AC_REQUIRE([AC_PROG_CC])
265
266# add automake conditional so we can recognize cl compiler in makefile
267coin_cc_is_cl=false
268case "$CC" in
269  clang* ) ;;
270  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
271    coin_cc_is_cl=true
272    ;;
273esac
274AM_CONDITIONAL(COIN_CC_IS_CL, [test $coin_cc_is_cl = true])
275
276# add -DPROJECT_BUILD to signal compiler preprocessor which config header file to include
277if test x$COIN_PRJCT != x; then
278  CFLAGS="$CFLAGS -D${COIN_PRJCT}_BUILD"
279fi
280
281AC_MSG_NOTICE([C compiler options are: $CFLAGS])
282
283]) # AC_COIN_PROG_CC
284
285###########################################################################
286#                             COIN_PROG_F77                               #
287###########################################################################
288
289
290AC_DEFUN([AC_COIN_PROG_F77],
291[AC_REQUIRE([AC_PROG_F77])
292
293AC_MSG_NOTICE([Fortran compiler options are: $FFLAGS])
294
295]) # AC_COIN_PROG_F77
296
297###########################################################################
298#                           COIN_F77_WRAPPERS                             #
299###########################################################################
300
301AC_DEFUN([AC_COIN_F77_WRAPPERS],[AC_REQUIRE([AC_F77_WRAPPERS])])
302
303###########################################################################
304#                          COIN_INIT_AUTOMAKE                             #
305###########################################################################
306
307# This macro calls the regular INIT_AUTOMAKE and MAINTAINER_MODE
308# macros, and defines additional variables and makefile conditionals,
309# that are used in the maintainer parts of the makfile.  It also
310# checks if the correct versions of the autotools are used.
311#
312# This also defines the AC_SUBST variables:
313# abs_source_dir     absolute path to source code for this package
314# abs_bin_dir        absolute path to the directory where binaries are
315#                    going to be installed (prefix/bin)
316# abs_lib_dir        absolute path to the directory where libraries are
317#                    going to be installed (prefix/lib)
318# abs_include_dir    absolute path to the directory where the header files
319#                    are installed (prefix/include)
320
321AC_DEFUN([AC_COIN_INIT_AUTOMAKE],
322[AC_REQUIRE([AC_PROG_EGREP])
323AC_REQUIRE([AC_PROG_LN_S])
324
325# AC_MSG_NOTICE([Beginning automake initialisation.])
326# Stuff for automake
327AM_INIT_AUTOMAKE
328AM_MAINTAINER_MODE
329
330coin_have_externals=no
331if test "$enable_maintainer_mode" = yes; then
332
333  # If maintainer mode is chosen, we make sure that the correct versions
334  # of the tools are used, and that we know where libtool.m4 is (to
335  # recreate acinclude.m4)
336
337  AC_SUBST(LIBTOOLM4)
338  LIBTOOLM4=
339  # Normally, $HOME
340  AUTOTOOLS_DFLT=$HOME
341
342  AC_CACHE_CHECK([whether we are using the correct autotools],
343                 [ac_cv_use_correct_autotools],
344                 [ac_cv_use_correct_autotools=check])
345
346  if test $ac_cv_use_correct_autotools = check; then
347    ac_cv_use_correct_autotools=yes
348    # Check if we have autoconf
349    AC_CHECK_PROG([have_autoconf],[autoconf],[yes],[no])
350    if test $have_autoconf = no; then
351      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find autoconf in your path.])
352    fi
353
354    # Check whether autoconf is the correct version
355    correct_version='2.69'
356    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
357    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of autoconf])
358    autoconf --version > confauto.out 2>&1
359    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
360      AC_MSG_RESULT([yes])
361    else
362      rm -f confauto.out
363      AC_MSG_RESULT([no])
364      AC_MSG_ERROR([You don't have the correct version of autoconf as the first one in your path.])
365    fi
366    rm -f confauto.out
367
368    # Check if the executable autoconf is picked up from the correct location
369    AC_MSG_CHECKING([whether autoconf is coming from the correct location])
370    autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
371    autoconf_dir=`cd $autoconf_dir; pwd`
372    if test x$AUTOTOOLS_DIR = x; then
373      want_dir=$AUTOTOOLS_DFLT/bin
374    else
375      want_dir=$AUTOTOOLS_DIR/bin
376    fi
377    if test $autoconf_dir = `cd $want_dir; pwd`; then
378      AC_MSG_RESULT([yes])
379    else
380      rm -f confauto.out
381      AC_MSG_RESULT([no])
382      AC_MSG_ERROR([The autoconf executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
383    fi
384
385    # Check if we have automake
386    AC_CHECK_PROG([have_automake],[automake],[yes],[no])
387    if test $have_automake = no; then
388      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find automake in your path.])
389    fi
390 
391    # Check whether automake is the correct version
392    correct_version='1.12'
393    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
394    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of automake])
395    automake --version > confauto.out 2>&1
396    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
397      AC_MSG_RESULT([yes])
398    else
399      rm -f confauto.out
400      AC_MSG_RESULT([no])
401      AC_MSG_ERROR([You don't have the correct version of automake as the first one in your path.])
402    fi
403    rm -f confauto.out
404
405    # Check if the executable automake is picked up from the correct location
406    AC_MSG_CHECKING([whether automake is coming from the correct location])
407    automake_dir=`which automake | sed -e 's=/automake=='`
408    automake_dir=`cd $automake_dir; pwd`
409    if test x$AUTOTOOLS_DIR = x; then
410      want_dir=$AUTOTOOLS_DFLT/bin
411    else
412      want_dir=$AUTOTOOLS_DIR/bin
413    fi
414    if test $automake_dir = `cd $want_dir; pwd`; then
415      AC_MSG_RESULT([yes])
416    else
417      rm -f confauto.out
418      AC_MSG_RESULT([no])
419      AC_MSG_ERROR([The automake executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
420    fi
421
422    # Check if this is the correct version of libtool (with escaped dots)
423    if test x$AUTOTOOLS_DIR = x; then
424      want_dir=$AUTOTOOLS_DFLT/share
425    else
426      want_dir=$AUTOTOOLS_DIR/share
427    fi
428    correct_version='2.4.2'
429    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
430    AC_COIN_CHECK_FILE([$want_dir/libtool/ltmain.sh],
431                       [have_ltmain=yes],
432                       [have_ltmain=no])
433    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of libtool.])
434    if test $have_ltmain = yes; then
435    if $EGREP $grep_version $want_dir/libtool/ltmain.sh >/dev/null 2>&1; then
436        AC_MSG_RESULT([yes])
437      else
438        AC_MSG_RESULT([no])
439        AC_MSG_ERROR([You don't have the correct version of libtool.])
440      fi
441    else
442      AC_MSG_RESULT([no])
443      AC_MSG_ERROR([I cannot find the ltmain.sh file.])
444    fi
445  fi
446
447  # Check if we can find the libtool file
448  if test x$AUTOTOOLS_DIR = x; then
449    want_dir=$AUTOTOOLS_DFLT/share
450  else
451    want_dir=$AUTOTOOLS_DIR/share
452  fi
453  AC_COIN_CHECK_FILE([$want_dir/aclocal/libtool.m4],
454                     [LIBTOOLM4="$want_dir/aclocal/libtool.m4"],
455                     [AC_MSG_ERROR([I cannot find the libtool.m4 file.])])
456
457  # Check if we have an Dependencies file
458  if test -r $srcdir/Dependencies; then
459    coin_have_externals=yes
460  fi
461  # Check if subversion is installed and understands https
462  AC_CHECK_PROG([have_svn],[svn],[yes],[no])
463  if test x$have_svn = xyes; then
464    AC_CACHE_CHECK([whether svn understands https],
465                   [ac_cv_svn_understands_https],
466                   [svn --version > confauto.out 2>&1
467                    if $EGREP https confauto.out >/dev/null 2>&1; then
468                      ac_cv_svn_understands_https=yes
469                    else
470                      ac_cv_svn_understands_https=no
471                      have_svn=no
472                      ac_cv_prog_have_svn=no
473                    fi
474                    rm -f confauto.out])
475  fi
476
477  # Find the location of the BuildTools directory
478  BUILDTOOLSDIR=
479  if test -r $srcdir/BuildTools/coin.m4; then
480    BUILDTOOLSDIR=$srcdir/BuildTools
481  else
482    if test -r $srcdir/../BuildTools/coin.m4; then
483      BUILDTOOLSDIR=$srcdir/../BuildTools
484    else
485      if test -r $srcdir/../../BuildTools/coin.m4; then
486        BUILDTOOLSDIR=$srcdir/../../BuildTools
487      else
488        AC_MSG_ERROR(Cannot find the BuildTools directory, better disable maintainer mode.)
489      fi
490    fi
491  fi
492  AC_SUBST(BUILDTOOLSDIR)
493 
494  # for running automake by make, we need to have Makemain.inc available at the place where it usually can be found during run_autotools
495  if test "$BUILDTOOLSDIR" != "$srcdir/BuildTools" ; then
496    $LN_S `cd $BUILDTOOLSDIR; pwd` "$srcdir/BuildTools"
497  fi
498
499  # The following variable is set to the name of the directory where
500  # the autotool scripts are located
501  AC_SUBST(AUX_DIR)
502  AUX_DIR=$ac_aux_dir
503fi
504
505# helpful variable for the base directory of this package
506abs_source_dir=`cd $srcdir; pwd`
507AC_SUBST(abs_source_dir)
508
509# Stuff for example Makefiles
510if test x$prefix = xNONE; then
511  full_prefix=$ac_default_prefix
512else
513  full_prefix=$prefix
514fi
515full_prefix=`cd $full_prefix ; pwd`
516AC_SUBST(abs_lib_dir)
517abs_lib_dir=$full_prefix/lib
518AC_SUBST(abs_include_dir)
519abs_include_dir=$full_prefix/include
520AC_SUBST(abs_bin_dir)
521abs_bin_dir=$full_prefix/bin
522
523AM_CONDITIONAL(HAVE_EXTERNALS,
524               test $coin_have_externals = yes && test x$have_svn = xyes)
525
526# AC_MSG_NOTICE([End automake initialisation.])
527
528]) # AC_COIN_INIT_AUTOMAKE
529
530###########################################################################
531#                          COIN_CREATE_LIBTOOL                            #
532###########################################################################
533
534# This does all the tests necessary to create the libtool script in the
535# package base directory.  If this is used, then the COIN_INIT_AUTO_TOOLS
536# test in the subdirectories will be able to skip the libtool tests and
537# just use the one in the package base directory.
538
539m4_define([AC_COIN_CREATE_LIBTOOL],
540[AC_CANONICAL_BUILD
541
542# Check if user wants to produce debugging code
543AC_COIN_DEBUG_COMPILE
544
545# Get the name of the C compiler and appropriate compiler options
546AC_COIN_PROG_CC
547
548# Get the name of the C++ compiler and appropriate compiler options
549AC_COIN_PROG_CXX
550
551# Get the name of the Fortran compiler and appropriate compiler options
552AC_COIN_PROG_F77
553
554# Initialize automake and libtool
555AC_COIN_INIT_AUTO_TOOLS
556])
557
558###########################################################################
559#                         COIN_INIT_AUTO_TOOLS                            #
560###########################################################################
561
562# Initialize the auto tools automake and libtool, with all
563# modifications we want for COIN packages.
564#
565# RPATH_FLAGS        link flags for hardcoding path to shared objects
566
567m4_define([AC_COIN_INIT_AUTO_TOOLS],
568[{AC_BEFORE([AC_COIN_PROG_CXX],[$0])
569AC_BEFORE([AC_COIN_PROG_CC],[$0])
570AC_BEFORE([AC_COIN_PROG_F77],[$0])
571
572# Initialize automake
573AC_COIN_INIT_AUTOMAKE
574
575LIBTOOL=
576if test -r ../libtool; then
577  coin_config_dir=..
578  LIBTOOL='$(SHELL) $(top_builddir)/../libtool'
579fi
580if test "x$LIBTOOL" = x; then
581  if test -r ../../libtool; then
582    coin_config_dir=../..
583    LIBTOOL='$(SHELL) $(top_builddir)/../../libtool'
584  fi
585fi
586
587# ToDo for now, do not reuse libtool script because code below may need some updates
588#   e.g., getting the SED and ECHO variables
589LIBTOOL=
590
591if test "x$LIBTOOL" = x; then
592  # Stuff for libtool
593  AC_COIN_PROG_LIBTOOL
594  # set RPATH_FLAGS to the compiler link flags required to hardcode location
595  # of the shared objects
596  AC_COIN_RPATH_FLAGS([$abs_lib_dir])
597
598else
599
600  AC_MSG_NOTICE([Using libtool script in directory $coin_config_dir])
601  # get all missing information from the config.log file
602
603  # output variables and defines
604  as_save_IFS=$IFS
605  IFS='
606'
607  for oneline in `cat $coin_config_dir/config.status`; do
608    case "$oneline" in
609         # First some automake conditionals
610      s,@am__fastdep* | s,@AR@* | s,@CPP@*  | s,@CPPFLAGS@* | s,@CXXCPP@*  | \
611      s,@RANLIB@* | s,@STRIP@* | s,@ac_ct_AR@* | s,@ac_ct_RANLIB@* | \
612      s,@ac_ct_STRIP@* | s,@host* | s,@LN_S@* | s,@RPATH_FLAGS@* | \
613      s,@ac_c_preproc_warn_flag@* |  s,@ac_cxx_preproc_warn_flag@* )
614        command=`echo $oneline | sed -e 's/^s,@//' -e 's/@,/="/' -e 's/,;t t/"/'`
615        eval "$command"
616        ;;
617      s,@DEFS@* )
618        command=`echo $oneline | sed -e 's/^s,@DEFS@,/defsline="/' -e 's/,;t t/"/'`
619        eval "$command"
620        ;;
621    esac
622  done
623  IFS=$as_save_IFS
624
625  # And some defines (assuming here that the packages base dir doesn't have a config.h file)
626  for word in $defsline; do
627    case $word in
628      -DHAVE_@<:@A-Z_@:>@*_H=1 | -DSTDC_HEADERS=1 )
629        i=`echo $word | sed -e 's/-D/#define /' -e 's/=/ /'`
630        echo $i >>confdefs.h
631        ;;
632    esac
633  done
634fi
635
636# ToDo
637# For now, don't use the -no-undefined flag, since the Makefiles are
638# not yet set up that way.  But we need to fix this, when we want
639# to comile DLLs under Windows.
640LT_LDFLAGS=
641
642# Check if we want to set the library version
643AC_MSG_CHECKING([if library version is set])
644if test x"$coin_libversion" != x; then
645  LT_LDFLAGS="$LT_LDFLAGS -version-info $coin_libversion"
646  AC_MSG_RESULT([$coin_libversion])
647else
648  AC_MSG_RESULT([no])
649fi
650
651AC_SUBST(LT_LDFLAGS)
652
653}])
654
655###########################################################################
656#                           COIN_PROG_LIBTOOL                             #
657###########################################################################
658
659# Setup the libtool stuff together with any modifications to make it
660# work on additional platforms.
661# If libtool exists in the directory higher up, we use that one
662# instead of creating a new one.
663
664AC_DEFUN([AC_COIN_PROG_LIBTOOL],
665[
666# It turns out that the code for AC_PROG_LIBTOOL is somehow AC_REQUIRED
667# out in front of this macro body. You'll notice that LIBTOOL is already
668# defined here.  We'll have to count on this macro not being called if libtool
669# already exists, or at least move the libtool fixes outside the conditional.
670# AC_MSG_NOTICE([Entering coin_prog_libtool, LIBTOOL = "$LIBTOOL".])
671# This test is therefore removed.  -- lh, 061214 --
672# if test "x$LIBTOOL" = x; then
673
674# AC_MSG_NOTICE([Calling PROG_LIBTOOL.])
675  AC_PROG_LIBTOOL
676# AC_MSG_NOTICE([Finished PROG_LIBTOOL.])
677  AC_SUBST(ac_c_preproc_warn_flag)
678  AC_SUBST(ac_cxx_preproc_warn_flag)
679
680  AC_MSG_NOTICE([Build is "$build".])
681  mydos2unix='| dos2unix'
682  case $build in
683    *-mingw*)
684      CYGPATH_W=echo
685      mydos2unix=
686      ;;
687  esac
688
689# This fi matches the commented `if test "x$LIBTOOL" = x;' up at the head of
690# the macro. -- lh, 061214 --
691# fi
692
693  sed -e 's|tool_oldlib|oldlib|' \
694      libtool > conftest.bla
695  mv conftest.bla libtool
696  chmod 755 libtool
697
698# AC_MSG_NOTICE([End libtool initialisation.])
699]) # AC_COIN_PROG_LIBTOOL
700
701###########################################################################
702#                            COIN_RPATH_FLAGS                             #
703###########################################################################
704
705# This macro, in case shared objects are used, defines a variable
706# RPATH_FLAGS that can be used by the linker to hardwire the library
707# search path for the given directories.  This is useful for example
708# Makefiles
709
710AC_DEFUN([AC_COIN_RPATH_FLAGS],
711[RPATH_FLAGS=
712
713if test $enable_shared = yes; then
714  case $build in
715    *-linux-*)
716      if test "$GXX" = "yes"; then
717        RPATH_FLAGS=
718        for dir in $1; do
719          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
720        done
721      fi ;;
722    *-darwin*)
723        RPATH_FLAGS=nothing ;;
724    *-ibm-*)
725      case "$CXX" in
726      xlC* | */xlC* | mpxlC* | */mpxlC*)
727        RPATH_FLAGS=nothing ;;
728      esac ;;
729    *-hp-*)
730        RPATH_FLAGS=nothing ;;
731    *-mingw32)
732        RPATH_FLAGS=nothing ;;
733    *-*-solaris*)
734        RPATH_FLAGS=
735        for dir in $1; do
736          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
737        done
738  esac
739
740  if test "$RPATH_FLAGS" = ""; then
741    AC_MSG_WARN([Could not automatically determine how to tell the linker about automatic inclusion of the path for shared libraries.  The test examples might not work if you link against shared objects.  You will need to set the LD_LIBRARY_PATH, DYLP_LIBRARY_PATH, or LIBDIR variable manually.])
742  fi
743  if test "$RPATH_FLAGS" = "nothing"; then
744    RPATH_FLAGS=
745  fi
746fi
747
748AC_SUBST(RPATH_FLAGS)
749]) # AC_COIN_RPATH_FLAGS
750
751###########################################################################
752#                        COIN_LINK_INPUT_CMD                              #
753###########################################################################
754
755# This macro determines which command should be used to "link" files
756# that are input to the generated executables.  On Windows, the codes
757# using the native Windows system libraries, cannot understand symbolic
758# links, and a copy should be used instead of 'ln -s'.
759# The result is stored in coin_link_input_cmd
760
761AC_DEFUN([AC_COIN_LINK_INPUT_CMD],
762[AC_REQUIRE([AC_PROG_LN_S])
763AC_BEFORE([AC_COIN_PROG_CC], [$0])
764AC_BEFORE([AC_COIN_ENABLE_DOSCOMPILE], [$0])
765
766AC_MSG_CHECKING([which command should be used to link input files])
767coin_link_input_cmd="$LN_S"
768if test "$enable_doscompile" = mingw; then
769  coin_link_input_cmd=cp
770fi
771case "$CC" in
772  clang* ) ;;
773  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
774    coin_link_input_cmd=cp ;;
775esac
776AC_MSG_RESULT($coin_link_input_cmd)
777])
778
779###########################################################################
780#                              COIN_FINALIZE                              #
781###########################################################################
782
783# This macro should be called at the very end of the configure.ac file.
784# It creates the output files (by using AC_OUTPUT), and might do some other
785# things (such as generating links to data files in a VPATH configuration).
786# It also prints the "success" message.
787# Note: If the variable coin_skip_ac_output is set to yes, then no output
788# files are written.
789
790AC_DEFUN([AC_COIN_FINALIZE],
791[
792AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
793if test x$coin_skip_ac_output != xyes; then
794
795  # Define VPATH_DISTCLEANFILES to be everything that needs to be
796  # cleaned for distclean in a vpath configuration
797  AC_SUBST(VPATH_DISTCLEANFILES)
798  VPATH_DISTCLEANFILES="$coin_vpath_link_files"
799
800  # Take out subdirectories if their configuration concluded that they
801  # don't need to be compiled
802  if test x"$coin_ac_skip_subdirs" != x; then
803    new_subdirs=
804    for i in $subdirs; do
805      skipme=no
806      for j in $coin_ac_skip_subdirs; do
807        if test $i = $j; then
808          skipme=yes;
809        fi
810      done
811      if test $skipme = no; then
812        new_subdirs="$new_subdirs $i"
813      fi
814    done
815    subdirs="$new_subdirs"
816  fi
817
818  # need to come before AC_OUTPUT
819  if test x$coin_projectdir != xyes; then
820    # write coin_subdirs to a file so that project configuration knows where to find uninstalled projects
821    echo $coin_subdirs > coin_subdirs.txt
822  else
823    # substitute for OBJDIR, needed to setup .pc file for uninstalled project
824    ABSBUILDDIR="`pwd`"
825    AC_SUBST(ABSBUILDDIR)
826  fi
827 
828  AC_OUTPUT
829
830  if test x"$coin_vpath_link_files" = x; then : ; else
831    lnkcmd="$coin_link_input_cmd"
832    if test "$lnkcmd" = cp; then
833      AC_MSG_NOTICE(Copying data files for VPATH configuration)
834    else
835      AC_MSG_NOTICE(Creating VPATH links for data files)
836    fi
837    for file in $coin_vpath_link_files; do
838      dir=`AS_DIRNAME(["./$file"])`
839      if test -d $dir; then : ; else
840        AS_MKDIR_P($dir)
841      fi
842      rm -f $file
843      $lnkcmd $abs_source_dir/$file $file
844    done
845  fi
846
847  AC_MSG_NOTICE([In case of trouble, first consult the troubleshooting page at https://projects.coin-or.org/BuildTools/wiki/user-troubleshooting])
848  if test x$coin_projectdir = xyes; then
849    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
850  else
851    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
852  fi
853else
854  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
855fi
856
857]) #AC_COIN_FINALIZE
858
859###########################################################################
860#                             COIN_VPATH_LINK                             #
861###########################################################################
862
863# This macro queues source files that need to be available in the build
864# directory. In a VPATH configuration, the files will be made available by
865# symbolic link or copy (when the platform does not support links). The list
866# is processed by COIN_FINALIZE. The parameter is a whitespace-separated
867# list of files.
868
869AC_DEFUN([AC_COIN_VPATH_LINK],
870[
871AC_REQUIRE([AC_COIN_CHECK_VPATH])
872# Allow for newlines in the parameter
873if test $coin_vpath_config = yes; then
874  cvl_tmp="$1"
875  for file in $cvl_tmp ; do
876    coin_vpath_link_files="$coin_vpath_link_files $file"
877  done
878fi
879]) #AC_COIN_VPATH_LINK
880
881###########################################################################
882#                       COIN_ENABLE_GNU_PACKAGES                          #
883###########################################################################
884
885# This macro defined the --enable-gnu-packages flag.  This can be used
886# to check if a user wants to compile GNU packges (such as readline)
887# into the executable.  By default, GNU packages are disabled.
888# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
889
890AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
891[AC_ARG_ENABLE([gnu-packages],
892               [AC_HELP_STRING([--enable-gnu-packages],
893                               [compile with GNU packages (disabled by default)])],
894               [coin_enable_gnu=$enableval],
895               [coin_enable_gnu=no])
896]) # AC_COIN_ENABLE_GNU_PACKAGES
897
898#######################################################################
899#                           COIN_CHECK_LIBM                           #
900#######################################################################
901
902# For a (space separated) list of arguments X, this macro adds the flags
903# for linking against the math library to a X_LIBS and X_PCLIBS.
904
905AC_DEFUN([AC_COIN_CHECK_LIBM],
906[AC_BEFORE([AC_COIN_PROG_CC],[$0])
907
908if test x$coin_cxx_is_cl != xtrue && test x$coin_cc_is_cl != xtrue ; then
909  coin_foreach_w([myvar], [$1], [
910    m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"
911    m4_toupper(myvar)_PCLIBS="-lm $m4_toupper(myvar)_PCLIBS"
912    m4_toupper(myvar)_LIBS_INSTALLED="-lm $m4_toupper(myvar)_LIBS_INSTALLED"
913  ])
914fi
915
916]) # AC_COIN_CHECK_LIBM
917
918###########################################################################
919#                           COIN_CHECK_GNU_ZLIB                           #
920###########################################################################
921
922# This macro checks for the libz library.  If found, it sets the automake
923# conditional COIN_HAS_ZLIB and defines the C preprocessor variable
924# COIN_HAS_ZLIB.  Further, for a (space separated) list of arguments X,
925# it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
926
927# TODO the macro name should be changed to AC_COIN_CHECK_ZLIB
928
929AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
930[
931AC_BEFORE([AC_COIN_PROG_CXX],[$0])
932AC_BEFORE([AC_COIN_PROG_CC],[$0])
933AC_BEFORE([AC_COIN_PROG_F77],[$0])
934AC_BEFORE([$0],[AC_COIN_FINALIZE])
935
936coin_has_zlib=no
937
938AC_ARG_ENABLE([zlib],
939              [AC_HELP_STRING([--disable-zlib],[do not compile with compression library zlib])],
940              [coin_enable_zlib=$enableval],
941              [coin_enable_zlib=yes])
942
943if test $coin_enable_zlib = yes; then
944  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
945
946  if test $coin_has_zlib = yes; then
947    AC_CHECK_LIB([z],[gzopen],[:],[coin_has_zlib=no])
948  fi
949
950  if test $coin_has_zlib = yes; then
951    coin_foreach_w([myvar], [$1], [
952                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
953                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
954                    m4_toupper(myvar)_LIBS_INSTALLED="-lz $m4_toupper(myvar)_LIBS_INSTALLED"
955                   ])
956    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
957  fi
958fi
959
960AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
961]) # AC_COIN_CHECK_GNU_ZLIB
962
963
964###########################################################################
965#                          COIN_CHECK_GNU_BZLIB                           #
966###########################################################################
967
968# This macro checks for the libbz2 library.  If found, it defines the C
969# preprocessor variable COIN_HAS_BZLIB.  Further, for a (space separated) list
970# of arguments X, it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
971
972# TODO the macro name should be changed to AC_COIN_CHECK_BZLIB
973
974AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
975[
976AC_BEFORE([AC_COIN_PROG_CXX],[$0])
977AC_BEFORE([AC_COIN_PROG_CC],[$0])
978AC_BEFORE([AC_COIN_PROG_F77],[$0])
979AC_BEFORE([$0],[AC_COIN_FINALIZE])
980
981AC_ARG_ENABLE([bzlib],
982              [AC_HELP_STRING([--disable-bzlib],[do not compile with compression library bzlib])],
983              [coin_enable_bzlib=$enableval],
984              [coin_enable_bzlib=yes])
985
986coin_has_bzlib=no
987if test $coin_enable_bzlib = yes; then
988  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
989
990  if test $coin_has_bzlib = yes; then
991    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],[:],[coin_has_bzlib=no])
992  fi
993
994  if test $coin_has_bzlib = yes; then
995    coin_foreach_w([myvar], [$1], [
996                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
997                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
998                    m4_toupper(myvar)_LIBS_INSTALLED="-lbz2 $m4_toupper(myvar)_LIBS_INSTALLED"
999                  ])
1000    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
1001  fi
1002fi
1003]) # AC_COIN_CHECK_GNU_BZLIB
1004
1005
1006###########################################################################
1007#                         COIN_CHECK_GNU_READLINE                         #
1008###########################################################################
1009
1010# This macro checks for GNU's readline.  It verifies that the header
1011# readline/readline.h is available, and that the -lreadline library
1012# contains "readline".  It is assumed that #include <stdio.h> is included
1013# in the source file before the #include<readline/readline.h>
1014# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
1015# Further, for a (space separated) list of arguments X, it adds the
1016# linker flag to the variable X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
1017
1018AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
1019[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1020AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1021AC_BEFORE([AC_COIN_PROG_CC],[$0])
1022AC_BEFORE([AC_COIN_PROG_F77],[$0])
1023AC_BEFORE([$0],[AC_COIN_FINALIZE])
1024
1025coin_has_readline=no
1026if test $coin_enable_gnu = yes; then
1027  AC_COIN_CHECK_HEADER([readline/readline.h],
1028                       [coin_has_readline=yes],[],
1029                       [#include <stdio.h>])
1030
1031  coin_save_LIBS="$LIBS"
1032  LIBS=
1033  # First we check if tputs and friends are available
1034  if test $coin_has_readline = yes; then
1035    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
1036                   [coin_has_readline=no])
1037  fi
1038
1039  # Now we check for readline
1040  if test $coin_has_readline = yes; then
1041    AC_CHECK_LIB([readline],[readline],[:],[coin_has_readline=no])
1042  fi
1043
1044  if test $coin_has_readline = yes; then
1045    coin_foreach_w([myvar], [$1], [
1046                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
1047                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
1048                    m4_toupper(myvar)_LIBS_INSTALLED="-lreadline $LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
1049                   ])
1050    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
1051  fi
1052
1053  LIBS="$coin_save_LIBS"
1054fi
1055]) # AC_COIN_CHECK_GNU_READLINE
1056
1057###########################################################################
1058#                              COIN_CHECK_GMP                             #
1059###########################################################################
1060
1061# This macro checks for the gmp library.  If found, it defines the C
1062# preprocessor variable COIN_HAS_GMP.  Further, for a (space separated) list
1063# of arguments X, it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
1064
1065AC_DEFUN([AC_COIN_CHECK_GMP],
1066[
1067AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1068AC_BEFORE([AC_COIN_PROG_CC],[$0])
1069AC_BEFORE([AC_COIN_PROG_F77],[$0])
1070AC_BEFORE([$0],[AC_COIN_FINALIZE])
1071
1072AC_ARG_ENABLE([gmp],
1073              [AC_HELP_STRING([--disable-gmp],[do not compile with GNU multiple precision library])],
1074              [coin_enable_gmp=$enableval],
1075              [coin_enable_gmp=yes])
1076
1077coin_has_gmp=no
1078if test $coin_enable_gmp = yes; then
1079  AC_COIN_CHECK_HEADER([gmp.h],[AC_CHECK_LIB([gmp],[__gmpz_init],[coin_has_gmp=yes])])
1080 
1081  if test $coin_has_gmp = yes ; then
1082    coin_foreach_w([myvar], [$1], [
1083                    m4_toupper(myvar)_LIBS="-lgmp $m4_toupper(myvar)_LIBS"
1084                    m4_toupper(myvar)_PCLIBS="-lgmp $m4_toupper(myvar)_PCLIBS"
1085                    m4_toupper(myvar)_LIBS_INSTALLED="-lgmp $m4_toupper(myvar)_LIBS_INSTALLED"
1086                   ])
1087    AC_DEFINE([COIN_HAS_GMP],[1],[Define to 1 if GMP is available])
1088  fi
1089fi
1090]) # AC_COIN_CHECK_GMP
1091
1092###########################################################################
1093#                            COIN_CHECK_ISFINITE                          #
1094###########################################################################
1095
1096# This macro checks for a usable implementation of a function to check
1097# whether a given floating point number is finite.
1098# If a function is found, then the macro defines the symbol
1099# toupper($1)_C_FINITE to the name of this function.
1100
1101AC_DEFUN([AC_COIN_CHECK_ISFINITE],[
1102
1103AC_LANG_PUSH(C++)
1104
1105AC_COIN_CHECK_CXX_CHEADER(math)
1106AC_COIN_CHECK_CXX_CHEADER(float)
1107AC_COIN_CHECK_CXX_CHEADER(ieeefp)
1108
1109COIN_C_FINITE=
1110AC_CHECK_DECL([isfinite],[COIN_C_FINITE=isfinite],,[
1111#ifdef HAVE_CMATH
1112# include <cmath>
1113#else
1114# ifdef HAVE_MATH_H
1115#  include <math.h>
1116# endif
1117#endif
1118#ifdef HAVE_CFLOAT
1119# include <cfloat>
1120#else
1121# ifdef HAVE_FLOAT_H
1122#  include <float.h>
1123# endif
1124#endif
1125#ifdef HAVE_CIEEEFP
1126# include <cieeefp>
1127#else
1128# ifdef HAVE_IEEEFP_H
1129#  include <ieeefp.h>
1130# endif
1131#endif])
1132if test -z "$COIN_C_FINITE"; then
1133  AC_CHECK_DECL([finite],[COIN_C_FINITE=finite],,[
1134#ifdef HAVE_CMATH
1135# include <cmath>
1136#else
1137# ifdef HAVE_MATH_H
1138#  include <math.h>
1139# endif
1140#endif
1141#ifdef HAVE_CFLOAT
1142# include <cfloat>
1143#else
1144# ifdef HAVE_FLOAT_H
1145#  include <float.h>
1146# endif
1147#endif
1148#ifdef HAVE_CIEEEFP
1149# include <cieeefp>
1150#else
1151# ifdef HAVE_IEEEFP_H
1152#  include <ieeefp.h>
1153# endif
1154#endif])
1155  if test -z "$COIN_C_FINITE"; then
1156    AC_CHECK_DECL([_finite],[COIN_C_FINITE=_finite],,[
1157#ifdef HAVE_CMATH
1158# include <cmath>
1159#else
1160# ifdef HAVE_MATH_H
1161#  include <math.h>
1162# endif
1163#endif
1164#ifdef HAVE_CFLOAT
1165# include <cfloat>
1166#else
1167# ifdef HAVE_FLOAT_H
1168#  include <float.h>
1169# endif
1170#endif
1171#ifdef HAVE_CIEEEFP
1172# include <cieeefp>
1173#else
1174# ifdef HAVE_IEEEFP_H
1175#  include <ieeefp.h>
1176# endif
1177#endif])
1178  fi
1179fi
1180if test -z "$COIN_C_FINITE"; then
1181  AC_MSG_WARN(Cannot find C-function for checking Inf.)
1182else
1183  AC_DEFINE_UNQUOTED(COIN_C_FINITE,[$COIN_C_FINITE],
1184                     [Define to be the name of C-function for Inf check])
1185fi
1186
1187AC_LANG_POP(C++)
1188])
1189
1190###########################################################################
1191#                              COIN_CHECK_ISNAN                           #
1192###########################################################################
1193
1194# This macro checks for a usable implementation of a function to check
1195# whether a given floating point number represents NaN.
1196# If a function is found, then the macro defines the symbol COIN_C_ISNAN
1197# to the name of this function.
1198
1199AC_DEFUN([AC_COIN_CHECK_ISNAN],[
1200
1201AC_LANG_PUSH(C++)
1202
1203AC_COIN_CHECK_CXX_CHEADER(math)
1204AC_COIN_CHECK_CXX_CHEADER(float)
1205AC_COIN_CHECK_CXX_CHEADER(ieeefp)
1206
1207COIN_C_ISNAN=
1208AC_CHECK_DECL([isnan],[COIN_C_ISNAN=isnan],,[
1209#ifdef HAVE_CMATH
1210# include <cmath>
1211#else
1212# ifdef HAVE_MATH_H
1213#  include <math.h>
1214# endif
1215#endif
1216#ifdef HAVE_CFLOAT
1217# include <cfloat>
1218#else
1219# ifdef HAVE_FLOAT_H
1220#  include <float.h>
1221# endif
1222#endif
1223#ifdef HAVE_CIEEEFP
1224# include <cieeefp>
1225#else
1226# ifdef HAVE_IEEEFP_H
1227#  include <ieeefp.h>
1228# endif
1229#endif])
1230
1231# It appears that for some systems (e.g., Mac OSX), cmath will provide only
1232# std::isnan, and bare isnan will be unavailable. Typically we need a parameter
1233# in the test to allow C++ to do overload resolution.
1234
1235if test -z "$COIN_C_ISNAN"; then
1236  AC_CHECK_DECL([std::isnan(42.42)],[COIN_C_ISNAN=std::isnan],,[
1237#ifdef HAVE_CMATH
1238# include <cmath>
1239#else
1240# ifdef HAVE_MATH_H
1241#  include <math.h>
1242# endif
1243#endif
1244#ifdef HAVE_CFLOAT
1245# include <cfloat>
1246#else
1247# ifdef HAVE_FLOAT_H
1248#  include <float.h>
1249# endif
1250#endif
1251#ifdef HAVE_CIEEEFP
1252# include <cieeefp>
1253#else
1254# ifdef HAVE_IEEEFP_H
1255#  include <ieeefp.h>
1256# endif
1257#endif])
1258fi
1259
1260if test -z "$COIN_C_ISNAN"; then
1261  AC_CHECK_DECL([_isnan],[COIN_C_ISNAN=_isnan],,[
1262#ifdef HAVE_CMATH
1263# include <cmath>
1264#else
1265# ifdef HAVE_MATH_H
1266#  include <math.h>
1267# endif
1268#endif
1269#ifdef HAVE_CFLOAT
1270# include <cfloat>
1271#else
1272# ifdef HAVE_FLOAT_H
1273#  include <float.h>
1274# endif
1275#endif
1276#ifdef HAVE_CIEEEFP
1277# include <cieeefp>
1278#else
1279# ifdef HAVE_IEEEFP_H
1280#  include <ieeefp.h>
1281# endif
1282#endif])
1283fi
1284if test -z "$COIN_C_ISNAN"; then
1285  AC_CHECK_DECL([isnand],[COIN_C_ISNAN=isnand],,[
1286#ifdef HAVE_CMATH
1287# include <cmath>
1288#else
1289# ifdef HAVE_MATH_H
1290#  include <math.h>
1291# endif
1292#endif
1293#ifdef HAVE_CFLOAT
1294# include <cfloat>
1295#else
1296# ifdef HAVE_FLOAT_H
1297#  include <float.h>
1298# endif
1299#endif
1300#ifdef HAVE_CIEEEFP
1301# include <cieeefp>
1302#else
1303# ifdef HAVE_IEEEFP_H
1304#  include <ieeefp.h>
1305# endif
1306#endif])
1307fi
1308if test -z "$COIN_C_ISNAN"; then
1309  AC_MSG_WARN(Cannot find C-function for checking NaN.)
1310else
1311  AC_DEFINE_UNQUOTED(COIN_C_ISNAN,[$COIN_C_ISNAN],
1312                     [Define to be the name of C-function for NaN check])
1313fi
1314
1315AC_LANG_POP(C++)
1316])
1317
1318###########################################################################
1319#                       COIN_LINK_FROM_FILELIST                           #
1320###########################################################################
1321
1322# This macro creates links (or copies, if necessary) to files listed
1323# as content in a text file (second argument) into a target directory
1324# (first argument), which is created if it doesn't exist yet.  If s link
1325# already exists, nothing happens.
1326
1327AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
1328[cmd="$3"
1329if test -e $srcdir/$2 ; then
1330  my_target_dir="$1"
1331  my_link_files=`cat $srcdir/$2`
1332  my_dirname=`AS_DIRNAME($2)`
1333#  if test -e $my_target_dir; then : ; else
1334#    AS_MKDIR_P($my_target_dir)
1335#  fi
1336  for i in $my_link_files; do
1337    #rm -rf $my_target_dir/$i
1338    if test -e $my_target_dir/$i; then : ; else
1339      dirn2=`AS_DIRNAME($my_target_dir/$i)`
1340      if test -e $dirn2; then : ; else
1341        AS_MKDIR_P($dirn2)
1342      fi
1343      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
1344    fi
1345  done
1346else
1347  AC_MSG_WARN([File list file $2 missing!])
1348fi
1349])
1350
1351AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
1352[
1353AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
1354echo Creating links in $1 ...
1355AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
1356])
1357
1358###########################################################################
1359#                       COIN_COPY_FROM_FILELIST                           #
1360###########################################################################
1361
1362# Like COIN_LINK_FROM_FILELIST, but copies the files.
1363
1364AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
1365[
1366echo Creating copies in $1 ...
1367AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
1368])
1369
1370###########################################################################
1371#                          COIN_EXAMPLE_FILES                             #
1372###########################################################################
1373
1374# This macro determines the names of the example files (using the
1375# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
1376# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
1377# creates soft links to the example files.
1378
1379AC_DEFUN([AC_COIN_EXAMPLE_FILES],
1380[AC_REQUIRE([AC_COIN_CHECK_VPATH])
1381AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1382AC_REQUIRE([AC_PROG_LN_S])
1383
1384files=`cd $srcdir; ls $1`
1385# We need to do the following loop to make sure that are no newlines
1386# in the variable
1387for file in $files; do
1388  EXAMPLE_FILES="$EXAMPLE_FILES $file"
1389done
1390if test $coin_vpath_config = yes; then
1391  lnkcmd=
1392  if test "$enable_doscompile" != no; then
1393    lnkcmd=cp
1394  fi
1395  case "$CC" in
1396    clang* ) ;;
1397    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1398      lnkcmd=cp ;;
1399  esac
1400  if test "x$lnkcmd" = xcp; then
1401    AC_MSG_NOTICE([Copying example files ($1)])
1402  else
1403    AC_MSG_NOTICE([Creating links to the example files ($1)])
1404    lnkcmd="$LN_S"
1405  fi
1406  for file in $EXAMPLE_FILES; do
1407    rm -f $file
1408    $lnkcmd $srcdir/$file $file
1409  done
1410  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
1411else
1412  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
1413fi
1414
1415# In case there are compressed files, we create a variable with the
1416# uncompressed names
1417EXAMPLE_UNCOMPRESSED_FILES=
1418for file in $EXAMPLE_FILES; do
1419  case $file in
1420    *.gz)
1421      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
1422      ;;
1423  esac
1424done
1425
1426AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
1427AC_SUBST(EXAMPLE_FILES)
1428AC_SUBST(EXAMPLE_CLEAN_FILES)
1429]) #AC_COIN_EXAMPLE_FILES
1430
1431###########################################################################
1432#                      COIN_CHECK_USER_LIBRARY                            #
1433###########################################################################
1434# This macro sets up usage of a user library with header files. The assumption
1435# is that the header file(s) and library do not reside in standard system
1436# directories, hence both the include directory and link flags must be
1437# specified. There are two mandatory arguments and two optional arguments.
1438#
1439# The first argument (mandatory) should be a name (LibraryName) for the
1440# library.  The second argument (mandatory) should be an abbreviation in
1441# upper case letters (LBRY) for the library. Ultimately, the macro will
1442# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
1443# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
1444# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
1445# directory containing include files for the library. LBRYLIB should specify
1446# the flags necessary to link to the library. A variable coin_has_lbry will
1447# be set to true or false, as appropriate. A variable lbry_libcheck will be
1448# be set to yes or no; no indicates link checks should not be attempted.
1449#
1450# The macro defines three configure arguments, --with-libraryname-incdir,
1451# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
1452# LibraryName to lower case.
1453#
1454# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
1455# part of the configure command using --with-libraryname-incdir and
1456# --with-libraryname-lib, respectively. Command line arguments override
1457# environment variables.
1458#
1459# If a third argument is given, it should specify a file in LBRYINCDIR.  The
1460# macro will check for the presence of the file. If a fourth argument is given,
1461# it should specify a function name, `fname'.  The macro will attempt to link a
1462# trivial program containing a parameterless call to the function, `fname()',
1463# using the LBRYLIB flags. The link check uses C as the language; this has been
1464# adequate to date but has limitations. It is possible to disable the link
1465# check by specifying --disable-libraryname-libcheck. This is a workaround for
1466# instances where the link check does not work properly, for whatever reason.
1467# If you're trying to link to a Fortran library, consider using F77_FUNC or
1468# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
1469# library, you're on your own unless the library declares some function with
1470# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
1471# name.
1472# A fifth argument can be specified to include linker flags that may be required
1473# to sucessfully perform the linking check.
1474#
1475# An optional sixth argument can be given to specify a list of targets.
1476# For each target X, the variables X_LIBS and X_PCLIBS will be extended by $LBRYLIB,
1477# if the library has been found and seems to work.
1478
1479AC_DEFUN([AC_COIN_CHECK_USER_LIBRARY],
1480[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
1481  AC_MSG_CHECKING(if user provides library for $1)
1482
1483# Check for header file directory
1484
1485  AC_ARG_WITH(m4_tolower($1)-incdir,
1486      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
1487                     [specify the header file directory for library $1]),
1488      [$2INCDIR=`cd $withval; pwd`])
1489
1490# Check for library directory
1491
1492  AC_ARG_WITH(m4_tolower($1)-lib,
1493      AS_HELP_STRING([--with-m4_tolower($1)-lib],
1494                     [specify the flags used to link with the library $1]),
1495      [$2LIB=$withval])
1496
1497# Switch to disable library check if requested
1498
1499  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
1500      AS_HELP_STRING([--disable-m4_tolower($1)-libcheck],
1501                     [skip the link check at configuration time]),
1502      [m4_tolower($1)_libcheck=$enableval],
1503      [m4_tolower($1)_libcheck=yes])
1504
1505# At this point, if we're going to use the library, both LBRYINCDIR and
1506# LBRYLIB must be defined and not empty.
1507
1508  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
1509    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
1510      AC_MSG_ERROR([You need to specify both an include directory and link flags to use library $1. Use --with-m4_tolower($1)-incdir of environment variable $$2INCDIR to specify the include directory. Use --with-m4_tolower($1)-lib or environment variable $$2LIB to specify link flags.])
1511    fi
1512    m4_tolower(coin_has_$2)=true
1513    AC_MSG_RESULT(yes)
1514  else
1515    m4_tolower(coin_has_$2)=false
1516    AC_MSG_RESULT(no)
1517  fi
1518
1519# If we have instructions for use, consider header and link checks.
1520
1521  if test $m4_tolower(coin_has_$2) = true; then
1522
1523# If argument 3 (file) is given, check for the file. Typically this will be a
1524# header file, but that's not assumed.
1525
1526    m4_ifval([$3],
1527        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
1528             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
1529
1530# Now see if we can link the function. There are arguments for and against
1531# assuming argument 3 is a header file declaring the function. A correct
1532# function declaration is the main argument in favour. Having to cope with
1533# possible dependencies or other oddities are the main arguments against.
1534# Force the use of C as the best single choice amongst C++, C, and Fortran.
1535# Obviously, this has limits.
1536
1537    m4_ifvaln([$4],
1538        [if test x"$m4_tolower($1)_libcheck" != xno; then
1539           coin_save_LIBS="$LIBS"
1540           LIBS="$$2LIB $5"
1541           coin_$2_link=no
1542           AC_LANG_PUSH(C)
1543           for fnm in $4 ; do
1544             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
1545             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
1546                 [AC_MSG_RESULT(yes)
1547                  coin_$2_link=yes
1548                  break],
1549                 [AC_MSG_RESULT(no)])
1550           done
1551           AC_LANG_POP(C)
1552           LIBS="$coin_save_LIBS"
1553           if test x"$coin_$2_link" != xyes ; then
1554             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
1555           fi
1556         fi])
1557
1558# If we make it this far, we've verified the file and linked the function. Add
1559# the necessary link flags to $6_{PC}LIBS and define the preprocessor symbol
1560# COIN_HAS_LBRY.
1561
1562    coin_foreach_w([myvar], [$6], [
1563      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
1564      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
1565      m4_toupper(myvar)_LIBS_INSTALLED="$$2LIB $m4_toupper(myvar)_LIBS_INSTALLED"
1566    ])
1567   
1568    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
1569  fi
1570
1571# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
1572# automake conditional. These actions must occur unconditionally.
1573
1574  AC_SUBST($2INCDIR)
1575  AC_SUBST($2LIB)
1576  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
1577]) #AC_COIN_CHECK_USER_LIBRARY
1578
1579###########################################################################
1580#                            COIN_TRY_FLINK                               #
1581###########################################################################
1582
1583# Auxilliary macro to test if a Fortran function name can be linked,
1584# given the current settings of LIBS.  We determine from the context, what
1585# the currently active programming language is, and cast the name accordingly.
1586# The first argument is the name of the function/subroutine, in small letters,
1587# the second argument are the actions taken when the test works, and the
1588# third argument are the actions taken if the test fails.
1589
1590AC_DEFUN([AC_COIN_TRY_FLINK],
1591[case $ac_ext in
1592  f)
1593    AC_TRY_LINK(,[      call $1],[$2],[$3])
1594    ;;
1595  c)
1596    AC_F77_FUNC($1,cfunc$1)
1597    if test x"$coin_need_flibs" = xyes; then
1598      flink_try=no;
1599    else
1600      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
1601                  [flink_try=yes],[flink_try=no])
1602    fi
1603    if test $flink_try = yes; then
1604      $2
1605    else
1606      if test x"$FLIBS" != x; then
1607        flink_save_libs="$LIBS"
1608        LIBS="$LIBS $FLIBS"
1609        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
1610                    [LIBS="$flink_save_libs"
1611                     coin_need_flibs=yes
1612                     $2
1613                    ],
1614                    [LIBS="$flink_save_libs"
1615                     $3])
1616      else
1617        $3
1618      fi
1619    fi
1620    ;;
1621  cc|cpp)
1622    AC_F77_FUNC($1,cfunc$1)
1623    if test x"$coin_need_flibs" = xyes; then
1624      flink_try=no;
1625    else
1626      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
1627                  [flink_try=yes],[flink_try=no])
1628    fi
1629    if test $flink_try = yes; then
1630      $2
1631    else
1632      if test x"$FLIBS" != x; then
1633        flink_save_libs="$LIBS"
1634        LIBS="$LIBS $FLIBS"
1635        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
1636                    [LIBS="$flink_save_libs"
1637                     coin_need_flibs=yes
1638                     $2
1639                    ],
1640                    [LIBS="$flink_save_libs"
1641                     $3])
1642      else
1643        $3
1644      fi
1645    fi
1646    ;;
1647esac
1648]) # AC_COIN_TRY_FLINK
1649
1650###########################################################################
1651#                           COIN_DOXYGEN                                  #
1652###########################################################################
1653#
1654# This macro determines the configuration information for doxygen, the tool
1655# used to generate online documentation of COIN code. It takes one parameter,
1656# a list of projects (mixed-case, to match the directory names) that should
1657# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
1658#
1659# This macro will define the following variables:
1660#  coin_have_doxygen    Yes if doxygen is found, no otherwise
1661#  coin_doxy_usedot     Defaults to `yes'; --with-dot will still check to see
1662#                       if dot is available
1663#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
1664#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
1665#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
1666#                       doxygen documentation
1667#  coin_doxy_excludes   Directories to exclude from doxygen processing
1668
1669AC_DEFUN([AC_COIN_DOXYGEN],
1670[
1671
1672AC_MSG_NOTICE([configuring doxygen documentation options])
1673
1674# Check to see if doxygen is available.
1675
1676AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
1677
1678# Look for the dot tool from the graphviz package, unless the user has
1679# disabled it.
1680
1681AC_ARG_WITH([dot],
1682  AS_HELP_STRING([--with-dot],
1683                 [use dot (from graphviz) when creating documentation with
1684                  doxygen if available; --without-dot to disable]),
1685  [],[withval=yes])
1686if test x"$withval" = xno ; then
1687  coin_doxy_usedot=NO
1688  AC_MSG_CHECKING([for dot ])
1689  AC_MSG_RESULT([disabled])
1690else
1691  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
1692fi
1693
1694# Generate a tag file name and a log file name
1695
1696AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
1697AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
1698
1699# Process the list of project names and massage them into possible doxygen
1700# doc'n directories. Prefer 1) classic external, source processed using
1701# a project-specific doxygen.conf, we use the tag file; 2) classic
1702# external, source processed using package doxygen.conf; 3) installed
1703# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
1704# configured, which we can't know unless this is the package base configure,
1705# since coin_subdirs is only set there. Hence it's sufficient to check for
1706# membership. If we use a tag file from a classic external, exclude the
1707# source from doxygen processing when doxygen runs in the base directory.
1708
1709coin_doxy_tagfiles=
1710coin_doxy_excludes=
1711tmp="$1"
1712for proj in $tmp ; do
1713  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
1714  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
1715  doxytag=${lc_proj}_doxy.tag
1716  doxyfound=no
1717  for chkProj in $coin_subdirs ; do
1718    if test "$chkProj" = "$proj" ; then
1719      # proj will be configured, hence doxydoc present in build tree
1720      doxysrcdir="${srcdir}/${proj}"
1721      # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
1722      if test -d "$doxysrcdir" ; then
1723        # with a doxydoc directory?
1724        doxydir="$doxysrcdir/doxydoc"
1725        # AC_MSG_NOTICE([Considering $doxydir (base)])
1726        # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
1727        if test -d "$doxydir" ; then
1728          # use tag file; don't process source
1729          eval doxydir="`pwd`/${proj}/doxydoc"
1730          coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
1731          AC_MSG_RESULT([$doxydir (tag)])
1732          coin_doxy_excludes="$coin_doxy_excludes */${proj}"
1733        else
1734          # will process the source -- nothing further to be done here
1735          AC_MSG_RESULT([$doxysrcdir (src)])
1736        fi
1737        doxyfound=yes
1738      fi
1739    fi
1740  done
1741  # Not built, fall back to installed tag file
1742  if test $doxyfound = no ; then
1743    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
1744    # AC_MSG_NOTICE([Considering $doxydir (install)])
1745    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
1746    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
1747    AC_MSG_RESULT([$doxydir (tag)])
1748  fi
1749done
1750AC_SUBST([coin_doxy_tagfiles])
1751AC_SUBST([coin_doxy_excludes])
1752
1753]) # AC_COIN_DOXYGEN
1754
1755
1756###########################################################################
1757#                           COIN_HAS_PKGCONFIG                            #
1758###########################################################################
1759
1760# This macro checks whether a pkg-config tool with a minimal version number
1761# is available.  If so, then the variable PKGCONFIG is set to its path.
1762# If not, PKGCONFIG is set to "".  The minimal version number can be given
1763# as first parameter, by default it is 0.16.0, since COIN-OR .pc files now
1764# include an URL field, which breaks pkg-config version <= 0.15.
1765# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
1766# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
1767# AC_SUBST'ed.  Finally, if this setup belongs to a project directory, then
1768# the search path for .pc files is assembled from the value of
1769# $PKG_CONFIG_PATH, the values of --prefix, --coin-instdir, and the directories
1770# named in a file ../coin_subdirs.txt or ../../coin_subdirs.txt in a variable
1771# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed. For a path xxx given in the
1772# coin-subdirs.txt, also the directory xxx/pkgconfig is added, if existing.
1773
1774AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
1775[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
1776
1777AC_ARG_ENABLE([pkg-config],
1778  [AC_HELP_STRING([--disable-pkg-config],[disable use of pkg-config (if available)])],
1779  [use_pkgconfig="$enableval"],
1780  [use_pkgconfig=yes])
1781
1782if test $use_pkgconfig = yes ; then
1783  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
1784    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
1785  fi
1786  if test -n "$PKG_CONFIG"; then
1787    _pkg_min_version=m4_default([$1], [0.16.0])
1788    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
1789    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
1790      AC_MSG_RESULT([yes])
1791    else
1792      AC_MSG_RESULT([no])
1793      PKG_CONFIG=""
1794    fi
1795  fi
1796
1797  # check if pkg-config supports the short-errors flag
1798  if test -n "$PKG_CONFIG" && \
1799    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
1800    pkg_short_errors=" --short-errors "
1801  else
1802    pkg_short_errors=""
1803  fi
1804fi
1805
1806AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
1807AC_SUBST(PKG_CONFIG)
1808
1809# assemble pkg-config search path for installed projects
1810COIN_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
1811
1812# 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
1813# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
1814# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
1815if test "x${prefix}" = xNONE ; then
1816  COIN_PKG_CONFIG_PATH="${ac_default_prefix}/lib/pkgconfig:${ac_default_prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
1817else
1818  COIN_PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
1819fi
1820
1821AC_ARG_WITH([coin-instdir],
1822  AC_HELP_STRING([--with-coin-instdir],
1823                 [prefix of installation directory for precompiled COIN packages]),
1824  [if test -d "$withval"; then : ; else
1825     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
1826   fi
1827   COIN_PKG_CONFIG_PATH="$withval/lib/pkgconfig:$withval/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
1828  ],[])
1829
1830AC_SUBST(COIN_PKG_CONFIG_PATH)
1831
1832# assemble additional pkg-config search paths for uninstalled projects
1833if test x$coin_projectdir = xyes ; then
1834  # if we are in a project setup, then in a classic setup, we want to find uninstalled projects
1835  # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
1836  # unfortunately, if the user set prefix, then we do not know where the project base directory is located
1837  # 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)
1838  COIN_PKG_CONFIG_PATH_UNINSTALLED=
1839  if test -e ../coin_subdirs.txt ; then
1840    for i in `cat ../coin_subdirs.txt` ; do
1841      if test -d ../$i ; then
1842        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
1843      fi
1844      if test -d ../$i/pkgconfig ; then
1845        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
1846      fi
1847    done
1848  fi
1849
1850  if test -e ../../coin_subdirs.txt ; then
1851    for i in `cat ../../coin_subdirs.txt` ; do
1852      if test -d ../../$i ; then
1853        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
1854      fi
1855      if test -d ../../$i/pkgconfig ; then
1856        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
1857      fi
1858    done
1859  fi
1860
1861  AC_SUBST(COIN_PKG_CONFIG_PATH_UNINSTALLED)
1862fi
1863
1864if test -n "$PKG_CONFIG" && test x$coin_cc_is_cl = xtrue; then
1865  AC_MSG_WARN([Using pkg-config together with MS or Intel Compiler on Windows is not support by example Makefiles. Consider using --disable-pkg-config.])
1866fi
1867
1868])
1869
1870###########################################################################
1871#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
1872###########################################################################
1873
1874# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1875#
1876# Check to see whether a particular project exists.  Similar
1877# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
1878#
1879AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
1880[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
1881if test -n "$PKG_CONFIG" ; then
1882  if $PKG_CONFIG --exists "m4_tolower($1)"; then
1883    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
1884    m4_ifval([$2], [$2], [:])
1885  else
1886    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
1887    $3
1888  fi
1889else
1890  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
1891fi
1892])
1893
1894###########################################################################
1895#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
1896###########################################################################
1897
1898# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1899#
1900# Check to see whether a particular set of packages exists.
1901# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
1902#
1903AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
1904[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
1905if test -n "$PKG_CONFIG" ; then
1906  if $PKG_CONFIG --exists "$2"; then
1907    m4_toupper($1)[]_VERSIONS=`$PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`
1908    $3
1909  else
1910    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
1911    $4
1912  fi
1913else
1914  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
1915fi
1916])
1917
1918###########################################################################
1919#                           COIN_PKG_HAS_MODULE                           #
1920###########################################################################
1921
1922# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1923#
1924# Checks whether pkg-config files for a given set of packages is available.
1925# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
1926# If not, then ACTION-IF-NOT-FOUND is executed.
1927# A reason for not finding a package is stored in MODULE_PKG_ERRORS
1928#
1929# --------------------------------------------------------------
1930AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
1931[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
1932
1933AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
1934  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
1935    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
1936        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
1937        # but only do this if is not trivial
1938    if test "$CYGPATH_W" != "echo" ; then
1939      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
1940      [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
1941    fi
1942    m4_toupper($1)[]_CFLAGS="$cflags"
1943    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
1944    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
1945    $3
1946  ],
1947  [ $4 ])
1948
1949])# PKG_CHECK_MODULES
1950
1951###########################################################################
1952#                           COIN_MAIN_PACKAGEDIR                          #
1953###########################################################################
1954
1955# This macro substitutes COIN_MAIN_SUBDIR.
1956# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
1957# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
1958# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
1959#   If so, include this directory into the list of directories where configure and make recourse into.
1960# tolower(coin_has_$1) is set to "no" if the project source is not available or will not be compiled.
1961# Otherwise, it will be set to "yes".
1962
1963AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],[
1964AC_MSG_CHECKING([whether source of project $1 is available and should be compiled])
1965
1966m4_tolower(coin_has_$1)=notGiven
1967coin_reason=
1968
1969# check if user wants to skip project in any case
1970AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
1971if test x"$COIN_SKIP_PROJECTS" != x; then
1972  for dir in $COIN_SKIP_PROJECTS; do
1973    if test $dir = "$1"; then
1974      m4_tolower(coin_has_$1)="no"
1975      coin_reason="$1 has been specified in COIN_SKIP_PROJECTS"
1976    fi
1977    m4_ifval($2,[
1978    if test $dir = "$2/$1"; then
1979      m4_tolower(coin_has_$1)="no"
1980      coin_reason="$2/$1 has been specified in COIN_SKIP_PROJECTS"
1981    fi])
1982  done
1983fi
1984
1985if test "$m4_tolower(coin_has_$1)" != no; then
1986  AC_ARG_WITH([m4_tolower($1)],,
1987    [if test "$withval" = no ; then
1988       m4_tolower(coin_has_$1)="no"
1989       coin_reason="--without-m4_tolower($1) has been specified"
1990     fi
1991    ])
1992fi
1993
1994if test "$m4_tolower(coin_has_$1)" != no; then
1995  AC_ARG_WITH([m4_tolower($1)-lib],
1996    AC_HELP_STRING([--with-m4_tolower($1)-lib],
1997                   [linker flags for using project $1]),
1998    [if test "$withval" = no ; then
1999       m4_tolower(coin_has_$1)="no"
2000       coin_reason="--without-m4_tolower($1)-lib has been specified"
2001     else
2002       m4_tolower(coin_has_$1)="no"
2003       coin_reason="--with-m4_tolower($1)-lib has been specified"
2004     fi],
2005    [])
2006fi
2007
2008if test "$m4_tolower(coin_has_$1)" != no; then
2009  AC_ARG_WITH([m4_tolower($1)-incdir],
2010    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
2011                   [directory with header files for using project $1]),
2012    [if test "$withval" = no ; then
2013       m4_tolower(coin_has_$1)="no"
2014       coin_reason="--without-m4_tolower($1)-incdir has been specified"
2015     else
2016       m4_tolower(coin_has_$1)="no"
2017       coin_reason="--with-m4_tolower($1)-incdir has been specified"
2018     fi],
2019    [])
2020fi
2021
2022if test "$m4_tolower(coin_has_$1)" != no; then
2023  AC_ARG_WITH([m4_tolower($1)-datadir],
2024    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
2025                   [directory with data files for using project $1]),
2026    [if test "$withval" = no ; then
2027       m4_tolower(coin_has_$1)="no"
2028       coin_reason="--without-m4_tolower($1)-datadir has been specified"
2029     else
2030       m4_tolower(coin_has_$1)="no"
2031       coin_reason="--with-m4_tolower($1)-datadir has been specified"
2032     fi],
2033    [])
2034fi
2035
2036m4_if(m4_tolower($1), blas, [
2037  if test $m4_tolower(coin_has_$1) != no; then
2038    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
2039    AC_ARG_WITH([blas],
2040      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
2041        [if test x"$withval" = "xno" ; then
2042           coin_has_blas="no"
2043           coin_reason="--without-blas has been specified"
2044         elif test x"$withval" != "xBUILD" ; then
2045           coin_has_blas="no"
2046           coin_reason="--with-blas has been specified"
2047         fi],
2048        [])
2049  fi
2050])
2051
2052m4_if(m4_tolower($1), lapack, [
2053  if test $m4_tolower(coin_has_$1) != skipping; then
2054    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
2055    AC_ARG_WITH([lapack],
2056      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
2057        [if test x"$withval" = "xno" ; then
2058           coin_has_lapack="no"
2059           coin_reason="--without-lapack has been specified"
2060         elif test x"$withval" != "xBUILD" ; then
2061           coin_has_lapack="no"
2062           coin_reason="--with-lapack has been specified"
2063         fi],
2064        [])
2065  fi
2066])
2067
2068# check if project is available in present directory
2069if test "$m4_tolower(coin_has_$1)" = notGiven; then
2070  m4_tolower(coin_has_$1)=no
2071  if test -d $srcdir/m4_ifval($2,[$2/],)$1; then
2072    coin_reason="source in m4_ifval($2,[$2/],)$1"
2073    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
2074    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
2075    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
2076    m4_ifvaln([$3],
2077      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
2078         if test -r $i; then
2079           m4_tolower(coin_has_$1)="yes"
2080         else
2081           m4_tolower(coin_has_$1)="no"
2082           coin_reason="source file $i not available"
2083           break
2084         fi
2085       done],
2086      [ m4_tolower(coin_has_$1)="yes" ])
2087  fi
2088fi
2089
2090if test -z "$coin_reason" ; then
2091  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2092else
2093  AC_MSG_RESULT([$m4_tolower(coin_has_$1), $coin_reason])
2094fi
2095
2096if test "$m4_tolower(coin_has_$1)" = yes ; then
2097  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
2098    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
2099    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
2100  fi
2101fi
2102])
2103
2104###########################################################################
2105#                            COIN_CHECK_PACKAGE                           #
2106###########################################################################
2107
2108# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
2109# A package can consists of one or more COIN-OR or other projects.
2110# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, PACKAGE_DEPENDENCIES, and PACKAGE_DATA variables, referring to the compiler and linker
2111# flags to use when linking against this module, the libraries the package depends on, and the directories where the module data resists.
2112# The difference between PACKAGE_LIBS and PACKAGE_DEPENDENCIES is that PACKAGE_DEPENDENCIES does not contain arguments starting with '-',
2113# so it can be used to setup the _DEPENDENCIES variable in a Makefile.am.
2114# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
2115# Further, tolower(coin_has_$1) is set to "yes".
2116# If a list of build targets using this projects is given in the third argument,
2117# then the compiler and linker variables and .pc file setup variable corresponding to this build target
2118# are extended with the values for this package.
2119# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_DEPENDENCIES, X_PCLIBS, X_PCREQUIRES are setup,
2120# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
2121#
2122# The first argument should be the name (PACKAGE) of the package (in correct lower
2123# and upper case).
2124# The second argument should be a (space separated) list of projects which this
2125# package consists of. Optionally, required version numbers can be added.
2126# The optional third argument should be a (space separated) list of build targets
2127# which use this package, if available.
2128#
2129# It is also possible to specify a preinstalled version of this package
2130# or to specify only the linker and compiler flags and data directory.
2131#
2132# If the user did not specify --with-$1-... flags and pkg-config is not available,
2133# COIN_CHECK_PACKAGE_FALLBACK($1, $2, $3) is called.
2134
2135AC_DEFUN([AC_COIN_CHECK_PACKAGE],
2136[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2137AC_MSG_CHECKING([for COIN-OR package $1])
2138
2139m4_tolower(coin_has_$1)=notGiven
2140
2141# check if user wants to skip package in any case
2142if test x"$COIN_SKIP_PROJECTS" != x; then
2143  for dir in $COIN_SKIP_PROJECTS; do
2144    if test $dir = "$1"; then
2145      m4_tolower(coin_has_$1)=skipping
2146    fi
2147  done
2148fi
2149
2150if test "$m4_tolower(coin_has_$1)" != skipping; then
2151  AC_ARG_WITH([m4_tolower($1)],,
2152    [if test "$withval" = no ; then
2153       m4_tolower(coin_has_$1)=skipping
2154     fi
2155    ])
2156fi
2157
2158m4_toupper($1_LIBS)=
2159m4_toupper($1_CFLAGS)=
2160m4_toupper($1_DATA)=
2161m4_toupper($1_DEPENDENCIES)=
2162m4_toupper($1_PCLIBS)=
2163m4_toupper($1_PCREQUIRES)=
2164m4_toupper($1_DATA)=
2165AC_SUBST(m4_toupper($1_LIBS))
2166AC_SUBST(m4_toupper($1_CFLAGS))
2167AC_SUBST(m4_toupper($1_DATA))
2168AC_SUBST(m4_toupper($1_DEPENDENCIES))
2169AC_SUBST(m4_toupper($1_LIBS_INSTALLED))
2170AC_SUBST(m4_toupper($1_CFLAGS_INSTALLED))
2171AC_SUBST(m4_toupper($1_DATA_INSTALLED))
2172coin_foreach_w([myvar], [$3], [
2173  AC_SUBST(m4_toupper(myvar)_CFLAGS)
2174  AC_SUBST(m4_toupper(myvar)_LIBS)
2175  AC_SUBST(m4_toupper(myvar)_PCLIBS)
2176  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
2177  AC_SUBST(m4_toupper(myvar)_DEPENDENCIES)
2178  AC_SUBST(m4_toupper(myvar)_CFLAGS_INSTALLED)
2179  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
2180])
2181
2182#check if user provided LIBS, CFLAGS, or DATA for package or disables use of package
2183if test $m4_tolower(coin_has_$1) != skipping; then
2184  AC_ARG_WITH([m4_tolower($1)-lib],
2185    AC_HELP_STRING([--with-m4_tolower($1)-lib],
2186                   [linker flags for using package $1]),
2187    [if test "$withval" = no ; then
2188       m4_tolower(coin_has_$1)=skipping
2189     else
2190       m4_tolower(coin_has_$1)=yes
2191       m4_toupper($1_LIBS)="$withval"
2192       m4_toupper($1_PCLIBS)="$withval"
2193       coin_foreach_w([myvar], [$3], [
2194         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
2195         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
2196       ])
2197       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
2198       if test -z "$PKG_CONFIG" ; then
2199         m4_toupper($1_LIBS_INSTALLED)="$withval"
2200         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_LIBS_INSTALLED="$withval $m4_toupper(myvar)_LIBS_INSTALLED"])
2201       fi
2202     fi
2203    ],
2204    [])
2205fi
2206
2207if test $m4_tolower(coin_has_$1) != skipping; then
2208  AC_ARG_WITH([m4_tolower($1)-incdir],
2209    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
2210                   [directory with header files for using package $1]),
2211    [if test "$withval" = no ; then
2212       m4_tolower(coin_has_$1)=skipping
2213     else
2214       m4_tolower(coin_has_$1)=yes
2215       m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
2216       coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="-I`${CYGPATH_W} $withval` $m4_toupper(myvar)_CFLAGS"])
2217       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
2218       if test -z "$PKG_CONFIG" ; then
2219         m4_toupper($1_CFLAGS_INSTALLED)="$m4_toupper($1_CFLAGS)"
2220         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1_CFLAGS) $m4_toupper(myvar)_CFLAGS_INSTALLED"])
2221       fi
2222     fi
2223    ],
2224    [])
2225fi
2226
2227if test $m4_tolower(coin_has_$1) != skipping; then
2228  AC_ARG_WITH([m4_tolower($1)-datadir],
2229    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
2230                   [directory with data files for using package $1]),
2231    [if test "$withval" = no ; then
2232       m4_tolower(coin_has_$1)=skipping
2233     else
2234       m4_tolower(coin_has_$1)=yes
2235       m4_toupper($1_DATA)="$withval"
2236       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
2237       if test -z "$PKG_CONFIG" ; then
2238         m4_toupper($1_DATA_INSTALLED)="$withval"
2239       fi
2240     fi
2241    ],
2242    [])
2243fi
2244
2245if test $m4_tolower(coin_has_$1) = notGiven; then
2246  if test -n "$PKG_CONFIG" ; then
2247    # set search path for pkg-config
2248    # need to export variable to be sure that the following pkg-config gets these values
2249    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
2250    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
2251    export PKG_CONFIG_PATH
2252   
2253    # let pkg-config do it's magic
2254    AC_COIN_PKG_HAS_MODULE([$1],[$2],
2255      [ m4_tolower(coin_has_$1)=yes
2256        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
2257
2258        # adjust linker flags for (i)cl compiler
2259        # for the LIBS, we replace everything of the form "/somepath/name.lib" by "`$(CYGPATH_W) /somepath/`name.lib | sed -e s|\|/|g" (where we have to use excessive many \ to get the \ into the command line for cl)
2260        if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
2261        then
2262          m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
2263        fi
2264        m4_toupper($1_PCREQUIRES)="$2"
2265   
2266        # augment X_PCREQUIRES, X_CFLAGS, and X_LIBS for each build target X in $3
2267        coin_foreach_w([myvar], [$3], [
2268          m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
2269          m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
2270          m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
2271        ])
2272      ],
2273      [ m4_tolower(coin_has_$1)=notGiven
2274        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
2275      ])
2276
2277    # reset PKG_CONFIG_PATH variable
2278    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
2279    export PKG_CONFIG_PATH
2280
2281  else
2282    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
2283    AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
2284  fi
2285
2286else
2287  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2288fi
2289
2290if test $m4_tolower(coin_has_$1) != skipping &&
2291   test $m4_tolower(coin_has_$1) != notGiven ; then
2292  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
2293
2294  AC_ARG_ENABLE([interpackage-dependencies],
2295    AC_HELP_STRING([--disable-interpackage-dependencies], [disables deduction of Makefile dependencies from package linker flags]),
2296    [], [enable_interpackage_dependencies=yes])
2297   
2298  if test $enable_interpackage_dependencies = yes ; then
2299     # construct dependencies variables from LIBS variables
2300     # we add an extra space in LIBS so we can substitute out everything starting with " -"
2301     # remove everything of the form -framework xxx as used on Mac and mkl* and libiomp5* as used on Windows
2302     # then remove everything of the form -xxx
2303     # also remove everything of the form `xxx`yyy (may have been added for cygwin/cl)
2304     m4_toupper($1)_DEPENDENCIES=`echo " $m4_toupper($1)_LIBS" | [sed -e 's/ mkl[^ ]*//g' -e 's/ libiomp5[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
2305     coin_foreach_w([myvar], [$3], [
2306       m4_toupper(myvar)_DEPENDENCIES=`echo " $m4_toupper(myvar)_LIBS " | [sed -e 's/ mkl[^ ]*//g' -e 's/ libiomp5[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
2307     ])
2308  fi
2309
2310  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
2311    if test -n "$m4_toupper($1)_CFLAGS" ; then
2312      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
2313    fi
2314    if test -n "$m4_toupper($1)_LIBS" ; then
2315      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
2316    fi
2317    if test -n "$m4_toupper($1)_DEPENDENCIES" ; then
2318      AC_MSG_NOTICE([$1 DEPENDENCIES are $m4_toupper($1)_DEPENDENCIES])
2319    fi
2320    if test -n "$m4_toupper($1)_DATA" ; then
2321      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
2322    fi
2323    if test -n "$m4_toupper($1)_PCLIBS" ; then
2324      AC_MSG_NOTICE([$1 PCLIBS are $m4_toupper($1)_PCLIBS])
2325    fi
2326    if test -n "$m4_toupper($1)_PCREQUIRES" ; then
2327      AC_MSG_NOTICE([$1 PCREQUIRES are $m4_toupper($1)_PCREQUIRES])
2328    fi
2329    coin_foreach_w([myvar], [$3], [
2330      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
2331      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
2332      AC_MSG_NOTICE([myvar DEPENDENCIES are $m4_toupper(myvar)_DEPENDENCIES])
2333    ])
2334  fi
2335fi
2336
2337# Define the Makefile conditional
2338AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2339               [test $m4_tolower(coin_has_$1) != notGiven &&
2340                test $m4_tolower(coin_has_$1) != skipping])
2341
2342]) # AC_COIN_CHECK_PACKAGE
2343
2344###########################################################################
2345#                       COIN_CHECK_PACKAGE_FALLBACK                       #
2346###########################################################################
2347
2348# This macro is used by COIN_CHECK_PACKAGE, if it fails to find a package
2349# because pkg-config was disabled or is not available.
2350#
2351# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc
2352# file in the directories specified in $COIN_PKG_CONFIG_PATH_UNINSTALLED. The
2353# latter variable is setup by COIN_HAS_PKGCONFIG and consists of the content
2354# of the coin_subdirs.txt file which has been created by configure in the
2355# base directory.  The content of xxx-uninstalled.pc is parsed in order
2356# to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
2357# referring to the compiler and linker flags to use when linking against this
2358# package and the directory where the package data resists.  Further, for each
2359# build target X specified in the third argument, the variables X_CFLAGS and
2360# X_LIBS are extended with the compiler and linker flags of this package and
2361# the variables X_PCLIBS and X_PCREQUIRES are extended by the list of linker
2362# flags and dependent projects as needed to setup a .pc file.  The macros
2363# checks also dependencies of $2.  Note that the PACKAGE_DATA variable is
2364# set to the content of datadir of the first .pc file that is parsed.
2365# Finally, for each X in the third argument, also variables
2366# X_CFLAGS_INSTALLED and X_LIBS_INSTALLED are setup. They contain the compiler
2367# and linker flags for X when all projects have been installed. Their content
2368# is assembled from the .pc files that correspond to installed projects. I.e.,
2369# whenever a file proj-uninstalled.pc is parsed, then also a corresponding
2370# proj.pc file is parsed for compiler and linker flags, if available in the
2371# same directory.
2372# Similar, a variable PACKAGE_DATA_INSTALLED is setup to the content of datadir
2373# of the first .pc file that is parsed.
2374#
2375# If .pc files for all projects in $2 and their dependencies is found,
2376# tolower(coin_has_$1) is set to "yes".  Otherwise, if some dependency
2377# is not found, tolower(coin_has_$1) is set to "notGiven".  Further, a
2378# COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
2379#
2380# The first argument should be the name (PACKAGE) of the package (in correct
2381# lower and upper case).  The second argument should be the base names of the
2382# projects .pc file which define this package.  The optional third argument
2383# should be a (space separated) list of build targets which use this package,
2384# if available.
2385#
2386# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into
2387# $COIN_PKG_CONFIG_PATH_UNINSTALLED.  When the content of this variable was
2388# setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
2389
2390AC_DEFUN([AC_COIN_CHECK_PACKAGE_FALLBACK],
2391[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2392AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
2393
2394m4_tolower(coin_has_$1)=notGiven
2395m4_toupper($1_LIBS)=
2396m4_toupper($1_LIBS_INSTALLED)=
2397m4_toupper($1_CFLAGS)=
2398m4_toupper($1_CFLAGS_INSTALLED)=
2399m4_toupper($1_DATA)=
2400m4_toupper($1_DATA_INSTALLED)=
2401m4_toupper($1_PCLIBS)=
2402m4_toupper($1_PCREQUIRES)=
2403
2404# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x, != x)
2405projtoprocess="m4_bpatsubsts([$2], [<?>?!?=[    ]*[^    ]+])"
2406
2407# we first expand the list of projects to process by adding all dependencies just behind the project which depends on it
2408# further, we collect the list of corresponding .pc files, but do this in reverse order, because we need this order afterwards
2409# the latter we also do with .pc files corresponding to the installed projects, which will be needed to setup Makefiles for examples
2410# also, we setup the DATA variable
2411allproj=""
2412allpcfiles=""
2413allpcifiles=""
2414while test "x$projtoprocess" != x ; do
2415
2416  for proj in $projtoprocess ; do
2417    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
2418    pcfile=""
2419    save_IFS="$IFS"
2420    IFS=":"
2421    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
2422      # 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
2423      if test -r "$dir/${proj}-uninstalled.pc" ; then
2424        pcfile="$dir/$proj-uninstalled.pc"
2425        if test -r "$dir/${proj}.pc" ; then
2426          pcifile="$dir/${proj}.pc"
2427        else
2428          AC_MSG_WARN([Found $pcfile, but $dir/${proj}.pc is not available. This may break Makefile's of examples.])
2429          pcifile=
2430        fi
2431        break
2432      fi
2433    done
2434    IFS="$save_IFS"
2435
2436    if test "x$pcfile" != x ; then
2437      # read dependencies from $pcfile and filter it
2438      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\{0,1\}>\{0,1\}=[       ]\{0,\}[^       ]\{1,\}//g'`]
2439
2440      # add projrequires to the front of the list of projects that have to be processed next
2441      # at the same time, remove $proj from this list
2442      projtoprocess=[`echo $projtoprocess | sed -e "s/$proj/$projrequires/"`]
2443
2444      # read DATA from $pcfile, if _DATA is still empty
2445      if test "x$m4_toupper($1_DATA)" = x ; then
2446        projdatadir=
2447        [pcfilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcfile`]
2448        eval `sh -c "$pcfilemod"`
2449        m4_toupper($1_DATA)="$projdatadir"
2450      fi
2451
2452      allproj="$allproj $proj"
2453      allpcfiles="$pcfile:$allpcfiles"
2454
2455    else
2456      AC_MSG_RESULT([no, dependency $proj not available])
2457      allproj=fail
2458      break 2
2459    fi
2460   
2461    if test "x$pcifile" != x ; then
2462      allpcifiles="$pcifile:$allpcifiles"
2463     
2464      # read DATA_INSTALLED from $pcifile, if _DATA_INSTALLED is still empty
2465      if test "x$m4_toupper($1_DATA_INSTALLED)" = x ; then
2466        projdatadir=
2467        [pcifilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcifile`]
2468        eval `sh -c "$pcifilemod"`
2469        if test "${CYGPATH_W}" != "echo"; then
2470          projdatadir="\`\$(CYGPATH_W) ${projdatadir} | sed -e 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g'\`"
2471        fi
2472        m4_toupper($1_DATA_INSTALLED)="$projdatadir"
2473      fi
2474     
2475    fi
2476
2477    break
2478  done
2479
2480  # remove spaces on begin of $projtoprocess
2481  projtoprocess=`echo $projtoprocess | sed -e 's/^[ ]*//'`
2482
2483done
2484
2485if test "$allproj" != fail ; then
2486
2487  # now go through the list of .pc files and assemble compiler and linker flags
2488  # important is here to obey the reverse order that has been setup before,
2489  # since then libraries that are required by several others should be after these other libraries
2490  pcfilesprocessed=""
2491
2492  save_IFS="$IFS"
2493  IFS=":"
2494  for pcfile in $allpcfiles ; do
2495
2496    # if $pcfile has been processed already, skip this round
2497    if test "x$pcfilesprocessed" != x ; then
2498      for pcfiledone in $pcfilesprocessed ; do
2499        if test "$pcfiledone" = "$pcfile" ; then
2500          continue 2
2501        fi
2502      done
2503    fi
2504
2505    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
2506    #   replace "Libs:" by "echo projlibs="
2507    #   replace "Cflags:" by "echo projcflags="
2508    #   remove every line starting with <some word>:
2509    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
2510
2511    # set projcflags and projlibs variables by running $pcfilemod
2512    # under mingw, the current IFS seem to make the : in the paths of the gfortran libs go away, so we temporarily set IFS back to its default
2513    projcflags=
2514    projlibs=
2515    IFS="$save_IFS"
2516    eval `sh -c "$pcfilemod"`
2517    IFS=":"
2518
2519    # add CYGPATH_W cludge into include flags and set CFLAGS variable
2520    if test "${CYGPATH_W}" != "echo"; then
2521      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
2522    fi
2523    m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
2524
2525    # set LIBS variable
2526    m4_toupper($1_LIBS)="$projlibs $m4_toupper($1_LIBS)"
2527
2528    # remember that we have processed $pcfile
2529    pcfilesprocessed="$pcfilesprocessed:$pcfile"
2530
2531  done
2532  IFS="$save_IFS"
2533
2534
2535  # now go through the list of .pc files for installed projects and assemble compiler and linker flags
2536  # important is here again to obey the reverse order that has been setup before,
2537  # since then libraries that are required by several others should be after these other libraries
2538  pcfilesprocessed=""
2539
2540  save_IFS="$IFS"
2541  IFS=":"
2542  for pcfile in $allpcifiles ; do
2543
2544    # if $pcfile has been processed already, skip this round
2545    if test "x$pcfilesprocessed" != x ; then
2546      for pcfiledone in $pcfilesprocessed ; do
2547        if test "$pcfiledone" = "$pcfile" ; then
2548          continue 2
2549        fi
2550      done
2551    fi
2552
2553    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
2554    #   replace "Libs:" by "echo projlibs="
2555    #   replace "Cflags:" by "echo projcflags="
2556    #   remove every line starting with <some word>:
2557    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
2558
2559    # set projcflags and projlibs variables by running $pcfilemod
2560    # under mingw, the current IFS seem to make the : in the paths of the gfortran libs go away, so we temporarily set IFS back to its default
2561    projcflags=
2562    projlibs=
2563    IFS="$save_IFS"
2564    eval `sh -c "$pcfilemod"`
2565    IFS=":"
2566
2567    # add CYGPATH_W cludge into include flags and set CFLAGS variable
2568    if test "${CYGPATH_W}" != "echo"; then
2569      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
2570    fi
2571    m4_toupper($1_CFLAGS_INSTALLED)="$projcflags $m4_toupper($1_CFLAGS_INSTALLED)"
2572
2573    # set LIBS variable
2574    m4_toupper($1_LIBS_INSTALLED)="$projlibs $m4_toupper($1_LIBS_INSTALLED)"
2575   
2576    # remember that we have processed $pcfile
2577    pcfilesprocessed="$pcfilesprocessed:$pcfile"
2578
2579  done
2580  IFS="$save_IFS"
2581
2582
2583  # finish up
2584  m4_tolower(coin_has_$1)=yes
2585  AC_MSG_RESULT([yes])
2586  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
2587
2588  # adjust linker flags for (i)cl compiler
2589  # for the LIBS, we replace everything of the form "/somepath/name.lib" by "`$(CYGPATH_W) /somepath/`name.lib | sed -e s|\|/|g" (where we have to use excessive many \ to get the \ into the command line for cl),
2590  # for the LIBS_INSTALLED, we replace everything of the form "/somepath/" by "`$(CYGPATH_W) /somepath/`",
2591  #    everything of the form "-lname" by "libname.lib", and
2592  #    everything of the form "-Lpath" by "-libpath:`$(CYGPATH_W) path`
2593  if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
2594  then
2595    m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
2596    m4_toupper($1_LIBS_INSTALLED)=`echo " $m4_toupper($1_LIBS_INSTALLED)" | [sed -e 's/ \(\/[^ ]*\/\)/ \`$(CYGPATH_W) \1\`/g' -e 's/ -l\([^ ]*\)/ lib\1.lib/g' -e 's/ -L\([^ ]*\)/ -libpath:\`$(CYGPATH_W) \1\`/g']`
2597  fi
2598
2599  m4_toupper($1_PCREQUIRES)="$2"
2600  coin_foreach_w([myvar], [$3], [
2601    m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
2602    m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
2603    m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
2604    m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1)_CFLAGS_INSTALLED $m4_toupper(myvar)_CFLAGS_INSTALLED"
2605    m4_toupper(myvar)_LIBS_INSTALLED="$m4_toupper($1)_LIBS_INSTALLED $m4_toupper(myvar)_LIBS_INSTALLED"
2606  ])
2607
2608fi
2609
2610AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2611               [test $m4_tolower(coin_has_$1) != notGiven &&
2612                test $m4_tolower(coin_has_$1) != skipping])
2613
2614]) # AC_COIN_CHECK_PACKAGE_FALLBACK
2615
2616###########################################################################
2617#                         COIN_CHECK_PACKAGE_BLAS                         #
2618###########################################################################
2619
2620# This macro checks for a library containing the BLAS library.  It
2621# 1. checks the --with-blas argument
2622# 2. if --with-blas=BUILD has been specified goes to point 5
2623# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
2624#    to its value
2625# 4. tries standard libraries
2626# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
2627#    ThirdParty/Blas
2628# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
2629# BLAS_LIBS is set to the flags required to link with a Blas library.
2630# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
2631# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
2632# In case 5, Blas is added to X_PCREQUIRES.
2633
2634AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
2635[
2636AC_ARG_WITH([blas],
2637            AC_HELP_STRING([--with-blas],
2638                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
2639            [use_blas="$withval"], [use_blas=])
2640
2641# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
2642# preference
2643AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
2644
2645# Check if user supplied option makes sense
2646if test x"$use_blas" != x; then
2647  if test "$use_blas" = "BUILD"; then
2648    # we come to this later
2649    :
2650  elif test "$use_blas" != "no"; then
2651    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2652    coin_need_flibs=no
2653    coin_save_LIBS="$LIBS"
2654    LIBS="$use_blas $LIBS"
2655    AC_COIN_TRY_FLINK([daxpy],
2656                      [if test $coin_need_flibs = yes ; then
2657                         use_blas="$use_blas $FLIBS"
2658                       fi
2659                       AC_MSG_RESULT([yes: $use_blas])],
2660                      [AC_MSG_RESULT([no])
2661                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2662    LIBS="$coin_save_LIBS"
2663  fi
2664else
2665# Try to autodetect the library for blas based on build system
2666  #AC_MSG_CHECKING([default locations for BLAS])
2667  skip_lblas_check=no
2668  case $build in
2669    *-sgi-*)
2670      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2671      coin_need_flibs=no
2672      coin_save_LIBS="$LIBS"
2673      LIBS="-lcomplib.sgimath $LIBS"
2674      AC_COIN_TRY_FLINK([daxpy],
2675                        [use_blas="-lcomplib.sgimath"
2676                         if test $coin_need_flibs = yes ; then
2677                           use_blas="$use_blas $FLIBS"
2678                         fi
2679                         AC_MSG_RESULT([yes: $use_blas])
2680                        ],
2681                        [AC_MSG_RESULT([no])])
2682      LIBS="$coin_save_LIBS"
2683      ;;
2684
2685# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
2686# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
2687# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
2688# that CC and cc will understand -library in Studio 13. The main extra
2689# function of -xlic_lib and -library is to arrange for the Fortran run-time
2690# libraries to be linked for C++ and C. We can arrange that explicitly.
2691    *-*-solaris*)
2692      AC_MSG_CHECKING([for BLAS in libsunperf])
2693      coin_need_flibs=no
2694      coin_save_LIBS="$LIBS"
2695      LIBS="-lsunperf $FLIBS $LIBS"
2696      AC_COIN_TRY_FLINK([daxpy],
2697                        [use_blas='-lsunperf'
2698                         if test $coin_need_flibs = yes ; then
2699                           use_blas="$use_blas $FLIBS"
2700                         fi
2701                         AC_MSG_RESULT([yes: $use_blas])
2702                        ],
2703                        [AC_MSG_RESULT([no])])
2704      LIBS="$coin_save_LIBS"
2705      ;;
2706     
2707    *-cygwin* | *-mingw*)
2708# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
2709# library will want to link with cygwin, hence won't run standalone in DOS.
2710      if test "$enable_doscompile" = mingw; then
2711        skip_lblas_check=yes
2712      fi
2713      case "$CC" in
2714        clang* ) ;;
2715        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2716          coin_save_LIBS="$LIBS"
2717          AC_MSG_CHECKING([for BLAS in MKL (32bit)])
2718          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
2719          AC_COIN_TRY_FLINK([daxpy],
2720                            [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
2721                             AC_MSG_RESULT([yes: $use_blas])
2722                            ],
2723                            [AC_MSG_RESULT([no])])
2724          LIBS="$coin_save_LIBS"
2725         
2726          if test "x$use_blas" = x ; then
2727            AC_MSG_CHECKING([for BLAS in MKL (64bit)])
2728            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
2729            AC_COIN_TRY_FLINK([daxpy],
2730                              [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
2731                               AC_MSG_RESULT([yes: $use_blas])
2732                              ],
2733                              [AC_MSG_RESULT([no])])
2734            LIBS="$coin_save_LIBS"
2735          fi
2736          ;;
2737      esac
2738      ;;
2739     
2740     *-darwin*)
2741      AC_MSG_CHECKING([for BLAS in Veclib])
2742      coin_need_flibs=no
2743      coin_save_LIBS="$LIBS"
2744      LIBS="-framework vecLib $LIBS"
2745      AC_COIN_TRY_FLINK([daxpy],
2746                        [use_blas='-framework vecLib'
2747                         if test $coin_need_flibs = yes ; then
2748                           use_blas="$use_blas $FLIBS"
2749                         fi
2750                         AC_MSG_RESULT([yes: $use_blas])
2751                        ],
2752                        [AC_MSG_RESULT([no])])
2753      LIBS="$coin_save_LIBS"
2754      ;;
2755  esac
2756
2757  if test -z "$use_blas" && test $skip_lblas_check = no; then
2758    AC_MSG_CHECKING([whether -lblas has BLAS])
2759    coin_need_flibs=no
2760    coin_save_LIBS="$LIBS"
2761    LIBS="-lblas $LIBS"
2762    AC_COIN_TRY_FLINK([daxpy],
2763                      [use_blas='-lblas'
2764                       if test $coin_need_flibs = yes ; then
2765                         use_blas="$use_blas $FLIBS"
2766                       fi
2767                       AC_MSG_RESULT([yes: $use_blas])
2768                      ],
2769                      [AC_MSG_RESULT([no])])
2770    LIBS="$coin_save_LIBS"
2771  fi
2772
2773  # If we have no other ideas, consider building BLAS.
2774  if test -z "$use_blas" ; then
2775    use_blas=BUILD
2776  fi
2777fi
2778
2779if test "x$use_blas" = xBUILD ; then
2780  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
2781 
2782elif test "x$use_blas" != x && test "$use_blas" != no; then
2783  coin_has_blas=yes
2784  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
2785  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
2786  BLAS_LIBS="$use_blas"
2787  BLAS_CFLAGS=
2788  BLAS_DATA=
2789  AC_SUBST(BLAS_LIBS)
2790  AC_SUBST(BLAS_CFLAGS)
2791  AC_SUBST(BLAS_DATA)
2792  coin_foreach_w([myvar], [$1], [
2793    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
2794    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
2795    m4_toupper(myvar)_LIBS_INSTALLED="$BLAS_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
2796  ])
2797 
2798else
2799  coin_has_blas=no
2800  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
2801fi
2802
2803coin_foreach_w([myvar], [$1], [
2804  AC_SUBST(m4_toupper(myvar)_PCLIBS)
2805  AC_SUBST(m4_toupper(myvar)_LIBS)
2806  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
2807])
2808
2809]) # AC_COIN_CHECK_PACKAGE_BLAS
2810
2811###########################################################################
2812#                       COIN_CHECK_PACKAGE_LAPACK                         #
2813###########################################################################
2814
2815# This macro checks for a library containing the LAPACK library.  It
2816# 1. checks the --with-lapack argument
2817# 2. if --with-lapack=BUILD has been specified goes to point 5
2818# 3. if --with-lapack has been specified to a working library, sets
2819#    LAPACK_LIBS to its value
2820# 4. tries standard libraries
2821# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
2822#    ThirdParty/Lapack
2823# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
2824# LAPACK_LIBS is set to the flags required to link with a Lapack library.
2825# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
2826# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
2827# In case 5, Lapack is added to X_PCREQUIRES.
2828#
2829# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
2830#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
2831#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
2832#   then we will get Blas as dependency of coinlapack.
2833
2834AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
2835[
2836AC_ARG_WITH([lapack],
2837            AC_HELP_STRING([--with-lapack],
2838                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
2839            [use_lapack=$withval], [use_lapack=])
2840
2841#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
2842AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
2843
2844# Check if user supplied option makes sense
2845if test x"$use_lapack" != x; then
2846  if test "$use_lapack" = "BUILD"; then
2847    # we come to this later
2848    :
2849  elif test "$use_lapack" != no; then
2850    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
2851    coin_need_flibs=no
2852    use_lapack="$use_lapack $BLAS_LIBS"
2853    coin_save_LIBS="$LIBS"
2854    LIBS="$use_lapack $LIBS"
2855    AC_COIN_TRY_FLINK([dsyev],
2856                      [if test $coin_need_flibs = yes ; then
2857                         use_lapack="$use_lapack $FLIBS"
2858                       fi
2859                       AC_MSG_RESULT([yes: $use_lapack])
2860                      ],
2861                      [AC_MSG_RESULT([no])
2862                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
2863    LIBS="$coin_save_LIBS"
2864  fi
2865else
2866  if test x$coin_has_blas = xyes; then
2867    # First try to see if LAPACK is already available with BLAS library
2868    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
2869    coin_save_LIBS="$LIBS"
2870    coin_need_flibs=no
2871    LIBS="$BLAS_LIBS $LIBS"
2872    AC_COIN_TRY_FLINK([dsyev],
2873                      [use_lapack="$BLAS_LIBS"
2874                       if test $coin_need_flibs = yes ; then
2875                         use_lapack="$use_lapack $FLIBS"
2876                       fi
2877                       AC_MSG_RESULT([yes: $use_lapack])
2878                      ],
2879                      [AC_MSG_RESULT([no])])
2880    LIBS="$coin_save_LIBS"
2881  fi
2882  skip_llapack_check=no
2883  if test -z "$use_lapack"; then
2884    # Try to autodetect the library for lapack based on build system
2885    case $build in
2886      # TODO: Is this check actually needed here, since -lcomplib.sigmath should have been recognized as Blas library,
2887      #       and above it is checked whether the Blas library already contains Lapack
2888      *-sgi-*)
2889        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
2890        coin_save_LIBS="$LIBS"
2891        coin_need_flibs=no
2892        LIBS="-lcomplib.sgimath $BLAS_LIBS $LIBS"
2893        AC_COIN_TRY_FLINK([dsyev],
2894                          [use_lapack="-lcomplib.sgimath $BLAS_LIBS"
2895                           if test $coin_need_flibs = yes ; then
2896                             use_lapack="$use_lapack $FLIBS"
2897                           fi
2898                           AC_MSG_RESULT([yes: $use_lapack])
2899                          ],
2900                          [AC_MSG_RESULT([no])])
2901        LIBS="$coin_save_LIBS"
2902        ;;
2903
2904      # See comments in COIN_CHECK_PACKAGE_BLAS.
2905      # TODO: Is this check actually needed here, since -lsunperf should have been recognized as Blas library,
2906      #       and above it is checked whether the Blas library already contains Lapack
2907      *-*-solaris*)
2908        AC_MSG_CHECKING([for LAPACK in libsunperf])
2909        coin_need_flibs=no
2910        coin_save_LIBS="$LIBS"
2911        LIBS="-lsunperf $BLAS_LIBS $FLIBS $LIBS"
2912        AC_COIN_TRY_FLINK([dsyev],
2913                          [use_lapack='-lsunperf $BLAS_LIBS'
2914                           if test $coin_need_flibs = yes ; then
2915                             use_lapack="$use_lapack $FLIBS"
2916                           fi
2917                           AC_MSG_RESULT([yes: $use_lapack])
2918                          ],
2919                          [AC_MSG_RESULT([no])])
2920        LIBS="$coin_save_LIBS"
2921        ;;
2922        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
2923        # will want to link with cygwin, hence won't run standalone in DOS.
2924       
2925      *-cygwin*)
2926        if test "$enable_doscompile" = mingw; then
2927          skip_llapack_check=yes
2928        fi
2929        ;;
2930       
2931    esac
2932  fi
2933
2934  if test -z "$use_lapack" && test $skip_llapack_check = no; then
2935    AC_MSG_CHECKING([whether -llapack has LAPACK])
2936    coin_need_flibs=no
2937    coin_save_LIBS="$LIBS"
2938    LIBS="-llapack $BLAS_LIBS $LIBS"
2939    AC_COIN_TRY_FLINK([dsyev],
2940                      [use_lapack='-llapack'
2941                       if test $coin_need_flibs = yes ; then
2942                         use_lapack="$use_lapack $FLIBS"
2943                       fi
2944                       AC_MSG_RESULT([yes: $use_lapack])
2945                      ],
2946                      [AC_MSG_RESULT([no])])
2947    LIBS="$coin_save_LIBS"
2948  fi
2949
2950  # If we have no other ideas, consider building LAPACK.
2951  if test -z "$use_lapack" ; then
2952    use_lapack=BUILD
2953  fi
2954fi
2955
2956if test "x$use_lapack" = xBUILD ; then
2957  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
2958
2959elif test "x$use_lapack" != x && test "$use_lapack" != no; then
2960  coin_has_lapack=yes
2961  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
2962  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
2963  LAPACK_LIBS="$use_lapack"
2964  LAPACK_CFLAGS=
2965  LAPACK_DATA=
2966  AC_SUBST(LAPACK_LIBS)
2967  AC_SUBST(LAPACK_CFLAGS)
2968  AC_SUBST(LAPACK_DATA)
2969  coin_foreach_w([myvar], [$1], [
2970    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
2971    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
2972    m4_toupper(myvar)_LIBS_INSTALLED="$LAPACK_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
2973  ])
2974 
2975else
2976  coin_has_lapack=no
2977  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
2978fi
2979
2980coin_foreach_w([myvar], [$1], [
2981  AC_SUBST(m4_toupper(myvar)_PCLIBS)
2982  AC_SUBST(m4_toupper(myvar)_LIBS)
2983  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
2984])
2985
2986]) # AC_COIN_CHECK_PACKAGE_LAPACK
Note: See TracBrowser for help on using the repository browser.