source: stable/0.7/coin.m4 @ 2098

Last change on this file since 2098 was 2098, checked in by stefan, 11 years ago

bugfix: setup X_INSTALLED variables also if project flags are given by user and pkg-config is disabled

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