source: trunk/coin.m4 @ 3007

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

allow --enable-msvc=MD as equivalent for --enable-msvc --enable-shared

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