source: stable/0.7/coin.m4 @ 2802

Last change on this file since 2802 was 2802, checked in by stefan, 7 years ago

merge r2800 and r2801 from trunk

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