source: trunk/coin.m4 @ 3111

Last change on this file since 3111 was 3111, checked in by tkr, 7 years ago

Merging r3110 from stable/0.7

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