source: trunk/coin.m4 @ 3004

Last change on this file since 3004 was 3004, checked in by stefan, 8 years ago

remove also -lgcc* flags from FLIBS

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