source: trunk/coin.m4 @ 3045

Last change on this file since 3045 was 3045, checked in by stefan, 8 years ago

patch by T. Kelman to setup proper CXXLIBS when clang is used

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