source: stable/0.7/coin.m4 @ 2225

Last change on this file since 2225 was 2225, checked in by andreasw, 11 years ago

removed -Wimplicit from C++ warning flags since gcc 4.6 does not like it

  • Property svn:keywords set to Author Date Id Revision
File size: 141.4 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 2225 2011-05-30 00:07:48Z andreasw $
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])],
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 this project ($1) with debug options])],
163 [case "${enableval}" in
164    yes) coin_debug_compile=true
165         enable_shared=no
166         ;;
167    no)  coin_debug_compile=false
168         ;;
169    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
170         ;;
171 esac],[:])
172]) # m4_ifvaln([$1],
173
174if test $coin_debug_compile = true; then
175  AC_MSG_RESULT([yes])
176else
177  AC_MSG_RESULT([no])
178fi
179
180m4_ifvaln([$1],
181[AC_ARG_WITH(m4_tolower($1)-verbosity,
182             AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
183                            [specify the debug verbosity level for project $1]),
184             [if test "$withval" = yes; then
185                withval=1
186              fi
187              m4_tolower(coin_$1_verbosity)=$withval],
188             [m4_tolower(coin_$1_verbosity)=0])
189 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
190                    m4_tolower($coin_$1_verbosity),
191                    [Define to the debug verbosity level (0 is no output)])
192
193 AC_ARG_WITH(m4_tolower($1)-checklevel,
194             AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
195                            [specify the sanity check level for project $1]),
196             [if test "$withval" = yes; then
197                withval=1
198              fi
199              m4_tolower(coin_$1_checklevel)=$withval],
200             [m4_tolower(coin_$1_checklevel)=0])
201 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
202                    m4_tolower($coin_$1_checklevel),
203                    [Define to the debug sanity check level (0 is no test)])
204]) # m4_ifvaln([$1],
205 
206]) # AC_COIN_DEBUG_COMPILE
207
208###########################################################################
209#                          COIN_MINGW_LD_FIX                              #
210###########################################################################
211
212# This macro is included by any PROG_compiler macro, to set the LD
213# environment variable on MinGW to the correct value (link). But note that
214# if we're building in cygwin with -mno-cygwin, we still want ld! If we're
215# building from cygwin with MSVC tools (cl/link), then we do want link and
216# you'd better have your PATH variable straight, else you'll be doing file
217# links instead of code links! Arguably, LDFLAGS should include -mno-cygwin
218# but in practice all linking seems to be handled through the compilers, so
219# CFLAGS and CXXFLAGS suffice.
220
221AC_DEFUN([AC_COIN_MINGW_LD_FIX],
222[case $build in
223  *-mingw*)
224    if test "${LD+set}" = set; then :; else
225      LD=link
226    fi
227    ;;
228 esac
229 case $enable_doscompile in
230   msvc)
231     if test "x${LD+set}" = xset; then :; else
232       LD=link
233     fi
234     ;;
235 esac
236])
237
238###########################################################################
239#                        COIN_ENABLE_DOSCOMPILE                           #
240###########################################################################
241
242# This macro is invoked by any PROG_compiler macro to establish the
243# --enable-doscompile option, used when one wants to compile an executable
244# under Cygwin which also runs directly under DOS (without requiring
245# Cygwin1.dll). The job of this macro is to make sure the option is correct and
246# to set enable_doscompile. Legal values are mingw, msvc, and no (disabled).
247# mingw: Fake mingw under cygwin, using GCC tools and -mno-cygwin. The most
248#        important thing here is that preprocess, compile, and link steps
249#        *all* see -mno-cygwin.
250# msvc:  Assume the presence of cl/link. It's the user's responsibility to
251#        make sure their PATH is correct. In particular, that MSVC link is
252#        found and not cygwin link (we want to do code linking, not file
253#        linking).
254# It's the responsibility of individual PROG_compiler macros to ensure that
255# they correctly set the compiler search list and preprocess, compile, and
256# link flags. This is tied to compiler setup because in practice invocations
257# of the preprocessor and linker are made through the compiler.
258
259AC_DEFUN([AC_COIN_ENABLE_DOSCOMPILE],
260[AC_REQUIRE([AC_CANONICAL_BUILD])
261 AC_ARG_ENABLE([doscompile],
262  [AC_HELP_STRING([--enable-doscompile],
263                  [Under Cygwin, compile so that executables run under DOS.
264                   Set to mingw to use gcc/g++/ld with -mno-cygwin.
265                   Set to msvc to use cl/link (or icl/link).
266                   Default when mentioned: mingw.
267                   Default when not mentioned: disabled.])],
268  [if test "$enable_doscompile" != no; then
269     case $build in
270       *-cygwin* | *-mingw*) ;;
271       *) AC_MSG_ERROR([--enable-doscompile option makes sense only under Cygwin or MinGW]) ;;
272     esac
273   fi],
274  [enable_doscompile=no])
275 case "$enable_doscompile" in
276   mingw)
277     case $build in
278       *-mingw*) enable_doscompile=no ;;
279     esac
280     ;;
281   msvc|no) ;;
282   yes) enable_doscompile=mingw ;;
283   *) AC_MSG_ERROR([Invalid value $enable_doscompile for --enable-doscompile.
284                    Try configure --help=recursive.])
285      ;;
286  esac
287  if test "$enable_doscompile" != no ; then
288    AC_MSG_NOTICE([DOS compile style is: $enable_doscompile])
289  fi
290])
291
292###########################################################################
293#                             COIN_PROG_CXX                               #
294###########################################################################
295
296# Find the compile command by running AC_PROG_CXX (with compiler names for
297# different operating systems) and put it into CXX (unless it was given by the
298# user). Then find an appropriate value for CXXFLAGS. If either of CXXFLAGS or
299# PRJCT_CXXFLAGS is defined, that value is used (replace PRJCT with the upper
300# case name of this project).  It is possible to provide additional -D flags
301# in the variable CXXDEFS, and additional compilation flags with ADD_CXXFLAGS.
302
303AC_DEFUN([AC_COIN_PROG_CXX],
304[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
305AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
306AC_LANG_PUSH(C++)
307
308AC_ARG_VAR(CXXDEFS,[Additional -D flags to be used when compiling C++ code.])
309AC_ARG_VAR(ADD_CXXFLAGS,[Additional C++ compiler options])
310AC_ARG_VAR(DBG_CXXFLAGS,[Debug C++ compiler options])
311AC_ARG_VAR(OPT_CXXFLAGS,[Optimize C++ compiler options])
312
313coin_has_cxx=yes
314
315save_cxxflags="$CXXFLAGS"
316# For *-*-solaris*, promote Studio/Workshop compiler to front of list.
317case $build in
318  *-cygwin* | *-mingw*)
319             if test "$enable_doscompile" = msvc ; then
320               comps="icl cl"
321             else
322               comps="g++ cl"
323             fi ;;
324  *-*-solaris*)
325             comps="CC xlC_r aCC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
326  *-darwin*) comps="g++ c++ CC" ;;
327  *-linux-gnu*)
328             comps="g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC xlC_r aCC CC" ;;
329          *) comps="xlC_r aCC CC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
330esac
331
332# We delete the cached value, since the test might not have been
333# performed with our choice of compilers earlier
334$as_unset ac_cv_prog_CXX || test "${ac_cv_prog_CXX+set}" != set || { ac_cv_prog_CXX=; export ac_cv_prog_CXX; }
335# AC_MSG_NOTICE([C++ compiler candidates: $comps])
336AC_PROG_CXX([$comps])
337
338#AC_PROG_CXX sets CXX to g++ if it cannot find a working C++ compiler
339#thus, we test here whether $CXX is actually working
340AC_LANG_PUSH(C++)
341AC_MSG_CHECKING([whether C++ compiler $CXX works]);
342AC_COMPILE_IFELSE(
343  [AC_LANG_PROGRAM(, [int i=0;])],
344  [AC_MSG_RESULT(yes)],
345  [AC_MSG_RESULT(no)
346   AC_MSG_ERROR(failed to find a C++ compiler or C++ compiler $CXX does not work)]
347)
348AC_LANG_POP(C++)
349
350coin_cxx_is_cl=false
351# It seems that we need to cleanup something here for the Windows
352case "$CXX" in
353  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
354    sed -e 's/^void exit (int);//' confdefs.h >> confdefs.hh
355    mv confdefs.hh confdefs.h
356    coin_cxx_is_cl=true
357    ;;
358esac
359
360# add automake conditional so we can recognize cl compiler in makefile
361AM_CONDITIONAL(COIN_CXX_IS_CL, [test $coin_cxx_is_cl = true])
362
363# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
364case "$CXX" in
365  cl* | */cl* | CL* | */CL* )
366    if test "$ac_cv_prog_cxx_g" = yes ; then
367      ac_cv_prog_cxx_g=no
368      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
369    fi ;;
370esac
371CXXFLAGS="$save_cxxflags"
372
373# Check if a project specific CXXFLAGS variable has been set
374if test x$COIN_PRJCT != x; then
375  eval coin_tmp=\${${COIN_PRJCT}_CXXFLAGS+set}
376  if test x$coin_tmp = xset; then
377    eval CXXFLAGS=\${${COIN_PRJCT}_CXXFLAGS}
378  fi
379fi
380
381if test x"$CXXFLAGS" = x; then
382
383# ToDo decide whether we want -DNDEBUG for optimization
384  coin_add_cxxflags=
385  coin_opt_cxxflags=
386  coin_dbg_cxxflags=
387  coin_warn_cxxflags=
388
389  if test "$GXX" = "yes"; then
390    case "$CXX" in
391      icpc* | */icpc*)
392        ;;
393      *)
394# ToDo decide about unroll-loops
395        coin_opt_cxxflags="-O3"
396        coin_add_cxxflags="-pipe"
397        coin_dbg_cxxflags="-g"
398        coin_warn_cxxflags="-Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long"
399        case $build in
400          *-darwin*)
401            ;;
402          *)
403            coin_warn_cxxflags="-pedantic-errors $coin_warn_cxxflags"
404            ;;
405        esac
406
407        case $enable_doscompile in
408          mingw)
409            CXXFLAGS="-mno-cygwin"
410            AC_TRY_LINK(,[int i=0; i++;],[coin_add_cxxflags="-mno-cygwin $coin_add_cxxflags"])
411            CXXFLAGS=
412          ;;
413        esac
414    esac
415  fi
416
417# Note that we do not need to cover GCC in the following tests.
418
419  if test -z "$coin_opt_cxxflags"; then
420    case $build in
421      *-cygwin* | *-mingw*)
422        case "$CXX" in
423          cl* | */cl* | CL* | */CL*)
424            # The MT and MTd options are mutually exclusive
425            coin_opt_cxxflags='-MT -O2'
426            coin_add_cxxflags='-nologo -EHsc -GR -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
427            coin_dbg_cxxflags='-MTd'
428            ;;
429          icl* | */icl* | ICL* | */ICL*)
430            # The MT and MTd options are mutually exclusive
431            coin_opt_cxxflags='-MT -Ox'
432            coin_add_cxxflags='-nologo -EHsc -GR -D_CRT_SECURE_NO_DEPRECATE'
433            coin_dbg_cxxflags='-MTd -debug'
434            ;;
435        esac
436        ;;
437      *-linux-*)
438        case "$CXX" in
439          icpc* | */icpc*)
440            coin_opt_cxxflags="-O3 -ip -mp1"
441            coin_add_cxxflags=""
442            coin_dbg_cxxflags="-g"
443            # Check if -i_dynamic is necessary (for new glibc library)
444            CXXFLAGS=
445            AC_TRY_LINK(,[int i=0; i++;],[],
446                        [coin_add_cxxflags="-i_dynamic $coin_add_cxxflags"])
447            ;;
448          pgCC* | */pgCC*)
449            coin_opt_cxxflags="-fast"
450            coin_add_cxxflags="-Kieee -pc 64"
451            coin_dbg_cxxflags="-g"
452            ;;
453        esac
454        ;;
455      *-ibm-*)
456        case "$CXX" in
457          xlC* | */xlC* | mpxlC* | */mpxlC*)
458            coin_opt_cxxflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
459            coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna -qsuppress=1500-036 -qsuppress=1500-029 -qsourcetype=c++"
460            coin_dbg_cxxflags="-g"
461            ;;
462        esac
463        ;;
464      *-hp-*)
465        case "$CXX" in
466          aCC* | */aCC* )
467            coin_opt_cxxflags="-O"
468            coin_add_cxxflags="-AA"
469            coin_dbg_cxxflags="-g"
470            ;;
471        esac
472        ;;
473      *-*-solaris*)
474          coin_opt_cxxflags="-O4"
475          coin_dbg_cxxflags="-g"
476        ;;
477    esac
478  fi
479
480# Generic flag settings. If these don't work, add a case above.
481
482  if test "$ac_cv_prog_cxx_g" = yes && test -z "$coin_dbg_cxxflags" ; then
483    coin_dbg_cxxflags="-g"
484  fi
485
486  if test -z "$coin_opt_cxxflags"; then
487    # Try if -O option works if nothing else is set
488    CXXFLAGS=-O
489    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cxxflags="-O"])
490  fi
491
492  # if PM doesn't want the warning messages, take them out
493  if test x"$coin_skip_warn_cxxflags" = xyes; then
494    coin_warn_cxxflags=
495  fi
496
497# Do final setup of flags based on values determined above.
498
499  if test x${DBG_CXXFLAGS+set} != xset; then
500    DBG_CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
501  fi
502  if test x${OPT_CXXFLAGS+set} != xset; then
503    OPT_CXXFLAGS="$coin_opt_cxxflags $coin_add_cxxflags -DNDEBUG $coin_warn_cxxflags"
504  fi
505
506  DBG_CXXFLAGS="$DBG_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
507  OPT_CXXFLAGS="$OPT_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
508
509  if test "$coin_debug_compile" = "true"; then
510    CXXFLAGS="$DBG_CXXFLAGS"
511  else
512    CXXFLAGS="$OPT_CXXFLAGS"
513  fi
514
515# Handle the case where CXXFLAGS was set externally.
516else
517  CXXFLAGS="$CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
518  if test x${DBG_CXXFLAGS+set} != xset; then
519    DBG_CXXFLAGS="$CXXFLAGS"
520  fi
521  if test x${OPT_CXXFLAGS+set} != xset; then
522    OPT_CXXFLAGS="$CXXFLAGS"
523  fi
524fi
525
526# If CXXFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
527
528case "$CXXFLAGS" in
529  *-mno-cygwin*)
530    if test x${CPPFLAGS+set} != xset ; then
531      CPPFLAGS="-mno-cygwin"
532    else
533      case "$CPPFLAGS" in
534        *-mno-cygwin*)
535          ;;
536        *)
537          CPPFLAGS="$CPPFLAGS -mno-cygwin"
538          ;;
539      esac
540    fi ;;
541esac
542
543# Try if CXXFLAGS works
544save_CXXFLAGS="$CXXFLAGS"
545AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
546if test -z "$CXXFLAGS"; then
547  AC_MSG_WARN([The flags CXXFLAGS="$save_CXXFLAGS" do not work.  I will now just try '-O', but you might want to set CXXFLAGS manually.])
548  CXXFLAGS='-O'
549  AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
550  if test -z "$CXXFLAGS"; then
551    AC_MSG_WARN([This value for CXXFLAGS does not work.  I will continue with empty CXXFLAGS, but you might want to set CXXFLAGS manually.])
552  fi
553fi
554
555AC_MSG_NOTICE([C++ compiler options are: $CXXFLAGS])
556
557AC_ARG_VAR(MPICXX,[C++ MPI Compiler])
558if test x"$MPICXX" = x; then :; else
559  AC_MSG_NOTICE([Will use MPI C++ compiler $MPICXX])
560  CXX="$MPICXX"
561fi
562
563# correct the LD variable in a mingw build with MS or intel compiler
564case "$CXX" in
565  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
566    AC_COIN_MINGW_LD_FIX
567    ;;
568esac
569
570AC_LANG_POP(C++)
571]) # AC_COIN_PROG_CXX
572
573
574###########################################################################
575#                             COIN_CXXLIBS                                #
576###########################################################################
577
578# Determine the C++ runtime libraries required for linking a C++ library
579# with a Fortran or C compiler.  The result is available in CXXLIBS.
580
581AC_DEFUN([AC_COIN_CXXLIBS],
582[AC_REQUIRE([AC_PROG_CXX])dnl
583AC_LANG_PUSH(C++)
584AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with Fortran compiler])
585if test -z "$CXXLIBS"; then
586  if test "$GXX" = "yes"; then
587    case "$CXX" in
588      icpc* | */icpc*)
589        CXXLIBS="-lstdc++"
590        ;;
591      *)
592        CXXLIBS="-lstdc++ -lm" # -lgcc"
593        ;;
594    esac
595  else
596    case $build in
597     *-mingw32 | *-cygwin* )
598      case "$CXX" in
599      cl* | */cl* | CL* | */CL*)
600        CXXLIBS=nothing;;
601      esac;;
602     *-linux-*)
603      case "$CXX" in
604      icpc* | */icpc*)
605        CXXLIBS="-lstdc++"
606             ;;
607      pgCC* | */pgCC*)
608        CXXLIBS="-lstd -lC -lc"
609             ;;
610      esac;;
611    *-ibm-*)
612      CXXLIBS="-lC -lc"
613      ;;
614    *-hp-*)
615      CXXLIBS="-L/opt/aCC/lib -l++ -lstd_v2 -lCsup_v2 -lm -lcl -lc"
616      ;;
617    *-*-solaris*)
618      CXXLIBS="-lCstd -lCrun"
619    esac
620  fi
621fi
622if test -z "$CXXLIBS"; then
623  AC_MSG_WARN([Could not automatically determine CXXLIBS (C++ link libraries; necessary if main program is in Fortran or C).])
624else
625  AC_MSG_NOTICE([Assuming that CXXLIBS is \"$CXXLIBS\".])
626fi
627if test x"$CXXLIBS" = xnothing; then
628  CXXLIBS=
629fi
630AC_LANG_POP(C++)
631]) # AC_COIN_CXXLIBS
632
633###########################################################################
634#                           COIN_CHECK_HEADER                             #
635###########################################################################
636
637# This macro checks for a header file, but it does so without the
638# standard header.  This avoids warning messages like:
639#
640# configure: WARNING: dlfcn.h: present but cannot be compiled
641# configure: WARNING: dlfcn.h:     check for missing prerequisite headers?
642# configure: WARNING: dlfcn.h: see the Autoconf documentation
643# configure: WARNING: dlfcn.h:     section "Present But Cannot Be Compiled"
644# configure: WARNING: dlfcn.h: proceeding with the preprocessor's result
645# configure: WARNING: dlfcn.h: in the future, the compiler will take precedence
646
647# My guess that the problem lay with CPPFLAGS seems to be correct. With this
648# macro reduced to a direct call to AC_CHECK_HEADERS, there are no warnings
649# now that CPPFLAGS contains -mno-cygwin when it needs it. -- lh, 061214 --
650
651# AW 070609: I restored the previous version, since otherwise the warnings
652# still pop up for the cl compiler
653
654AC_DEFUN([AC_COIN_CHECK_HEADER],
655[#if test x"$4" = x; then
656#  hdr="#include <$1>"
657#else
658#  hdr="$4"
659#fi
660#AC_CHECK_HEADERS([$1],[$2],[$3],[$hdr])
661AC_CHECK_HEADERS([$1],[$2],[$3],[$4])
662]) # AC_COIN_CHECK_HEADER
663
664###########################################################################
665#                       COIN_CHECK_CXX_CHEADER                             #
666###########################################################################
667
668# This macro checks for C header files that are used from C++.  For a give
669# stub (e.g., math), it first checks if the C++ library (cmath) is available.
670# If it is, it defines HAVE_CMATH (or whatever the stub is).  If it is not
671# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
672# if that one exists.
673
674AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
675[AC_LANG_PUSH(C++)
676AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
677if test "$ac_cv_header_c$1" != "yes"; then
678  AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
679fi
680AC_LANG_POP(C++)
681]) # AC_COIN_CHECK_CXX_CHEADER
682
683###########################################################################
684#                             COIN_PROG_CC                                #
685###########################################################################
686
687# Find the compile command by running AC_PROG_CC (with compiler names
688# for different operating systems) and put it into CC (unless it was
689# given my the user), and find an appropriate value for CFLAGS.  It is
690# possible to provide additional -D flags in the variable CDEFS.
691
692AC_DEFUN([AC_COIN_PROG_CC],
693[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
694AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
695AC_LANG_PUSH(C)
696
697# For consistency, we set the C compiler to the same value of the C++
698# compiler, if the C++ is set, but the C compiler isn't (only for CXX=cl)
699if test x"$CXX" != x; then
700  case "$CXX" in
701    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
702      if test x"$CC" = x; then
703        CC="$CXX"
704        AC_MSG_WARN([C++ compiler name provided as $CXX, but CC is unset. Setting CC to $CXX])
705      fi
706      ;;
707  esac
708fi
709
710AC_ARG_VAR(CDEFS,[Additional -D flags to be used when compiling C code.])
711AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options])
712AC_ARG_VAR(DBG_CFLAGS,[Debug C compiler options])
713AC_ARG_VAR(OPT_CFLAGS,[Optimize C compiler options])
714
715coin_has_cc=yes
716
717save_cflags="$CFLAGS"
718
719# For *-*-solaris*, promote Studio/Workshop cc compiler to front of list.
720# Depending on the user's PATH, when Studio/Workshop cc is not present we may
721# find /usr/ucb/cc, which is almost certainly not a good choice for the C
722# compiler. In this case, put cc after gcc.
723
724case $build in
725  *-cygwin* | *-mingw*)
726             if test "$enable_doscompile" = msvc ; then
727               comps="icl cl"
728             else
729               comps="gcc cl"
730             fi ;;
731  *-*-solaris*)
732             AC_CHECK_PROG(sol_cc_compiler,cc,cc,[],[],/usr/ucb/cc)
733             if test "$sol_cc_compiler" = "cc" ; then
734               comps="cc xlc gcc pgcc icc"
735             else
736               comps="xlc gcc pgcc icc cc"
737             fi
738             ;;
739  *-linux-gnu*) comps="gcc cc pgcc icc xlc" ;;
740  *-linux-*) comps="xlc gcc cc pgcc icc" ;;
741  *)         comps="xlc_r xlc cc gcc pgcc icc" ;;
742esac
743
744# We delete the cached value, since the test might not have been
745# performed with our choice of compilers earlier
746$as_unset ac_cv_prog_CC || test "${ac_cv_prog_CC+set}" != set || { ac_cv_prog_CC=; export ac_cv_prog_CC; }
747# AC_MSG_NOTICE([C compiler candidates: $comps])
748AC_PROG_CC([$comps])
749if test -z "$CC" ; then
750  AC_MSG_ERROR([Failed to find a C compiler!])
751fi
752# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
753case "$CC" in
754  cl* | */cl* | CL* | */CL* )
755    if test "$ac_cv_prog_cc_g" = yes ; then
756      ac_cv_prog_cc_g=no
757      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
758    fi ;;
759esac
760CFLAGS="$save_cflags"
761
762# add automake conditional so we can recognize cl compiler in makefile
763coin_cc_is_cl=false
764case "$CC" in
765  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
766    coin_cc_is_cl=true
767    ;;
768esac
769AM_CONDITIONAL(COIN_CC_IS_CL, [test $coin_cc_is_cl = true])
770
771# Check if a project specific CFLAGS variable has been set
772if test x$COIN_PRJCT != x; then
773  eval coin_tmp=\${${COIN_PRJCT}_CFLAGS+set}
774  if test x$coin_tmp = xset; then
775    eval CFLAGS=\${${COIN_PRJCT}_CFLAGS}
776  fi
777fi
778
779if test x"$CFLAGS" = x; then
780
781  coin_add_cflags=
782  coin_opt_cflags=
783  coin_dbg_cflags=
784  coin_warn_cflags=
785
786  if test "$GCC" = "yes"; then
787    case "$CC" in
788      icc* | */icc*)
789        ;;
790      *)
791        coin_opt_cflags="-O3"
792        coin_add_cflags="-pipe"
793        coin_dbg_cflags="-g"
794        coin_warn_cflags="-Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall -Wno-unknown-pragmas -Wno-long-long"
795        case $build in
796          *-darwin*)
797            ;;
798          *)
799            coin_warn_cflags="-pedantic-errors $coin_warn_cflags"
800            ;;
801        esac
802        case $enable_doscompile in
803          mingw)
804            CFLAGS="-mno-cygwin"
805            AC_TRY_LINK([],[int i=0; i++;],
806                        [coin_add_cflags="-mno-cygwin $coin_add_cflags"])
807            CFLAGS=
808          ;;
809        esac
810    esac
811  fi
812  if test -z "$coin_opt_cflags"; then
813    case $build in
814      *-cygwin* | *-mingw*)
815        case "$CC" in
816          cl* | */cl* | CL* | */CL*)
817            coin_opt_cflags='-MT -O2'
818            coin_add_cflags='-nologo -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
819            coin_dbg_cflags='-MTd'
820            ;;
821          icl* | */icl* | ICL* | */ICL*)
822            coin_opt_cflags='-MT -Ox'
823            coin_add_cflags='-nologo -D_CRT_SECURE_NO_DEPRECATE'
824            coin_dbg_cflags='-MTd -debug'
825            ;;
826        esac
827        ;;
828      *-linux-*)
829        case "$CC" in
830          icc* | */icc*)
831            coin_opt_cflags="-O3 -ip -mp1"
832            coin_add_cflags=""
833            coin_dbg_cflags="-g"
834            # Check if -i_dynamic is necessary (for new glibc library)
835            CFLAGS=
836            AC_TRY_LINK([],[int i=0; i++;],[],
837                        [coin_add_cflags="-i_dynamic $coin_add_cflags"])
838            ;;
839          pgcc* | */pgcc*)
840            coin_opt_cflags="-fast"
841            coin_add_cflags="-Kieee -pc 64"
842            coin_dbg_cflags="-g"
843            ;;
844        esac
845        ;;
846      *-ibm-*)
847        case "$CC" in
848          xlc* | */xlc* | mpxlc* | */mpxlc*)
849            coin_opt_cflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
850            coin_add_cflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
851            coin_dbg_cflags="-g"
852          ;;
853        esac
854        ;;
855      *-hp-*)
856        coin_opt_cflags="-O"
857        coin_add_cflags="-Ae"
858        coin_dbg_cflags="-g"
859        ;;
860      *-*-solaris*)
861        coin_opt_cflags="-xO4"
862        coin_dbg_cflags="-g"
863        ;;
864      *-sgi-*)
865        coin_opt_cflags="-O -OPT:Olimit=0"
866        coin_dbg_cflags="-g"
867        ;;
868    esac
869  fi
870
871  if test "$ac_cv_prog_cc_g" = yes && test -z "$coin_dbg_cflags" ; then
872    coin_dbg_cflags="-g"
873  fi
874
875  if test -z "$coin_opt_cflags"; then
876    # Try if -O option works if nothing else is set
877    CFLAGS="-O"
878    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cflags="-O"])
879  fi
880
881  # if PM doesn't want the warning messages, take them out
882  if test x"$coin_skip_warn_cflags" = xyes; then
883    coin_warn_cflags=
884  fi
885
886  if test x${DBG_CFLAGS+set} != xset; then
887    DBG_CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
888  fi
889  if test x${OPT_CFLAGS+set} != xset; then
890    OPT_CFLAGS="$coin_opt_cflags $coin_add_cflags -DNDEBUG $coin_warn_cflags"
891  fi
892
893  DBG_CFLAGS="$DBG_CFLAGS $ADD_CFLAGS $CDEFS"
894  OPT_CFLAGS="$OPT_CFLAGS $ADD_CFLAGS $CDEFS"
895
896  if test "$coin_debug_compile" = "true"; then
897    CFLAGS="$DBG_CFLAGS"
898  else
899    CFLAGS="$OPT_CFLAGS"
900  fi
901else
902  CFLAGS="$CFLAGS $ADD_CFLAGS $CDEFS"
903  if test x${DBG_CFLAGS+set} != xset; then
904    DBG_CFLAGS="$CFLAGS"
905  fi
906  if test x${OPT_CFLAGS+set} != xset; then
907    OPT_CFLAGS="$CFLAGS"
908  fi
909fi
910
911# If CFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
912
913case "$CFLAGS" in
914  *-mno-cygwin*)
915    if test x${CPPFLAGS+set} != xset ; then
916      CPPFLAGS="-mno-cygwin"
917    else
918      case "$CPPFLAGS" in
919        *-mno-cygwin*)
920          ;;
921        *)
922          CPPFLAGS="$CPPFLAGS -mno-cygwin"
923          ;;
924      esac
925    fi ;;
926esac
927
928# Try if CFLAGS works
929save_CFLAGS="$CFLAGS"
930AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
931if test -z "$CFLAGS"; then
932  AC_MSG_WARN([The value CFLAGS="$save_CFLAGS" do not work.  I will now just try '-O', but you might want to set CFLAGS manually.])
933  CFLAGS='-O'
934  AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
935  if test -z "$CFLAGS"; then
936    AC_MSG_WARN([This value for CFLAGS does not work.  I will continue with empty CFLAGS, but you might want to set CFLAGS manually.])
937  fi
938fi
939
940AC_MSG_NOTICE([C compiler options are: $CFLAGS])
941
942AC_ARG_VAR(MPICC,[C MPI Compiler])
943if test x"$MPICC" = x; then :; else
944  AC_MSG_NOTICE([Will use MPI C compiler $MPICC])
945  CC="$MPICC"
946fi
947
948# Correct the LD variable if we are using the MS or Intel-windows compiler
949case "$CC" in
950  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
951    AC_COIN_MINGW_LD_FIX
952    ;;
953esac
954
955AC_LANG_POP(C)
956]) # AC_COIN_PROG_CC
957
958###########################################################################
959#                             COIN_PROG_F77                               #
960###########################################################################
961
962# Find the compile command by running AC_PROG_F77 (with compiler names
963# for different operating systems) and put it into F77 (unless it was
964# given by the user), and find an appropriate value for FFLAGS
965
966AC_DEFUN([AC_COIN_PROG_F77],
967[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
968AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
969AC_REQUIRE([AC_COIN_PROG_CC])
970AC_REQUIRE([AC_COIN_F77_COMPS])
971AC_LANG_PUSH([Fortran 77])
972
973AC_ARG_VAR(ADD_FFLAGS,[Additional Fortran compiler options])
974AC_ARG_VAR(DBG_FFLAGS,[Debug Fortran compiler options])
975AC_ARG_VAR(OPT_FFLAGS,[Optimize Fortran compiler options])
976
977coin_has_f77=yes
978
979save_fflags="$FFLAGS"
980
981# We delete the cached value, since the test might not have been
982# performed with our choice of compilers earlier
983$as_unset ac_cv_prog_F77 || test "${ac_cv_prog_F77+set}" != set || { ac_cv_prog_F77=; export ac_cv_prog_F77; }
984
985# This is a real belt-and-suspenders approach. AC_COIN_FIND_F77 will use
986# coin_f77_comps to see if there's a program that matches one of the names.
987# If there's no such program, F77 = unavailable. If we match the name,
988# feed AC_PROG_F77 the same search list, just to be sure it's a functioning
989# compiler.
990# AC_MSG_NOTICE([Fortran compiler candidates: $coin_f77_comps])
991AC_COIN_FIND_F77
992if test "$F77" != "unavailable" ; then
993  AC_PROG_F77($coin_f77_comps)
994else
995  AC_MSG_WARN([Failed to find a Fortran compiler!])
996fi
997
998FFLAGS="$save_fflags"
999
1000# Check if a project specific FFLAGS variable has been set
1001if test x$COIN_PRJCT != x; then
1002  eval coin_tmp=\${${COIN_PRJCT}_FFLAGS+set}
1003  if test x$coin_tmp = xset; then
1004    eval FFLAGS=\${${COIN_PRJCT}_FFLAGS}
1005  fi
1006fi
1007
1008if test "$F77" != "unavailable" && test x"$FFLAGS" = x ; then
1009
1010  coin_add_fflags=
1011  coin_opt_fflags=
1012  coin_dbg_fflags=
1013  coin_warn_fflags=
1014
1015  if test "$G77" = "yes"; then
1016    coin_opt_fflags="-O3"
1017    coin_add_fflags="-pipe"
1018    coin_dbg_fflags="-g"
1019    case $enable_doscompile in
1020      mingw)
1021        FFLAGS="-mno-cygwin"
1022        AC_TRY_LINK(,[      write(*,*) 'Hello world'],
1023                    [coin_add_fflags="-mno-cygwin $coin_add_fflags"])
1024        FFLAGS=
1025      ;;
1026    esac
1027  else
1028    case $build in
1029      *-cygwin* | *-mingw*)
1030        case $F77 in
1031          ifort* | */ifort* | IFORT* | */IFORT* )
1032            coin_opt_fflags='-MT -O3'
1033            coin_add_fflags='-fpp -nologo'
1034            coin_dbg_fflags='-MTd -debug'
1035          ;;
1036          compile_f2c*)
1037            coin_opt_fflags='-MT -O2'
1038            coin_add_fflags='-nologo -wd4996'
1039            coin_dbg_fflags='-MTd'
1040          ;;
1041        esac
1042        ;;
1043      *-linux-*)
1044        case $F77 in
1045          ifc* | */ifc* | ifort* | */ifort*)
1046            coin_opt_fflags="-O3 -ip"
1047            coin_add_fflags="-cm -w90 -w95"
1048            coin_dbg_fflags="-g -CA -CB -CS"
1049            # Check if -i_dynamic is necessary (for new glibc library)
1050            FFLAGS=
1051            AC_TRY_LINK(,[      write(*,*) 'Hello world'],[],
1052                        [coin_add_fflags="-i_dynamic $coin_add_fflags"])
1053            ;;
1054          pgf77* | */pgf77* | pgf90* | */pgf90*)
1055            coin_opt_fflags="-fast"
1056            coin_add_fflags="-Kieee -pc 64"
1057            coin_dbg_fflags="-g"
1058          ;;
1059        esac
1060        ;;
1061      *-ibm-*)
1062        case "$F77" in
1063          xlf* | */xlf* | mpxlf* | */mpxlf* )
1064            coin_opt_fflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
1065            coin_add_fflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
1066            coin_dbg_fflags="-g -C"
1067            ;;
1068        esac
1069        ;;
1070      *-hp-*)
1071        coin_opt_fflags="+O3"
1072        coin_add_fflags="+U77"
1073        coin_dbg_fflags="-C -g"
1074        ;;
1075      *-*-solaris*)
1076        coin_opt_fflags="-O4"
1077        coin_dbg_fflags="-g"
1078        ;;
1079      *-sgi-*)
1080        coin_opt_fflags="-O5 -OPT:Olimit=0"
1081        coin_dbg_fflags="-g"
1082        ;;
1083    esac
1084  fi
1085
1086  if test "$ac_cv_prog_f77_g" = yes && test -z "$coin_dbg_fflags" ; then
1087    coin_dbg_fflags="-g"
1088  fi
1089
1090  if test -z "$coin_opt_fflags"; then
1091    # Try if -O option works if nothing else is set
1092    FFLAGS=-O
1093    AC_TRY_LINK(,[      integer i], [coin_opt_fflags="-O"])
1094  fi
1095
1096  # if PM doesn't want the warning messages, take them out
1097  if test x"$coin_skip_warn_fflags" = xyes; then
1098    coin_warn_fflags=
1099  fi
1100
1101  if test x${DBG_FFLAGS+set} != xset; then
1102    DBG_FFLAGS="$coin_dbg_fflags $coin_add_fflags $coin_warn_fflags"
1103  fi
1104  if test x${OPT_FFLAGS+set} != xset; then
1105    OPT_FFLAGS="$coin_opt_fflags $coin_add_fflags $coin_warn_fflags"
1106  fi
1107
1108  DBG_FFLAGS="$DBG_FFLAGS $ADD_FFLAGS"
1109  OPT_FFLAGS="$OPT_FFLAGS $ADD_FFLAGS"
1110
1111  if test "$coin_debug_compile" = "true"; then
1112    FFLAGS="$DBG_FFLAGS"
1113  else
1114    FFLAGS="$OPT_FFLAGS"
1115  fi
1116else
1117  FFLAGS="$FFLAGS $ADD_FFLAGS"
1118  if test x${DBG_FFLAGS+set} != xset; then
1119    DBG_FFLAGS="$FFLAGS"
1120  fi
1121  if test x${OPT_FFLAGS+set} != xset; then
1122    OPT_FFLAGS="$FFLAGS"
1123  fi
1124fi
1125
1126# If FFLAGS contains -mno-cygwin, CPPFLAGS must have it.
1127case "$FFLAGS" in
1128  *-mno-cygwin*)
1129    if test x${CPPFLAGS+set} != xset ; then
1130      CPPFLAGS="-mno-cygwin"
1131    else
1132      case "$CPPFLAGS" in
1133        *-mno-cygwin*)
1134          ;;
1135        *)
1136          CPPFLAGS="$CPPFLAGS -mno-cygwin"
1137          ;;
1138      esac
1139    fi ;;
1140esac
1141
1142# Try if FFLAGS works
1143if test "$F77" != "unavailable" ; then
1144  AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1145  if test -z "$FFLAGS"; then
1146    AC_MSG_WARN([The flags FFLAGS="$FFLAGS" do not work.  I will now just try '-O', but you might want to set FFLAGS manually.])
1147    FFLAGS='-O'
1148    AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1149    if test -z "$FFLAGS"; then
1150      AC_MSG_WARN([This value for FFLAGS does not work.  I will continue with empty FFLAGS, but you might want to set FFLAGS manually.])
1151    fi
1152  fi
1153fi
1154
1155AC_MSG_NOTICE([Fortran compiler options are: $FFLAGS])
1156
1157AC_ARG_VAR(MPIF77,[Fortran MPI Compiler])
1158if test x"$MPIF77" = x; then :; else
1159  AC_MSG_NOTICE([Will use MPI Fortran compiler $MPIF77])
1160  F77="$MPIF77"
1161fi
1162
1163# correct the LD variable if we use the intel fortran compiler in windows
1164case "$F77" in
1165  ifort* | */ifort* | IFORT* | */IFORT*)
1166    AC_COIN_MINGW_LD_FIX
1167    ;;
1168esac
1169
1170AC_LANG_POP([Fortran 77])
1171]) # AC_COIN_PROG_F77
1172
1173###########################################################################
1174#                           COIN_F77_WRAPPERS                             #
1175###########################################################################
1176
1177# Calls autoconfs AC_F77_LIBRARY_LDFLAGS and does additional corrections to FLIBS.
1178# Then calls AC_F77_WRAPPERS to get Fortran namemangling scheme.
1179#
1180# To ensure that the FLIBS are determined and corrected before linking against
1181# Fortran compilers is attempted by other macros, we put it into an extra macro
1182# and call it via AC_REQUIRE. This way it seems to be called before the macros
1183# required by AC_F77_WRAPPERS.
1184
1185AC_DEFUN([_AC_COIN_F77_LIBRARY_LDFLAGS],
1186[AC_BEFORE([AC_PROG_F77],[$0])dnl
1187
1188# get FLIBS
1189AC_F77_LIBRARY_LDFLAGS
1190orig_FLIBS="$FLIBS"
1191
1192# If FLIBS has been set by the user, we just restore its value here
1193if test x"$save_FLIBS" != x; then
1194  FLIBS="$save_FLIBS"
1195else
1196  # This is to correct a missing exclusion in autoconf 2.59
1197  if test x"$FLIBS" != x; then
1198    my_flibs=
1199    for flag in $FLIBS; do
1200      case $flag in
1201        -lcrt*.o) ;;
1202        -lcygwin) ;;
1203               *) my_flibs="$my_flibs $flag" ;;
1204      esac
1205    done
1206    FLIBS="$my_flibs"
1207  fi
1208
1209  case $build in
1210  # The following is a fix to define FLIBS for ifort on Windows
1211  # In its original version, it linked in libifcorert.lib or libifcorertd.lib on Windows/ifort explicitly.
1212  # However, this seem to create a dependency on libifcorert.dll (or libifcorertd.dll) in the executables.
1213  # This is seem to be unnecessary, libifcorert(d).lib has been removed from the link line.
1214  # Further, excluding libc.lib from the default libs seemed to be necessary only for VS < 8.
1215  # Since the corresponding flag seems to make more trouble than it avoids, it has been removed now.
1216     *-cygwin* | *-mingw*)
1217       case "$F77" in
1218#         ifort* | */ifort* | IFORT* | */IFORT*)
1219#           FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib"
1220#           if "$coin_debug_compile" = true ; then
1221#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib"
1222#           else
1223#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib"
1224#           fi
1225#           ;;
1226         compile_f2c*)
1227           FLIBS=`$F77 -FLIBS` ;;
1228       esac;;
1229     *-hp-*)
1230         FLIBS="$FLIBS -lm";;
1231     *-ibm-*)
1232         FLIBS=`echo $FLIBS | sed 's/-lc)/-lc/g'` ;;
1233     *-linux-*)
1234       case "$F77" in
1235         pgf77* | */pgf77* | pgf90* | */pgf90*)
1236# ask linker to go through the archives multiple times
1237# (the Fortran compiler seems to do that automatically...)
1238           FLIBS="-Wl,--start-group $FLIBS -Wl,--end-group" ;;
1239       esac
1240  esac
1241  ac_cv_f77_libs="$FLIBS"
1242fi
1243
1244if test "x$orig_FLIBS" != "x$FLIBS" ; then
1245  AC_MSG_NOTICE([Corrected Fortran libraries: $FLIBS])
1246fi
1247]) # _AC_COIN_F77_LIBRARY_LDFLAGS
1248
1249AC_DEFUN([AC_COIN_F77_WRAPPERS],
1250[AC_BEFORE([AC_COIN_PROG_F77],[$0])dnl
1251AC_REQUIRE([_AC_COIN_F77_LIBRARY_LDFLAGS])dnl
1252
1253AC_LANG_PUSH([Fortran 77])
1254AC_F77_WRAPPERS
1255AC_LANG_POP([Fortran 77])
1256
1257]) # AC_COIN_F77_WRAPPERS
1258
1259###########################################################################
1260#                             COIN_FIND_F77                               #
1261###########################################################################
1262
1263# Attempt to preempt autoconf by locating an appropriate F77 program. This
1264# macro will not trigger a fatal error if a suitable compiler cannot be
1265# found. It should be called before COIN_PROG_F77 or COIN_TRY_FLINK.
1266
1267AC_DEFUN([AC_COIN_FIND_F77],
1268[AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1269AC_REQUIRE([AC_COIN_F77_COMPS])
1270AC_MSG_NOTICE([Trying to determine Fortran compiler name])
1271AC_CHECK_PROGS([F77],[$coin_f77_comps],[unavailable])
1272])
1273
1274# Auxilliary macro to make sure both COIN_PROG_F77 and COIN_FIND_F77 use
1275# the same search lists for compiler names.
1276# For *-*-solaris*, promote Studio/Workshop compilers to front of list.
1277AC_DEFUN([AC_COIN_F77_COMPS],
1278[case $build in
1279  *-cygwin* | *-mingw*)
1280     if test "$enable_doscompile" = msvc ; then
1281       coin_f77_comps="ifort fl32 compile_f2c"
1282     else
1283       coin_f77_comps="gfortran ifort g95 g77 fl32 compile_f2c"
1284     fi ;;
1285  *-*-solaris*)
1286     coin_f77_comps="f95 f90 g95 f77 xlf_r fort77 gfortran g77 pgf90 pgf77 ifort ifc frt af77" ;;
1287  *-linux-gnu*)
1288     coin_f77_comps="gfortran ifort g95 fort77 f77 g77 pgf90 pgf77 ifc frt af77 xlf_r" ;;
1289  *) coin_f77_comps="xlf_r fort77 gfortran ifort g95 f77 g77 pgf90 pgf77 ifc frt af77" ;;
1290 esac
1291])
1292
1293###########################################################################
1294#                          COIN_INIT_AUTOMAKE                             #
1295###########################################################################
1296
1297# This macro calls the regular INIT_AUTOMAKE and MAINTAINER_MODE
1298# macros, and defines additional variables and makefile conditionals,
1299# that are used in the maintainer parts of the makfile.  It also
1300# checks if the correct versions of the autotools are used.
1301#
1302# This also defines the AC_SUBST variables:
1303# abs_source_dir     absolute path to source code for this package
1304# abs_bin_dir        absolute path to the directory where binaries are
1305#                    going to be installed (prefix/bin)
1306# abs_lib_dir        absolute path to the directory where libraries are
1307#                    going to be installed (prefix/lib)
1308# abs_include_dir    absolute path to the directory where the header files
1309#                    are installed (prefix/include)
1310
1311AC_DEFUN([AC_COIN_INIT_AUTOMAKE],
1312[AC_REQUIRE([AC_PROG_EGREP])
1313AC_REQUIRE([AC_PROG_LN_S])
1314
1315# AC_MSG_NOTICE([Beginning automake initialisation.])
1316# Stuff for automake
1317AM_INIT_AUTOMAKE
1318AM_MAINTAINER_MODE
1319
1320coin_have_externals=no
1321if test "$enable_maintainer_mode" = yes; then
1322
1323  # If maintainer mode is chosen, we make sure that the correct versions
1324  # of the tools are used, and that we know where libtool.m4 is (to
1325  # recreate acinclude.m4)
1326
1327  AC_SUBST(LIBTOOLM4)
1328  LIBTOOLM4=
1329  # Normally, $HOME
1330  AUTOTOOLS_DFLT=$HOME
1331
1332  AC_CACHE_CHECK([whether we are using the correct autotools],
1333                 [ac_cv_use_correct_autotools],
1334                 [ac_cv_use_correct_autotools=check])
1335
1336  if test $ac_cv_use_correct_autotools = check; then
1337    ac_cv_use_correct_autotools=yes
1338    # Check if we have autoconf
1339    AC_CHECK_PROG([have_autoconf],[autoconf],[yes],[no])
1340    if test $have_autoconf = no; then
1341      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find autoconf in your path.])
1342    fi
1343
1344    # Check whether autoconf is the correct version
1345    correct_version='2.59'
1346    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1347    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of autoconf])
1348    autoconf --version > confauto.out 2>&1
1349    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1350      AC_MSG_RESULT([yes])
1351    else
1352      rm -f confauto.out
1353      AC_MSG_RESULT([no])
1354      AC_MSG_ERROR([You don't have the correct version of autoconf as the first one in your path.])
1355    fi
1356    rm -f confauto.out
1357
1358    # Check if the executable autoconf is picked up from the correct location
1359    AC_MSG_CHECKING([whether autoconf is coming from the correct location])
1360    autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
1361    autoconf_dir=`cd $autoconf_dir; pwd`
1362    if test x$AUTOTOOLS_DIR = x; then
1363      want_dir=$AUTOTOOLS_DFLT/bin
1364    else
1365      want_dir=$AUTOTOOLS_DIR/bin
1366    fi
1367    if test $autoconf_dir = `cd $want_dir; pwd`; then
1368      AC_MSG_RESULT([yes])
1369    else
1370      rm -f confauto.out
1371      AC_MSG_RESULT([no])
1372      AC_MSG_ERROR([The autoconf executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1373    fi
1374
1375    # Check if we have automake
1376    AC_CHECK_PROG([have_automake],[automake],[yes],[no])
1377    if test $have_automake = no; then
1378      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find automake in your path.])
1379    fi
1380 
1381    # Check whether automake is the correct version
1382    correct_version='1.9.6'
1383    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1384    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of automake])
1385    automake --version > confauto.out 2>&1
1386    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1387      AC_MSG_RESULT([yes])
1388    else
1389      rm -f confauto.out
1390      AC_MSG_RESULT([no])
1391      AC_MSG_ERROR([You don't have the correct version of automake as the first one in your path.])
1392    fi
1393    rm -f confauto.out
1394
1395    # Check if the executable automake is picked up from the correct location
1396    AC_MSG_CHECKING([whether automake is coming from the correct location])
1397    automake_dir=`which automake | sed -e 's=/automake=='`
1398    automake_dir=`cd $automake_dir; pwd`
1399    if test x$AUTOTOOLS_DIR = x; then
1400      want_dir=$AUTOTOOLS_DFLT/bin
1401    else
1402      want_dir=$AUTOTOOLS_DIR/bin
1403    fi
1404    if test $automake_dir = `cd $want_dir; pwd`; then
1405      AC_MSG_RESULT([yes])
1406    else
1407      rm -f confauto.out
1408      AC_MSG_RESULT([no])
1409      AC_MSG_ERROR([The automake executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1410    fi
1411
1412    # Check if this is the correct version of libtool (with escaped dots)
1413    if test x$AUTOTOOLS_DIR = x; then
1414      want_dir=$AUTOTOOLS_DFLT/share
1415    else
1416      want_dir=$AUTOTOOLS_DIR/share
1417    fi
1418    correct_version='1.5.22'
1419    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1420    AC_COIN_CHECK_FILE([$want_dir/libtool/ltmain.sh],
1421                       [have_ltmain=yes],
1422                       [have_ltmain=no])
1423    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of libtool.])
1424    if test $have_ltmain = yes; then
1425    if $EGREP $grep_version $want_dir/libtool/ltmain.sh >/dev/null 2>&1; then
1426        AC_MSG_RESULT([yes])
1427      else
1428        AC_MSG_RESULT([no])
1429        AC_MSG_ERROR([You don't have the correct version of libtool.])
1430      fi
1431    else
1432      AC_MSG_RESULT([no])
1433      AC_MSG_ERROR([I cannot find the ltmain.sh file.])
1434    fi
1435  fi
1436
1437  # Check if we can find the libtool file
1438  if test x$AUTOTOOLS_DIR = x; then
1439    want_dir=$AUTOTOOLS_DFLT/share
1440  else
1441    want_dir=$AUTOTOOLS_DIR/share
1442  fi
1443  AC_COIN_CHECK_FILE([$want_dir/aclocal/libtool.m4],
1444                     [LIBTOOLM4="$want_dir/aclocal/libtool.m4"],
1445                     [AC_MSG_ERROR([I cannot find the libtool.m4 file.])])
1446
1447  # Check if we have an Dependencies file
1448  if test -r $srcdir/Dependencies; then
1449    coin_have_externals=yes
1450  fi
1451  # Check if subversion is installed and understands https
1452  AC_CHECK_PROG([have_svn],[svn],[yes],[no])
1453  if test x$have_svn = xyes; then
1454    AC_CACHE_CHECK([whether svn understands https],
1455                   [ac_cv_svn_understands_https],
1456                   [svn --version > confauto.out 2>&1
1457                    if $EGREP https confauto.out >/dev/null 2>&1; then
1458                      ac_cv_svn_understands_https=yes
1459                    else
1460                      ac_cv_svn_understands_https=no
1461                      have_svn=no
1462                      ac_cv_prog_have_svn=no
1463                    fi
1464                    rm -f confauto.out])
1465  fi
1466
1467  # Find the location of the BuildTools directory
1468  BUILDTOOLSDIR=
1469  if test -r $srcdir/BuildTools/coin.m4; then
1470    BUILDTOOLSDIR=$srcdir/BuildTools
1471  else
1472    if test -r $srcdir/../BuildTools/coin.m4; then
1473      BUILDTOOLSDIR=$srcdir/../BuildTools
1474    else
1475      if test -r $srcdir/../../BuildTools/coin.m4; then
1476        BUILDTOOLSDIR=$srcdir/../../BuildTools
1477      else
1478        AC_MSG_ERROR(Cannot find the BuildTools directory, better disable maintainer mode.)
1479      fi
1480    fi
1481  fi
1482  AC_SUBST(BUILDTOOLSDIR)
1483 
1484  # for running automake by make, we need to have Makemain.inc available at the place where it usually can be found during run_autotools
1485  if test "$BUILDTOOLSDIR" != "$srcdir/BuildTools" ; then
1486    $LN_S `cd $BUILDTOOLSDIR; pwd` "$srcdir/BuildTools"
1487  fi
1488
1489  # The following variable is set to the name of the directory where
1490  # the autotool scripts are located
1491  AC_SUBST(AUX_DIR)
1492  AUX_DIR=$ac_aux_dir
1493fi
1494
1495# helpful variable for the base directory of this package
1496abs_source_dir=`cd $srcdir; pwd`
1497AC_SUBST(abs_source_dir)
1498
1499# Stuff for example Makefiles
1500if test x$prefix = xNONE; then
1501  full_prefix=$ac_default_prefix
1502else
1503  full_prefix=$prefix
1504fi
1505full_prefix=`cd $full_prefix ; pwd`
1506AC_SUBST(abs_lib_dir)
1507abs_lib_dir=$full_prefix/lib
1508AC_SUBST(abs_include_dir)
1509abs_include_dir=$full_prefix/include
1510AC_SUBST(abs_bin_dir)
1511abs_bin_dir=$full_prefix/bin
1512
1513AM_CONDITIONAL(HAVE_EXTERNALS,
1514               test $coin_have_externals = yes && test x$have_svn = xyes)
1515
1516# AC_MSG_NOTICE([End automake initialisation.])
1517
1518]) # AC_COIN_INIT_AUTOMAKE
1519
1520###########################################################################
1521#                          COIN_CREATE_LIBTOOL                            #
1522###########################################################################
1523
1524# This does all the tests necessary to create the libtool script in the
1525# package base directory.  If this is used, then the COIN_INIT_AUTO_TOOLS
1526# test in the subdirectories will be able to skip the libtool tests and
1527# just use the one in the package base directory.
1528
1529m4_define([AC_COIN_CREATE_LIBTOOL],
1530[AC_CANONICAL_BUILD
1531
1532# Check if user wants to produce debugging code
1533AC_COIN_DEBUG_COMPILE
1534
1535# Get the name of the C compiler and appropriate compiler options
1536AC_COIN_PROG_CC
1537
1538# Get the name of the C++ compiler and appropriate compiler options
1539AC_COIN_PROG_CXX
1540
1541# Get the name of the Fortran compiler and appropriate compiler options
1542AC_COIN_PROG_F77
1543
1544# Initialize automake and libtool
1545# AC_MSG_NOTICE([Calling INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1546AC_COIN_INIT_AUTO_TOOLS
1547# AC_MSG_NOTICE([Finished INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1548])
1549
1550###########################################################################
1551#                         COIN_INIT_AUTO_TOOLS                            #
1552###########################################################################
1553
1554# Initialize the auto tools automake and libtool, with all
1555# modifications we want for COIN packages.
1556#
1557# RPATH_FLAGS        link flags for hardcoding path to shared objects
1558
1559# This is a trick to have this code before AC_COIN_PROG_LIBTOOL
1560AC_DEFUN([AC_COIN_DISABLE_STATIC],
1561[
1562# Test if force_shared has been set
1563if test "x$1" = xforce_shared; then
1564  if test x$enable_shared = xno; then
1565    AC_MSG_ERROR([Shared libraries are disabled by user, but this is not feasible with the given options])
1566  fi
1567  enable_shared=yes;
1568else
1569  # On Cygwin and AIX, building DLLs doesn't work
1570  case $build in
1571    *-cygwin*)
1572      coin_disable_shared=yes
1573      platform=Cygwin
1574    ;;
1575    *-aix*)
1576      coin_disable_shared=yes
1577      platform=AIX
1578    ;;
1579    *-mingw*)
1580      coin_disable_shared=yes
1581      platform="Msys"
1582#      case "$CXX" in
1583#        cl*)
1584#          coin_disable_shared=yes
1585#          platform="Msys with cl"
1586#      ;;
1587#      esac
1588    ;;
1589  esac
1590fi
1591if test x"$coin_disable_shared" = xyes; then
1592  if test x"$enable_shared" = xyes; then
1593    AC_MSG_WARN([On $platform, shared objects are not supported. I'm disabling your choice.])
1594  fi
1595  enable_shared=no
1596fi
1597# By default, we only want the shared objects to be compiled
1598AC_DISABLE_STATIC
1599])
1600
1601m4_define([AC_COIN_INIT_AUTO_TOOLS],
1602[{AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1603AC_BEFORE([AC_COIN_PROG_CC],[$0])
1604AC_BEFORE([AC_COIN_PROG_F77],[$0])
1605
1606# START
1607AC_COIN_DISABLE_STATIC([$1])
1608
1609# Initialize automake
1610AC_COIN_INIT_AUTOMAKE
1611
1612LIBTOOL=
1613if test -r ../libtool; then
1614  coin_config_dir=..
1615  LIBTOOL='$(SHELL) $(top_builddir)/../libtool'
1616fi
1617if test "x$LIBTOOL" = x; then
1618  if test -r ../../libtool; then
1619    coin_config_dir=../..
1620    LIBTOOL='$(SHELL) $(top_builddir)/../../libtool'
1621  fi
1622fi
1623
1624if test "x$LIBTOOL" = x; then
1625# AC_MSG_NOTICE([Creating libtool script (calling COIN_PROG_LIBTOOL).])
1626  # Stuff for libtool
1627  AC_COIN_PROG_LIBTOOL
1628# AC_MSG_NOTICE([Finished COIN_PROG_LIBTOOL.])
1629  # set RPATH_FLAGS to the compiler link flags required to hardcode location
1630  # of the shared objects
1631  AC_COIN_RPATH_FLAGS([$abs_lib_dir])
1632
1633else
1634
1635  AC_MSG_NOTICE([Using libtool script in directory $coin_config_dir])
1636  # get all missing information from the config.log file
1637
1638  # output variables and defines
1639  as_save_IFS=$IFS
1640  IFS='
1641'
1642  for oneline in `cat $coin_config_dir/config.status`; do
1643    case "$oneline" in
1644         # First some automake conditionals
1645      s,@am__fastdep* | s,@AR@* | s,@CPP@*  | s,@CPPFLAGS@* | s,@CXXCPP@*  | \
1646      s,@RANLIB@* | s,@STRIP@* | s,@ac_ct_AR@* | s,@ac_ct_RANLIB@* | \
1647      s,@ac_ct_STRIP@* | s,@host* | s,@LN_S@* | s,@RPATH_FLAGS@* | \
1648      s,@ac_c_preproc_warn_flag@* |  s,@ac_cxx_preproc_warn_flag@* )
1649        command=`echo $oneline | sed -e 's/^s,@//' -e 's/@,/="/' -e 's/,;t t/"/'`
1650#        echo "$command"
1651        eval "$command"
1652        ;;
1653      s,@DEFS@* )
1654        command=`echo $oneline | sed -e 's/^s,@DEFS@,/defsline="/' -e 's/,;t t/"/'`
1655#        echo "$command"
1656        eval "$command"
1657        ;;
1658    esac
1659  done
1660  IFS=$as_save_IFS
1661
1662  # And some defines (assuming here that the packages base dir
1663  # doesn't have a config.h file
1664  for word in $defsline; do
1665#    echo word $word
1666    case $word in
1667      -DHAVE_@<:@A-Z_@:>@*_H=1 | -DSTDC_HEADERS=1 )
1668        i=`echo $word | sed -e 's/-D/#define /' -e 's/=/ /'`
1669#        echo dd $i
1670        echo $i >>confdefs.h
1671        ;;
1672    esac
1673  done
1674fi
1675
1676# AC_MSG_NOTICE([End of INIT_AUTO_TOOLS.])
1677
1678# ToDo
1679# For now, don't use the -no-undefined flag, since the Makefiles are
1680# not yet set up that way.  But we need to fix this, when we want
1681# to comile DLLs under Windows.
1682LT_LDFLAGS=
1683
1684# Check if we want to set the library version
1685AC_MSG_CHECKING([if library version is set])
1686if test x"$coin_libversion" != x; then
1687  LT_LDFLAGS="$LT_LDFLAGS -version-info $coin_libversion"
1688  AC_MSG_RESULT([$coin_libversion])
1689else
1690  AC_MSG_RESULT([no])
1691fi
1692
1693AC_SUBST(LT_LDFLAGS)
1694
1695#END
1696}])
1697
1698###########################################################################
1699#                      COIN_PATCH_LIBTOOL_CYGWIN                          #
1700###########################################################################
1701
1702# Patches to libtool for cygwin. Lots for cl, a few for GCC.
1703# For cl:
1704# - cygpath is not correctly quoted in fix_srcfile_path
1705# - paths generated for .lib files is not run through cygpath -w
1706
1707
1708AC_DEFUN([AC_COIN_PATCH_LIBTOOL_CYGWIN],
1709[ case "$CXX" in
1710    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1711      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1712      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1713          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1714          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1715          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1716          -e 's%lib /OUT:%lib -OUT:%' \
1717          -e "s%cygpath -w%$CYGPATH_W%" \
1718          -e 's%$AR x \\$f_ex_an_ar_oldlib%bla=\\`lib -nologo -list \\$f_ex_an_ar_oldlib | xargs echo '"$mydos2unix"'\\`; echo \\$bla; for i in \\$bla; do lib -nologo -extract:\\$i \\$f_ex_an_ar_oldlib; done%' \
1719          -e 's/$AR t/lib -nologo -list/' \
1720          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1721          -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1722          -e 's%old_archive_cmds="lib -OUT:\\$oldlib\\$oldobjs\\$old_deplibs"%old_archive_cmds="if test -r \\$oldlib; then bla=\\"\\$oldlib\\"; else bla=; fi; lib -OUT:\\$oldlib \\\\\\$bla\\$oldobjs\\$old_deplibs"%' \
1723      libtool > conftest.bla
1724
1725      mv conftest.bla libtool
1726      chmod 755 libtool
1727      ;;
1728    *)
1729      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
1730      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1731          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1732          -e 's|libext="lib"|libext="a"|' \
1733      libtool > conftest.bla
1734
1735      mv conftest.bla libtool
1736      chmod 755 libtool
1737      ;;
1738  esac ]) # COIN_PATCH_LIBTOOL_CYGWIN
1739
1740###########################################################################
1741#                    COIN_PATCH_LIBTOOL_SOLARIS                           #
1742###########################################################################
1743# If we want to do a 64-bit build with GCC on Solaris, the system search
1744# libraries need to point to 64-bit subdirectories. If they do not already do
1745# that, fix them. This patch is evolving, as are GCC compilers.  GCC 4.2.1
1746# reports the correct search list, given the correct call. GCC 4.1.1 does not.
1747# `Correct call' means -m64 is specified. `Correct search list' seems to amount
1748# to prepending the list of 64-bit subdirectories to the 32-bit directories.
1749# Both SPARC and x86 have this issue, but a different hardware id string is
1750# required depending on the underlying CPU. The macro executes isainfo to get
1751# the string. This will fail, of course, if we're cross-compiling. The
1752# alternative is to fail on a regular basis each time a new CPU identifier is
1753# needed. This macro will also fail if the search list reported with
1754# -print-search-dirs differs between the C, C++, and Fortran compilers; each
1755# have their own setting in libtool.  If GCC reports the correct search list
1756# given the -m64 flag, the best solution is to define CC='gcc -m64', and
1757# similarly for CXX, F77, so that libtool will make the correct call.
1758###########################################################################
1759AC_DEFUN([AC_COIN_PATCH_LIBTOOL_SOLARIS],
1760[ if test "$GCC" = yes && \
1761     (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm64' >/dev/null 2>&1) ; then
1762    hdwisa=`isainfo | sed -e 's/\(@<:@^ @:>@*\) .*$/\1/'`
1763    if `$EGREP 'sys_lib_search_path_spec=' libtool | $EGREP -v $hdwisa >/dev/null 2>&1` ; then
1764      AC_MSG_NOTICE([Applying patches to libtool for 64-bit GCC compilation])
1765      fixlibtmp=`$CC -m64 -print-search-dirs | $EGREP '^libraries:'`
1766      fixlibtmp=`echo $fixlibtmp | sed -e 's/libraries: =//' -e 's/:/ /g'`
1767      if `echo "$fixlibtmp" | $EGREP -v $hdwisa  >/dev/null 2>&1` ; then
1768        # AC_MSG_NOTICE(Compensating for broken gcc)
1769        for lib in $fixlibtmp ; do
1770          if test -d "${lib}${hdwisa}" ; then
1771            syslibpath64="$syslibpath64 ${lib}${hdwisa}/"
1772          fi
1773        done
1774        syslibpath64="${syslibpath64} ${fixlibtmp}"
1775      else
1776        syslibpath64="$fixlibtmp"
1777      fi
1778      sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="'"$syslibpath64"'"|' libtool > conftest.bla
1779      mv conftest.bla libtool
1780      chmod 755 libtool 
1781    fi
1782    # AC_MSG_NOTICE(Result is )
1783    # $EGREP 'sys_lib_search_path_spec=' libtool
1784  fi ]) # COIN_PATCH_LIBTOOL_SOLARIS
1785
1786###########################################################################
1787#                           COIN_PROG_LIBTOOL                             #
1788###########################################################################
1789
1790# Setup the libtool stuff together with any modifications to make it
1791# work on additional platforms
1792
1793AC_DEFUN([AC_COIN_LIBTOOL_WRAPPER],
1794[AC_BEFORE([AC_COIN_BLA],[$0])
1795AC_PROG_LIBTOOL])
1796
1797AC_DEFUN([AC_COIN_BLA],[echo bla])
1798
1799AC_DEFUN([AC_COIN_PROG_LIBTOOL],
1800[# No longer needed now that CPPFLAGS is correctly set -- lh, 061214 --
1801 # AC_REQUIRE([AC_COIN_DLFCN_H])
1802
1803# NEW: If libtool exists in the directory higher up, we use that one
1804#      instead of creating a new one
1805
1806# It turns out that the code for AC_PROG_LIBTOOL is somehow AC_REQUIRED
1807# out in front of this macro body. You'll notice that LIBTOOL is already
1808# defined here.  We'll have to count on this macro not being called if libtool
1809# already exists, or at least move the libtool fixes outside the conditional.
1810# AC_MSG_NOTICE([Entering coin_prog_libtool, LIBTOOL = "$LIBTOOL".])
1811# This test is therefore removed.  -- lh, 061214 --
1812# if test "x$LIBTOOL" = x; then
1813
1814# AC_MSG_NOTICE([Calling PROG_LIBTOOL.])
1815  AC_PROG_LIBTOOL
1816# AC_MSG_NOTICE([Finished PROG_LIBTOOL.])
1817  AC_SUBST(ac_c_preproc_warn_flag)
1818  AC_SUBST(ac_cxx_preproc_warn_flag)
1819
1820  AC_MSG_NOTICE([Build is "$build".])
1821  mydos2unix='| dos2unix'
1822  case $build in
1823    *-mingw*)
1824      CYGPATH_W=echo
1825      mydos2unix=
1826      ;;
1827  esac
1828
1829  case $build in
1830    # Here we need to check if -m32 is specified.  If so, we need to correct
1831    # sys_lib_search_path_spec
1832    *x86_64-*)
1833      if test "$GCC" = yes && (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm32' >& /dev/null); then
1834        AC_MSG_NOTICE(Applying patches to libtool for 32bit compilation)
1835        sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="/lib /usr/lib"|' libtool > conftest.bla
1836        mv conftest.bla libtool
1837        chmod 755 libtool 
1838      fi
1839      ;;
1840
1841    *-solaris*)
1842      AC_COIN_PATCH_LIBTOOL_SOLARIS
1843      ;;
1844    # Cygwin. Ah, cygwin. Too big and ugly to inline; see the macro.
1845    *-cygwin* | *-mingw*)
1846      AC_COIN_PATCH_LIBTOOL_CYGWIN
1847      ;;
1848    *-darwin*)
1849      AC_MSG_NOTICE(Applying patches to libtool for Darwin)
1850      sed -e 's/verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"/verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"/' \
1851        -e 's/ -dynamiclib / -dynamiclib -single_module /g' \
1852      libtool > conftest.bla
1853
1854      mv conftest.bla libtool
1855      chmod 755 libtool
1856      ;;
1857  esac
1858# This fi matches the commented `if test "x$LIBTOOL" = x;' up at the head of
1859# the macro. -- lh, 061214 --
1860# fi
1861
1862# AC_MSG_NOTICE([End libtool initialisation.])
1863]) # AC_COIN_PROG_LIBTOOL
1864
1865# This is a trick to force the check for the dlfcn header to be done before
1866# the checks for libtool
1867# No longer needed now that CPPFLAGS is correctly set.  -- lh, 061214 --
1868# ACDEFUN([AC_COIN_DLFCN_H],
1869# [AC_LANG_PUSH(C)
1870# AC_COIN_CHECK_HEADER([dlfcn.h])
1871# AC_LANG_POP(C)
1872# ]) # AC_COIN_DLFCN_H
1873
1874###########################################################################
1875#                            COIN_RPATH_FLAGS                             #
1876###########################################################################
1877
1878# This macro, in case shared objects are used, defines a variable
1879# RPATH_FLAGS that can be used by the linker to hardwire the library
1880# search path for the given directories.  This is useful for example
1881# Makefiles
1882
1883AC_DEFUN([AC_COIN_RPATH_FLAGS],
1884[RPATH_FLAGS=
1885
1886if test $enable_shared = yes; then
1887  case $build in
1888    *-linux-*)
1889      if test "$GXX" = "yes"; then
1890        RPATH_FLAGS=
1891        for dir in $1; do
1892          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1893        done
1894      fi ;;
1895    *-darwin*)
1896        RPATH_FLAGS=nothing ;;
1897    *-ibm-*)
1898      case "$CXX" in
1899      xlC* | */xlC* | mpxlC* | */mpxlC*)
1900        RPATH_FLAGS=nothing ;;
1901      esac ;;
1902    *-hp-*)
1903        RPATH_FLAGS=nothing ;;
1904    *-mingw32)
1905        RPATH_FLAGS=nothing ;;
1906    *-*-solaris*)
1907        RPATH_FLAGS=
1908        for dir in $1; do
1909          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
1910        done
1911  esac
1912
1913  if test "$RPATH_FLAGS" = ""; then
1914    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.])
1915  fi
1916  if test "$RPATH_FLAGS" = "nothing"; then
1917    RPATH_FLAGS=
1918  fi
1919fi
1920
1921AC_SUBST(RPATH_FLAGS)
1922]) # AC_COIN_RPATH_FLAGS
1923
1924###########################################################################
1925#                        COIN_LINK_INPUT_CMD                              #
1926###########################################################################
1927
1928# This macro determines which command should be used to "link" files
1929# that are input to the generated executables.  On Windows, the codes
1930# using the native Windows system libraries, cannot understand symbolic
1931# links, and a copy should be used instead of 'ln -s'.
1932# The result is stored in coin_link_input_cmd
1933
1934AC_DEFUN([AC_COIN_LINK_INPUT_CMD],
1935[AC_REQUIRE([AC_PROG_LN_S])
1936AC_BEFORE([AC_COIN_PROG_CC], [$0])
1937AC_BEFORE([AC_COIN_ENABLE_DOSCOMPILE], [$0])
1938
1939AC_MSG_CHECKING([which command should be used to link input files])
1940coin_link_input_cmd="$LN_S"
1941if test "$enable_doscompile" = mingw; then
1942  coin_link_input_cmd=cp
1943fi
1944case "$CC" in
1945  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1946    coin_link_input_cmd=cp ;;
1947esac
1948AC_MSG_RESULT($coin_link_input_cmd)
1949])
1950
1951###########################################################################
1952#                              COIN_FINALIZE                              #
1953###########################################################################
1954
1955# This macro should be called at the very end of the configure.ac file.
1956# It creates the output files (by using AC_OUTPUT), and might do some other
1957# things (such as generating links to data files in a VPATH configuration).
1958# It also prints the "success" message.
1959# Note: If the variable coin_skip_ac_output is set to yes, then no output
1960# files are written.
1961
1962AC_DEFUN([AC_COIN_FINALIZE],
1963[
1964AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
1965if test x$coin_skip_ac_output != xyes; then
1966
1967  # library extension
1968  AC_SUBST(LIBEXT)
1969  case "$CC" in
1970    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1971         LIBEXT=lib ;;
1972      *) LIBEXT=a ;;
1973  esac
1974
1975  # Define VPATH_DISTCLEANFILES to be everything that needs to be
1976  # cleaned for distclean in a vpath configuration
1977  AC_SUBST(VPATH_DISTCLEANFILES)
1978  VPATH_DISTCLEANFILES="$coin_vpath_link_files"
1979
1980  # Take out subdirectories if their configuration concluded that they
1981  # don't need to be compiled
1982  if test x"$coin_ac_skip_subdirs" != x; then
1983    new_subdirs=
1984    for i in $subdirs; do
1985      skipme=no
1986      for j in $coin_ac_skip_subdirs; do
1987        if test $i = $j; then
1988          skipme=yes;
1989        fi
1990      done
1991      if test $skipme = no; then
1992        new_subdirs="$new_subdirs $i"
1993      fi
1994    done
1995    subdirs="$new_subdirs"
1996  fi
1997
1998  # need to come before AC_OUTPUT
1999  if test x$coin_projectdir != xyes; then
2000    # write coin_subdirs to a file so that project configuration knows where to find uninstalled projects
2001    echo $coin_subdirs > coin_subdirs.txt
2002  else
2003    # substitute for OBJDIR, needed to setup .pc file for uninstalled project
2004    ABSBUILDDIR="`pwd`"
2005    AC_SUBST(ABSBUILDDIR)
2006  fi
2007 
2008  AC_OUTPUT
2009
2010  if test x"$coin_vpath_link_files" = x; then : ; else
2011    lnkcmd="$coin_link_input_cmd"
2012    if test "$lnkcmd" = cp; then
2013      AC_MSG_NOTICE(Copying data files for VPATH configuration)
2014    else
2015      AC_MSG_NOTICE(Creating VPATH links for data files)
2016    fi
2017    for file in $coin_vpath_link_files; do
2018      dir=`AS_DIRNAME(["./$file"])`
2019      if test -d $dir; then : ; else
2020        AS_MKDIR_P($dir)
2021      fi
2022      rm -f $file
2023      $lnkcmd $abs_source_dir/$file $file
2024    done
2025  fi
2026
2027  if test x$coin_projectdir = xyes; then
2028    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
2029  else
2030    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
2031  fi
2032else
2033  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
2034fi
2035
2036]) #AC_COIN_FINALIZE
2037
2038###########################################################################
2039#                             COIN_VPATH_LINK                             #
2040###########################################################################
2041
2042# This macro queues source files that need to be available in the build
2043# directory. In a VPATH configuration, the files will be made available by
2044# symbolic link or copy (when the platform does not support links). The list
2045# is processed by COIN_FINALIZE. The parameter is a whitespace-separated
2046# list of files.
2047
2048AC_DEFUN([AC_COIN_VPATH_LINK],
2049[
2050AC_REQUIRE([AC_COIN_CHECK_VPATH])
2051# Allow for newlines in the parameter
2052if test $coin_vpath_config = yes; then
2053  cvl_tmp="$1"
2054  for file in $cvl_tmp ; do
2055    coin_vpath_link_files="$coin_vpath_link_files $file"
2056  done
2057fi
2058]) #AC_COIN_VPATH_LINK
2059
2060###########################################################################
2061#                       COIN_ENABLE_GNU_PACKAGES                          #
2062###########################################################################
2063
2064# This macro defined the --enable-gnu-packages flag.  This can be used
2065# to check if a user wants to compile GNU packges (such as readline or
2066# zlib) into the executable.  By default, GNU packages are disabled.
2067# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
2068
2069AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
2070[AC_ARG_ENABLE([gnu-packages],
2071               [AC_HELP_STRING([--enable-gnu-packages],
2072                               [compile with GNU packages (disabled by default)])],
2073               [coin_enable_gnu=$enableval],
2074               [coin_enable_gnu=no])
2075]) # AC_COIN_ENABLE_GNU_PACKAGES
2076
2077#######################################################################
2078#                           COIN_CHECK_LIBM                           #
2079#######################################################################
2080
2081# For a (space separated) list of arguments X, this macro adds the flags
2082# for linking against the math library to a X_LIBS and X_PCLIBS.
2083
2084AC_DEFUN([AC_COIN_CHECK_LIBM],
2085[AC_BEFORE([AC_COIN_PROG_CC],[$0])
2086
2087case "$CC" in
2088  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2089    ;;
2090  *)
2091    coin_foreach_w([myvar], [$1], [
2092      m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"
2093      m4_toupper(myvar)_PCLIBS="-lm $m4_toupper(myvar)_PCLIBS"
2094      m4_toupper(myvar)_LIBS_INSTALLED="-lm $m4_toupper(myvar)_LIBS_INSTALLED"
2095    ])
2096  ;;
2097esac
2098
2099]) # AC_COIN_CHECK_LIBM
2100
2101###########################################################################
2102#                           COIN_CHECK_GNU_ZLIB                           #
2103###########################################################################
2104
2105# This macro checks for the libz library.  If found, it sets the automake
2106# conditional COIN_HAS_ZLIB and defines the C preprocessor variable
2107# COIN_HAS_ZLIB.  Further, for a (space separated) list of arguments X,
2108# it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2109
2110AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2111[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2112AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2113AC_BEFORE([AC_COIN_PROG_CC],[$0])
2114AC_BEFORE([AC_COIN_PROG_F77],[$0])
2115AC_BEFORE([$0],[AC_COIN_FINALIZE])
2116
2117coin_has_zlib=no
2118if test $coin_enable_gnu = yes; then
2119  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2120
2121  if test $coin_has_zlib = yes; then
2122    AC_CHECK_LIB([z],[gzopen],
2123                 [coin_foreach_w([myvar], [$1], [
2124                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
2125                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
2126                    m4_toupper(myvar)_LIBS_INSTALLED="-lz $m4_toupper(myvar)_LIBS_INSTALLED"
2127                  ])
2128                 :],
2129                 [coin_has_zlib=no])
2130  fi
2131
2132  if test $coin_has_zlib = yes; then
2133    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2134  fi
2135fi
2136
2137AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2138]) # AC_COIN_CHECK_GNU_ZLIB
2139
2140
2141###########################################################################
2142#                          COIN_CHECK_GNU_BZLIB                           #
2143###########################################################################
2144
2145# This macro checks for the libbz2 library.  If found, it defines the C
2146# preprocessor variable COIN_HAS_BZLIB.  Further, for a (space separated) list
2147# of arguments X, it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2148
2149AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2150[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2151AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2152AC_BEFORE([AC_COIN_PROG_CC],[$0])
2153AC_BEFORE([AC_COIN_PROG_F77],[$0])
2154AC_BEFORE([$0],[AC_COIN_FINALIZE])
2155
2156coin_has_bzlib=no
2157if test $coin_enable_gnu = yes; then
2158  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2159
2160  if test $coin_has_bzlib = yes; then
2161    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2162                 [coin_foreach_w([myvar], [$1], [
2163                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
2164                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
2165                    m4_toupper(myvar)_LIBS_INSTALLED="-lbz2 $m4_toupper(myvar)_LIBS_INSTALLED"
2166                  ])
2167                 :],
2168                 [coin_has_bzlib=no])
2169  fi
2170
2171  if test $coin_has_bzlib = yes; then
2172    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2173  fi
2174fi
2175]) # AC_COIN_CHECK_GNU_BZLIB
2176
2177
2178###########################################################################
2179#                         COIN_CHECK_GNU_READLINE                         #
2180###########################################################################
2181
2182# This macro checks for GNU's readline.  It verifies that the header
2183# readline/readline.h is available, and that the -lreadline library
2184# contains "readline".  It is assumed that #include <stdio.h> is included
2185# in the source file before the #include<readline/readline.h>
2186# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
2187# Further, for a (space separated) list of arguments X, it adds the
2188# linker flag to the variable X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2189
2190AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2191[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2192AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2193AC_BEFORE([AC_COIN_PROG_CC],[$0])
2194AC_BEFORE([AC_COIN_PROG_F77],[$0])
2195AC_BEFORE([$0],[AC_COIN_FINALIZE])
2196
2197coin_has_readline=no
2198if test $coin_enable_gnu = yes; then
2199  AC_COIN_CHECK_HEADER([readline/readline.h],
2200                       [coin_has_readline=yes],[],
2201                       [#include <stdio.h>])
2202
2203  coin_save_LIBS="$LIBS"
2204  LIBS=
2205  # First we check if tputs and friends are available
2206  if test $coin_has_readline = yes; then
2207    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2208                   [coin_has_readline=no])
2209  fi
2210
2211  # Now we check for readline
2212  if test $coin_has_readline = yes; then
2213    AC_CHECK_LIB([readline],[readline],
2214                 [coin_foreach_w([myvar], [$1], [
2215                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
2216                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
2217                    m4_toupper(myvar)_LIBS_INSTALLED="-lreadline $LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
2218                  ])
2219                 :],
2220                 [coin_has_readline=no])
2221  fi
2222
2223  if test $coin_has_readline = yes; then
2224    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2225  fi
2226
2227  LIBS="$coin_save_LIBS"
2228fi
2229]) # AC_COIN_CHECK_GNU_READLINE
2230
2231###########################################################################
2232#                             COIN_DATA_PATH                              #
2233###########################################################################
2234
2235# This macro defines a preprocessor macro with the absolute path to a
2236# subdirectory of Data.  The argument of this macro is the name of the
2237# subdirectory (in correct case), and the name of the macro is
2238# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2239# the directory.  The path ends with a separator ("/" for linux and
2240# '\\' for Windows).  The default value for this path can be
2241# overwritten with the input variable with the same name
2242# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2243# $srcdir/../Data subdirectory.
2244
2245AC_DEFUN([AC_COIN_DATA_PATH],
2246[AC_MSG_CHECKING([absolute path to data directory $1])
2247
2248AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2249
2250if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2251  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2252fi
2253
2254# Under Cygwin, use Windows path.  Add separator
2255case $build in
2256  *-cygwin*)
2257    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2258    ;;
2259  *)
2260    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2261    ;;
2262esac
2263
2264if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2265  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2266            [Define to absolute path for Data subdirectory $1])
2267  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2268else
2269  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2270fi
2271]) # AC_COIN_DATA_PATH
2272
2273###########################################################################
2274#                       COIN_LINK_FROM_FILELIST                           #
2275###########################################################################
2276
2277# This macro creates links (or copies, if necessary) to files listed
2278# as content in a text file (second argument) into a target directory
2279# (first argument), which is created if it doesn't exist yet.  If s link
2280# already exists, nothing happens.
2281
2282AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
2283[cmd="$3"
2284if test -e $srcdir/$2 ; then
2285  my_target_dir="$1"
2286  my_link_files=`cat $srcdir/$2`
2287  my_dirname=`AS_DIRNAME($2)`
2288#  if test -e $my_target_dir; then : ; else
2289#    AS_MKDIR_P($my_target_dir)
2290#  fi
2291  for i in $my_link_files; do
2292    #rm -rf $my_target_dir/$i
2293    if test -e $my_target_dir/$i; then : ; else
2294      dirn2=`AS_DIRNAME($my_target_dir/$i)`
2295      if test -e $dirn2; then : ; else
2296        AS_MKDIR_P($dirn2)
2297      fi
2298      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
2299    fi
2300  done
2301else
2302  AC_MSG_WARN([File list file $2 missing!])
2303fi
2304])
2305
2306AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
2307[
2308AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2309echo Creating links in $1 ...
2310AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
2311])
2312
2313###########################################################################
2314#                       COIN_COPY_FROM_FILELIST                           #
2315###########################################################################
2316
2317# Like COIN_LINK_FROM_FILELIST, but copies the files.
2318
2319AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
2320[
2321echo Creating copies in $1 ...
2322AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
2323])
2324
2325###########################################################################
2326#                          COIN_EXAMPLE_FILES                             #
2327###########################################################################
2328
2329# This macro determines the names of the example files (using the
2330# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2331# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2332# creates soft links to the example files.
2333
2334AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2335[AC_REQUIRE([AC_COIN_CHECK_VPATH])
2336AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
2337AC_REQUIRE([AC_PROG_LN_S])
2338
2339files=`cd $srcdir; ls $1`
2340# We need to do the following loop to make sure that are no newlines
2341# in the variable
2342for file in $files; do
2343  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2344done
2345if test $coin_vpath_config = yes; then
2346  lnkcmd=
2347  if test "$enable_doscompile" != no; then
2348    lnkcmd=cp
2349  fi
2350  case "$CC" in
2351    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2352      lnkcmd=cp ;;
2353  esac
2354  if test "x$lnkcmd" = xcp; then
2355    AC_MSG_NOTICE([Copying example files ($1)])
2356  else
2357    AC_MSG_NOTICE([Creating links to the example files ($1)])
2358    lnkcmd="$LN_S"
2359  fi
2360  for file in $EXAMPLE_FILES; do
2361    rm -f $file
2362    $lnkcmd $srcdir/$file $file
2363  done
2364  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2365else
2366  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2367fi
2368
2369# In case there are compressed files, we create a variable with the
2370# uncompressed names
2371EXAMPLE_UNCOMPRESSED_FILES=
2372for file in $EXAMPLE_FILES; do
2373  case $file in
2374    *.gz)
2375      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2376      ;;
2377  esac
2378done
2379
2380AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2381AC_SUBST(EXAMPLE_FILES)
2382AC_SUBST(EXAMPLE_CLEAN_FILES)
2383]) #AC_COIN_EXAMPLE_FILES
2384
2385###########################################################################
2386#                      COIN_CHECK_USER_LIBRARY                            #
2387###########################################################################
2388# This macro sets up usage of a user library with header files. The assumption
2389# is that the header file(s) and library do not reside in standard system
2390# directories, hence both the include directory and link flags must be
2391# specified. There are two mandatory arguments and two optional arguments.
2392#
2393# The first argument (mandatory) should be a name (LibraryName) for the
2394# library.  The second argument (mandatory) should be an abbreviation in
2395# upper case letters (LBRY) for the library. Ultimately, the macro will
2396# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2397# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2398# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2399# directory containing include files for the library. LBRYLIB should specify
2400# the flags necessary to link to the library. A variable coin_has_lbry will
2401# be set to true or false, as appropriate. A variable lbry_libcheck will be
2402# be set to yes or no; no indicates link checks should not be attempted.
2403#
2404# The macro defines three configure arguments, --with-libraryname-incdir,
2405# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2406# LibraryName to lower case.
2407#
2408# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2409# part of the configure command using --with-libraryname-incdir and
2410# --with-libraryname-lib, respectively. Command line arguments override
2411# environment variables.
2412#
2413# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2414# macro will check for the presence of the file. If a fourth argument is given,
2415# it should specify a function name, `fname'.  The macro will attempt to link a
2416# trivial program containing a parameterless call to the function, `fname()',
2417# using the LBRYLIB flags. The link check uses C as the language; this has been
2418# adequate to date but has limitations. It is possible to disable the link
2419# check by specifying --disable-libraryname-libcheck. This is a workaround for
2420# instances where the link check does not work properly, for whatever reason.
2421# If you're trying to link to a Fortran library, consider using F77_FUNC or
2422# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2423# library, you're on your own unless the library declares some function with
2424# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2425# name.
2426# A fifth argument can be specified to include linker flags that may be required
2427# to sucessfully perform the linking check.
2428#
2429# An optional sixth argument can be given to specify a list of targets.
2430# For each target X, the variables X_LIBS and X_PCLIBS will be extended by $LBRYLIB,
2431# if the library has been found and seems to work.
2432
2433AC_DEFUN([AC_COIN_CHECK_USER_LIBRARY],
2434[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2435  AC_MSG_CHECKING(if user provides library for $1)
2436
2437# Check for header file directory
2438
2439  AC_ARG_WITH(m4_tolower($1)-incdir,
2440      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2441                     [specify the header file directory for library $1]),
2442      [$2INCDIR=`cd $withval; pwd`])
2443
2444# Check for library directory
2445
2446  AC_ARG_WITH(m4_tolower($1)-lib,
2447      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2448                     [specify the flags used to link with the library $1]),
2449      [$2LIB=$withval])
2450
2451# Switch to disable library check if requested
2452
2453  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2454      AS_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2455                     [use disable-m4_tolower($1)-libcheck to skip the link
2456                      check at configuration time]),
2457      [m4_tolower($1)_libcheck=$enableval],
2458      [m4_tolower($1)_libcheck=yes])
2459
2460# At this point, if we're going to use the library, both LBRYINCDIR and
2461# LBRYLIB must be defined and not empty.
2462
2463  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2464    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2465      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.])
2466    fi
2467    m4_tolower(coin_has_$2)=true
2468    AC_MSG_RESULT(yes)
2469  else
2470    m4_tolower(coin_has_$2)=false
2471    AC_MSG_RESULT(no)
2472  fi
2473
2474# If we have instructions for use, consider header and link checks.
2475
2476  if test $m4_tolower(coin_has_$2) = true; then
2477
2478# If argument 3 (file) is given, check for the file. Typically this will be a
2479# header file, but that's not assumed.
2480
2481    m4_ifval([$3],
2482        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2483             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2484
2485# Now see if we can link the function. There are arguments for and against
2486# assuming argument 3 is a header file declaring the function. A correct
2487# function declaration is the main argument in favour. Having to cope with
2488# possible dependencies or other oddities are the main arguments against.
2489# Force the use of C as the best single choice amongst C++, C, and Fortran.
2490# Obviously, this has limits.
2491
2492    m4_ifvaln([$4],
2493        [if test x"$m4_tolower($1)_libcheck" != xno; then
2494           coin_save_LIBS="$LIBS"
2495           LIBS="$$2LIB $5"
2496           coin_$2_link=no
2497           AC_LANG_PUSH(C)
2498           for fnm in $4 ; do
2499             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2500             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2501                 [AC_MSG_RESULT(yes)
2502                  coin_$2_link=yes
2503                  break],
2504                 [AC_MSG_RESULT(no)])
2505           done
2506           AC_LANG_POP(C)
2507           LIBS="$coin_save_LIBS"
2508           if test x"$coin_$2_link" != xyes ; then
2509             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2510           fi
2511         fi])
2512
2513# If we make it this far, we've verified the file and linked the function. Add
2514# the necessary link flags to $6_{PC}LIBS and define the preprocessor symbol
2515# COIN_HAS_LBRY.
2516
2517    coin_foreach_w([myvar], [$6], [
2518      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
2519      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
2520      m4_toupper(myvar)_LIBS_INSTALLED="$$2LIB $m4_toupper(myvar)_LIBS_INSTALLED"
2521    ])
2522   
2523    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2524  fi
2525
2526# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2527# automake conditional. These actions must occur unconditionally.
2528
2529  AC_SUBST($2INCDIR)
2530  AC_SUBST($2LIB)
2531  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2532]) #AC_COIN_CHECK_USER_LIBRARY
2533
2534###########################################################################
2535#                            COIN_TRY_FLINK                               #
2536###########################################################################
2537
2538# Auxilliary macro to test if a Fortran function name can be linked,
2539# given the current settings of LIBS.  We determine from the context, what
2540# the currently active programming language is, and cast the name accordingly.
2541# The first argument is the name of the function/subroutine, in small letters,
2542# the second argument are the actions taken when the test works, and the
2543# third argument are the actions taken if the test fails.
2544
2545AC_DEFUN([AC_COIN_TRY_FLINK],
2546[case $ac_ext in
2547  f)
2548    AC_TRY_LINK(,[      call $1],[$2],[$3])
2549    ;;
2550  c)
2551    AC_F77_FUNC($1,cfunc$1)
2552    if test x"$coin_need_flibs" = xyes; then
2553      flink_try=no;
2554    else
2555      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2556                  [flink_try=yes],[flink_try=no])
2557    fi
2558    if test $flink_try = yes; then
2559      $2
2560    else
2561      if test x"$FLIBS" != x; then
2562        flink_save_libs="$LIBS"
2563        LIBS="$LIBS $FLIBS"
2564        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2565                    [LIBS="$flink_save_libs"
2566                     coin_need_flibs=yes
2567                     $2
2568                    ],
2569                    [LIBS="$flink_save_libs"
2570                     $3])
2571      else
2572        $3
2573      fi
2574    fi
2575    ;;
2576  cc|cpp)
2577    AC_F77_FUNC($1,cfunc$1)
2578    if test x"$coin_need_flibs" = xyes; then
2579      flink_try=no;
2580    else
2581      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2582                  [flink_try=yes],[flink_try=no])
2583    fi
2584    if test $flink_try = yes; then
2585      $2
2586    else
2587      if test x"$FLIBS" != x; then
2588        flink_save_libs="$LIBS"
2589        LIBS="$LIBS $FLIBS"
2590        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2591                    [LIBS="$flink_save_libs"
2592                     coin_need_flibs=yes
2593                     $2
2594                    ],
2595                    [LIBS="$flink_save_libs"
2596                     $3])
2597      else
2598        $3
2599      fi
2600    fi
2601    ;;
2602esac
2603]) # AC_COIN_TRY_FLINK
2604
2605###########################################################################
2606#                           COIN_DOXYGEN                                  #
2607###########################################################################
2608#
2609# This macro determines the configuration information for doxygen, the tool
2610# used to generate online documentation of COIN code. It takes one parameter,
2611# a list of projects (mixed-case, to match the directory names) that should
2612# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
2613#
2614# This macro will define the following variables:
2615#  coin_have_doxygen    Yes if doxygen is found, no otherwise
2616#  coin_doxy_usedot     Defaults to `yes'; --with-dot will still check to see
2617#                       if dot is available
2618#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
2619#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
2620#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
2621#                       doxygen documentation
2622#  coin_doxy_excludes   Directories to exclude from doxygen processing
2623
2624AC_DEFUN([AC_COIN_DOXYGEN],
2625[
2626
2627AC_MSG_NOTICE([configuring doxygen documentation options])
2628
2629# Check to see if doxygen is available.
2630
2631AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
2632
2633# Look for the dot tool from the graphviz package, unless the user has
2634# disabled it.
2635
2636AC_ARG_WITH([dot],
2637  AS_HELP_STRING([--with-dot],
2638                 [use dot (from graphviz) when creating documentation with
2639                  doxygen if available; --without-dot to disable]),
2640  [],[withval=yes])
2641if test x"$withval" = xno ; then
2642  coin_doxy_usedot=NO
2643  AC_MSG_CHECKING([for dot ])
2644  AC_MSG_RESULT([disabled])
2645else
2646  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
2647fi
2648
2649# Generate a tag file name and a log file name
2650
2651AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
2652AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
2653
2654# Process the list of project names and massage them into possible doxygen
2655# doc'n directories. Prefer 1) classic external, source processed using
2656# a project-specific doxygen.conf, we use the tag file; 2) classic
2657# external, source processed using package doxygen.conf; 3) installed
2658# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
2659# configured, which we can't know unless this is the package base configure,
2660# since coin_subdirs is only set there. Hence it's sufficient to check for
2661# membership. If we use a tag file from a classic external, exclude the
2662# source from doxygen processing when doxygen runs in the base directory.
2663
2664coin_doxy_tagfiles=
2665coin_doxy_excludes=
2666tmp="$1"
2667for proj in $tmp ; do
2668  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
2669  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
2670  doxytag=${lc_proj}_doxy.tag
2671  doxyfound=no
2672  for chkProj in $coin_subdirs ; do
2673    if test "$chkProj" = "$proj" ; then
2674      # proj will be configured, hence doxydoc present in build tree
2675      doxysrcdir="${srcdir}/${proj}"
2676      # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
2677      if test -d "$doxysrcdir" ; then
2678        # with a doxydoc directory?
2679        doxydir="$doxysrcdir/doxydoc"
2680        # AC_MSG_NOTICE([Considering $doxydir (base)])
2681        # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
2682        if test -d "$doxydir" ; then
2683          # use tag file; don't process source
2684          eval doxydir="`pwd`/${proj}/doxydoc"
2685          coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
2686          AC_MSG_RESULT([$doxydir (tag)])
2687          coin_doxy_excludes="$coin_doxy_excludes */${proj}"
2688        else
2689          # will process the source -- nothing further to be done here
2690          AC_MSG_RESULT([$doxysrcdir (src)])
2691        fi
2692        doxyfound=yes
2693      fi
2694    fi
2695  done
2696  # Not built, fall back to installed tag file
2697  if test $doxyfound = no ; then
2698    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
2699    # AC_MSG_NOTICE([Considering $doxydir (install)])
2700    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
2701    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
2702    AC_MSG_RESULT([$doxydir (tag)])
2703  fi
2704done
2705AC_SUBST([coin_doxy_tagfiles])
2706AC_SUBST([coin_doxy_excludes])
2707
2708]) # AC_COIN_DOXYGEN
2709
2710
2711###########################################################################
2712#                           COIN_HAS_PKGCONFIG                            #
2713###########################################################################
2714
2715# This macro checks whether a pkg-config tool with a minimal version number
2716# is available.  If so, then the variable PKGCONFIG is set to its path.
2717# If not, PKGCONFIG is set to "".  The minimal version number can be given
2718# as first parameter, by default it is 0.16.0, since COIN-OR .pc files now
2719# include an URL field, which breaks pkg-config version <= 0.15.
2720# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
2721# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
2722# AC_SUBST'ed.  Finally, if this setup belongs to a project directory, then
2723# the search path for .pc files is assembled from the value of
2724# $PKG_CONFIG_PATH, the values of --prefix, --coin-instdir, and the directories
2725# named in a file ../coin_subdirs.txt or ../../coin_subdirs.txt in a variable
2726# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed. For a path xxx given in the
2727# coin-subdirs.txt, also the directory xxx/pkgconfig is added, if existing.
2728
2729AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
2730[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
2731
2732AC_ARG_ENABLE([pkg-config],
2733  [AC_HELP_STRING([--enable-pkg-config],[use pkg-config if available (default is yes)])],
2734  [use_pkgconfig="$enableval"],
2735  [use_pkgconfig=yes])
2736
2737if test $use_pkgconfig = yes ; then
2738  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
2739    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2740  fi
2741  if test -n "$PKG_CONFIG"; then
2742    _pkg_min_version=m4_default([$1], [0.16.0])
2743    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
2744    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
2745      AC_MSG_RESULT([yes])
2746    else
2747      AC_MSG_RESULT([no])
2748      PKG_CONFIG=""
2749    fi
2750  fi
2751
2752  # check if pkg-config supports the short-errors flag
2753  if test -n "$PKG_CONFIG" && \
2754    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
2755    pkg_short_errors=" --short-errors "
2756  else
2757    pkg_short_errors=""
2758  fi
2759fi
2760
2761AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
2762AC_SUBST(PKG_CONFIG)
2763
2764# assemble pkg-config search path for installed projects
2765COIN_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
2766
2767# 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
2768# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
2769# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
2770if test "x${prefix}" = xNONE ; then
2771  COIN_PKG_CONFIG_PATH="${ac_default_prefix}/lib/pkgconfig:${ac_default_prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2772else
2773  COIN_PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2774fi
2775
2776AC_ARG_WITH([coin-instdir],
2777  AC_HELP_STRING([--with-coin-instdir],
2778                 [prefix of installation directory for precompiled COIN packages]),
2779  [if test -d "$withval"; then : ; else
2780     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
2781   fi
2782   COIN_PKG_CONFIG_PATH="$withval/lib/pkgconfig:$withval/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2783  ],[])
2784
2785AC_SUBST(COIN_PKG_CONFIG_PATH)
2786
2787# assemble additional pkg-config search paths for uninstalled projects
2788if test x$coin_projectdir = xyes ; then
2789  # if we are in a project setup, then in a classic setup, we want to find uninstalled projects
2790  # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
2791  # unfortunately, if the user set prefix, then we do not know where the project base directory is located
2792  # 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)
2793  COIN_PKG_CONFIG_PATH_UNINSTALLED=
2794  if test -e ../coin_subdirs.txt ; then
2795    for i in `cat ../coin_subdirs.txt` ; do
2796      if test -d ../$i ; then
2797        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2798      fi
2799      if test -d ../$i/pkgconfig ; then
2800        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2801      fi
2802    done
2803  fi
2804
2805  if test -e ../../coin_subdirs.txt ; then
2806    for i in `cat ../../coin_subdirs.txt` ; do
2807      if test -d ../../$i ; then
2808        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2809      fi
2810      if test -d ../../$i/pkgconfig ; then
2811        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2812      fi
2813    done
2814  fi
2815
2816  AC_SUBST(COIN_PKG_CONFIG_PATH_UNINSTALLED)
2817fi
2818
2819if test -n "$PKG_CONFIG" && test x$coin_cc_is_cl = xtrue; then
2820  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.])
2821fi
2822
2823])
2824
2825###########################################################################
2826#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
2827###########################################################################
2828
2829# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2830#
2831# Check to see whether a particular project exists.  Similar
2832# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
2833#
2834AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
2835[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2836if test -n "$PKG_CONFIG" ; then
2837  if $PKG_CONFIG --exists "m4_tolower($1)"; then
2838    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
2839    m4_ifval([$2], [$2], [:])
2840  else
2841    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
2842    $3
2843  fi
2844else
2845  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
2846fi
2847])
2848
2849###########################################################################
2850#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
2851###########################################################################
2852
2853# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2854#
2855# Check to see whether a particular set of packages exists.
2856# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
2857#
2858AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
2859[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2860if test -n "$PKG_CONFIG" ; then
2861  if $PKG_CONFIG --exists "$2"; then
2862    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`"
2863    $3
2864  else
2865    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
2866    $4
2867  fi
2868else
2869  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
2870fi
2871])
2872
2873###########################################################################
2874#                           COIN_PKG_HAS_MODULE                           #
2875###########################################################################
2876
2877# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2878#
2879# Checks whether pkg-config files for a given set of packages is available.
2880# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
2881# If not, then ACTION-IF-NOT-FOUND is executed.
2882# A reason for not finding a package is stored in MODULE_PKG_ERRORS
2883#
2884# --------------------------------------------------------------
2885AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
2886[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2887
2888AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
2889  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
2890    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
2891        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
2892        # but only do this if is not trivial
2893    if test "$CYGPATH_W" != "echo" ; then
2894      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
2895      [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
2896    fi
2897    m4_toupper($1)[]_CFLAGS="$cflags"
2898    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
2899    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
2900    $3
2901  ],
2902  [ $4 ])
2903
2904])# PKG_CHECK_MODULES
2905
2906###########################################################################
2907#                           COIN_MAIN_PACKAGEDIR                          #
2908###########################################################################
2909
2910# This macro substitutes COIN_MAIN_SUBDIR.
2911# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
2912# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
2913# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
2914#   If so, include this directory into the list of directories where configure and make recourse into.
2915# tolower(coin_has_$1) is set to "no" if the project source is not available or will not be compiled.
2916# Otherwise, it will be set to "yes".
2917
2918AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],[
2919AC_MSG_CHECKING([whether source of project $1 is available and should be compiled])
2920
2921m4_tolower(coin_has_$1)=notGiven
2922coin_reason=
2923
2924# check if user wants to skip project in any case
2925AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
2926if test x"$COIN_SKIP_PROJECTS" != x; then
2927  for dir in $COIN_SKIP_PROJECTS; do
2928    if test $dir = "$1"; then
2929      m4_tolower(coin_has_$1)="no"
2930      coin_reason="$1 has been specified in COIN_SKIP_PROJECTS"
2931    fi
2932    m4_ifval($2,[
2933    if test $dir = "$2/$1"; then
2934      m4_tolower(coin_has_$1)="no"
2935      coin_reason="$2/$1 has been specified in COIN_SKIP_PROJECTS"
2936    fi])
2937  done
2938fi
2939
2940if test "$m4_tolower(coin_has_$1)" != no; then
2941  AC_ARG_WITH([m4_tolower($1)-lib],
2942    AC_HELP_STRING([--with-m4_tolower($1)-lib],
2943                   [linker flags for using project $1]),
2944    [if test "$withval" = no ; then
2945       m4_tolower(coin_has_$1)="no"
2946       coin_reason="--without-m4_tolower($1)-lib has been specified"
2947     else
2948       m4_tolower(coin_has_$1)="no"
2949       coin_reason="--with-m4_tolower($1)-lib has been specified"
2950     fi],
2951    [])
2952fi
2953
2954if test "$m4_tolower(coin_has_$1)" != no; then
2955  AC_ARG_WITH([m4_tolower($1)-incdir],
2956    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
2957                   [directory with header files for using project $1]),
2958    [if test "$withval" = no ; then
2959       m4_tolower(coin_has_$1)="no"
2960       coin_reason="--without-m4_tolower($1)-incdir has been specified"
2961     else
2962       m4_tolower(coin_has_$1)="no"
2963       coin_reason="--with-m4_tolower($1)-incdir has been specified"
2964     fi],
2965    [])
2966fi
2967
2968if test "$m4_tolower(coin_has_$1)" != no; then
2969  AC_ARG_WITH([m4_tolower($1)-datadir],
2970    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
2971                   [directory with data files for using project $1]),
2972    [if test "$withval" = no ; then
2973       m4_tolower(coin_has_$1)="no"
2974       coin_reason="--without-m4_tolower($1)-datadir has been specified"
2975     else
2976       m4_tolower(coin_has_$1)="no"
2977       coin_reason="--with-m4_tolower($1)-datadir has been specified"
2978     fi],
2979    [])
2980fi
2981
2982m4_if(m4_tolower($1), blas, [
2983  if test $m4_tolower(coin_has_$1) != no; then
2984    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
2985    AC_ARG_WITH([blas],
2986      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
2987        [if test x"$withval" = "xno" ; then
2988           coin_has_blas="no"
2989           coin_reason="--without-blas has been specified"
2990         elif test x"$withval" != "xBUILD" ; then
2991           coin_has_blas="no"
2992           coin_reason="--with-blas has been specified"
2993         fi],
2994        [])
2995  fi
2996])
2997
2998m4_if(m4_tolower($1), lapack, [
2999  if test $m4_tolower(coin_has_$1) != skipping; then
3000    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
3001    AC_ARG_WITH([lapack],
3002      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
3003        [if test x"$withval" = "xno" ; then
3004           coin_has_lapack="no"
3005           coin_reason="--without-lapack has been specified"
3006         elif test x"$withval" != "xBUILD" ; then
3007           coin_has_lapack="no"
3008           coin_reason="--with-lapack has been specified"
3009         fi],
3010        [])
3011  fi
3012])
3013
3014# check if project is available in present directory
3015if test "$m4_tolower(coin_has_$1)" = notGiven; then
3016  m4_tolower(coin_has_$1)=no
3017  if test -d $srcdir/m4_ifval($2,[$2/],)$1; then
3018    coin_reason="source in m4_ifval($2,[$2/],)$1"
3019    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
3020    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
3021    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
3022    m4_ifvaln([$3],
3023      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
3024         if test -r $i; then
3025           m4_tolower(coin_has_$1)="yes"
3026         else
3027           m4_tolower(coin_has_$1)="no"
3028           coin_reason="source file $i not available"
3029           break
3030         fi
3031       done],
3032      [ m4_tolower(coin_has_$1)="yes" ])
3033  fi
3034fi
3035
3036if test -z "$coin_reason" ; then
3037  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3038else
3039  AC_MSG_RESULT([$m4_tolower(coin_has_$1), $coin_reason])
3040fi
3041
3042if test "$m4_tolower(coin_has_$1)" = yes ; then
3043  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
3044    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
3045    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
3046  fi
3047fi
3048])
3049
3050###########################################################################
3051#                            COIN_CHECK_PACKAGE                           #
3052###########################################################################
3053
3054# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
3055# A package can consists of one or more COIN-OR or other projects.
3056# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, PACKAGE_DEPENDENCIES, and PACKAGE_DATA variables, referring to the compiler and linker
3057# flags to use when linking against this module, the libraries the package depends on, and the directories where the module data resists.
3058# The difference between PACKAGE_LIBS and PACKAGE_DEPENDENCIES is that PACKAGE_DEPENDENCIES does not contain arguments starting with '-',
3059# so it can be used to setup the _DEPENDENCIES variable in a Makefile.am.
3060# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
3061# Further, tolower(coin_has_$1) is set to "yes".
3062# If a list of build targets using this projects is given in the third argument,
3063# then the compiler and linker variables and .pc file setup variable corresponding to this build target
3064# are extended with the values for this package.
3065# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_DEPENDENCIES, X_PCLIBS, X_PCREQUIRES are setup,
3066# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
3067#
3068# The first argument should be the name (PACKAGE) of the package (in correct lower
3069# and upper case).
3070# The second argument should be a (space separated) list of projects which this
3071# package consists of. Optionally, required version numbers can be added.
3072# The optional third argument should be a (space separated) list of build targets
3073# which use this package, if available.
3074#
3075# It is also possible to specify a preinstalled version of this package
3076# or to specify only the linker and compiler flags and data directory.
3077#
3078# If the user did not specify --with-$1-... flags and pkg-config is not available,
3079# COIN_CHECK_PACKAGE_FALLBACK($1, $2, $3) is called.
3080
3081AC_DEFUN([AC_COIN_CHECK_PACKAGE],
3082[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3083AC_MSG_CHECKING([for COIN-OR package $1])
3084
3085m4_tolower(coin_has_$1)=notGiven
3086
3087# check if user wants to skip package in any case
3088if test x"$COIN_SKIP_PROJECTS" != x; then
3089  for dir in $COIN_SKIP_PROJECTS; do
3090    if test $dir = "$1"; then
3091      m4_tolower(coin_has_$1)=skipping
3092    fi
3093  done
3094fi
3095
3096m4_toupper($1_LIBS)=
3097m4_toupper($1_CFLAGS)=
3098m4_toupper($1_DATA)=
3099AC_SUBST(m4_toupper($1_LIBS))
3100AC_SUBST(m4_toupper($1_CFLAGS))
3101AC_SUBST(m4_toupper($1_DATA))
3102AC_SUBST(m4_toupper($1_DEPENDENCIES))
3103AC_SUBST(m4_toupper($1_LIBS_INSTALLED))
3104AC_SUBST(m4_toupper($1_CFLAGS_INSTALLED))
3105AC_SUBST(m4_toupper($1_DATA_INSTALLED))
3106coin_foreach_w([myvar], [$3], [
3107  AC_SUBST(m4_toupper(myvar)_CFLAGS)
3108  AC_SUBST(m4_toupper(myvar)_LIBS)
3109  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3110  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
3111  AC_SUBST(m4_toupper(myvar)_DEPENDENCIES)
3112  AC_SUBST(m4_toupper(myvar)_CFLAGS_INSTALLED)
3113  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3114])
3115
3116#check if user provided LIBS, CFLAGS, or DATA for package or disables use of package
3117if test $m4_tolower(coin_has_$1) != skipping; then
3118  AC_ARG_WITH([m4_tolower($1)-lib],
3119    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3120                   [linker flags for using package $1]),
3121    [if test "$withval" = no ; then
3122       m4_tolower(coin_has_$1)=skipping
3123     else
3124       m4_tolower(coin_has_$1)=yes
3125       m4_toupper($1_LIBS)="$withval"
3126       coin_foreach_w([myvar], [$3], [
3127         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
3128         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
3129       ])
3130       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3131       if test -z "$PKG_CONFIG" ; then
3132         m4_toupper($1_LIBS_INSTALLED)="$withval"
3133         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_LIBS_INSTALLED="$withval $m4_toupper(myvar)_LIBS_INSTALLED"])
3134       fi
3135     fi
3136    ],
3137    [])
3138fi
3139
3140if test $m4_tolower(coin_has_$1) != skipping; then
3141  AC_ARG_WITH([m4_tolower($1)-incdir],
3142    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3143                   [directory with header files for using package $1]),
3144    [if test "$withval" = no ; then
3145       m4_tolower(coin_has_$1)=skipping
3146     else
3147       m4_tolower(coin_has_$1)=yes
3148       m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
3149       coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="-I`${CYGPATH_W} $withval` $m4_toupper(myvar)_CFLAGS"])
3150       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3151       if test -z "$PKG_CONFIG" ; then
3152         m4_toupper($1_CFLAGS_INSTALLED)="$m4_toupper($1_CFLAGS)"
3153         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1_CFLAGS) $m4_toupper(myvar)_CFLAGS_INSTALLED"])
3154       fi
3155     fi
3156    ],
3157    [])
3158fi
3159
3160if test $m4_tolower(coin_has_$1) != skipping; then
3161  AC_ARG_WITH([m4_tolower($1)-datadir],
3162    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3163                   [directory with data files for using package $1]),
3164    [if test "$withval" = no ; then
3165       m4_tolower(coin_has_$1)=skipping
3166     else
3167       m4_tolower(coin_has_$1)=yes
3168       m4_toupper($1_DATA)="$withval"
3169       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3170       if test -z "$PKG_CONFIG" ; then
3171         m4_toupper($1_DATA_INSTALLED)="$withval"
3172       fi
3173     fi
3174    ],
3175    [])
3176fi
3177
3178if test $m4_tolower(coin_has_$1) = notGiven; then
3179  if test -n "$PKG_CONFIG" ; then
3180    # set search path for pkg-config
3181    # need to export variable to be sure that the following pkg-config gets these values
3182    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3183    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
3184    export PKG_CONFIG_PATH
3185   
3186    # let pkg-config do it's magic
3187    AC_COIN_PKG_HAS_MODULE([$1],[$2],
3188      [ m4_tolower(coin_has_$1)=yes
3189        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
3190
3191        # adjust linker flags for (i)cl compiler
3192        # 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)
3193        if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3194        then
3195          m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3196        fi
3197   
3198        # augment X_PCREQUIRES, X_CFLAGS, and X_LIBS for each build target X in $3
3199        coin_foreach_w([myvar], [$3], [
3200          m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3201          m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3202          m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3203        ])
3204      ],
3205      [ m4_tolower(coin_has_$1)=notGiven
3206        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
3207      ])
3208
3209    # reset PKG_CONFIG_PATH variable
3210    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3211    export PKG_CONFIG_PATH
3212
3213  else
3214    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
3215    AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
3216  fi
3217
3218else
3219  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3220fi
3221
3222if test $m4_tolower(coin_has_$1) != skipping &&
3223   test $m4_tolower(coin_has_$1) != notGiven ; then
3224  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3225
3226  AC_ARG_ENABLE([interpackage-dependencies],
3227    AC_HELP_STRING([--enable-interpackage-dependencies], [whether to deduce Makefile dependencies from package linker flags (default: yes)]),
3228    [], [enable_interpackage_dependencies=yes])
3229   
3230  if test $enable_interpackage_dependencies = yes ; then
3231     # construct dependencies variables from LIBS variables
3232     # we add an extra space in LIBS so we can substitute out everything starting with " -"
3233     # remove everything of the form -framework xxx as used on Mac and mklxxx as used on Windows
3234     # then remove everything of the form -xxx
3235     # also remove everything of the form `xxx`yyy (may have been added for cygwin/cl)
3236     m4_toupper($1)_DEPENDENCIES=`echo " $m4_toupper($1)_LIBS" | [sed -e 's/ mkl[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
3237     coin_foreach_w([myvar], [$3], [
3238       m4_toupper(myvar)_DEPENDENCIES=`echo " $m4_toupper(myvar)_LIBS " | [sed -e 's/ mkl[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
3239     ])
3240  fi
3241
3242  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
3243    if test -n "$m4_toupper($1)_CFLAGS" ; then
3244      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3245    fi
3246    if test -n "$m4_toupper($1)_LIBS" ; then
3247      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
3248    fi
3249    if test -n "$m4_toupper($1)_DEPENDENCIES" ; then
3250      AC_MSG_NOTICE([$1 DEPENDENCIES are $m4_toupper($1)_DEPENDENCIES])
3251    fi
3252    if test -n "$m4_toupper($1)_DATA" ; then
3253      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
3254    fi
3255    if test -n "$m4_toupper($1)_CFLAGS" ; then
3256      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3257    fi
3258    coin_foreach_w([myvar], [$3], [
3259      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
3260      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
3261      AC_MSG_NOTICE([myvar DEPENDENCIES are $m4_toupper(myvar)_DEPENDENCIES])
3262    ])
3263  fi
3264fi
3265
3266# Define the Makefile conditional
3267AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3268               [test $m4_tolower(coin_has_$1) != notGiven &&
3269                test $m4_tolower(coin_has_$1) != skipping])
3270
3271]) # AC_COIN_CHECK_PACKAGE
3272
3273###########################################################################
3274#                       COIN_CHECK_PACKAGE_FALLBACK                       #
3275###########################################################################
3276
3277# This macro is used by COIN_CHECK_PACKAGE, if it fails to find a package
3278# because pkg-config was disabled or is not available.
3279#
3280# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc
3281# file in the directories specified in $COIN_PKG_CONFIG_PATH_UNINSTALLED. The
3282# latter variable is setup by COIN_HAS_PKGCONFIG and consists of the content
3283# of the coin_subdirs.txt file which has been created by configure in the
3284# base directory.  The content of xxx-uninstalled.pc is parsed in order
3285# to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
3286# referring to the compiler and linker flags to use when linking against this
3287# package and the directory where the package data resists.  Further, for each
3288# build target X specified in the third argument, the variables X_CFLAGS and
3289# X_LIBS are extended with the compiler and linker flags of this package and
3290# the variables X_PCLIBS and X_PCREQUIRES are extended by the list of linker
3291# flags and dependent projects as needed to setup a .pc file.  The macros
3292# checks also dependencies of $2.  Note that the PACKAGE_DATA variable is
3293# set to the content of datadir of the first .pc file that is parsed.
3294# Finally, for each X in the third argument, also variables
3295# X_CFLAGS_INSTALLED and X_LIBS_INSTALLED are setup. They contain the compiler
3296# and linker flags for X when all projects have been installed. Their content
3297# is assembled from the .pc files that correspond to installed projects. I.e.,
3298# whenever a file proj-uninstalled.pc is parsed, then also a corresponding
3299# proj.pc file is parsed for compiler and linker flags, if available in the
3300# same directory.
3301# Similar, a variable PACKAGE_DATA_INSTALLED is setup to the content of datadir
3302# of the first .pc file that is parsed.
3303#
3304# If .pc files for all projects in $2 and their dependencies is found,
3305# tolower(coin_has_$1) is set to "yes".  Otherwise, if some dependency
3306# is not found, tolower(coin_has_$1) is set to "notGiven".  Further, a
3307# COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
3308#
3309# The first argument should be the name (PACKAGE) of the package (in correct
3310# lower and upper case).  The second argument should be the base names of the
3311# projects .pc file which define this package.  The optional third argument
3312# should be a (space separated) list of build targets which use this package,
3313# if available.
3314#
3315# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into
3316# $COIN_PKG_CONFIG_PATH_UNINSTALLED.  When the content of this variable was
3317# setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
3318
3319AC_DEFUN([AC_COIN_CHECK_PACKAGE_FALLBACK],
3320[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3321AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
3322
3323m4_tolower(coin_has_$1)=notGiven
3324m4_toupper($1_LIBS)=
3325m4_toupper($1_LIBS_INSTALLED)=
3326m4_toupper($1_CFLAGS)=
3327m4_toupper($1_CFLAGS_INSTALLED)=
3328m4_toupper($1_DATA)=
3329m4_toupper($1_DATA_INSTALLED)=
3330
3331# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x)
3332projtoprocess="m4_bpatsubsts([$2], [<?>?=[      ]*[^    ]+])"
3333
3334# we first expand the list of projects to process by adding all dependencies just behind the project which depends on it
3335# further, we collect the list of corresponding .pc files, but do this in reverse order, because we need this order afterwards
3336# the latter we also do with .pc files corresponding to the installed projects, which will be needed to setup Makefiles for examples
3337# also, we setup the DATA variable
3338allproj=""
3339allpcfiles=""
3340allpcifiles=""
3341while test "x$projtoprocess" != x ; do
3342
3343  for proj in $projtoprocess ; do
3344    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
3345    pcfile=""
3346    save_IFS="$IFS"
3347    IFS=":"
3348    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
3349      # 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
3350      if test -r "$dir/${proj}-uninstalled.pc" ; then
3351        pcfile="$dir/$proj-uninstalled.pc"
3352        if test -r "$dir/${proj}.pc" ; then
3353          pcifile="$dir/${proj}.pc"
3354        else
3355          AC_MSG_WARN([Found $pcfile, but $dir/${proj}.pc is not available. This may break Makefile's of examples.])
3356          pcifile=
3357        fi
3358        break
3359      fi
3360    done
3361    IFS="$save_IFS"
3362
3363    if test "x$pcfile" != x ; then
3364      # read dependencies from $pcfile and filter it
3365      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\{0,1\}>\{0,1\}=[       ]\{0,\}[^       ]\{1,\}//g'`]
3366
3367      # add projrequires to the front of the list of projects that have to be processed next
3368      # at the same time, remove $proj from this list
3369      projtoprocess=${projtoprocess/$proj/$projrequires}
3370
3371      # read DATA from $pcfile, if _DATA is still empty
3372      if test "x$m4_toupper($1_DATA)" = x ; then
3373        projdatadir=
3374        [pcfilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcfile`]
3375        eval `sh -c "$pcfilemod"`
3376        m4_toupper($1_DATA)="$projdatadir"
3377      fi
3378
3379      allproj="$allproj $proj"
3380      allpcfiles="$pcfile:$allpcfiles"
3381
3382    else
3383      AC_MSG_RESULT([no, dependency $proj not available])
3384      allproj=fail
3385      break 2
3386    fi
3387   
3388    if test "x$pcifile" != x ; then
3389      allpcifiles="$pcifile:$allpcifiles"
3390     
3391      # read DATA_INSTALLED from $pcifile, if _DATA_INSTALLED is still empty
3392      if test "x$m4_toupper($1_DATA_INSTALLED)" = x ; then
3393        projdatadir=
3394        [pcifilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcifile`]
3395        eval `sh -c "$pcifilemod"`
3396        if test "${CYGPATH_W}" != "echo"; then
3397          projdatadir="\`\$(CYGPATH_W) ${projdatadir} | sed -e 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g'\`"
3398        fi
3399        m4_toupper($1_DATA_INSTALLED)="$projdatadir"
3400      fi
3401     
3402    fi
3403
3404    break
3405  done
3406
3407  # remove spaces on begin of $projtoprocess
3408  projtoprocess=`echo $projtoprocess | sed -e 's/^[ ]*//'`
3409
3410done
3411
3412if test "$allproj" != fail ; then
3413
3414  # now go through the list of .pc files and assemble compiler and linker flags
3415  # important is here to obey the reverse order that has been setup before,
3416  # since then libraries that are required by several others should be after these other libraries
3417  pcfilesprocessed=""
3418
3419  save_IFS="$IFS"
3420  IFS=":"
3421  for pcfile in $allpcfiles ; do
3422
3423    # if $pcfile has been processed already, skip this round
3424    if test "x$pcfilesprocessed" != x ; then
3425      for pcfiledone in $pcfilesprocessed ; do
3426        if test "$pcfiledone" = "$pcfile" ; then
3427          continue 2
3428        fi
3429      done
3430    fi
3431
3432    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3433    #   replace "Libs:" by "echo projlibs="
3434    #   replace "Cflags:" by "echo projcflags="
3435    #   remove every line starting with <some word>:
3436    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
3437
3438    # set projcflags and projlibs variables by running $pcfilemod
3439    projcflags=
3440    projlibs=
3441    eval `sh -c "$pcfilemod"`
3442
3443    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3444    if test "${CYGPATH_W}" != "echo"; then
3445      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3446    fi
3447    m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
3448
3449    # set LIBS variable
3450    m4_toupper($1_LIBS)="$projlibs $m4_toupper($1_LIBS)"
3451
3452    # remember that we have processed $pcfile
3453    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3454
3455  done
3456  IFS="$save_IFS"
3457
3458
3459  # now go through the list of .pc files for installed projects and assemble compiler and linker flags
3460  # important is here again to obey the reverse order that has been setup before,
3461  # since then libraries that are required by several others should be after these other libraries
3462  pcfilesprocessed=""
3463
3464  save_IFS="$IFS"
3465  IFS=":"
3466  for pcfile in $allpcifiles ; do
3467
3468    # if $pcfile has been processed already, skip this round
3469    if test "x$pcfilesprocessed" != x ; then
3470      for pcfiledone in $pcfilesprocessed ; do
3471        if test "$pcfiledone" = "$pcfile" ; then
3472          continue 2
3473        fi
3474      done
3475    fi
3476
3477    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3478    #   replace "Libs:" by "echo projlibs="
3479    #   replace "Cflags:" by "echo projcflags="
3480    #   remove every line starting with <some word>:
3481    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
3482
3483    # set projcflags and projlibs variables by running $pcfilemod
3484    projcflags=
3485    projlibs=
3486    eval `sh -c "$pcfilemod"`
3487
3488    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3489    if test "${CYGPATH_W}" != "echo"; then
3490      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3491    fi
3492    m4_toupper($1_CFLAGS_INSTALLED)="$projcflags $m4_toupper($1_CFLAGS_INSTALLED)"
3493
3494    # set LIBS variable
3495    m4_toupper($1_LIBS_INSTALLED)="$projlibs $m4_toupper($1_LIBS_INSTALLED)"
3496   
3497    # remember that we have processed $pcfile
3498    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3499
3500  done
3501  IFS="$save_IFS"
3502
3503
3504  # finish up
3505  m4_tolower(coin_has_$1)=yes
3506  AC_MSG_RESULT([yes])
3507  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3508
3509  # adjust linker flags for (i)cl compiler
3510  # 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),
3511  # for the LIBS_INSTALLED, we replace everything of the form "/somepath/" by "`$(CYGPATH_W) /somepath/`",
3512  #    everything of the form "-Lpath" by "/libpath:`$(CYGPATH_W) path`, and
3513  #    everything of the form "-lname" by "libname.lib"
3514  if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3515  then
3516    m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3517    m4_toupper($1_LIBS_INSTALLED)=`echo " $m4_toupper($1_LIBS_INSTALLED)" | [sed -e 's/ \(\/[^ ]*\/\)/ \`$(CYGPATH_W) \1\`/g' -e 's/ -L\([^ ]*\)/ \/libpath:\`$(CYGPATH_W) \1\`/g' -e 's/ -l\([^ ]*\)/ lib\1.lib/g']`
3518  fi
3519
3520  coin_foreach_w([myvar], [$3], [
3521    m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3522    m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3523    m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3524    m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1)_CFLAGS_INSTALLED $m4_toupper(myvar)_CFLAGS_INSTALLED"
3525    m4_toupper(myvar)_LIBS_INSTALLED="$m4_toupper($1)_LIBS_INSTALLED $m4_toupper(myvar)_LIBS_INSTALLED"
3526  ])
3527
3528fi
3529
3530AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3531               [test $m4_tolower(coin_has_$1) != notGiven &&
3532                test $m4_tolower(coin_has_$1) != skipping])
3533
3534]) # AC_COIN_CHECK_PACKAGE_FALLBACK
3535
3536###########################################################################
3537#                         COIN_CHECK_PACKAGE_BLAS                         #
3538###########################################################################
3539
3540# This macro checks for a library containing the BLAS library.  It
3541# 1. checks the --with-blas argument
3542# 2. if --with-blas=BUILD has been specified goes to point 5
3543# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
3544#    to its value
3545# 4. tries standard libraries
3546# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
3547#    ThirdParty/Blas
3548# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
3549# BLAS_LIBS is set to the flags required to link with a Blas library.
3550# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
3551# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
3552# In case 5, Blas is added to X_PCREQUIRES.
3553
3554AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
3555[
3556AC_ARG_WITH([blas],
3557            AC_HELP_STRING([--with-blas],
3558                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
3559            [use_blas="$withval"], [use_blas=])
3560
3561# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
3562# preference
3563AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
3564
3565# Check if user supplied option makes sense
3566if test x"$use_blas" != x; then
3567  if test "$use_blas" = "BUILD"; then
3568    # we come to this later
3569    :
3570  elif test "$use_blas" != "no"; then
3571    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
3572    coin_need_flibs=no
3573    coin_save_LIBS="$LIBS"
3574    LIBS="$use_blas $LIBS"
3575    AC_COIN_TRY_FLINK([daxpy],
3576                      [if test $coin_need_flibs = yes ; then
3577                         use_blas="$use_blas $FLIBS"
3578                       fi
3579                       AC_MSG_RESULT([yes: $use_blas])],
3580                      [AC_MSG_RESULT([no])
3581                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
3582    LIBS="$coin_save_LIBS"
3583  fi
3584else
3585# Try to autodetect the library for blas based on build system
3586  #AC_MSG_CHECKING([default locations for BLAS])
3587  skip_lblas_check=no
3588  case $build in
3589    *-sgi-*)
3590      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
3591      coin_need_flibs=no
3592      coin_save_LIBS="$LIBS"
3593      LIBS="-lcomplib.sgimath $LIBS"
3594      AC_COIN_TRY_FLINK([daxpy],
3595                        [use_blas="-lcomplib.sgimath"
3596                         if test $coin_need_flibs = yes ; then
3597                           use_blas="$use_blas $FLIBS"
3598                         fi
3599                         AC_MSG_RESULT([yes: $use_blas])
3600                        ],
3601                        [AC_MSG_RESULT([no])])
3602      LIBS="$coin_save_LIBS"
3603      ;;
3604
3605# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
3606# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
3607# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
3608# that CC and cc will understand -library in Studio 13. The main extra
3609# function of -xlic_lib and -library is to arrange for the Fortran run-time
3610# libraries to be linked for C++ and C. We can arrange that explicitly.
3611    *-*-solaris*)
3612      AC_MSG_CHECKING([for BLAS in libsunperf])
3613      coin_need_flibs=no
3614      coin_save_LIBS="$LIBS"
3615      LIBS="-lsunperf $FLIBS $LIBS"
3616      AC_COIN_TRY_FLINK([daxpy],
3617                        [use_blas='-lsunperf'
3618                         if test $coin_need_flibs = yes ; then
3619                           use_blas="$use_blas $FLIBS"
3620                         fi
3621                         AC_MSG_RESULT([yes: $use_blas])
3622                        ],
3623                        [AC_MSG_RESULT([no])])
3624      LIBS="$coin_save_LIBS"
3625      ;;
3626     
3627    *-cygwin* | *-mingw*)
3628# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
3629# library will want to link with cygwin, hence won't run standalone in DOS.
3630      if test "$enable_doscompile" = mingw; then
3631        skip_lblas_check=yes
3632      fi
3633      case "$CC" in
3634        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
3635          coin_save_LIBS="$LIBS"
3636          AC_MSG_CHECKING([for BLAS in MKL (32bit)])
3637          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
3638          AC_COIN_TRY_FLINK([daxpy],
3639                            [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
3640                             AC_MSG_RESULT([yes: $use_blas])
3641                            ],
3642                            [AC_MSG_RESULT([no])])
3643          LIBS="$coin_save_LIBS"
3644         
3645          if test "x$use_blas" = x ; then
3646            AC_MSG_CHECKING([for BLAS in MKL (64bit)])
3647            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
3648            AC_COIN_TRY_FLINK([daxpy],
3649                              [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
3650                               AC_MSG_RESULT([yes: $use_blas])
3651                              ],
3652                              [AC_MSG_RESULT([no])])
3653            LIBS="$coin_save_LIBS"
3654          fi
3655          ;;
3656      esac
3657      ;;
3658     
3659     *-darwin*)
3660      AC_MSG_CHECKING([for BLAS in Veclib])
3661      coin_need_flibs=no
3662      coin_save_LIBS="$LIBS"
3663      LIBS="-framework vecLib $LIBS"
3664      AC_COIN_TRY_FLINK([daxpy],
3665                        [use_blas='-framework vecLib'
3666                         if test $coin_need_flibs = yes ; then
3667                           use_blas="$use_blas $FLIBS"
3668                         fi
3669                         AC_MSG_RESULT([yes: $use_blas])
3670                        ],
3671                        [AC_MSG_RESULT([no])])
3672      LIBS="$coin_save_LIBS"
3673      ;;
3674  esac
3675
3676  if test -z "$use_blas" && test $skip_lblas_check = no; then
3677    AC_MSG_CHECKING([whether -lblas has BLAS])
3678    coin_need_flibs=no
3679    coin_save_LIBS="$LIBS"
3680    LIBS="-lblas $LIBS"
3681    AC_COIN_TRY_FLINK([daxpy],
3682                      [use_blas='-lblas'
3683                       if test $coin_need_flibs = yes ; then
3684                         use_blas="$use_blas $FLIBS"
3685                       fi
3686                       AC_MSG_RESULT([yes: $use_blas])
3687                      ],
3688                      [AC_MSG_RESULT([no])])
3689    LIBS="$coin_save_LIBS"
3690  fi
3691
3692  # If we have no other ideas, consider building BLAS.
3693  if test -z "$use_blas" ; then
3694    use_blas=BUILD
3695  fi
3696fi
3697
3698if test "x$use_blas" = xBUILD ; then
3699  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
3700 
3701elif test "x$use_blas" != x && test "$use_blas" != no; then
3702  coin_has_blas=yes
3703  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
3704  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
3705  BLAS_LIBS="$use_blas"
3706  BLAS_CFLAGS=
3707  BLAS_DATA=
3708  AC_SUBST(BLAS_LIBS)
3709  AC_SUBST(BLAS_CFLAGS)
3710  AC_SUBST(BLAS_DATA)
3711  coin_foreach_w([myvar], [$1], [
3712    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
3713    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
3714    m4_toupper(myvar)_LIBS_INSTALLED="$BLAS_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
3715  ])
3716 
3717else
3718  coin_has_blas=no
3719  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
3720fi
3721
3722coin_foreach_w([myvar], [$1], [
3723  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3724  AC_SUBST(m4_toupper(myvar)_LIBS)
3725  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3726])
3727
3728]) # AC_COIN_CHECK_PACKAGE_BLAS
3729
3730###########################################################################
3731#                       COIN_CHECK_PACKAGE_LAPACK                         #
3732###########################################################################
3733
3734# This macro checks for a library containing the LAPACK library.  It
3735# 1. checks the --with-lapack argument
3736# 2. if --with-lapack=BUILD has been specified goes to point 5
3737# 3. if --with-lapack has been specified to a working library, sets
3738#    LAPACK_LIBS to its value
3739# 4. tries standard libraries
3740# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
3741#    ThirdParty/Lapack
3742# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
3743# LAPACK_LIBS is set to the flags required to link with a Lapack library.
3744# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
3745# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
3746# In case 5, Lapack is added to X_PCREQUIRES.
3747#
3748# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
3749#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
3750#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
3751#   then we will get Blas as dependency of coinlapack.
3752
3753AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
3754[
3755AC_ARG_WITH([lapack],
3756            AC_HELP_STRING([--with-lapack],
3757                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
3758            [use_lapack=$withval], [use_lapack=])
3759
3760#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
3761AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
3762
3763# Check if user supplied option makes sense
3764if test x"$use_lapack" != x; then
3765  if test "$use_lapack" = "BUILD"; then
3766    # we come to this later
3767    :
3768  elif test "$use_lapack" != no; then
3769    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
3770    coin_need_flibs=no
3771    use_lapack="$use_lapack $BLAS_LIBS"
3772    coin_save_LIBS="$LIBS"
3773    LIBS="$use_lapack $LIBS"
3774    AC_COIN_TRY_FLINK([dsyev],
3775                      [if test $coin_need_flibs = yes ; then
3776                         use_lapack="$use_lapack $FLIBS"
3777                       fi
3778                       AC_MSG_RESULT([yes: $use_lapack])
3779                      ],
3780                      [AC_MSG_RESULT([no])
3781                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
3782    LIBS="$coin_save_LIBS"
3783  fi
3784else
3785  if test x$coin_has_blas = xyes; then
3786    # First try to see if LAPACK is already available with BLAS library
3787    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
3788    coin_save_LIBS="$LIBS"
3789    coin_need_flibs=no
3790    LIBS="$BLAS_LIBS $LIBS"
3791    AC_COIN_TRY_FLINK([dsyev],
3792                      [use_lapack="$BLAS_LIBS"
3793                       if test $coin_need_flibs = yes ; then
3794                         use_lapack="$use_lapack $FLIBS"
3795                       fi
3796                       AC_MSG_RESULT([yes: $use_lapack])
3797                      ],
3798                      [AC_MSG_RESULT([no])])
3799    LIBS="$coin_save_LIBS"
3800  fi
3801  skip_llapack_check=no
3802  if test -z "$use_lapack"; then
3803    # Try to autodetect the library for lapack based on build system
3804    case $build in
3805      # TODO: Is this check actually needed here, since -lcomplib.sigmath should have been recognized as Blas library,
3806      #       and above it is checked whether the Blas library already contains Lapack
3807      *-sgi-*)
3808        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
3809        coin_save_LIBS="$LIBS"
3810        coin_need_flibs=no
3811        LIBS="-lcomplib.sgimath $BLAS_LIBS $LIBS"
3812        AC_COIN_TRY_FLINK([dsyev],
3813                          [use_lapack="-lcomplib.sgimath $BLAS_LIBS"
3814                           if test $coin_need_flibs = yes ; then
3815                             use_lapack="$use_lapack $FLIBS"
3816                           fi
3817                           AC_MSG_RESULT([yes: $use_lapack])
3818                          ],
3819                          [AC_MSG_RESULT([no])])
3820        LIBS="$coin_save_LIBS"
3821        ;;
3822
3823      # See comments in COIN_CHECK_PACKAGE_BLAS.
3824      # TODO: Is this check actually needed here, since -lsunperf should have been recognized as Blas library,
3825      #       and above it is checked whether the Blas library already contains Lapack
3826      *-*-solaris*)
3827        AC_MSG_CHECKING([for LAPACK in libsunperf])
3828        coin_need_flibs=no
3829        coin_save_LIBS="$LIBS"
3830        LIBS="-lsunperf $BLAS_LIBS $FLIBS $LIBS"
3831        AC_COIN_TRY_FLINK([dsyev],
3832                          [use_lapack='-lsunperf $BLAS_LIBS'
3833                           if test $coin_need_flibs = yes ; then
3834                             use_lapack="$use_lapack $FLIBS"
3835                           fi
3836                           AC_MSG_RESULT([yes: $use_lapack])
3837                          ],
3838                          [AC_MSG_RESULT([no])])
3839        LIBS="$coin_save_LIBS"
3840        ;;
3841        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
3842        # will want to link with cygwin, hence won't run standalone in DOS.
3843       
3844      *-cygwin*)
3845        if test "$enable_doscompile" = mingw; then
3846          skip_llapack_check=yes
3847        fi
3848        ;;
3849       
3850    esac
3851  fi
3852
3853  if test -z "$use_lapack" && test $skip_llapack_check = no; then
3854    AC_MSG_CHECKING([whether -llapack has LAPACK])
3855    coin_need_flibs=no
3856    coin_save_LIBS="$LIBS"
3857    LIBS="-llapack $BLAS_LIBS $LIBS"
3858    AC_COIN_TRY_FLINK([dsyev],
3859                      [use_lapack='-llapack'
3860                       if test $coin_need_flibs = yes ; then
3861                         use_lapack="$use_lapack $FLIBS"
3862                       fi
3863                       AC_MSG_RESULT([yes: $use_lapack])
3864                      ],
3865                      [AC_MSG_RESULT([no])])
3866    LIBS="$coin_save_LIBS"
3867  fi
3868
3869  # If we have no other ideas, consider building LAPACK.
3870  if test -z "$use_lapack" ; then
3871    use_lapack=BUILD
3872  fi
3873fi
3874
3875if test "x$use_lapack" = xBUILD ; then
3876  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
3877
3878elif test "x$use_lapack" != x && test "$use_lapack" != no; then
3879  coin_has_lapack=yes
3880  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
3881  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
3882  LAPACK_LIBS="$use_lapack"
3883  LAPACK_CFLAGS=
3884  LAPACK_DATA=
3885  AC_SUBST(LAPACK_LIBS)
3886  AC_SUBST(LAPACK_CFLAGS)
3887  AC_SUBST(LAPACK_DATA)
3888  coin_foreach_w([myvar], [$1], [
3889    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
3890    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
3891    m4_toupper(myvar)_LIBS_INSTALLED="$LAPACK_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
3892  ])
3893 
3894else
3895  coin_has_lapack=no
3896  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
3897fi
3898
3899coin_foreach_w([myvar], [$1], [
3900  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3901  AC_SUBST(m4_toupper(myvar)_LIBS)
3902  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3903])
3904
3905]) # AC_COIN_CHECK_PACKAGE_LAPACK
Note: See TracBrowser for help on using the repository browser.