source: trunk/coin.m4 @ 2099

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

merge chgset 2098 from stable/0.7: fix for using --with-xxx-yyy and no pkg-config and examples

  • Property svn:keywords set to Author Date Id Revision
File size: 140.3 KB
Line 
1# Copyright (C) 2006, 2009 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Eclipse Public License.
4#
5## $Id: coin.m4 2099 2011-01-28 18:10:11Z 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.16.0, since COIN-OR .pc files now
2690# include an URL field, which breaks pkg-config version <= 0.15.
2691# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
2692# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
2693# AC_SUBST'ed.  Finally, if this setup belongs to a project directory, then
2694# the search path for .pc files is assembled from the value of
2695# $PKG_CONFIG_PATH, the values of --prefix, --coin-instdir, and the directories
2696# named in a file ../coin_subdirs.txt or ../../coin_subdirs.txt in a variable
2697# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed. For a path xxx given in the
2698# coin-subdirs.txt, also the directory xxx/pkgconfig is added, if existing.
2699
2700AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
2701[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
2702
2703AC_ARG_ENABLE([pkg-config],
2704  [AC_HELP_STRING([--enable-pkg-config],[use pkg-config if available (default is yes)])],
2705  [use_pkgconfig="$enableval"],
2706  [use_pkgconfig=yes])
2707
2708if test $use_pkgconfig = yes ; then
2709  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
2710    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2711  fi
2712  if test -n "$PKG_CONFIG"; then
2713    _pkg_min_version=m4_default([$1], [0.16.0])
2714    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
2715    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
2716      AC_MSG_RESULT([yes])
2717    else
2718      AC_MSG_RESULT([no])
2719      PKG_CONFIG=""
2720    fi
2721  fi
2722
2723  # check if pkg-config supports the short-errors flag
2724  if test -n "$PKG_CONFIG" && \
2725    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
2726    pkg_short_errors=" --short-errors "
2727  else
2728    pkg_short_errors=""
2729  fi
2730fi
2731
2732AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
2733AC_SUBST(PKG_CONFIG)
2734
2735# assemble pkg-config search path for installed projects
2736COIN_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
2737
2738# 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
2739# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
2740# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
2741if test "x${prefix}" = xNONE ; then
2742  COIN_PKG_CONFIG_PATH="${ac_default_prefix}/lib/pkgconfig:${ac_default_prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2743else
2744  COIN_PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2745fi
2746
2747AC_ARG_WITH([coin-instdir],
2748  AC_HELP_STRING([--with-coin-instdir],
2749                 [prefix of installation directory for precompiled COIN packages]),
2750  [if test -d "$withval"; then : ; else
2751     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
2752   fi
2753   COIN_PKG_CONFIG_PATH="$withval/lib/pkgconfig:$withval/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2754  ],[])
2755
2756AC_SUBST(COIN_PKG_CONFIG_PATH)
2757
2758# assemble additional pkg-config search paths for uninstalled projects
2759if test x$coin_projectdir = xyes ; then
2760  # if we are in a project setup, then in a classic setup, we want to find uninstalled projects
2761  # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
2762  # unfortunately, if the user set prefix, then we do not know where the project base directory is located
2763  # 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)
2764  COIN_PKG_CONFIG_PATH_UNINSTALLED=
2765  if test -e ../coin_subdirs.txt ; then
2766    for i in `cat ../coin_subdirs.txt` ; do
2767      if test -d ../$i ; then
2768        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2769      fi
2770      if test -d ../$i/pkgconfig ; then
2771        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2772      fi
2773    done
2774  fi
2775
2776  if test -e ../../coin_subdirs.txt ; then
2777    for i in `cat ../../coin_subdirs.txt` ; do
2778      if test -d ../../$i ; then
2779        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2780      fi
2781      if test -d ../../$i/pkgconfig ; then
2782        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2783      fi
2784    done
2785  fi
2786
2787  AC_SUBST(COIN_PKG_CONFIG_PATH_UNINSTALLED)
2788fi
2789
2790if test -n "$PKG_CONFIG" && test x$coin_cc_is_cl = xtrue; then
2791  AC_MSG_WARN([Using pkg-config together with MS or Intel Compiler on Windows is not support by example Makefiles. Consider using --disable-pkg-config.])
2792fi
2793
2794])
2795
2796###########################################################################
2797#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
2798###########################################################################
2799
2800# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2801#
2802# Check to see whether a particular project exists.  Similar
2803# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
2804#
2805AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
2806[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2807if test -n "$PKG_CONFIG" ; then
2808  if $PKG_CONFIG --exists "m4_tolower($1)"; then
2809    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
2810    m4_ifval([$2], [$2], [:])
2811  else
2812    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
2813    $3
2814  fi
2815else
2816  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
2817fi
2818])
2819
2820###########################################################################
2821#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
2822###########################################################################
2823
2824# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2825#
2826# Check to see whether a particular set of packages exists.
2827# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
2828#
2829AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
2830[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2831if test -n "$PKG_CONFIG" ; then
2832  if $PKG_CONFIG --exists "$2"; then
2833    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`"
2834    $3
2835  else
2836    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
2837    $4
2838  fi
2839else
2840  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
2841fi
2842])
2843
2844###########################################################################
2845#                           COIN_PKG_HAS_MODULE                           #
2846###########################################################################
2847
2848# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2849#
2850# Checks whether pkg-config files for a given set of packages is available.
2851# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
2852# If not, then ACTION-IF-NOT-FOUND is executed.
2853# A reason for not finding a package is stored in MODULE_PKG_ERRORS
2854#
2855# --------------------------------------------------------------
2856AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
2857[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2858
2859AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
2860  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
2861    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
2862        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
2863        # but only do this if is not trivial
2864    if test "$CYGPATH_W" != "echo" ; then
2865      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
2866      [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
2867    fi
2868    m4_toupper($1)[]_CFLAGS="$cflags"
2869    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
2870    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
2871    $3
2872  ],
2873  [ $4 ])
2874
2875])# PKG_CHECK_MODULES
2876
2877###########################################################################
2878#                           COIN_MAIN_PACKAGEDIR                          #
2879###########################################################################
2880
2881# This macro substitutes COIN_MAIN_SUBDIR.
2882# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
2883# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
2884# Otherwise, if pkg-config is available, use it to check whether the package is available.
2885#   If $4 is given, then pkg-config is asked for the existance of $4, otherwise tolower($1) is used.
2886# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
2887#   If so, include this directory into the list of directories where configure and make recourse into.
2888# tolower(coin_has_$1) is set to notGiven, skipping, installed, the version of an installed project, or the projects main directory (if uninstalled).
2889
2890AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],
2891[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2892AC_MSG_CHECKING([whether project $1 is available])
2893
2894m4_tolower(coin_has_$1)=notGiven
2895coin_have_project_dir=no
2896
2897# check if user wants to skip project in any case
2898AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
2899if test x"$COIN_SKIP_PROJECTS" != x; then
2900  for dir in $COIN_SKIP_PROJECTS; do
2901    if test $dir = "$1"; then
2902      m4_tolower(coin_has_$1)=skipping
2903    fi
2904    if test $dir = "$2/$1"; then
2905      m4_tolower(coin_has_$1)=skipping
2906    fi
2907  done
2908fi
2909
2910if test "$m4_tolower(coin_has_$1)" != skipping; then
2911  if test $PACKAGE_TARNAME = m4_tolower($1); then
2912    m4_tolower(coin_has_$1)=yes
2913    coin_have_project_dir=yes
2914  fi
2915
2916  AC_ARG_WITH([m4_tolower($1)-lib],
2917    AC_HELP_STRING([--with-m4_tolower($1)-lib],
2918                   [linker flags for using project $1]),
2919    [if test "$withval" = no ; then
2920       m4_tolower(coin_has_$1)=skipping
2921     else
2922       m4_tolower(coin_has_$1)="yes, via --with-m4_tolower($1)-lib"
2923     fi],
2924    [])
2925fi
2926
2927if test "$m4_tolower(coin_has_$1)" != skipping; then
2928  AC_ARG_WITH([m4_tolower($1)-incdir],
2929    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
2930                   [directory with header files for using project $1]),
2931    [if test "$withval" = no ; then
2932       m4_tolower(coin_has_$1)=skipping
2933     else
2934       m4_tolower(coin_has_$1)="yes, via --with-m4_tolower($1)-incdir"
2935     fi],
2936    [])
2937fi
2938
2939if test "$m4_tolower(coin_has_$1)" != skipping; then
2940  AC_ARG_WITH([m4_tolower($1)-datadir],
2941    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
2942                   [directory with data files for using project $1]),
2943    [if test "$withval" = no ; then
2944       m4_tolower(coin_has_$1)=skipping
2945     else
2946       m4_tolower(coin_has_$1)="yes, via --with-m4_tolower($1)-datadir"
2947     fi],
2948    [])
2949fi
2950
2951m4_if(m4_tolower($1), blas, [
2952  if test $m4_tolower(coin_has_$1) != skipping; then
2953    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
2954    AC_ARG_WITH([blas],
2955      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
2956        [if test x"$withval" = "xBUILD" ; then
2957           coin_has_blas=notGiven
2958         elif test x"$withval" = "xno" ; then
2959           coin_has_blas=skipping
2960         else
2961           coin_has_blas="yes, via --with-blas"
2962         fi],
2963        [])
2964  fi
2965])
2966
2967m4_if(m4_tolower($1), lapack, [
2968  if test $m4_tolower(coin_has_$1) != skipping; then
2969    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
2970    AC_ARG_WITH([lapack],
2971      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
2972        [if test x"$withval" = "xBUILD" ; then
2973           coin_has_lapack=notGiven
2974         elif test x"$withval" = "xno" ; then
2975           coin_has_lapack=skipping
2976         else
2977           coin_has_lapack="yes, via --with-lapack"
2978         fi],
2979        [])
2980  fi
2981])
2982
2983# check if project is available in present directory
2984if test "$m4_tolower(coin_has_$1)" = notGiven; then
2985  if test -d $srcdir/$2/$1; then
2986    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
2987    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
2988    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
2989    m4_ifvaln([$3],
2990      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
2991         if test -r $i; then
2992           coin_have_project_dir=yes
2993         fi
2994       done],
2995      [ coin_have_project_dir=yes ])
2996    if test $coin_have_project_dir = yes; then
2997      m4_tolower(coin_has_$1)="yes, source in m4_ifval($2,[$2/],)$1"
2998    fi
2999  fi
3000fi
3001
3002# check for project by using pkg-config, if pkg-config is available
3003if test "$m4_tolower(coin_has_$1)" = notGiven; then
3004  #we are only interested in installed packages here, so we do not search in $COIN_PKG_CONFIG_PATH_UNINSTALLED
3005  if test -n "$PKG_CONFIG" ; then
3006    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3007    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" ; export PKG_CONFIG_PATH
3008      m4_ifval([$4],
3009        [AC_COIN_PKG_CHECK_PROJECT_EXISTS([$4],
3010                [m4_tolower(coin_has_$1)="yes, found installed version $m4_toupper([$4])_VERSION"])],
3011              [AC_COIN_PKG_CHECK_PROJECT_EXISTS([$1],
3012                [m4_tolower(coin_has_$1)="yes, found installed version $m4_toupper([$1])_VERSION"])])
3013    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3014    export PKG_CONFIG_PATH
3015  fi
3016fi
3017
3018if test "$m4_tolower(coin_has_$1)" = notGiven; then
3019  m4_case(m4_tolower($1),
3020    [blas],
3021    [AC_MSG_RESULT([no (but will check for system blas later)])],
3022    [lapack],
3023    [AC_MSG_RESULT([no (but will check for system lapack later)])],
3024    [AC_MSG_RESULT([not given])]
3025  )
3026else
3027  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3028fi
3029
3030if test "$coin_have_project_dir" = yes ; then
3031  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
3032    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
3033    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
3034  fi
3035fi
3036])
3037
3038###########################################################################
3039#                            COIN_CHECK_PACKAGE                           #
3040###########################################################################
3041
3042# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
3043# A package can consists of one or more COIN-OR or other projects.
3044# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, PACKAGE_DEPENDENCIES, and PACKAGE_DATA variables, referring to the compiler and linker
3045# flags to use when linking against this module, the libraries the package depends on, and the directories where the module data resists.
3046# The difference between PACKAGE_LIBS and PACKAGE_DEPENDENCIES is that PACKAGE_DEPENDENCIES does not contain arguments starting with '-',
3047# so it can be used to setup the _DEPENDENCIES variable in a Makefile.am.
3048# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
3049# Further, tolower(coin_has_$1) is set to "yes".
3050# If a list of build targets using this projects is given in the third argument,
3051# then the compiler and linker variables and .pc file setup variable corresponding to this build target
3052# are extended with the values for this package.
3053# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_DEPENDENCIES, X_PCLIBS, X_PCREQUIRES are setup,
3054# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
3055#
3056# The first argument should be the name (PACKAGE) of the package (in correct lower
3057# and upper case).
3058# The second argument should be a (space separated) list of projects which this
3059# package consists of. Optionally, required version numbers can be added.
3060# The optional third argument should be a (space separated) list of build targets
3061# which use this package, if available.
3062#
3063# It is also possible to specify a preinstalled version of this package
3064# or to specify only the linker and compiler flags and data directory.
3065#
3066# If the user did not specify --with-$1-... flags and pkg-config is not available,
3067# COIN_CHECK_PACKAGE_FALLBACK($1, $2, $3) is called.
3068
3069AC_DEFUN([AC_COIN_CHECK_PACKAGE],
3070[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3071AC_MSG_CHECKING([for COIN-OR package $1])
3072
3073m4_tolower(coin_has_$1)=notGiven
3074
3075# check if user wants to skip package in any case
3076if test x"$COIN_SKIP_PROJECTS" != x; then
3077  for dir in $COIN_SKIP_PROJECTS; do
3078    if test $dir = "$1"; then
3079      m4_tolower(coin_has_$1)=skipping
3080    fi
3081  done
3082fi
3083
3084m4_toupper($1_LIBS)=
3085m4_toupper($1_CFLAGS)=
3086m4_toupper($1_DATA)=
3087AC_SUBST(m4_toupper($1_LIBS))
3088AC_SUBST(m4_toupper($1_CFLAGS))
3089AC_SUBST(m4_toupper($1_DATA))
3090AC_SUBST(m4_toupper($1_DEPENDENCIES))
3091AC_SUBST(m4_toupper($1_LIBS_INSTALLED))
3092AC_SUBST(m4_toupper($1_CFLAGS_INSTALLED))
3093AC_SUBST(m4_toupper($1_DATA_INSTALLED))
3094coin_foreach_w([myvar], [$3], [
3095  AC_SUBST(m4_toupper(myvar)_CFLAGS)
3096  AC_SUBST(m4_toupper(myvar)_LIBS)
3097  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3098  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
3099  AC_SUBST(m4_toupper(myvar)_DEPENDENCIES)
3100  AC_SUBST(m4_toupper(myvar)_CFLAGS_INSTALLED)
3101  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3102])
3103
3104#check if user provided LIBS, CFLAGS, or DATA for package or disables use of package
3105if test $m4_tolower(coin_has_$1) != skipping; then
3106  AC_ARG_WITH([m4_tolower($1)-lib],
3107    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3108                   [linker flags for using package $1]),
3109    [if test "$withval" = no ; then
3110       m4_tolower(coin_has_$1)=skipping
3111     else
3112       m4_tolower(coin_has_$1)=yes
3113       m4_toupper($1_LIBS)="$withval"
3114       coin_foreach_w([myvar], [$3], [
3115         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
3116         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
3117       ])
3118       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3119       if test -z "$PKG_CONFIG" ; then
3120         m4_toupper($1_LIBS_INSTALLED)="$withval"
3121         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_LIBS_INSTALLED="$withval $m4_toupper(myvar)_LIBS_INSTALLED"])
3122       fi
3123     fi
3124    ],
3125    [])
3126fi
3127
3128if test $m4_tolower(coin_has_$1) != skipping; then
3129  AC_ARG_WITH([m4_tolower($1)-incdir],
3130    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3131                   [directory with header files for using package $1]),
3132    [if test "$withval" = no ; then
3133       m4_tolower(coin_has_$1)=skipping
3134     else
3135       m4_tolower(coin_has_$1)=yes
3136       m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
3137       coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="-I`${CYGPATH_W} $withval` $m4_toupper(myvar)_CFLAGS"])
3138       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3139       if test -z "$PKG_CONFIG" ; then
3140         m4_toupper($1_CFLAGS_INSTALLED)="$m4_toupper($1_CFLAGS)"
3141         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1_CFLAGS) $m4_toupper(myvar)_CFLAGS_INSTALLED"])
3142       fi
3143     fi
3144    ],
3145    [])
3146fi
3147
3148if test $m4_tolower(coin_has_$1) != skipping; then
3149  AC_ARG_WITH([m4_tolower($1)-datadir],
3150    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3151                   [directory with data files for using package $1]),
3152    [if test "$withval" = no ; then
3153       m4_tolower(coin_has_$1)=skipping
3154     else
3155       m4_tolower(coin_has_$1)=yes
3156       m4_toupper($1_DATA)="$withval"
3157       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3158       if test -z "$PKG_CONFIG" ; then
3159         m4_toupper($1_DATA_INSTALLED)="$withval"
3160       fi
3161     fi
3162    ],
3163    [])
3164fi
3165
3166if test $m4_tolower(coin_has_$1) = notGiven; then
3167  if test -n "$PKG_CONFIG" ; then
3168    # set search path for pkg-config
3169    # need to export variable to be sure that the following pkg-config gets these values
3170    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3171    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
3172    export PKG_CONFIG_PATH
3173   
3174    # let pkg-config do it's magic
3175    AC_COIN_PKG_HAS_MODULE([$1],[$2],
3176      [ m4_tolower(coin_has_$1)=yes
3177        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
3178
3179        # adjust linker flags for (i)cl compiler
3180        # 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)
3181        if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3182        then
3183          m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3184        fi
3185   
3186        # augment X_PCREQUIRES, X_CFLAGS, and X_LIBS for each build target X in $3
3187        coin_foreach_w([myvar], [$3], [
3188          m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3189          m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3190          m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3191        ])
3192      ],
3193      [ m4_tolower(coin_has_$1)=notGiven
3194        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
3195      ])
3196
3197    # reset PKG_CONFIG_PATH variable
3198    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3199    export PKG_CONFIG_PATH
3200
3201  else
3202    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
3203    AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
3204  fi
3205
3206else
3207  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3208fi
3209
3210if test $m4_tolower(coin_has_$1) != skipping &&
3211   test $m4_tolower(coin_has_$1) != notGiven ; then
3212  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3213
3214  AC_ARG_ENABLE([interpackage-dependencies],
3215    AC_HELP_STRING([--enable-interpackage-dependencies], [whether to deduce Makefile dependencies from package linker flags (default: yes)]),
3216    [], [enable_interpackage_dependencies=yes])
3217   
3218  if test $enable_interpackage_dependencies = yes ; then
3219     # construct dependencies variables from LIBS variables
3220     # we add an extra space in LIBS so we can substitute out everything starting with " -"
3221     # remove everything of the form -framework xxx as used on Mac and mklxxx as used on Windows
3222     # then remove everything of the form -xxx
3223     # also remove everything of the form `xxx`yyy (may have been added for cygwin/cl)
3224     m4_toupper($1)_DEPENDENCIES=`echo " $m4_toupper($1)_LIBS" | [sed -e 's/ mkl[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
3225     coin_foreach_w([myvar], [$3], [
3226       m4_toupper(myvar)_DEPENDENCIES=`echo " $m4_toupper(myvar)_LIBS " | [sed -e 's/ mkl[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
3227     ])
3228  fi
3229
3230  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
3231    if test -n "$m4_toupper($1)_CFLAGS" ; then
3232      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3233    fi
3234    if test -n "$m4_toupper($1)_LIBS" ; then
3235      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
3236    fi
3237    if test -n "$m4_toupper($1)_DEPENDENCIES" ; then
3238      AC_MSG_NOTICE([$1 DEPENDENCIES are $m4_toupper($1)_DEPENDENCIES])
3239    fi
3240    if test -n "$m4_toupper($1)_DATA" ; then
3241      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
3242    fi
3243    if test -n "$m4_toupper($1)_CFLAGS" ; then
3244      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3245    fi
3246    coin_foreach_w([myvar], [$3], [
3247      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
3248      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
3249      AC_MSG_NOTICE([myvar DEPENDENCIES are $m4_toupper(myvar)_DEPENDENCIES])
3250    ])
3251  fi
3252fi
3253
3254# Define the Makefile conditional
3255AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3256               [test $m4_tolower(coin_has_$1) != notGiven &&
3257                test $m4_tolower(coin_has_$1) != skipping])
3258
3259]) # AC_COIN_CHECK_PACKAGE
3260
3261###########################################################################
3262#                       COIN_CHECK_PACKAGE_FALLBACK                       #
3263###########################################################################
3264
3265# This macro is used by COIN_CHECK_PACKAGE, if it fails to find a package
3266# because pkg-config was disabled or is not available.
3267#
3268# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc
3269# file in the directories specified in $COIN_PKG_CONFIG_PATH_UNINSTALLED. The
3270# latter variable is setup by COIN_HAS_PKGCONFIG and consists of the content
3271# of the coin_subdirs.txt file which has been created by configure in the
3272# base directory.  The content of xxx-uninstalled.pc is parsed in order
3273# to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
3274# referring to the compiler and linker flags to use when linking against this
3275# package and the directory where the package data resists.  Further, for each
3276# build target X specified in the third argument, the variables X_CFLAGS and
3277# X_LIBS are extended with the compiler and linker flags of this package and
3278# the variables X_PCLIBS and X_PCREQUIRES are extended by the list of linker
3279# flags and dependent projects as needed to setup a .pc file.  The macros
3280# checks also dependencies of $2.  Note that the PACKAGE_DATA variable is
3281# set to the content of datadir of the first .pc file that is parsed.
3282# Finally, for each X in the third argument, also variables
3283# X_CFLAGS_INSTALLED and X_LIBS_INSTALLED are setup. They contain the compiler
3284# and linker flags for X when all projects have been installed. Their content
3285# is assembled from the .pc files that correspond to installed projects. I.e.,
3286# whenever a file proj-uninstalled.pc is parsed, then also a corresponding
3287# proj.pc file is parsed for compiler and linker flags, if available in the
3288# same directory.
3289# Similar, a variable PACKAGE_DATA_INSTALLED is setup to the content of datadir
3290# of the first .pc file that is parsed.
3291#
3292# If .pc files for all projects in $2 and their dependencies is found,
3293# tolower(coin_has_$1) is set to "yes".  Otherwise, if some dependency
3294# is not found, tolower(coin_has_$1) is set to "notGiven".  Further, a
3295# COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
3296#
3297# The first argument should be the name (PACKAGE) of the package (in correct
3298# lower and upper case).  The second argument should be the base names of the
3299# projects .pc file which define this package.  The optional third argument
3300# should be a (space separated) list of build targets which use this package,
3301# if available.
3302#
3303# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into
3304# $COIN_PKG_CONFIG_PATH_UNINSTALLED.  When the content of this variable was
3305# setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
3306
3307AC_DEFUN([AC_COIN_CHECK_PACKAGE_FALLBACK],
3308[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3309AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
3310
3311m4_tolower(coin_has_$1)=notGiven
3312m4_toupper($1_LIBS)=
3313m4_toupper($1_LIBS_INSTALLED)=
3314m4_toupper($1_CFLAGS)=
3315m4_toupper($1_CFLAGS_INSTALLED)=
3316m4_toupper($1_DATA)=
3317m4_toupper($1_DATA_INSTALLED)=
3318
3319# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x)
3320projtoprocess="m4_bpatsubsts([$2], [<?>?=[      ]*[^    ]+])"
3321
3322# we first expand the list of projects to process by adding all dependencies just behind the project which depends on it
3323# further, we collect the list of corresponding .pc files, but do this in reverse order, because we need this order afterwards
3324# the latter we also do with .pc files corresponding to the installed projects, which will be needed to setup Makefiles for examples
3325# also, we setup the DATA variable
3326allproj=""
3327allpcfiles=""
3328allpcifiles=""
3329while test "x$projtoprocess" != x ; do
3330
3331  for proj in $projtoprocess ; do
3332    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
3333    pcfile=""
3334    save_IFS="$IFS"
3335    IFS=":"
3336    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
3337      # 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
3338      if test -r "$dir/${proj}-uninstalled.pc" ; then
3339        pcfile="$dir/$proj-uninstalled.pc"
3340        if test -r "$dir/${proj}.pc" ; then
3341          pcifile="$dir/${proj}.pc"
3342        else
3343          AC_MSG_WARN([Found $pcfile, but $dir/${proj}.pc is not available. This may break Makefile's of examples.])
3344          pcifile=
3345        fi
3346        break
3347      fi
3348    done
3349    IFS="$save_IFS"
3350
3351    if test "x$pcfile" != x ; then
3352      # read dependencies from $pcfile and filter it
3353      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\{0,1\}>\{0,1\}=[       ]\{0,\}[^       ]\{1,\}//g'`]
3354
3355      # add projrequires to the front of the list of projects that have to be processed next
3356      # at the same time, remove $proj from this list
3357      projtoprocess=${projtoprocess/$proj/$projrequires}
3358
3359      # read DATA from $pcfile, if _DATA is still empty
3360      if test "x$m4_toupper($1_DATA)" = x ; then
3361        projdatadir=
3362        [pcfilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcfile`]
3363        eval `sh -c "$pcfilemod"`
3364        m4_toupper($1_DATA)="$projdatadir"
3365      fi
3366
3367      allproj="$allproj $proj"
3368      allpcfiles="$pcfile:$allpcfiles"
3369
3370    else
3371      AC_MSG_RESULT([no, dependency $proj not available])
3372      allproj=fail
3373      break 2
3374    fi
3375   
3376    if test "x$pcifile" != x ; then
3377      allpcifiles="$pcifile:$allpcifiles"
3378     
3379      # read DATA_INSTALLED from $pcifile, if _DATA_INSTALLED is still empty
3380      if test "x$m4_toupper($1_DATA_INSTALLED)" = x ; then
3381        projdatadir=
3382        [pcifilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcifile`]
3383        eval `sh -c "$pcifilemod"`
3384        if test "${CYGPATH_W}" != "echo"; then
3385          projdatadir="\`\$(CYGPATH_W) ${projdatadir} | sed -e 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g'\`"
3386        fi
3387        m4_toupper($1_DATA_INSTALLED)="$projdatadir"
3388      fi
3389     
3390    fi
3391
3392    break
3393  done
3394
3395  # remove spaces on begin of $projtoprocess
3396  projtoprocess=`echo $projtoprocess | sed -e 's/^[ ]*//'`
3397
3398done
3399
3400if test "$allproj" != fail ; then
3401
3402  # now go through the list of .pc files and assemble compiler and linker flags
3403  # important is here to obey the reverse order that has been setup before,
3404  # since then libraries that are required by several others should be after these other libraries
3405  pcfilesprocessed=""
3406
3407  save_IFS="$IFS"
3408  IFS=":"
3409  for pcfile in $allpcfiles ; do
3410
3411    # if $pcfile has been processed already, skip this round
3412    if test "x$pcfilesprocessed" != x ; then
3413      for pcfiledone in $pcfilesprocessed ; do
3414        if test "$pcfiledone" = "$pcfile" ; then
3415          continue 2
3416        fi
3417      done
3418    fi
3419
3420    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3421    #   replace "Libs:" by "echo projlibs="
3422    #   replace "Cflags:" by "echo projcflags="
3423    #   remove every line starting with <some word>:
3424    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/[a-zA-Z]:/d' $pcfile`]
3425
3426    # set projcflags and projlibs variables by running $pcfilemod
3427    projcflags=
3428    projlibs=
3429    eval `sh -c "$pcfilemod"`
3430
3431    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3432    if test "${CYGPATH_W}" != "echo"; then
3433      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3434    fi
3435    m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
3436
3437    # set LIBS variable
3438    m4_toupper($1_LIBS)="$projlibs $m4_toupper($1_LIBS)"
3439
3440    # remember that we have processed $pcfile
3441    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3442
3443  done
3444  IFS="$save_IFS"
3445
3446
3447  # now go through the list of .pc files for installed projects and assemble compiler and linker flags
3448  # important is here again to obey the reverse order that has been setup before,
3449  # since then libraries that are required by several others should be after these other libraries
3450  pcfilesprocessed=""
3451
3452  save_IFS="$IFS"
3453  IFS=":"
3454  for pcfile in $allpcifiles ; do
3455
3456    # if $pcfile has been processed already, skip this round
3457    if test "x$pcfilesprocessed" != x ; then
3458      for pcfiledone in $pcfilesprocessed ; do
3459        if test "$pcfiledone" = "$pcfile" ; then
3460          continue 2
3461        fi
3462      done
3463    fi
3464
3465    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3466    #   replace "Libs:" by "echo projlibs="
3467    #   replace "Cflags:" by "echo projcflags="
3468    #   remove every line starting with <some word>:
3469    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/[a-zA-Z]:/d' $pcfile`]
3470
3471    # set projcflags and projlibs variables by running $pcfilemod
3472    projcflags=
3473    projlibs=
3474    eval `sh -c "$pcfilemod"`
3475
3476    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3477    if test "${CYGPATH_W}" != "echo"; then
3478      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3479    fi
3480    m4_toupper($1_CFLAGS_INSTALLED)="$projcflags $m4_toupper($1_CFLAGS_INSTALLED)"
3481
3482    # set LIBS variable
3483    m4_toupper($1_LIBS_INSTALLED)="$projlibs $m4_toupper($1_LIBS_INSTALLED)"
3484   
3485    # remember that we have processed $pcfile
3486    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3487
3488  done
3489  IFS="$save_IFS"
3490
3491
3492  # finish up
3493  m4_tolower(coin_has_$1)=yes
3494  AC_MSG_RESULT([yes])
3495  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3496
3497  # adjust linker flags for (i)cl compiler
3498  # 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),
3499  # for the LIBS_INSTALLED, we replace everything of the form "/somepath/" by "`$(CYGPATH_W) /somepath/`",
3500  #    everything of the form "-Lpath" by "/libpath:`$(CYGPATH_W) path`, and
3501  #    everything of the form "-lname" by "libname.lib"
3502  if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3503  then
3504    m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3505    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']`
3506  fi
3507
3508  coin_foreach_w([myvar], [$3], [
3509    m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3510    m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3511    m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3512    m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1)_CFLAGS_INSTALLED $m4_toupper(myvar)_CFLAGS_INSTALLED"
3513    m4_toupper(myvar)_LIBS_INSTALLED="$m4_toupper($1)_LIBS_INSTALLED $m4_toupper(myvar)_LIBS_INSTALLED"
3514  ])
3515
3516fi
3517
3518AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3519               [test $m4_tolower(coin_has_$1) != notGiven &&
3520                test $m4_tolower(coin_has_$1) != skipping])
3521
3522]) # AC_COIN_CHECK_PACKAGE_FALLBACK
3523
3524###########################################################################
3525#                         COIN_CHECK_PACKAGE_BLAS                         #
3526###########################################################################
3527
3528# This macro checks for a library containing the BLAS library.  It
3529# 1. checks the --with-blas argument
3530# 2. if --with-blas=BUILD has been specified goes to point 5
3531# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
3532#    to its value
3533# 4. tries standard libraries
3534# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
3535#    ThirdParty/Blas
3536# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
3537# BLAS_LIBS is set to the flags required to link with a Blas library.
3538# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
3539# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
3540# In case 5, Blas is added to X_PCREQUIRES.
3541
3542AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
3543[
3544AC_ARG_WITH([blas],
3545            AC_HELP_STRING([--with-blas],
3546                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
3547            [use_blas="$withval"], [use_blas=])
3548
3549# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
3550# preference
3551AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
3552
3553# Check if user supplied option makes sense
3554if test x"$use_blas" != x; then
3555  if test "$use_blas" = "BUILD"; then
3556    # we come to this later
3557    :
3558  elif test "$use_blas" != "no"; then
3559    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
3560    coin_need_flibs=no
3561    coin_save_LIBS="$LIBS"
3562    LIBS="$use_blas $LIBS"
3563    AC_COIN_TRY_FLINK([daxpy],
3564                      [if test $coin_need_flibs = yes ; then
3565                         use_blas="$use_blas $FLIBS"
3566                       fi
3567                       AC_MSG_RESULT([yes: $use_blas])],
3568                      [AC_MSG_RESULT([no])
3569                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
3570    LIBS="$coin_save_LIBS"
3571  fi
3572else
3573# Try to autodetect the library for blas based on build system
3574  #AC_MSG_CHECKING([default locations for BLAS])
3575  skip_lblas_check=no
3576  case $build in
3577    *-sgi-*)
3578      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
3579      coin_need_flibs=no
3580      coin_save_LIBS="$LIBS"
3581      LIBS="-lcomplib.sgimath $LIBS"
3582      AC_COIN_TRY_FLINK([daxpy],
3583                        [use_blas="-lcomplib.sgimath"
3584                         if test $coin_need_flibs = yes ; then
3585                           use_blas="$use_blas $FLIBS"
3586                         fi
3587                         AC_MSG_RESULT([yes: $use_blas])
3588                        ],
3589                        [AC_MSG_RESULT([no])])
3590      LIBS="$coin_save_LIBS"
3591      ;;
3592
3593# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
3594# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
3595# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
3596# that CC and cc will understand -library in Studio 13. The main extra
3597# function of -xlic_lib and -library is to arrange for the Fortran run-time
3598# libraries to be linked for C++ and C. We can arrange that explicitly.
3599    *-*-solaris*)
3600      AC_MSG_CHECKING([for BLAS in libsunperf])
3601      coin_need_flibs=no
3602      coin_save_LIBS="$LIBS"
3603      LIBS="-lsunperf $FLIBS $LIBS"
3604      AC_COIN_TRY_FLINK([daxpy],
3605                        [use_blas='-lsunperf'
3606                         if test $coin_need_flibs = yes ; then
3607                           use_blas="$use_blas $FLIBS"
3608                         fi
3609                         AC_MSG_RESULT([yes: $use_blas])
3610                        ],
3611                        [AC_MSG_RESULT([no])])
3612      LIBS="$coin_save_LIBS"
3613      ;;
3614     
3615    *-cygwin* | *-mingw*)
3616# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
3617# library will want to link with cygwin, hence won't run standalone in DOS.
3618      if test "$enable_doscompile" = mingw; then
3619        skip_lblas_check=yes
3620      fi
3621      case "$CC" in
3622        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
3623          coin_save_LIBS="$LIBS"
3624          AC_MSG_CHECKING([for BLAS in MKL (32bit)])
3625          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
3626          AC_COIN_TRY_FLINK([daxpy],
3627                            [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
3628                             AC_MSG_RESULT([yes: $use_blas])
3629                            ],
3630                            [AC_MSG_RESULT([no])])
3631          LIBS="$coin_save_LIBS"
3632         
3633          if test "x$use_blas" = x ; then
3634            AC_MSG_CHECKING([for BLAS in MKL (64bit)])
3635            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
3636            AC_COIN_TRY_FLINK([daxpy],
3637                              [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
3638                               AC_MSG_RESULT([yes: $use_blas])
3639                              ],
3640                              [AC_MSG_RESULT([no])])
3641            LIBS="$coin_save_LIBS"
3642          fi
3643          ;;
3644      esac
3645      ;;
3646     
3647     *-darwin*)
3648      AC_MSG_CHECKING([for BLAS in Veclib])
3649      coin_need_flibs=no
3650      coin_save_LIBS="$LIBS"
3651      LIBS="-framework vecLib $LIBS"
3652      AC_COIN_TRY_FLINK([daxpy],
3653                        [use_blas='-framework vecLib'
3654                         if test $coin_need_flibs = yes ; then
3655                           use_blas="$use_blas $FLIBS"
3656                         fi
3657                         AC_MSG_RESULT([yes: $use_blas])
3658                        ],
3659                        [AC_MSG_RESULT([no])])
3660      LIBS="$coin_save_LIBS"
3661      ;;
3662  esac
3663
3664  if test -z "$use_blas" && test $skip_lblas_check = no; then
3665    AC_MSG_CHECKING([whether -lblas has BLAS])
3666    coin_need_flibs=no
3667    coin_save_LIBS="$LIBS"
3668    LIBS="-lblas $LIBS"
3669    AC_COIN_TRY_FLINK([daxpy],
3670                      [use_blas='-lblas'
3671                       if test $coin_need_flibs = yes ; then
3672                         use_blas="$use_blas $FLIBS"
3673                       fi
3674                       AC_MSG_RESULT([yes: $use_blas])
3675                      ],
3676                      [AC_MSG_RESULT([no])])
3677    LIBS="$coin_save_LIBS"
3678  fi
3679
3680  # If we have no other ideas, consider building BLAS.
3681  if test -z "$use_blas" ; then
3682    use_blas=BUILD
3683  fi
3684fi
3685
3686if test "x$use_blas" = xBUILD ; then
3687  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
3688 
3689elif test "x$use_blas" != x && test "$use_blas" != no; then
3690  coin_has_blas=yes
3691  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
3692  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
3693  BLAS_LIBS="$use_blas"
3694  BLAS_CFLAGS=
3695  BLAS_DATA=
3696  AC_SUBST(BLAS_LIBS)
3697  AC_SUBST(BLAS_CFLAGS)
3698  AC_SUBST(BLAS_DATA)
3699  coin_foreach_w([myvar], [$1], [
3700    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
3701    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
3702    m4_toupper(myvar)_LIBS_INSTALLED="$BLAS_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
3703  ])
3704 
3705else
3706  coin_has_blas=no
3707  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
3708fi
3709
3710coin_foreach_w([myvar], [$1], [
3711  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3712  AC_SUBST(m4_toupper(myvar)_LIBS)
3713  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3714])
3715
3716]) # AC_COIN_CHECK_PACKAGE_BLAS
3717
3718###########################################################################
3719#                       COIN_CHECK_PACKAGE_LAPACK                         #
3720###########################################################################
3721
3722# This macro checks for a library containing the LAPACK library.  It
3723# 1. checks the --with-lapack argument
3724# 2. if --with-lapack=BUILD has been specified goes to point 5
3725# 3. if --with-lapack has been specified to a working library, sets
3726#    LAPACK_LIBS to its value
3727# 4. tries standard libraries
3728# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
3729#    ThirdParty/Lapack
3730# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
3731# LAPACK_LIBS is set to the flags required to link with a Lapack library.
3732# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
3733# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
3734# In case 5, Lapack is added to X_PCREQUIRES.
3735#
3736# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
3737#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
3738#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
3739#   then we will get Blas as dependency of coinlapack.
3740
3741AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
3742[
3743AC_ARG_WITH([lapack],
3744            AC_HELP_STRING([--with-lapack],
3745                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
3746            [use_lapack=$withval], [use_lapack=])
3747
3748#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
3749AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
3750
3751# Check if user supplied option makes sense
3752if test x"$use_lapack" != x; then
3753  if test "$use_lapack" = "BUILD"; then
3754    # we come to this later
3755    :
3756  elif test "$use_lapack" != no; then
3757    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
3758    coin_need_flibs=no
3759    use_lapack="$use_lapack $BLAS_LIBS"
3760    coin_save_LIBS="$LIBS"
3761    LIBS="$use_lapack $LIBS"
3762    AC_COIN_TRY_FLINK([dsyev],
3763                      [if test $coin_need_flibs = yes ; then
3764                         use_lapack="$use_lapack $FLIBS"
3765                       fi
3766                       AC_MSG_RESULT([yes: $use_lapack])
3767                      ],
3768                      [AC_MSG_RESULT([no])
3769                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
3770    LIBS="$coin_save_LIBS"
3771  fi
3772else
3773  if test x$coin_has_blas = xyes; then
3774    # First try to see if LAPACK is already available with BLAS library
3775    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
3776    coin_save_LIBS="$LIBS"
3777    coin_need_flibs=no
3778    LIBS="$BLAS_LIBS $LIBS"
3779    AC_COIN_TRY_FLINK([dsyev],
3780                      [use_lapack="$BLAS_LIBS"
3781                       if test $coin_need_flibs = yes ; then
3782                         use_lapack="$use_lapack $FLIBS"
3783                       fi
3784                       AC_MSG_RESULT([yes: $use_lapack])
3785                      ],
3786                      [AC_MSG_RESULT([no])])
3787    LIBS="$coin_save_LIBS"
3788  fi
3789  skip_llapack_check=no
3790  if test -z "$use_lapack"; then
3791    # Try to autodetect the library for lapack based on build system
3792    case $build in
3793      # TODO: Is this check actually needed here, since -lcomplib.sigmath should have been recognized as Blas library,
3794      #       and above it is checked whether the Blas library already contains Lapack
3795      *-sgi-*)
3796        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
3797        coin_save_LIBS="$LIBS"
3798        coin_need_flibs=no
3799        LIBS="-lcomplib.sgimath $BLAS_LIBS $LIBS"
3800        AC_COIN_TRY_FLINK([dsyev],
3801                          [use_lapack="-lcomplib.sgimath $BLAS_LIBS"
3802                           if test $coin_need_flibs = yes ; then
3803                             use_lapack="$use_lapack $FLIBS"
3804                           fi
3805                           AC_MSG_RESULT([yes: $use_lapack])
3806                          ],
3807                          [AC_MSG_RESULT([no])])
3808        LIBS="$coin_save_LIBS"
3809        ;;
3810
3811      # See comments in COIN_CHECK_PACKAGE_BLAS.
3812      # TODO: Is this check actually needed here, since -lsunperf should have been recognized as Blas library,
3813      #       and above it is checked whether the Blas library already contains Lapack
3814      *-*-solaris*)
3815        AC_MSG_CHECKING([for LAPACK in libsunperf])
3816        coin_need_flibs=no
3817        coin_save_LIBS="$LIBS"
3818        LIBS="-lsunperf $BLAS_LIBS $FLIBS $LIBS"
3819        AC_COIN_TRY_FLINK([dsyev],
3820                          [use_lapack='-lsunperf $BLAS_LIBS'
3821                           if test $coin_need_flibs = yes ; then
3822                             use_lapack="$use_lapack $FLIBS"
3823                           fi
3824                           AC_MSG_RESULT([yes: $use_lapack])
3825                          ],
3826                          [AC_MSG_RESULT([no])])
3827        LIBS="$coin_save_LIBS"
3828        ;;
3829        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
3830        # will want to link with cygwin, hence won't run standalone in DOS.
3831       
3832      *-cygwin*)
3833        if test "$enable_doscompile" = mingw; then
3834          skip_llapack_check=yes
3835        fi
3836        ;;
3837       
3838    esac
3839  fi
3840
3841  if test -z "$use_lapack" && test $skip_llapack_check = no; then
3842    AC_MSG_CHECKING([whether -llapack has LAPACK])
3843    coin_need_flibs=no
3844    coin_save_LIBS="$LIBS"
3845    LIBS="-llapack $BLAS_LIBS $LIBS"
3846    AC_COIN_TRY_FLINK([dsyev],
3847                      [use_lapack='-llapack'
3848                       if test $coin_need_flibs = yes ; then
3849                         use_lapack="$use_lapack $FLIBS"
3850                       fi
3851                       AC_MSG_RESULT([yes: $use_lapack])
3852                      ],
3853                      [AC_MSG_RESULT([no])])
3854    LIBS="$coin_save_LIBS"
3855  fi
3856
3857  # If we have no other ideas, consider building LAPACK.
3858  if test -z "$use_lapack" ; then
3859    use_lapack=BUILD
3860  fi
3861fi
3862
3863if test "x$use_lapack" = xBUILD ; then
3864  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
3865
3866elif test "x$use_lapack" != x && test "$use_lapack" != no; then
3867  coin_has_lapack=yes
3868  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
3869  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
3870  LAPACK_LIBS="$use_lapack"
3871  LAPACK_CFLAGS=
3872  LAPACK_DATA=
3873  AC_SUBST(LAPACK_LIBS)
3874  AC_SUBST(LAPACK_CFLAGS)
3875  AC_SUBST(LAPACK_DATA)
3876  coin_foreach_w([myvar], [$1], [
3877    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
3878    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
3879    m4_toupper(myvar)_LIBS_INSTALLED="$LAPACK_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
3880  ])
3881 
3882else
3883  coin_has_lapack=no
3884  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
3885fi
3886
3887coin_foreach_w([myvar], [$1], [
3888  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3889  AC_SUBST(m4_toupper(myvar)_LIBS)
3890  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3891])
3892
3893]) # AC_COIN_CHECK_PACKAGE_LAPACK
Note: See TracBrowser for help on using the repository browser.