source: trunk/coin.m4 @ 2801

Last change on this file since 2801 was 2801, checked in by stefan, 6 years ago

adapt whitespace to avoid changes in configure

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