source: stable/0.7/coin.m4 @ 2891

Last change on this file since 2891 was 2891, checked in by tkr, 7 years ago

Merging r2866:2880 from trunk

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