source: trunk/coin.m4 @ 2882

Last change on this file since 2882 was 2880, checked in by tkr, 7 years ago

Fixing issue with CYGWIN and MSVC++

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