source: stable/0.7/coin.m4 @ 2432

Last change on this file since 2432 was 2432, checked in by stefan, 10 years ago

sync with trunk rev2431

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