source: stable/0.7/coin.m4 @ 2768

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

merge r2758 and r2764..r2767 from trunk

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