source: trunk/coin.m4 @ 2767

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

compiler flags may be determined before deciding on shared or static (fix for previous commit)

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