source: trunk/coin.m4 @ 2304

Last change on this file since 2304 was 2304, checked in by stefan, 9 years ago

add COIN_CHECK_ISFINITE and COIN_CHECK_ISNAN (copied from CoinUtils?)

  • Property svn:keywords set to Author Date Id Revision
File size: 148.2 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 2304 2011-06-18 14:42:19Z 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  # On AIX, the default sed cannot deal with somewhat long sed commands executed by config.status.
2012  # So we reduce the hardcoded number of commands given to sed from 48 to 5 in config.status, hoping this will suffice.
2013  AC_CONFIG_COMMANDS_POST([
2014    case $build in
2015      *-aix*)
2016        AC_MSG_NOTICE(patching config.status to reduce ac_max_sed_lines to 5)
2017        sed -e 's/ac_max_sed_lines=48/ac_max_sed_lines=5/g' config.status > config.status.tmp
2018        mv config.status.tmp config.status
2019      ;;
2020    esac
2021  ])
2022 
2023  AC_OUTPUT
2024
2025  if test x"$coin_vpath_link_files" = x; then : ; else
2026    lnkcmd="$coin_link_input_cmd"
2027    if test "$lnkcmd" = cp; then
2028      AC_MSG_NOTICE(Copying data files for VPATH configuration)
2029    else
2030      AC_MSG_NOTICE(Creating VPATH links for data files)
2031    fi
2032    for file in $coin_vpath_link_files; do
2033      dir=`AS_DIRNAME(["./$file"])`
2034      if test -d $dir; then : ; else
2035        AS_MKDIR_P($dir)
2036      fi
2037      rm -f $file
2038      $lnkcmd $abs_source_dir/$file $file
2039    done
2040  fi
2041
2042  AC_MSG_NOTICE([In case of trouble, first consult the troubleshooting page at https://projects.coin-or.org/BuildTools/wiki/user-troubleshooting])
2043  if test x$coin_projectdir = xyes; then
2044    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
2045  else
2046    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
2047  fi
2048else
2049  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
2050fi
2051
2052]) #AC_COIN_FINALIZE
2053
2054###########################################################################
2055#                             COIN_VPATH_LINK                             #
2056###########################################################################
2057
2058# This macro queues source files that need to be available in the build
2059# directory. In a VPATH configuration, the files will be made available by
2060# symbolic link or copy (when the platform does not support links). The list
2061# is processed by COIN_FINALIZE. The parameter is a whitespace-separated
2062# list of files.
2063
2064AC_DEFUN([AC_COIN_VPATH_LINK],
2065[
2066AC_REQUIRE([AC_COIN_CHECK_VPATH])
2067# Allow for newlines in the parameter
2068if test $coin_vpath_config = yes; then
2069  cvl_tmp="$1"
2070  for file in $cvl_tmp ; do
2071    coin_vpath_link_files="$coin_vpath_link_files $file"
2072  done
2073fi
2074]) #AC_COIN_VPATH_LINK
2075
2076###########################################################################
2077#                       COIN_ENABLE_GNU_PACKAGES                          #
2078###########################################################################
2079
2080# This macro defined the --enable-gnu-packages flag.  This can be used
2081# to check if a user wants to compile GNU packges (such as readline or
2082# zlib) into the executable.  By default, GNU packages are disabled.
2083# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
2084
2085AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
2086[AC_ARG_ENABLE([gnu-packages],
2087               [AC_HELP_STRING([--enable-gnu-packages],
2088                               [compile with GNU packages (disabled by default)])],
2089               [coin_enable_gnu=$enableval],
2090               [coin_enable_gnu=no])
2091]) # AC_COIN_ENABLE_GNU_PACKAGES
2092
2093#######################################################################
2094#                           COIN_CHECK_LIBM                           #
2095#######################################################################
2096
2097# For a (space separated) list of arguments X, this macro adds the flags
2098# for linking against the math library to a X_LIBS and X_PCLIBS.
2099
2100AC_DEFUN([AC_COIN_CHECK_LIBM],
2101[AC_BEFORE([AC_COIN_PROG_CC],[$0])
2102
2103case "$CC" in
2104  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2105    ;;
2106  *)
2107    coin_foreach_w([myvar], [$1], [
2108      m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"
2109      m4_toupper(myvar)_PCLIBS="-lm $m4_toupper(myvar)_PCLIBS"
2110      m4_toupper(myvar)_LIBS_INSTALLED="-lm $m4_toupper(myvar)_LIBS_INSTALLED"
2111    ])
2112  ;;
2113esac
2114
2115]) # AC_COIN_CHECK_LIBM
2116
2117###########################################################################
2118#                           COIN_CHECK_GNU_ZLIB                           #
2119###########################################################################
2120
2121# This macro checks for the libz library.  If found, it sets the automake
2122# conditional COIN_HAS_ZLIB and defines the C preprocessor variable
2123# COIN_HAS_ZLIB.  Further, for a (space separated) list of arguments X,
2124# it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2125
2126AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2127[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2128AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2129AC_BEFORE([AC_COIN_PROG_CC],[$0])
2130AC_BEFORE([AC_COIN_PROG_F77],[$0])
2131AC_BEFORE([$0],[AC_COIN_FINALIZE])
2132
2133coin_has_zlib=no
2134if test $coin_enable_gnu = yes; then
2135  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2136
2137  if test $coin_has_zlib = yes; then
2138    AC_CHECK_LIB([z],[gzopen],
2139                 [coin_foreach_w([myvar], [$1], [
2140                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
2141                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
2142                    m4_toupper(myvar)_LIBS_INSTALLED="-lz $m4_toupper(myvar)_LIBS_INSTALLED"
2143                  ])
2144                 :],
2145                 [coin_has_zlib=no])
2146  fi
2147
2148  if test $coin_has_zlib = yes; then
2149    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2150  fi
2151fi
2152
2153AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2154]) # AC_COIN_CHECK_GNU_ZLIB
2155
2156
2157###########################################################################
2158#                          COIN_CHECK_GNU_BZLIB                           #
2159###########################################################################
2160
2161# This macro checks for the libbz2 library.  If found, it defines the C
2162# preprocessor variable COIN_HAS_BZLIB.  Further, for a (space separated) list
2163# of arguments X, it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2164
2165AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2166[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2167AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2168AC_BEFORE([AC_COIN_PROG_CC],[$0])
2169AC_BEFORE([AC_COIN_PROG_F77],[$0])
2170AC_BEFORE([$0],[AC_COIN_FINALIZE])
2171
2172coin_has_bzlib=no
2173if test $coin_enable_gnu = yes; then
2174  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2175
2176  if test $coin_has_bzlib = yes; then
2177    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2178                 [coin_foreach_w([myvar], [$1], [
2179                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
2180                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
2181                    m4_toupper(myvar)_LIBS_INSTALLED="-lbz2 $m4_toupper(myvar)_LIBS_INSTALLED"
2182                  ])
2183                 :],
2184                 [coin_has_bzlib=no])
2185  fi
2186
2187  if test $coin_has_bzlib = yes; then
2188    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2189  fi
2190fi
2191]) # AC_COIN_CHECK_GNU_BZLIB
2192
2193
2194###########################################################################
2195#                         COIN_CHECK_GNU_READLINE                         #
2196###########################################################################
2197
2198# This macro checks for GNU's readline.  It verifies that the header
2199# readline/readline.h is available, and that the -lreadline library
2200# contains "readline".  It is assumed that #include <stdio.h> is included
2201# in the source file before the #include<readline/readline.h>
2202# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
2203# Further, for a (space separated) list of arguments X, it adds the
2204# linker flag to the variable X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2205
2206AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2207[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2208AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2209AC_BEFORE([AC_COIN_PROG_CC],[$0])
2210AC_BEFORE([AC_COIN_PROG_F77],[$0])
2211AC_BEFORE([$0],[AC_COIN_FINALIZE])
2212
2213coin_has_readline=no
2214if test $coin_enable_gnu = yes; then
2215  AC_COIN_CHECK_HEADER([readline/readline.h],
2216                       [coin_has_readline=yes],[],
2217                       [#include <stdio.h>])
2218
2219  coin_save_LIBS="$LIBS"
2220  LIBS=
2221  # First we check if tputs and friends are available
2222  if test $coin_has_readline = yes; then
2223    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2224                   [coin_has_readline=no])
2225  fi
2226
2227  # Now we check for readline
2228  if test $coin_has_readline = yes; then
2229    AC_CHECK_LIB([readline],[readline],
2230                 [coin_foreach_w([myvar], [$1], [
2231                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
2232                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
2233                    m4_toupper(myvar)_LIBS_INSTALLED="-lreadline $LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
2234                  ])
2235                 :],
2236                 [coin_has_readline=no])
2237  fi
2238
2239  if test $coin_has_readline = yes; then
2240    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2241  fi
2242
2243  LIBS="$coin_save_LIBS"
2244fi
2245]) # AC_COIN_CHECK_GNU_READLINE
2246
2247###########################################################################
2248#                            COIN_CHECK_ISFINITE                          #
2249###########################################################################
2250
2251# This macro checks for a usable implementation of a function to check
2252# whether a given floating point number is finite.
2253# If a function is found, then the macro defines the symbol
2254# toupper($1)_C_FINITE to the name of this function.
2255
2256AC_DEFUN([AC_COIN_CHECK_ISFINITE],[
2257
2258AC_LANG_PUSH(C++)
2259
2260AC_COIN_CHECK_CXX_CHEADER(math)
2261AC_COIN_CHECK_CXX_CHEADER(float)
2262AC_COIN_CHECK_CXX_CHEADER(ieeefp)
2263
2264m4_toupper($1)_C_FINITE=
2265AC_CHECK_DECL([finite],[m4_toupper($1)_C_FINITE=finite],,[
2266#ifdef HAVE_CMATH
2267# include <cmath>
2268#else
2269# ifdef HAVE_MATH_H
2270#  include <math.h>
2271# endif
2272#endif
2273#ifdef HAVE_CFLOAT
2274# include <cfloat>
2275#else
2276# ifdef HAVE_FLOAT_H
2277#  include <float.h>
2278# endif
2279#endif
2280#ifdef HAVE_CIEEEFP
2281# include <cieeefp>
2282#else
2283# ifdef HAVE_IEEEFP_H
2284#  include <ieeefp.h>
2285# endif
2286#endif])
2287if test -z "$m4_toupper($1)_C_FINITE"; then
2288  AC_CHECK_DECL([_finite],[m4_toupper($1)_C_FINITE=_finite],,[
2289#ifdef HAVE_CMATH
2290# include <cmath>
2291#else
2292# ifdef HAVE_MATH_H
2293#  include <math.h>
2294# endif
2295#endif
2296#ifdef HAVE_CFLOAT
2297# include <cfloat>
2298#else
2299# ifdef HAVE_FLOAT_H
2300#  include <float.h>
2301# endif
2302#endif
2303#ifdef HAVE_CIEEEFP
2304# include <cieeefp>
2305#else
2306# ifdef HAVE_IEEEFP_H
2307#  include <ieeefp.h>
2308# endif
2309#endif])
2310  if test -z "$m4_toupper($1)_C_FINITE"; then
2311    AC_CHECK_DECL([isfinite],[m4_toupper($1)_C_FINITE=isfinite],,[
2312#ifdef HAVE_CMATH
2313# include <cmath>
2314#else
2315# ifdef HAVE_MATH_H
2316#  include <math.h>
2317# endif
2318#endif
2319#ifdef HAVE_CFLOAT
2320# include <cfloat>
2321#else
2322# ifdef HAVE_FLOAT_H
2323#  include <float.h>
2324# endif
2325#endif
2326#ifdef HAVE_CIEEEFP
2327# include <cieeefp>
2328#else
2329# ifdef HAVE_IEEEFP_H
2330#  include <ieeefp.h>
2331# endif
2332#endif])
2333  fi
2334fi
2335if test -z "$m4_toupper($1)_C_FINITE"; then
2336  AC_MSG_WARN(Cannot find C-function for checking Inf.)
2337else
2338  AC_DEFINE_UNQUOTED(m4_toupper($1)_C_FINITE,[$m4_toupper($1)_C_FINITE],
2339                     [Define to be the name of C-function for Inf check])
2340fi
2341
2342AC_LANG_POP(C++)
2343])
2344
2345###########################################################################
2346#                              COIN_CHECK_ISNAN                           #
2347###########################################################################
2348
2349# This macro checks for a usable implementation of a function to check
2350# whether a given floating point number represents NaN.
2351# If a function is found, then the macro defines the symbol
2352# toupper($1)_C_ISNAN to the name of this function.
2353
2354AC_DEFUN([AC_COIN_CHECK_ISNAN],[
2355
2356AC_LANG_PUSH(C++)
2357
2358AC_COIN_CHECK_CXX_CHEADER(math)
2359AC_COIN_CHECK_CXX_CHEADER(float)
2360AC_COIN_CHECK_CXX_CHEADER(ieeefp)
2361
2362m4_toupper($1)_C_ISNAN=
2363AC_CHECK_DECL([isnan],[m4_toupper($1)_C_ISNAN=isnan],,[
2364#ifdef HAVE_CMATH
2365# include <cmath>
2366#else
2367# ifdef HAVE_MATH_H
2368#  include <math.h>
2369# endif
2370#endif
2371#ifdef HAVE_CFLOAT
2372# include <cfloat>
2373#else
2374# ifdef HAVE_FLOAT_H
2375#  include <float.h>
2376# endif
2377#endif
2378#ifdef HAVE_CIEEEFP
2379# include <cieeefp>
2380#else
2381# ifdef HAVE_IEEEFP_H
2382#  include <ieeefp.h>
2383# endif
2384#endif])
2385
2386# It appears that for some systems (e.g., Mac OSX), cmath will provide only
2387# std::isnan, and bare isnan will be unavailable. Typically we need a parameter
2388# in the test to allow C++ to do overload resolution.
2389
2390if test -z "$m4_toupper($1)_C_ISNAN"; then
2391  AC_CHECK_DECL([std::isnan(42.42)],[m4_toupper($1)_C_ISNAN=std::isnan],,[
2392#ifdef HAVE_CMATH
2393# include <cmath>
2394#else
2395# ifdef HAVE_MATH_H
2396#  include <math.h>
2397# endif
2398#endif
2399#ifdef HAVE_CFLOAT
2400# include <cfloat>
2401#else
2402# ifdef HAVE_FLOAT_H
2403#  include <float.h>
2404# endif
2405#endif
2406#ifdef HAVE_CIEEEFP
2407# include <cieeefp>
2408#else
2409# ifdef HAVE_IEEEFP_H
2410#  include <ieeefp.h>
2411# endif
2412#endif])
2413fi
2414
2415if test -z "$m4_toupper($1)_C_ISNAN"; then
2416  AC_CHECK_DECL([_isnan],[m4_toupper($1)_C_ISNAN=_isnan],,[
2417#ifdef HAVE_CMATH
2418# include <cmath>
2419#else
2420# ifdef HAVE_MATH_H
2421#  include <math.h>
2422# endif
2423#endif
2424#ifdef HAVE_CFLOAT
2425# include <cfloat>
2426#else
2427# ifdef HAVE_FLOAT_H
2428#  include <float.h>
2429# endif
2430#endif
2431#ifdef HAVE_CIEEEFP
2432# include <cieeefp>
2433#else
2434# ifdef HAVE_IEEEFP_H
2435#  include <ieeefp.h>
2436# endif
2437#endif])
2438fi
2439if test -z "$m4_toupper($1)_C_ISNAN"; then
2440  AC_CHECK_DECL([isnand],[m4_toupper($1)_C_ISNAN=isnand],,[
2441#ifdef HAVE_CMATH
2442# include <cmath>
2443#else
2444# ifdef HAVE_MATH_H
2445#  include <math.h>
2446# endif
2447#endif
2448#ifdef HAVE_CFLOAT
2449# include <cfloat>
2450#else
2451# ifdef HAVE_FLOAT_H
2452#  include <float.h>
2453# endif
2454#endif
2455#ifdef HAVE_CIEEEFP
2456# include <cieeefp>
2457#else
2458# ifdef HAVE_IEEEFP_H
2459#  include <ieeefp.h>
2460# endif
2461#endif])
2462fi
2463if test -z "$m4_toupper($1)_C_ISNAN"; then
2464  AC_MSG_WARN(Cannot find C-function for checking NaN.)
2465else
2466  AC_DEFINE_UNQUOTED(m4_toupper($1)_C_ISNAN,[$m4_toupper($1)_C_ISNAN],
2467                     [Define to be the name of C-function for NaN check])
2468fi
2469
2470AC_LANG_POP(C++)
2471])
2472
2473###########################################################################
2474#                             COIN_DATA_PATH                              #
2475###########################################################################
2476
2477# This macro defines a preprocessor macro with the absolute path to a
2478# subdirectory of Data.  The argument of this macro is the name of the
2479# subdirectory (in correct case), and the name of the macro is
2480# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2481# the directory.  The path ends with a separator ("/" for linux and
2482# '\\' for Windows).  The default value for this path can be
2483# overwritten with the input variable with the same name
2484# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2485# $srcdir/../Data subdirectory.
2486
2487AC_DEFUN([AC_COIN_DATA_PATH],
2488[AC_MSG_CHECKING([absolute path to data directory $1])
2489
2490AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2491
2492if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2493  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2494fi
2495
2496# Under Cygwin, use Windows path.  Add separator
2497case $build in
2498  *-cygwin*)
2499    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2500    ;;
2501  *)
2502    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2503    ;;
2504esac
2505
2506if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2507  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2508            [Define to absolute path for Data subdirectory $1])
2509  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2510else
2511  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2512fi
2513]) # AC_COIN_DATA_PATH
2514
2515###########################################################################
2516#                       COIN_LINK_FROM_FILELIST                           #
2517###########################################################################
2518
2519# This macro creates links (or copies, if necessary) to files listed
2520# as content in a text file (second argument) into a target directory
2521# (first argument), which is created if it doesn't exist yet.  If s link
2522# already exists, nothing happens.
2523
2524AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
2525[cmd="$3"
2526if test -e $srcdir/$2 ; then
2527  my_target_dir="$1"
2528  my_link_files=`cat $srcdir/$2`
2529  my_dirname=`AS_DIRNAME($2)`
2530#  if test -e $my_target_dir; then : ; else
2531#    AS_MKDIR_P($my_target_dir)
2532#  fi
2533  for i in $my_link_files; do
2534    #rm -rf $my_target_dir/$i
2535    if test -e $my_target_dir/$i; then : ; else
2536      dirn2=`AS_DIRNAME($my_target_dir/$i)`
2537      if test -e $dirn2; then : ; else
2538        AS_MKDIR_P($dirn2)
2539      fi
2540      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
2541    fi
2542  done
2543else
2544  AC_MSG_WARN([File list file $2 missing!])
2545fi
2546])
2547
2548AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
2549[
2550AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2551echo Creating links in $1 ...
2552AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
2553])
2554
2555###########################################################################
2556#                       COIN_COPY_FROM_FILELIST                           #
2557###########################################################################
2558
2559# Like COIN_LINK_FROM_FILELIST, but copies the files.
2560
2561AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
2562[
2563echo Creating copies in $1 ...
2564AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
2565])
2566
2567###########################################################################
2568#                          COIN_EXAMPLE_FILES                             #
2569###########################################################################
2570
2571# This macro determines the names of the example files (using the
2572# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2573# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2574# creates soft links to the example files.
2575
2576AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2577[AC_REQUIRE([AC_COIN_CHECK_VPATH])
2578AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
2579AC_REQUIRE([AC_PROG_LN_S])
2580
2581files=`cd $srcdir; ls $1`
2582# We need to do the following loop to make sure that are no newlines
2583# in the variable
2584for file in $files; do
2585  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2586done
2587if test $coin_vpath_config = yes; then
2588  lnkcmd=
2589  if test "$enable_doscompile" != no; then
2590    lnkcmd=cp
2591  fi
2592  case "$CC" in
2593    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2594      lnkcmd=cp ;;
2595  esac
2596  if test "x$lnkcmd" = xcp; then
2597    AC_MSG_NOTICE([Copying example files ($1)])
2598  else
2599    AC_MSG_NOTICE([Creating links to the example files ($1)])
2600    lnkcmd="$LN_S"
2601  fi
2602  for file in $EXAMPLE_FILES; do
2603    rm -f $file
2604    $lnkcmd $srcdir/$file $file
2605  done
2606  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2607else
2608  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2609fi
2610
2611# In case there are compressed files, we create a variable with the
2612# uncompressed names
2613EXAMPLE_UNCOMPRESSED_FILES=
2614for file in $EXAMPLE_FILES; do
2615  case $file in
2616    *.gz)
2617      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2618      ;;
2619  esac
2620done
2621
2622AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2623AC_SUBST(EXAMPLE_FILES)
2624AC_SUBST(EXAMPLE_CLEAN_FILES)
2625]) #AC_COIN_EXAMPLE_FILES
2626
2627###########################################################################
2628#                      COIN_CHECK_USER_LIBRARY                            #
2629###########################################################################
2630# This macro sets up usage of a user library with header files. The assumption
2631# is that the header file(s) and library do not reside in standard system
2632# directories, hence both the include directory and link flags must be
2633# specified. There are two mandatory arguments and two optional arguments.
2634#
2635# The first argument (mandatory) should be a name (LibraryName) for the
2636# library.  The second argument (mandatory) should be an abbreviation in
2637# upper case letters (LBRY) for the library. Ultimately, the macro will
2638# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2639# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2640# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2641# directory containing include files for the library. LBRYLIB should specify
2642# the flags necessary to link to the library. A variable coin_has_lbry will
2643# be set to true or false, as appropriate. A variable lbry_libcheck will be
2644# be set to yes or no; no indicates link checks should not be attempted.
2645#
2646# The macro defines three configure arguments, --with-libraryname-incdir,
2647# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2648# LibraryName to lower case.
2649#
2650# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2651# part of the configure command using --with-libraryname-incdir and
2652# --with-libraryname-lib, respectively. Command line arguments override
2653# environment variables.
2654#
2655# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2656# macro will check for the presence of the file. If a fourth argument is given,
2657# it should specify a function name, `fname'.  The macro will attempt to link a
2658# trivial program containing a parameterless call to the function, `fname()',
2659# using the LBRYLIB flags. The link check uses C as the language; this has been
2660# adequate to date but has limitations. It is possible to disable the link
2661# check by specifying --disable-libraryname-libcheck. This is a workaround for
2662# instances where the link check does not work properly, for whatever reason.
2663# If you're trying to link to a Fortran library, consider using F77_FUNC or
2664# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2665# library, you're on your own unless the library declares some function with
2666# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2667# name.
2668# A fifth argument can be specified to include linker flags that may be required
2669# to sucessfully perform the linking check.
2670#
2671# An optional sixth argument can be given to specify a list of targets.
2672# For each target X, the variables X_LIBS and X_PCLIBS will be extended by $LBRYLIB,
2673# if the library has been found and seems to work.
2674
2675AC_DEFUN([AC_COIN_CHECK_USER_LIBRARY],
2676[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2677  AC_MSG_CHECKING(if user provides library for $1)
2678
2679# Check for header file directory
2680
2681  AC_ARG_WITH(m4_tolower($1)-incdir,
2682      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2683                     [specify the header file directory for library $1]),
2684      [$2INCDIR=`cd $withval; pwd`])
2685
2686# Check for library directory
2687
2688  AC_ARG_WITH(m4_tolower($1)-lib,
2689      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2690                     [specify the flags used to link with the library $1]),
2691      [$2LIB=$withval])
2692
2693# Switch to disable library check if requested
2694
2695  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2696      AS_HELP_STRING([--disable-m4_tolower($1)-libcheck],
2697                     [skip the link check at configuration time]),
2698      [m4_tolower($1)_libcheck=$enableval],
2699      [m4_tolower($1)_libcheck=yes])
2700
2701# At this point, if we're going to use the library, both LBRYINCDIR and
2702# LBRYLIB must be defined and not empty.
2703
2704  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2705    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2706      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.])
2707    fi
2708    m4_tolower(coin_has_$2)=true
2709    AC_MSG_RESULT(yes)
2710  else
2711    m4_tolower(coin_has_$2)=false
2712    AC_MSG_RESULT(no)
2713  fi
2714
2715# If we have instructions for use, consider header and link checks.
2716
2717  if test $m4_tolower(coin_has_$2) = true; then
2718
2719# If argument 3 (file) is given, check for the file. Typically this will be a
2720# header file, but that's not assumed.
2721
2722    m4_ifval([$3],
2723        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2724             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2725
2726# Now see if we can link the function. There are arguments for and against
2727# assuming argument 3 is a header file declaring the function. A correct
2728# function declaration is the main argument in favour. Having to cope with
2729# possible dependencies or other oddities are the main arguments against.
2730# Force the use of C as the best single choice amongst C++, C, and Fortran.
2731# Obviously, this has limits.
2732
2733    m4_ifvaln([$4],
2734        [if test x"$m4_tolower($1)_libcheck" != xno; then
2735           coin_save_LIBS="$LIBS"
2736           LIBS="$$2LIB $5"
2737           coin_$2_link=no
2738           AC_LANG_PUSH(C)
2739           for fnm in $4 ; do
2740             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2741             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2742                 [AC_MSG_RESULT(yes)
2743                  coin_$2_link=yes
2744                  break],
2745                 [AC_MSG_RESULT(no)])
2746           done
2747           AC_LANG_POP(C)
2748           LIBS="$coin_save_LIBS"
2749           if test x"$coin_$2_link" != xyes ; then
2750             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2751           fi
2752         fi])
2753
2754# If we make it this far, we've verified the file and linked the function. Add
2755# the necessary link flags to $6_{PC}LIBS and define the preprocessor symbol
2756# COIN_HAS_LBRY.
2757
2758    coin_foreach_w([myvar], [$6], [
2759      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
2760      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
2761      m4_toupper(myvar)_LIBS_INSTALLED="$$2LIB $m4_toupper(myvar)_LIBS_INSTALLED"
2762    ])
2763   
2764    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2765  fi
2766
2767# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2768# automake conditional. These actions must occur unconditionally.
2769
2770  AC_SUBST($2INCDIR)
2771  AC_SUBST($2LIB)
2772  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2773]) #AC_COIN_CHECK_USER_LIBRARY
2774
2775###########################################################################
2776#                            COIN_TRY_FLINK                               #
2777###########################################################################
2778
2779# Auxilliary macro to test if a Fortran function name can be linked,
2780# given the current settings of LIBS.  We determine from the context, what
2781# the currently active programming language is, and cast the name accordingly.
2782# The first argument is the name of the function/subroutine, in small letters,
2783# the second argument are the actions taken when the test works, and the
2784# third argument are the actions taken if the test fails.
2785
2786AC_DEFUN([AC_COIN_TRY_FLINK],
2787[case $ac_ext in
2788  f)
2789    AC_TRY_LINK(,[      call $1],[$2],[$3])
2790    ;;
2791  c)
2792    AC_F77_FUNC($1,cfunc$1)
2793    if test x"$coin_need_flibs" = xyes; then
2794      flink_try=no;
2795    else
2796      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2797                  [flink_try=yes],[flink_try=no])
2798    fi
2799    if test $flink_try = yes; then
2800      $2
2801    else
2802      if test x"$FLIBS" != x; then
2803        flink_save_libs="$LIBS"
2804        LIBS="$LIBS $FLIBS"
2805        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2806                    [LIBS="$flink_save_libs"
2807                     coin_need_flibs=yes
2808                     $2
2809                    ],
2810                    [LIBS="$flink_save_libs"
2811                     $3])
2812      else
2813        $3
2814      fi
2815    fi
2816    ;;
2817  cc|cpp)
2818    AC_F77_FUNC($1,cfunc$1)
2819    if test x"$coin_need_flibs" = xyes; then
2820      flink_try=no;
2821    else
2822      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2823                  [flink_try=yes],[flink_try=no])
2824    fi
2825    if test $flink_try = yes; then
2826      $2
2827    else
2828      if test x"$FLIBS" != x; then
2829        flink_save_libs="$LIBS"
2830        LIBS="$LIBS $FLIBS"
2831        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2832                    [LIBS="$flink_save_libs"
2833                     coin_need_flibs=yes
2834                     $2
2835                    ],
2836                    [LIBS="$flink_save_libs"
2837                     $3])
2838      else
2839        $3
2840      fi
2841    fi
2842    ;;
2843esac
2844]) # AC_COIN_TRY_FLINK
2845
2846###########################################################################
2847#                           COIN_DOXYGEN                                  #
2848###########################################################################
2849#
2850# This macro determines the configuration information for doxygen, the tool
2851# used to generate online documentation of COIN code. It takes one parameter,
2852# a list of projects (mixed-case, to match the directory names) that should
2853# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
2854#
2855# This macro will define the following variables:
2856#  coin_have_doxygen    Yes if doxygen is found, no otherwise
2857#  coin_doxy_usedot     Defaults to `yes'; --with-dot will still check to see
2858#                       if dot is available
2859#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
2860#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
2861#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
2862#                       doxygen documentation
2863#  coin_doxy_excludes   Directories to exclude from doxygen processing
2864
2865AC_DEFUN([AC_COIN_DOXYGEN],
2866[
2867
2868AC_MSG_NOTICE([configuring doxygen documentation options])
2869
2870# Check to see if doxygen is available.
2871
2872AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
2873
2874# Look for the dot tool from the graphviz package, unless the user has
2875# disabled it.
2876
2877AC_ARG_WITH([dot],
2878  AS_HELP_STRING([--with-dot],
2879                 [use dot (from graphviz) when creating documentation with
2880                  doxygen if available; --without-dot to disable]),
2881  [],[withval=yes])
2882if test x"$withval" = xno ; then
2883  coin_doxy_usedot=NO
2884  AC_MSG_CHECKING([for dot ])
2885  AC_MSG_RESULT([disabled])
2886else
2887  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
2888fi
2889
2890# Generate a tag file name and a log file name
2891
2892AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
2893AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
2894
2895# Process the list of project names and massage them into possible doxygen
2896# doc'n directories. Prefer 1) classic external, source processed using
2897# a project-specific doxygen.conf, we use the tag file; 2) classic
2898# external, source processed using package doxygen.conf; 3) installed
2899# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
2900# configured, which we can't know unless this is the package base configure,
2901# since coin_subdirs is only set there. Hence it's sufficient to check for
2902# membership. If we use a tag file from a classic external, exclude the
2903# source from doxygen processing when doxygen runs in the base directory.
2904
2905coin_doxy_tagfiles=
2906coin_doxy_excludes=
2907tmp="$1"
2908for proj in $tmp ; do
2909  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
2910  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
2911  doxytag=${lc_proj}_doxy.tag
2912  doxyfound=no
2913  for chkProj in $coin_subdirs ; do
2914    if test "$chkProj" = "$proj" ; then
2915      # proj will be configured, hence doxydoc present in build tree
2916      doxysrcdir="${srcdir}/${proj}"
2917      # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
2918      if test -d "$doxysrcdir" ; then
2919        # with a doxydoc directory?
2920        doxydir="$doxysrcdir/doxydoc"
2921        # AC_MSG_NOTICE([Considering $doxydir (base)])
2922        # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
2923        if test -d "$doxydir" ; then
2924          # use tag file; don't process source
2925          eval doxydir="`pwd`/${proj}/doxydoc"
2926          coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
2927          AC_MSG_RESULT([$doxydir (tag)])
2928          coin_doxy_excludes="$coin_doxy_excludes */${proj}"
2929        else
2930          # will process the source -- nothing further to be done here
2931          AC_MSG_RESULT([$doxysrcdir (src)])
2932        fi
2933        doxyfound=yes
2934      fi
2935    fi
2936  done
2937  # Not built, fall back to installed tag file
2938  if test $doxyfound = no ; then
2939    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
2940    # AC_MSG_NOTICE([Considering $doxydir (install)])
2941    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
2942    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
2943    AC_MSG_RESULT([$doxydir (tag)])
2944  fi
2945done
2946AC_SUBST([coin_doxy_tagfiles])
2947AC_SUBST([coin_doxy_excludes])
2948
2949]) # AC_COIN_DOXYGEN
2950
2951
2952###########################################################################
2953#                           COIN_HAS_PKGCONFIG                            #
2954###########################################################################
2955
2956# This macro checks whether a pkg-config tool with a minimal version number
2957# is available.  If so, then the variable PKGCONFIG is set to its path.
2958# If not, PKGCONFIG is set to "".  The minimal version number can be given
2959# as first parameter, by default it is 0.16.0, since COIN-OR .pc files now
2960# include an URL field, which breaks pkg-config version <= 0.15.
2961# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
2962# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
2963# AC_SUBST'ed.  Finally, if this setup belongs to a project directory, then
2964# the search path for .pc files is assembled from the value of
2965# $PKG_CONFIG_PATH, the values of --prefix, --coin-instdir, and the directories
2966# named in a file ../coin_subdirs.txt or ../../coin_subdirs.txt in a variable
2967# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed. For a path xxx given in the
2968# coin-subdirs.txt, also the directory xxx/pkgconfig is added, if existing.
2969
2970AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
2971[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
2972
2973AC_ARG_ENABLE([pkg-config],
2974  [AC_HELP_STRING([--disable-pkg-config],[disable use of pkg-config (if available)])],
2975  [use_pkgconfig="$enableval"],
2976  [use_pkgconfig=yes])
2977
2978if test $use_pkgconfig = yes ; then
2979  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
2980    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2981  fi
2982  if test -n "$PKG_CONFIG"; then
2983    _pkg_min_version=m4_default([$1], [0.16.0])
2984    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
2985    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
2986      AC_MSG_RESULT([yes])
2987    else
2988      AC_MSG_RESULT([no])
2989      PKG_CONFIG=""
2990    fi
2991  fi
2992
2993  # check if pkg-config supports the short-errors flag
2994  if test -n "$PKG_CONFIG" && \
2995    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
2996    pkg_short_errors=" --short-errors "
2997  else
2998    pkg_short_errors=""
2999  fi
3000fi
3001
3002AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
3003AC_SUBST(PKG_CONFIG)
3004
3005# assemble pkg-config search path for installed projects
3006COIN_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3007
3008# 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
3009# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
3010# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
3011if test "x${prefix}" = xNONE ; then
3012  COIN_PKG_CONFIG_PATH="${ac_default_prefix}/lib/pkgconfig:${ac_default_prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
3013else
3014  COIN_PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
3015fi
3016
3017AC_ARG_WITH([coin-instdir],
3018  AC_HELP_STRING([--with-coin-instdir],
3019                 [prefix of installation directory for precompiled COIN packages]),
3020  [if test -d "$withval"; then : ; else
3021     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
3022   fi
3023   COIN_PKG_CONFIG_PATH="$withval/lib/pkgconfig:$withval/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
3024  ],[])
3025
3026AC_SUBST(COIN_PKG_CONFIG_PATH)
3027
3028# assemble additional pkg-config search paths for uninstalled projects
3029if test x$coin_projectdir = xyes ; then
3030  # if we are in a project setup, then in a classic setup, we want to find uninstalled projects
3031  # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
3032  # unfortunately, if the user set prefix, then we do not know where the project base directory is located
3033  # 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)
3034  COIN_PKG_CONFIG_PATH_UNINSTALLED=
3035  if test -e ../coin_subdirs.txt ; then
3036    for i in `cat ../coin_subdirs.txt` ; do
3037      if test -d ../$i ; then
3038        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3039      fi
3040      if test -d ../$i/pkgconfig ; then
3041        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3042      fi
3043    done
3044  fi
3045
3046  if test -e ../../coin_subdirs.txt ; then
3047    for i in `cat ../../coin_subdirs.txt` ; do
3048      if test -d ../../$i ; then
3049        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3050      fi
3051      if test -d ../../$i/pkgconfig ; then
3052        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3053      fi
3054    done
3055  fi
3056
3057  AC_SUBST(COIN_PKG_CONFIG_PATH_UNINSTALLED)
3058fi
3059
3060if test -n "$PKG_CONFIG" && test x$coin_cc_is_cl = xtrue; then
3061  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.])
3062fi
3063
3064])
3065
3066###########################################################################
3067#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
3068###########################################################################
3069
3070# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3071#
3072# Check to see whether a particular project exists.  Similar
3073# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
3074#
3075AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
3076[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3077if test -n "$PKG_CONFIG" ; then
3078  if $PKG_CONFIG --exists "m4_tolower($1)"; then
3079    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
3080    m4_ifval([$2], [$2], [:])
3081  else
3082    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
3083    $3
3084  fi
3085else
3086  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
3087fi
3088])
3089
3090###########################################################################
3091#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
3092###########################################################################
3093
3094# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3095#
3096# Check to see whether a particular set of packages exists.
3097# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
3098#
3099AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
3100[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3101if test -n "$PKG_CONFIG" ; then
3102  if $PKG_CONFIG --exists "$2"; then
3103    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion "$2" 2>/dev/null | sed -n -e "1h;2,\\$H;\\${g;s/\n/ /g;p}"`"
3104    $3
3105  else
3106    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
3107    $4
3108  fi
3109else
3110  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
3111fi
3112])
3113
3114###########################################################################
3115#                           COIN_PKG_HAS_MODULE                           #
3116###########################################################################
3117
3118# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3119#
3120# Checks whether pkg-config files for a given set of packages is available.
3121# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
3122# If not, then ACTION-IF-NOT-FOUND is executed.
3123# A reason for not finding a package is stored in MODULE_PKG_ERRORS
3124#
3125# --------------------------------------------------------------
3126AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
3127[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3128
3129AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
3130  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
3131    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
3132        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
3133        # but only do this if is not trivial
3134    if test "$CYGPATH_W" != "echo" ; then
3135      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
3136      [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3137    fi
3138    m4_toupper($1)[]_CFLAGS="$cflags"
3139    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
3140    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
3141    $3
3142  ],
3143  [ $4 ])
3144
3145])# PKG_CHECK_MODULES
3146
3147###########################################################################
3148#                           COIN_MAIN_PACKAGEDIR                          #
3149###########################################################################
3150
3151# This macro substitutes COIN_MAIN_SUBDIR.
3152# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
3153# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
3154# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
3155#   If so, include this directory into the list of directories where configure and make recourse into.
3156# tolower(coin_has_$1) is set to "no" if the project source is not available or will not be compiled.
3157# Otherwise, it will be set to "yes".
3158
3159AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],[
3160AC_MSG_CHECKING([whether source of project $1 is available and should be compiled])
3161
3162m4_tolower(coin_has_$1)=notGiven
3163coin_reason=
3164
3165# check if user wants to skip project in any case
3166AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
3167if test x"$COIN_SKIP_PROJECTS" != x; then
3168  for dir in $COIN_SKIP_PROJECTS; do
3169    if test $dir = "$1"; then
3170      m4_tolower(coin_has_$1)="no"
3171      coin_reason="$1 has been specified in COIN_SKIP_PROJECTS"
3172    fi
3173    m4_ifval($2,[
3174    if test $dir = "$2/$1"; then
3175      m4_tolower(coin_has_$1)="no"
3176      coin_reason="$2/$1 has been specified in COIN_SKIP_PROJECTS"
3177    fi])
3178  done
3179fi
3180
3181if test "$m4_tolower(coin_has_$1)" != no; then
3182  AC_ARG_WITH([m4_tolower($1)],,
3183    [if test "$withval" = no ; then
3184       m4_tolower(coin_has_$1)="no"
3185       coin_reason="--without-m4_tolower($1) has been specified"
3186     fi
3187    ])
3188fi
3189
3190if test "$m4_tolower(coin_has_$1)" != no; then
3191  AC_ARG_WITH([m4_tolower($1)-lib],
3192    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3193                   [linker flags for using project $1]),
3194    [if test "$withval" = no ; then
3195       m4_tolower(coin_has_$1)="no"
3196       coin_reason="--without-m4_tolower($1)-lib has been specified"
3197     else
3198       m4_tolower(coin_has_$1)="no"
3199       coin_reason="--with-m4_tolower($1)-lib has been specified"
3200     fi],
3201    [])
3202fi
3203
3204if test "$m4_tolower(coin_has_$1)" != no; then
3205  AC_ARG_WITH([m4_tolower($1)-incdir],
3206    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3207                   [directory with header files for using project $1]),
3208    [if test "$withval" = no ; then
3209       m4_tolower(coin_has_$1)="no"
3210       coin_reason="--without-m4_tolower($1)-incdir has been specified"
3211     else
3212       m4_tolower(coin_has_$1)="no"
3213       coin_reason="--with-m4_tolower($1)-incdir has been specified"
3214     fi],
3215    [])
3216fi
3217
3218if test "$m4_tolower(coin_has_$1)" != no; then
3219  AC_ARG_WITH([m4_tolower($1)-datadir],
3220    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3221                   [directory with data files for using project $1]),
3222    [if test "$withval" = no ; then
3223       m4_tolower(coin_has_$1)="no"
3224       coin_reason="--without-m4_tolower($1)-datadir has been specified"
3225     else
3226       m4_tolower(coin_has_$1)="no"
3227       coin_reason="--with-m4_tolower($1)-datadir has been specified"
3228     fi],
3229    [])
3230fi
3231
3232m4_if(m4_tolower($1), blas, [
3233  if test $m4_tolower(coin_has_$1) != no; then
3234    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
3235    AC_ARG_WITH([blas],
3236      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
3237        [if test x"$withval" = "xno" ; then
3238           coin_has_blas="no"
3239           coin_reason="--without-blas has been specified"
3240         elif test x"$withval" != "xBUILD" ; then
3241           coin_has_blas="no"
3242           coin_reason="--with-blas has been specified"
3243         fi],
3244        [])
3245  fi
3246])
3247
3248m4_if(m4_tolower($1), lapack, [
3249  if test $m4_tolower(coin_has_$1) != skipping; then
3250    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
3251    AC_ARG_WITH([lapack],
3252      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
3253        [if test x"$withval" = "xno" ; then
3254           coin_has_lapack="no"
3255           coin_reason="--without-lapack has been specified"
3256         elif test x"$withval" != "xBUILD" ; then
3257           coin_has_lapack="no"
3258           coin_reason="--with-lapack has been specified"
3259         fi],
3260        [])
3261  fi
3262])
3263
3264# check if project is available in present directory
3265if test "$m4_tolower(coin_has_$1)" = notGiven; then
3266  m4_tolower(coin_has_$1)=no
3267  if test -d $srcdir/m4_ifval($2,[$2/],)$1; then
3268    coin_reason="source in m4_ifval($2,[$2/],)$1"
3269    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
3270    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
3271    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
3272    m4_ifvaln([$3],
3273      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
3274         if test -r $i; then
3275           m4_tolower(coin_has_$1)="yes"
3276         else
3277           m4_tolower(coin_has_$1)="no"
3278           coin_reason="source file $i not available"
3279           break
3280         fi
3281       done],
3282      [ m4_tolower(coin_has_$1)="yes" ])
3283  fi
3284fi
3285
3286if test -z "$coin_reason" ; then
3287  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3288else
3289  AC_MSG_RESULT([$m4_tolower(coin_has_$1), $coin_reason])
3290fi
3291
3292if test "$m4_tolower(coin_has_$1)" = yes ; then
3293  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
3294    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
3295    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
3296  fi
3297fi
3298])
3299
3300###########################################################################
3301#                            COIN_CHECK_PACKAGE                           #
3302###########################################################################
3303
3304# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
3305# A package can consists of one or more COIN-OR or other projects.
3306# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, PACKAGE_DEPENDENCIES, and PACKAGE_DATA variables, referring to the compiler and linker
3307# flags to use when linking against this module, the libraries the package depends on, and the directories where the module data resists.
3308# The difference between PACKAGE_LIBS and PACKAGE_DEPENDENCIES is that PACKAGE_DEPENDENCIES does not contain arguments starting with '-',
3309# so it can be used to setup the _DEPENDENCIES variable in a Makefile.am.
3310# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
3311# Further, tolower(coin_has_$1) is set to "yes".
3312# If a list of build targets using this projects is given in the third argument,
3313# then the compiler and linker variables and .pc file setup variable corresponding to this build target
3314# are extended with the values for this package.
3315# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_DEPENDENCIES, X_PCLIBS, X_PCREQUIRES are setup,
3316# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
3317#
3318# The first argument should be the name (PACKAGE) of the package (in correct lower
3319# and upper case).
3320# The second argument should be a (space separated) list of projects which this
3321# package consists of. Optionally, required version numbers can be added.
3322# The optional third argument should be a (space separated) list of build targets
3323# which use this package, if available.
3324#
3325# It is also possible to specify a preinstalled version of this package
3326# or to specify only the linker and compiler flags and data directory.
3327#
3328# If the user did not specify --with-$1-... flags and pkg-config is not available,
3329# COIN_CHECK_PACKAGE_FALLBACK($1, $2, $3) is called.
3330
3331AC_DEFUN([AC_COIN_CHECK_PACKAGE],
3332[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3333AC_MSG_CHECKING([for COIN-OR package $1])
3334
3335m4_tolower(coin_has_$1)=notGiven
3336
3337# check if user wants to skip package in any case
3338if test x"$COIN_SKIP_PROJECTS" != x; then
3339  for dir in $COIN_SKIP_PROJECTS; do
3340    if test $dir = "$1"; then
3341      m4_tolower(coin_has_$1)=skipping
3342    fi
3343  done
3344fi
3345
3346if test "$m4_tolower(coin_has_$1)" != skipping; then
3347  AC_ARG_WITH([m4_tolower($1)],,
3348    [if test "$withval" = no ; then
3349       m4_tolower(coin_has_$1)=skipping
3350     fi
3351    ])
3352fi
3353
3354m4_toupper($1_LIBS)=
3355m4_toupper($1_CFLAGS)=
3356m4_toupper($1_DATA)=
3357m4_toupper($1_DEPENDENCIES)=
3358m4_toupper($1_PCLIBS)=
3359m4_toupper($1_PCREQUIRES)=
3360m4_toupper($1_DATA)=
3361AC_SUBST(m4_toupper($1_LIBS))
3362AC_SUBST(m4_toupper($1_CFLAGS))
3363AC_SUBST(m4_toupper($1_DATA))
3364AC_SUBST(m4_toupper($1_DEPENDENCIES))
3365AC_SUBST(m4_toupper($1_LIBS_INSTALLED))
3366AC_SUBST(m4_toupper($1_CFLAGS_INSTALLED))
3367AC_SUBST(m4_toupper($1_DATA_INSTALLED))
3368coin_foreach_w([myvar], [$3], [
3369  AC_SUBST(m4_toupper(myvar)_CFLAGS)
3370  AC_SUBST(m4_toupper(myvar)_LIBS)
3371  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3372  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
3373  AC_SUBST(m4_toupper(myvar)_DEPENDENCIES)
3374  AC_SUBST(m4_toupper(myvar)_CFLAGS_INSTALLED)
3375  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3376])
3377
3378#check if user provided LIBS, CFLAGS, or DATA for package or disables use of package
3379if test $m4_tolower(coin_has_$1) != skipping; then
3380  AC_ARG_WITH([m4_tolower($1)-lib],
3381    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3382                   [linker flags for using package $1]),
3383    [if test "$withval" = no ; then
3384       m4_tolower(coin_has_$1)=skipping
3385     else
3386       m4_tolower(coin_has_$1)=yes
3387       m4_toupper($1_LIBS)="$withval"
3388       m4_toupper($1_PCLIBS)="$withval"
3389       coin_foreach_w([myvar], [$3], [
3390         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
3391         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
3392       ])
3393       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3394       if test -z "$PKG_CONFIG" ; then
3395         m4_toupper($1_LIBS_INSTALLED)="$withval"
3396         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_LIBS_INSTALLED="$withval $m4_toupper(myvar)_LIBS_INSTALLED"])
3397       fi
3398     fi
3399    ],
3400    [])
3401fi
3402
3403if test $m4_tolower(coin_has_$1) != skipping; then
3404  AC_ARG_WITH([m4_tolower($1)-incdir],
3405    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3406                   [directory with header files for using package $1]),
3407    [if test "$withval" = no ; then
3408       m4_tolower(coin_has_$1)=skipping
3409     else
3410       m4_tolower(coin_has_$1)=yes
3411       m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
3412       coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="-I`${CYGPATH_W} $withval` $m4_toupper(myvar)_CFLAGS"])
3413       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3414       if test -z "$PKG_CONFIG" ; then
3415         m4_toupper($1_CFLAGS_INSTALLED)="$m4_toupper($1_CFLAGS)"
3416         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1_CFLAGS) $m4_toupper(myvar)_CFLAGS_INSTALLED"])
3417       fi
3418     fi
3419    ],
3420    [])
3421fi
3422
3423if test $m4_tolower(coin_has_$1) != skipping; then
3424  AC_ARG_WITH([m4_tolower($1)-datadir],
3425    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3426                   [directory with data files for using package $1]),
3427    [if test "$withval" = no ; then
3428       m4_tolower(coin_has_$1)=skipping
3429     else
3430       m4_tolower(coin_has_$1)=yes
3431       m4_toupper($1_DATA)="$withval"
3432       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3433       if test -z "$PKG_CONFIG" ; then
3434         m4_toupper($1_DATA_INSTALLED)="$withval"
3435       fi
3436     fi
3437    ],
3438    [])
3439fi
3440
3441if test $m4_tolower(coin_has_$1) = notGiven; then
3442  if test -n "$PKG_CONFIG" ; then
3443    # set search path for pkg-config
3444    # need to export variable to be sure that the following pkg-config gets these values
3445    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3446    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
3447    export PKG_CONFIG_PATH
3448   
3449    # let pkg-config do it's magic
3450    AC_COIN_PKG_HAS_MODULE([$1],[$2],
3451      [ m4_tolower(coin_has_$1)=yes
3452        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
3453
3454        # adjust linker flags for (i)cl compiler
3455        # 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)
3456        if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3457        then
3458          m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3459        fi
3460        m4_toupper($1_PCREQUIRES)="$2"
3461   
3462        # augment X_PCREQUIRES, X_CFLAGS, and X_LIBS for each build target X in $3
3463        coin_foreach_w([myvar], [$3], [
3464          m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3465          m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3466          m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3467        ])
3468      ],
3469      [ m4_tolower(coin_has_$1)=notGiven
3470        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
3471      ])
3472
3473    # reset PKG_CONFIG_PATH variable
3474    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3475    export PKG_CONFIG_PATH
3476
3477  else
3478    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
3479    AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
3480  fi
3481
3482else
3483  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3484fi
3485
3486if test $m4_tolower(coin_has_$1) != skipping &&
3487   test $m4_tolower(coin_has_$1) != notGiven ; then
3488  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3489
3490  AC_ARG_ENABLE([interpackage-dependencies],
3491    AC_HELP_STRING([--disable-interpackage-dependencies], [disables deduction of Makefile dependencies from package linker flags]),
3492    [], [enable_interpackage_dependencies=yes])
3493   
3494  if test $enable_interpackage_dependencies = yes ; then
3495     # construct dependencies variables from LIBS variables
3496     # we add an extra space in LIBS so we can substitute out everything starting with " -"
3497     # remove everything of the form -framework xxx as used on Mac and mklxxx as used on Windows
3498     # then remove everything of the form -xxx
3499     # also remove everything of the form `xxx`yyy (may have been added for cygwin/cl)
3500     m4_toupper($1)_DEPENDENCIES=`echo " $m4_toupper($1)_LIBS" | [sed -e 's/ mkl[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
3501     coin_foreach_w([myvar], [$3], [
3502       m4_toupper(myvar)_DEPENDENCIES=`echo " $m4_toupper(myvar)_LIBS " | [sed -e 's/ mkl[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
3503     ])
3504  fi
3505
3506  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
3507    if test -n "$m4_toupper($1)_CFLAGS" ; then
3508      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3509    fi
3510    if test -n "$m4_toupper($1)_LIBS" ; then
3511      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
3512    fi
3513    if test -n "$m4_toupper($1)_DEPENDENCIES" ; then
3514      AC_MSG_NOTICE([$1 DEPENDENCIES are $m4_toupper($1)_DEPENDENCIES])
3515    fi
3516    if test -n "$m4_toupper($1)_DATA" ; then
3517      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
3518    fi
3519    if test -n "$m4_toupper($1)_PCLIBS" ; then
3520      AC_MSG_NOTICE([$1 PCLIBS are $m4_toupper($1)_PCLIBS])
3521    fi
3522    if test -n "$m4_toupper($1)_PCREQUIRES" ; then
3523      AC_MSG_NOTICE([$1 PCREQUIRES are $m4_toupper($1)_PCREQUIRES])
3524    fi
3525    coin_foreach_w([myvar], [$3], [
3526      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
3527      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
3528      AC_MSG_NOTICE([myvar DEPENDENCIES are $m4_toupper(myvar)_DEPENDENCIES])
3529    ])
3530  fi
3531fi
3532
3533# Define the Makefile conditional
3534AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3535               [test $m4_tolower(coin_has_$1) != notGiven &&
3536                test $m4_tolower(coin_has_$1) != skipping])
3537
3538]) # AC_COIN_CHECK_PACKAGE
3539
3540###########################################################################
3541#                       COIN_CHECK_PACKAGE_FALLBACK                       #
3542###########################################################################
3543
3544# This macro is used by COIN_CHECK_PACKAGE, if it fails to find a package
3545# because pkg-config was disabled or is not available.
3546#
3547# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc
3548# file in the directories specified in $COIN_PKG_CONFIG_PATH_UNINSTALLED. The
3549# latter variable is setup by COIN_HAS_PKGCONFIG and consists of the content
3550# of the coin_subdirs.txt file which has been created by configure in the
3551# base directory.  The content of xxx-uninstalled.pc is parsed in order
3552# to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
3553# referring to the compiler and linker flags to use when linking against this
3554# package and the directory where the package data resists.  Further, for each
3555# build target X specified in the third argument, the variables X_CFLAGS and
3556# X_LIBS are extended with the compiler and linker flags of this package and
3557# the variables X_PCLIBS and X_PCREQUIRES are extended by the list of linker
3558# flags and dependent projects as needed to setup a .pc file.  The macros
3559# checks also dependencies of $2.  Note that the PACKAGE_DATA variable is
3560# set to the content of datadir of the first .pc file that is parsed.
3561# Finally, for each X in the third argument, also variables
3562# X_CFLAGS_INSTALLED and X_LIBS_INSTALLED are setup. They contain the compiler
3563# and linker flags for X when all projects have been installed. Their content
3564# is assembled from the .pc files that correspond to installed projects. I.e.,
3565# whenever a file proj-uninstalled.pc is parsed, then also a corresponding
3566# proj.pc file is parsed for compiler and linker flags, if available in the
3567# same directory.
3568# Similar, a variable PACKAGE_DATA_INSTALLED is setup to the content of datadir
3569# of the first .pc file that is parsed.
3570#
3571# If .pc files for all projects in $2 and their dependencies is found,
3572# tolower(coin_has_$1) is set to "yes".  Otherwise, if some dependency
3573# is not found, tolower(coin_has_$1) is set to "notGiven".  Further, a
3574# COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
3575#
3576# The first argument should be the name (PACKAGE) of the package (in correct
3577# lower and upper case).  The second argument should be the base names of the
3578# projects .pc file which define this package.  The optional third argument
3579# should be a (space separated) list of build targets which use this package,
3580# if available.
3581#
3582# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into
3583# $COIN_PKG_CONFIG_PATH_UNINSTALLED.  When the content of this variable was
3584# setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
3585
3586AC_DEFUN([AC_COIN_CHECK_PACKAGE_FALLBACK],
3587[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3588AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
3589
3590m4_tolower(coin_has_$1)=notGiven
3591m4_toupper($1_LIBS)=
3592m4_toupper($1_LIBS_INSTALLED)=
3593m4_toupper($1_CFLAGS)=
3594m4_toupper($1_CFLAGS_INSTALLED)=
3595m4_toupper($1_DATA)=
3596m4_toupper($1_DATA_INSTALLED)=
3597m4_toupper($1_PCLIBS)=
3598m4_toupper($1_PCREQUIRES)=
3599
3600# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x, != x)
3601projtoprocess="m4_bpatsubsts([$2], [<?>?!?=[    ]*[^    ]+])"
3602
3603# we first expand the list of projects to process by adding all dependencies just behind the project which depends on it
3604# further, we collect the list of corresponding .pc files, but do this in reverse order, because we need this order afterwards
3605# the latter we also do with .pc files corresponding to the installed projects, which will be needed to setup Makefiles for examples
3606# also, we setup the DATA variable
3607allproj=""
3608allpcfiles=""
3609allpcifiles=""
3610while test "x$projtoprocess" != x ; do
3611
3612  for proj in $projtoprocess ; do
3613    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
3614    pcfile=""
3615    save_IFS="$IFS"
3616    IFS=":"
3617    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
3618      # 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
3619      if test -r "$dir/${proj}-uninstalled.pc" ; then
3620        pcfile="$dir/$proj-uninstalled.pc"
3621        if test -r "$dir/${proj}.pc" ; then
3622          pcifile="$dir/${proj}.pc"
3623        else
3624          AC_MSG_WARN([Found $pcfile, but $dir/${proj}.pc is not available. This may break Makefile's of examples.])
3625          pcifile=
3626        fi
3627        break
3628      fi
3629    done
3630    IFS="$save_IFS"
3631
3632    if test "x$pcfile" != x ; then
3633      # read dependencies from $pcfile and filter it
3634      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\{0,1\}>\{0,1\}=[       ]\{0,\}[^       ]\{1,\}//g'`]
3635
3636      # add projrequires to the front of the list of projects that have to be processed next
3637      # at the same time, remove $proj from this list
3638      projtoprocess=[`echo $projtoprocess | sed -e "s/$proj/$projrequires/"`]
3639
3640      # read DATA from $pcfile, if _DATA is still empty
3641      if test "x$m4_toupper($1_DATA)" = x ; then
3642        projdatadir=
3643        [pcfilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcfile`]
3644        eval `sh -c "$pcfilemod"`
3645        m4_toupper($1_DATA)="$projdatadir"
3646      fi
3647
3648      allproj="$allproj $proj"
3649      allpcfiles="$pcfile:$allpcfiles"
3650
3651    else
3652      AC_MSG_RESULT([no, dependency $proj not available])
3653      allproj=fail
3654      break 2
3655    fi
3656   
3657    if test "x$pcifile" != x ; then
3658      allpcifiles="$pcifile:$allpcifiles"
3659     
3660      # read DATA_INSTALLED from $pcifile, if _DATA_INSTALLED is still empty
3661      if test "x$m4_toupper($1_DATA_INSTALLED)" = x ; then
3662        projdatadir=
3663        [pcifilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcifile`]
3664        eval `sh -c "$pcifilemod"`
3665        if test "${CYGPATH_W}" != "echo"; then
3666          projdatadir="\`\$(CYGPATH_W) ${projdatadir} | sed -e 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g'\`"
3667        fi
3668        m4_toupper($1_DATA_INSTALLED)="$projdatadir"
3669      fi
3670     
3671    fi
3672
3673    break
3674  done
3675
3676  # remove spaces on begin of $projtoprocess
3677  projtoprocess=`echo $projtoprocess | sed -e 's/^[ ]*//'`
3678
3679done
3680
3681if test "$allproj" != fail ; then
3682
3683  # now go through the list of .pc files and assemble compiler and linker flags
3684  # important is here to obey the reverse order that has been setup before,
3685  # since then libraries that are required by several others should be after these other libraries
3686  pcfilesprocessed=""
3687
3688  save_IFS="$IFS"
3689  IFS=":"
3690  for pcfile in $allpcfiles ; do
3691
3692    # if $pcfile has been processed already, skip this round
3693    if test "x$pcfilesprocessed" != x ; then
3694      for pcfiledone in $pcfilesprocessed ; do
3695        if test "$pcfiledone" = "$pcfile" ; then
3696          continue 2
3697        fi
3698      done
3699    fi
3700
3701    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3702    #   replace "Libs:" by "echo projlibs="
3703    #   replace "Cflags:" by "echo projcflags="
3704    #   remove every line starting with <some word>:
3705    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
3706
3707    # set projcflags and projlibs variables by running $pcfilemod
3708    # 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
3709    projcflags=
3710    projlibs=
3711    IFS="$save_IFS"
3712    eval `sh -c "$pcfilemod"`
3713    IFS=":"
3714
3715    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3716    if test "${CYGPATH_W}" != "echo"; then
3717      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3718    fi
3719    m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
3720
3721    # set LIBS variable
3722    m4_toupper($1_LIBS)="$projlibs $m4_toupper($1_LIBS)"
3723
3724    # remember that we have processed $pcfile
3725    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3726
3727  done
3728  IFS="$save_IFS"
3729
3730
3731  # now go through the list of .pc files for installed projects and assemble compiler and linker flags
3732  # important is here again to obey the reverse order that has been setup before,
3733  # since then libraries that are required by several others should be after these other libraries
3734  pcfilesprocessed=""
3735
3736  save_IFS="$IFS"
3737  IFS=":"
3738  for pcfile in $allpcifiles ; do
3739
3740    # if $pcfile has been processed already, skip this round
3741    if test "x$pcfilesprocessed" != x ; then
3742      for pcfiledone in $pcfilesprocessed ; do
3743        if test "$pcfiledone" = "$pcfile" ; then
3744          continue 2
3745        fi
3746      done
3747    fi
3748
3749    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3750    #   replace "Libs:" by "echo projlibs="
3751    #   replace "Cflags:" by "echo projcflags="
3752    #   remove every line starting with <some word>:
3753    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
3754
3755    # set projcflags and projlibs variables by running $pcfilemod
3756    # 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
3757    projcflags=
3758    projlibs=
3759    IFS="$save_IFS"
3760    eval `sh -c "$pcfilemod"`
3761    IFS=":"
3762
3763    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3764    if test "${CYGPATH_W}" != "echo"; then
3765      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3766    fi
3767    m4_toupper($1_CFLAGS_INSTALLED)="$projcflags $m4_toupper($1_CFLAGS_INSTALLED)"
3768
3769    # set LIBS variable
3770    m4_toupper($1_LIBS_INSTALLED)="$projlibs $m4_toupper($1_LIBS_INSTALLED)"
3771   
3772    # remember that we have processed $pcfile
3773    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3774
3775  done
3776  IFS="$save_IFS"
3777
3778
3779  # finish up
3780  m4_tolower(coin_has_$1)=yes
3781  AC_MSG_RESULT([yes])
3782  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3783
3784  # adjust linker flags for (i)cl compiler
3785  # 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),
3786  # for the LIBS_INSTALLED, we replace everything of the form "/somepath/" by "`$(CYGPATH_W) /somepath/`",
3787  #    everything of the form "-lname" by "libname.lib", and
3788  #    everything of the form "-Lpath" by "-libpath:`$(CYGPATH_W) path`
3789  if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3790  then
3791    m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3792    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']`
3793  fi
3794
3795  m4_toupper($1_PCREQUIRES)="$2"
3796  coin_foreach_w([myvar], [$3], [
3797    m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3798    m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3799    m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3800    m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1)_CFLAGS_INSTALLED $m4_toupper(myvar)_CFLAGS_INSTALLED"
3801    m4_toupper(myvar)_LIBS_INSTALLED="$m4_toupper($1)_LIBS_INSTALLED $m4_toupper(myvar)_LIBS_INSTALLED"
3802  ])
3803
3804fi
3805
3806AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3807               [test $m4_tolower(coin_has_$1) != notGiven &&
3808                test $m4_tolower(coin_has_$1) != skipping])
3809
3810]) # AC_COIN_CHECK_PACKAGE_FALLBACK
3811
3812###########################################################################
3813#                         COIN_CHECK_PACKAGE_BLAS                         #
3814###########################################################################
3815
3816# This macro checks for a library containing the BLAS library.  It
3817# 1. checks the --with-blas argument
3818# 2. if --with-blas=BUILD has been specified goes to point 5
3819# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
3820#    to its value
3821# 4. tries standard libraries
3822# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
3823#    ThirdParty/Blas
3824# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
3825# BLAS_LIBS is set to the flags required to link with a Blas library.
3826# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
3827# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
3828# In case 5, Blas is added to X_PCREQUIRES.
3829
3830AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
3831[
3832AC_ARG_WITH([blas],
3833            AC_HELP_STRING([--with-blas],
3834                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
3835            [use_blas="$withval"], [use_blas=])
3836
3837# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
3838# preference
3839AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
3840
3841# Check if user supplied option makes sense
3842if test x"$use_blas" != x; then
3843  if test "$use_blas" = "BUILD"; then
3844    # we come to this later
3845    :
3846  elif test "$use_blas" != "no"; then
3847    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
3848    coin_need_flibs=no
3849    coin_save_LIBS="$LIBS"
3850    LIBS="$use_blas $LIBS"
3851    AC_COIN_TRY_FLINK([daxpy],
3852                      [if test $coin_need_flibs = yes ; then
3853                         use_blas="$use_blas $FLIBS"
3854                       fi
3855                       AC_MSG_RESULT([yes: $use_blas])],
3856                      [AC_MSG_RESULT([no])
3857                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
3858    LIBS="$coin_save_LIBS"
3859  fi
3860else
3861# Try to autodetect the library for blas based on build system
3862  #AC_MSG_CHECKING([default locations for BLAS])
3863  skip_lblas_check=no
3864  case $build in
3865    *-sgi-*)
3866      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
3867      coin_need_flibs=no
3868      coin_save_LIBS="$LIBS"
3869      LIBS="-lcomplib.sgimath $LIBS"
3870      AC_COIN_TRY_FLINK([daxpy],
3871                        [use_blas="-lcomplib.sgimath"
3872                         if test $coin_need_flibs = yes ; then
3873                           use_blas="$use_blas $FLIBS"
3874                         fi
3875                         AC_MSG_RESULT([yes: $use_blas])
3876                        ],
3877                        [AC_MSG_RESULT([no])])
3878      LIBS="$coin_save_LIBS"
3879      ;;
3880
3881# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
3882# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
3883# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
3884# that CC and cc will understand -library in Studio 13. The main extra
3885# function of -xlic_lib and -library is to arrange for the Fortran run-time
3886# libraries to be linked for C++ and C. We can arrange that explicitly.
3887    *-*-solaris*)
3888      AC_MSG_CHECKING([for BLAS in libsunperf])
3889      coin_need_flibs=no
3890      coin_save_LIBS="$LIBS"
3891      LIBS="-lsunperf $FLIBS $LIBS"
3892      AC_COIN_TRY_FLINK([daxpy],
3893                        [use_blas='-lsunperf'
3894                         if test $coin_need_flibs = yes ; then
3895                           use_blas="$use_blas $FLIBS"
3896                         fi
3897                         AC_MSG_RESULT([yes: $use_blas])
3898                        ],
3899                        [AC_MSG_RESULT([no])])
3900      LIBS="$coin_save_LIBS"
3901      ;;
3902     
3903    *-cygwin* | *-mingw*)
3904# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
3905# library will want to link with cygwin, hence won't run standalone in DOS.
3906      if test "$enable_doscompile" = mingw; then
3907        skip_lblas_check=yes
3908      fi
3909      case "$CC" in
3910        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
3911          coin_save_LIBS="$LIBS"
3912          AC_MSG_CHECKING([for BLAS in MKL (32bit)])
3913          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
3914          AC_COIN_TRY_FLINK([daxpy],
3915                            [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
3916                             AC_MSG_RESULT([yes: $use_blas])
3917                            ],
3918                            [AC_MSG_RESULT([no])])
3919          LIBS="$coin_save_LIBS"
3920         
3921          if test "x$use_blas" = x ; then
3922            AC_MSG_CHECKING([for BLAS in MKL (64bit)])
3923            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
3924            AC_COIN_TRY_FLINK([daxpy],
3925                              [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
3926                               AC_MSG_RESULT([yes: $use_blas])
3927                              ],
3928                              [AC_MSG_RESULT([no])])
3929            LIBS="$coin_save_LIBS"
3930          fi
3931          ;;
3932      esac
3933      ;;
3934     
3935     *-darwin*)
3936      AC_MSG_CHECKING([for BLAS in Veclib])
3937      coin_need_flibs=no
3938      coin_save_LIBS="$LIBS"
3939      LIBS="-framework vecLib $LIBS"
3940      AC_COIN_TRY_FLINK([daxpy],
3941                        [use_blas='-framework vecLib'
3942                         if test $coin_need_flibs = yes ; then
3943                           use_blas="$use_blas $FLIBS"
3944                         fi
3945                         AC_MSG_RESULT([yes: $use_blas])
3946                        ],
3947                        [AC_MSG_RESULT([no])])
3948      LIBS="$coin_save_LIBS"
3949      ;;
3950  esac
3951
3952  if test -z "$use_blas" && test $skip_lblas_check = no; then
3953    AC_MSG_CHECKING([whether -lblas has BLAS])
3954    coin_need_flibs=no
3955    coin_save_LIBS="$LIBS"
3956    LIBS="-lblas $LIBS"
3957    AC_COIN_TRY_FLINK([daxpy],
3958                      [use_blas='-lblas'
3959                       if test $coin_need_flibs = yes ; then
3960                         use_blas="$use_blas $FLIBS"
3961                       fi
3962                       AC_MSG_RESULT([yes: $use_blas])
3963                      ],
3964                      [AC_MSG_RESULT([no])])
3965    LIBS="$coin_save_LIBS"
3966  fi
3967
3968  # If we have no other ideas, consider building BLAS.
3969  if test -z "$use_blas" ; then
3970    use_blas=BUILD
3971  fi
3972fi
3973
3974if test "x$use_blas" = xBUILD ; then
3975  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
3976 
3977elif test "x$use_blas" != x && test "$use_blas" != no; then
3978  coin_has_blas=yes
3979  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
3980  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
3981  BLAS_LIBS="$use_blas"
3982  BLAS_CFLAGS=
3983  BLAS_DATA=
3984  AC_SUBST(BLAS_LIBS)
3985  AC_SUBST(BLAS_CFLAGS)
3986  AC_SUBST(BLAS_DATA)
3987  coin_foreach_w([myvar], [$1], [
3988    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
3989    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
3990    m4_toupper(myvar)_LIBS_INSTALLED="$BLAS_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
3991  ])
3992 
3993else
3994  coin_has_blas=no
3995  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
3996fi
3997
3998coin_foreach_w([myvar], [$1], [
3999  AC_SUBST(m4_toupper(myvar)_PCLIBS)
4000  AC_SUBST(m4_toupper(myvar)_LIBS)
4001  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
4002])
4003
4004]) # AC_COIN_CHECK_PACKAGE_BLAS
4005
4006###########################################################################
4007#                       COIN_CHECK_PACKAGE_LAPACK                         #
4008###########################################################################
4009
4010# This macro checks for a library containing the LAPACK library.  It
4011# 1. checks the --with-lapack argument
4012# 2. if --with-lapack=BUILD has been specified goes to point 5
4013# 3. if --with-lapack has been specified to a working library, sets
4014#    LAPACK_LIBS to its value
4015# 4. tries standard libraries
4016# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
4017#    ThirdParty/Lapack
4018# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
4019# LAPACK_LIBS is set to the flags required to link with a Lapack library.
4020# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
4021# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
4022# In case 5, Lapack is added to X_PCREQUIRES.
4023#
4024# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
4025#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
4026#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
4027#   then we will get Blas as dependency of coinlapack.
4028
4029AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
4030[
4031AC_ARG_WITH([lapack],
4032            AC_HELP_STRING([--with-lapack],
4033                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
4034            [use_lapack=$withval], [use_lapack=])
4035
4036#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
4037AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
4038
4039# Check if user supplied option makes sense
4040if test x"$use_lapack" != x; then
4041  if test "$use_lapack" = "BUILD"; then
4042    # we come to this later
4043    :
4044  elif test "$use_lapack" != no; then
4045    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
4046    coin_need_flibs=no
4047    use_lapack="$use_lapack $BLAS_LIBS"
4048    coin_save_LIBS="$LIBS"
4049    LIBS="$use_lapack $LIBS"
4050    AC_COIN_TRY_FLINK([dsyev],
4051                      [if test $coin_need_flibs = yes ; then
4052                         use_lapack="$use_lapack $FLIBS"
4053                       fi
4054                       AC_MSG_RESULT([yes: $use_lapack])
4055                      ],
4056                      [AC_MSG_RESULT([no])
4057                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
4058    LIBS="$coin_save_LIBS"
4059  fi
4060else
4061  if test x$coin_has_blas = xyes; then
4062    # First try to see if LAPACK is already available with BLAS library
4063    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
4064    coin_save_LIBS="$LIBS"
4065    coin_need_flibs=no
4066    LIBS="$BLAS_LIBS $LIBS"
4067    AC_COIN_TRY_FLINK([dsyev],
4068                      [use_lapack="$BLAS_LIBS"
4069                       if test $coin_need_flibs = yes ; then
4070                         use_lapack="$use_lapack $FLIBS"
4071                       fi
4072                       AC_MSG_RESULT([yes: $use_lapack])
4073                      ],
4074                      [AC_MSG_RESULT([no])])
4075    LIBS="$coin_save_LIBS"
4076  fi
4077  skip_llapack_check=no
4078  if test -z "$use_lapack"; then
4079    # Try to autodetect the library for lapack based on build system
4080    case $build in
4081      # TODO: Is this check actually needed here, since -lcomplib.sigmath should have been recognized as Blas library,
4082      #       and above it is checked whether the Blas library already contains Lapack
4083      *-sgi-*)
4084        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
4085        coin_save_LIBS="$LIBS"
4086        coin_need_flibs=no
4087        LIBS="-lcomplib.sgimath $BLAS_LIBS $LIBS"
4088        AC_COIN_TRY_FLINK([dsyev],
4089                          [use_lapack="-lcomplib.sgimath $BLAS_LIBS"
4090                           if test $coin_need_flibs = yes ; then
4091                             use_lapack="$use_lapack $FLIBS"
4092                           fi
4093                           AC_MSG_RESULT([yes: $use_lapack])
4094                          ],
4095                          [AC_MSG_RESULT([no])])
4096        LIBS="$coin_save_LIBS"
4097        ;;
4098
4099      # See comments in COIN_CHECK_PACKAGE_BLAS.
4100      # TODO: Is this check actually needed here, since -lsunperf should have been recognized as Blas library,
4101      #       and above it is checked whether the Blas library already contains Lapack
4102      *-*-solaris*)
4103        AC_MSG_CHECKING([for LAPACK in libsunperf])
4104        coin_need_flibs=no
4105        coin_save_LIBS="$LIBS"
4106        LIBS="-lsunperf $BLAS_LIBS $FLIBS $LIBS"
4107        AC_COIN_TRY_FLINK([dsyev],
4108                          [use_lapack='-lsunperf $BLAS_LIBS'
4109                           if test $coin_need_flibs = yes ; then
4110                             use_lapack="$use_lapack $FLIBS"
4111                           fi
4112                           AC_MSG_RESULT([yes: $use_lapack])
4113                          ],
4114                          [AC_MSG_RESULT([no])])
4115        LIBS="$coin_save_LIBS"
4116        ;;
4117        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
4118        # will want to link with cygwin, hence won't run standalone in DOS.
4119       
4120      *-cygwin*)
4121        if test "$enable_doscompile" = mingw; then
4122          skip_llapack_check=yes
4123        fi
4124        ;;
4125       
4126    esac
4127  fi
4128
4129  if test -z "$use_lapack" && test $skip_llapack_check = no; then
4130    AC_MSG_CHECKING([whether -llapack has LAPACK])
4131    coin_need_flibs=no
4132    coin_save_LIBS="$LIBS"
4133    LIBS="-llapack $BLAS_LIBS $LIBS"
4134    AC_COIN_TRY_FLINK([dsyev],
4135                      [use_lapack='-llapack'
4136                       if test $coin_need_flibs = yes ; then
4137                         use_lapack="$use_lapack $FLIBS"
4138                       fi
4139                       AC_MSG_RESULT([yes: $use_lapack])
4140                      ],
4141                      [AC_MSG_RESULT([no])])
4142    LIBS="$coin_save_LIBS"
4143  fi
4144
4145  # If we have no other ideas, consider building LAPACK.
4146  if test -z "$use_lapack" ; then
4147    use_lapack=BUILD
4148  fi
4149fi
4150
4151if test "x$use_lapack" = xBUILD ; then
4152  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
4153
4154elif test "x$use_lapack" != x && test "$use_lapack" != no; then
4155  coin_has_lapack=yes
4156  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
4157  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
4158  LAPACK_LIBS="$use_lapack"
4159  LAPACK_CFLAGS=
4160  LAPACK_DATA=
4161  AC_SUBST(LAPACK_LIBS)
4162  AC_SUBST(LAPACK_CFLAGS)
4163  AC_SUBST(LAPACK_DATA)
4164  coin_foreach_w([myvar], [$1], [
4165    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
4166    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
4167    m4_toupper(myvar)_LIBS_INSTALLED="$LAPACK_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
4168  ])
4169 
4170else
4171  coin_has_lapack=no
4172  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
4173fi
4174
4175coin_foreach_w([myvar], [$1], [
4176  AC_SUBST(m4_toupper(myvar)_PCLIBS)
4177  AC_SUBST(m4_toupper(myvar)_LIBS)
4178  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
4179])
4180
4181]) # AC_COIN_CHECK_PACKAGE_LAPACK
Note: See TracBrowser for help on using the repository browser.