source: trunk/coin.m4 @ 2362

Last change on this file since 2362 was 2335, checked in by andreasw, 8 years ago

type in quotation

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