source: stable/0.7/coin.m4

Last change on this file was 3273, checked in by tkr, 6 years ago

Fix for vecLib on OS X

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