source: trunk/coin.m4 @ 3062

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

add a so far undocumented configure option that could be used in
projects Makefiles to enable linking of dependencies into shared
libraries (via LIBADD), see #105:11

  • sets AM_CONDITIONAL DEPENDENCY_LINKING
  • sets LT_LDFLAGS to -no-undefined if enabled
  • default is disabled so far
  • Property svn:keywords set to Author Date Id Revision
File size: 154.3 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 3062 2013-11-11 17:07:23Z stefan $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_PREREQ(2.59)
14
15###########################################################################
16#                           coin_foreach_w                                #
17###########################################################################
18
19# the autoconf version used by COIN-OR is so old that it does not have the M4 macro foreach_w.
20# thus, we define our own one which applies the foreach macro to the same arguments but with
21# all spaces replaced by ',' in the second argument.
22# further, we run the loop only if the second argument is not empty
23AC_DEFUN([coin_foreach_w], [m4_ifval([$2], [m4_foreach([$1], [m4_bpatsubsts([$2],[[     ]+],[, ])], [$3])])])
24
25###########################################################################
26#                            COIN_CHECK_FILE                              #
27###########################################################################
28
29# A simple replacement for AC_CHECK_FILE that works for cross compilation
30
31AC_DEFUN([AC_COIN_CHECK_FILE],
32[if test -r $1; then
33  $2
34  :
35else
36  $3
37  :
38fi
39])
40
41###########################################################################
42#                           COIN_CHECK_VPATH                              #
43###########################################################################
44
45# This macro sets the variable coin_vpath_config to true if this is a
46# VPATH configuration, otherwise it sets it to false.
47
48AC_DEFUN([AC_COIN_CHECK_VPATH],
49[
50AC_MSG_CHECKING(whether this is a VPATH configuration)
51if test `cd $srcdir; pwd` != `pwd`; then
52  coin_vpath_config=yes;
53else
54  coin_vpath_config=no;
55fi
56AC_MSG_RESULT($coin_vpath_config)
57]) # AC_COIN_CHECK_VPATH
58
59
60###########################################################################
61#                          COIN_PROJECTVERSION                            #
62###########################################################################
63
64# This macro is used by COIN_PROJECTDIR_INIT and sets up variables related
65# to versioning numbers of the project.
66
67AC_DEFUN([AC_COIN_PROJECTVERSION],
68[m4_ifvaln([$1],[
69  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION), ["$PACKAGE_VERSION"],[Version number of project])
70 
71  [coin_majorver=`echo $PACKAGE_VERSION | sed -n -e 's/^\([0-9]*\).*/\1/gp'`]
72  [coin_minorver=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.\([0-9]*\).*/\1/gp'`]
73  [coin_releasever=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/gp'`]
74  if test "x$coin_majorver" = x ; then coin_majorver=9999 ; fi
75  if test "x$coin_minorver" = x ; then coin_minorver=9999 ; fi
76  if test "x$coin_releasever" = x ; then coin_releasever=9999 ; fi
77  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MAJOR),   [$coin_majorver],   [Major Version number of project])
78  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MINOR),   [$coin_minorver],   [Minor Version number of project])
79  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_RELEASE), [$coin_releasever], [Release Version number of project])
80
81  # We use the following variable to have a string with the upper case
82  # version of the project name
83  COIN_PRJCT=m4_toupper($1)
84
85  # Set the project's SVN revision number. The complicated sed expression
86  # (made worse by quadrigraphs) ensures that things like 4123:4168MS end up
87  # as a single number.
88  AC_CHECK_PROG([have_svnversion],[svnversion],[yes],[no])
89  if test "x$have_svnversion" = xyes; then
90    AC_SUBST(m4_toupper($1_SVN_REV))
91    svn_rev_tmp=`LANG=en_EN svnversion $srcdir 2>/dev/null`
92    if test "x$svn_rev_tmp" != xexported -a "x$svn_rev_tmp" != x -a "x$svn_rev_tmp" != "xUnversioned directory"; then
93      m4_toupper($1_SVN_REV)=`echo $svn_rev_tmp | sed -n -e 's/^@<:@0-9@:>@*://' -e 's/\(@<:@0-9@:>@\)@<:@^0-9@:>@*$/\1/p'`
94      AC_DEFINE_UNQUOTED(m4_toupper($1_SVN_REV), $m4_toupper($1_SVN_REV), [SVN revision number of project])
95    fi
96  fi
97 ])
98 
99# Capture libtool library version, if given.
100 m4_ifvaln([$2],[coin_libversion=$2],[])
101])
102
103###########################################################################
104#                         COIN_PROJECTDIR_INIT                            #
105###########################################################################
106
107# This macro does everything that is required in the early part in the
108# configure script, such as defining a few variables.  This should only be used
109# in the main directory of a project directory (the one which holds the src
110# directory for the project). The first parameter is the project name. The
111# second (optional) is the libtool library version (important for releases,
112# less so for stable or trunk).
113
114AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
115[
116# As backup, we make sure we don't loose an FLIBS if it has been set
117# by the user
118save_FLIBS="$FLIBS"
119
120# A useful makefile conditional that is always false
121AM_CONDITIONAL(ALWAYS_FALSE, false)
122
123# We set the following variable so that we know later in AC_COIN_FINALIZE
124# that we are in a project main directory
125coin_projectdir=yes
126
127# Set the project's version numbers
128AC_COIN_PROJECTVERSION($1, $2)
129]) # AC_COIN_PROJECTDIR_INIT
130
131###########################################################################
132#                          COIN_DEBUG_COMPILE                             #
133###########################################################################
134
135# enable the configure flags --enable-debug and --enable-debug-prjct
136# (where prcjt is the name of the project in lower case) and set the
137# variable coin_debug_compile to true or false This is used by
138# COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77 to determine the
139# compilation flags.  This macro also makes the switches
140# --with-prjct-verbosity and --with-prjct-checklevel available, which
141# define the preprocessor macros COIN_PRJCT_VERBOSITY and
142# COIN_PRJCT_CHECKLEVEL to the specified value (default is 0).
143#
144# The project specific flags are only made available, if one gives the
145# name of the project as first argument to this macro.
146
147AC_DEFUN([AC_COIN_DEBUG_COMPILE],
148[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
149AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
150AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
151
152AC_MSG_CHECKING([whether we want to compile in debug mode])
153
154AC_ARG_ENABLE([debug],
155[AC_HELP_STRING([--enable-debug],
156                [compile all projects with debug options tests (implies --disable-shared)])],
157[case "${enableval}" in
158   yes) coin_debug_compile=true
159        if test "${enable_shared+set}" = set; then :; else
160          enable_shared=no
161        fi
162        ;;
163   no)  coin_debug_compile=false
164        ;;
165   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
166        ;;
167esac],
168[coin_debug_compile=false])
169
170m4_ifvaln([$1],
171[AC_ARG_ENABLE(debug-m4_tolower($1),
172 [AC_HELP_STRING([--enable-debug-m4_tolower($1)],
173                 [compile project $1 with debug compiler flags])],
174 [case "${enableval}" in
175    yes) coin_debug_compile=true
176         ;;
177    no)  coin_debug_compile=false
178         ;;
179    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
180         ;;
181 esac],[:])
182]) # m4_ifvaln([$1],
183
184if test $coin_debug_compile = true; then
185  AC_MSG_RESULT([yes])
186else
187  AC_MSG_RESULT([no])
188fi
189
190m4_ifvaln([$1],
191[AC_ARG_WITH(m4_tolower($1)-verbosity,
192             AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
193                            [specify the debug verbosity level for project $1]),
194             [if test "$withval" = yes; then
195                withval=1
196              fi
197              m4_tolower(coin_$1_verbosity)=$withval],
198             [m4_tolower(coin_$1_verbosity)=0])
199 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
200                    m4_tolower($coin_$1_verbosity),
201                    [Define to the debug verbosity level (0 is no output)])
202
203 AC_ARG_WITH(m4_tolower($1)-checklevel,
204             AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
205                            [specify the sanity check level for project $1]),
206             [if test "$withval" = yes; then
207                withval=1
208              fi
209              m4_tolower(coin_$1_checklevel)=$withval],
210             [m4_tolower(coin_$1_checklevel)=0])
211 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
212                    m4_tolower($coin_$1_checklevel),
213                    [Define to the debug sanity check level (0 is no test)])
214]) # m4_ifvaln([$1],
215 
216]) # AC_COIN_DEBUG_COMPILE
217
218###########################################################################
219#                          COIN_MINGW_LD_FIX                              #
220###########################################################################
221
222# This macro is included by any PROG_compiler macro, to set the LD
223# environment variable on MinGW to the correct value (link). If we're
224# building from cygwin with MSVC tools (cl/link), then we do want link and
225# you'd better have your PATH variable straight, else you'll be doing file
226# links instead of code links!
227
228AC_DEFUN([AC_COIN_MINGW_LD_FIX],
229[AC_REQUIRE([AC_COIN_ENABLE_MSVC])
230 case $build in
231  *-mingw*)
232    if test "${LD+set}" = set; then :; else
233      LD=link
234    fi
235    ;;
236 esac
237 if test $enable_msvc = yes ; then
238   if test "x${LD+set}" = xset; then :; else
239     LD=link
240   fi
241 fi
242])
243
244###########################################################################
245#                          COIN_ENABLE_MSVC                               #
246###########################################################################
247
248# This macro is invoked by any PROG_compiler macro to establish the
249# --enable-msvc option.
250# The job of this macro is to make sure the option is correct and
251# to set enable_msvc. Legal values are yes and no (disabled).
252# If set, assume the presence of cl/link. It's the user's responsibility to
253# make sure their PATH is correct. In particular, that MSVC link is found
254# and not cygwin link (we want to do code linking, not file linking).
255# It's the responsibility of individual PROG_compiler macros to ensure that
256# they correctly set the compiler search list and preprocess, compile, and
257# link flags. This is tied to compiler setup because in practice invocations
258# of the preprocessor and linker are made through the compiler.
259# For backward compatibility, we also check for --enable-doscompile=msvc.
260
261AC_DEFUN([AC_COIN_ENABLE_MSVC],
262[AC_REQUIRE([AC_CANONICAL_BUILD])
263
264  # for backward compatibility
265  AC_ARG_ENABLE([doscompile],,[enable_doscompile=$enableval],[enable_doscompile=no])
266 
267  AC_ARG_ENABLE([msvc],
268    [AC_HELP_STRING([--enable-msvc],
269                    [Prefer (i)cl/ifort/link over GNU on MinGW/Cygwin.])],
270    [enable_msvc=$enableval],
271    [enable_msvc=no
272     if test "$enable_doscompile" = msvc ; then
273       enable_msvc=yes
274     elif test "$enable_doscompile" != no ; then
275       AC_MSG_ERROR([--enable-doscompile=$enable_doscompile not supported anymore.])
276     fi
277    ])
278   
279  if test "$enable_msvc" = 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      coin_disable_shared=yes
1707      if test x"$enable_shared" = xyes; then
1708        case "$CXX" in
1709          clang* )
1710            AC_MSG_WARN([DLL building not supported. I'm disabling your choice.])
1711            ;;
1712          cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1713            AC_MSG_NOTICE([DLL building not supported, but will build with -MD(d) instead of -MT(d).])
1714            ;;
1715          *)
1716            AC_MSG_WARN([DLL building not supported. I'm disabling your choice.])
1717            ;;
1718        esac
1719      fi
1720    ;;
1721    *-aix*)
1722      coin_disable_shared=yes
1723      platform=AIX
1724      if test x"$enable_shared" = xyes; then
1725        AC_MSG_WARN([Shared objects are not supported. I'm disabling your choice.])
1726      fi
1727    ;;
1728  esac
1729fi
1730if test x"$coin_disable_shared" = xyes; then
1731  if test x"$enable_shared" = xyes; then
1732    :
1733  else
1734    # we don't disable shared, because it was not selected anyway
1735    coin_disable_shared=no
1736  fi
1737  enable_shared=no
1738fi
1739# By default, we only want the shared objects to be compiled
1740AC_DISABLE_STATIC
1741])
1742
1743m4_define([AC_COIN_INIT_AUTO_TOOLS],
1744[{AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1745AC_BEFORE([AC_COIN_PROG_CC],[$0])
1746AC_BEFORE([AC_COIN_PROG_F77],[$0])
1747
1748# START
1749AC_COIN_DISABLE_STATIC([$1])
1750
1751# Initialize automake
1752AC_COIN_INIT_AUTOMAKE
1753
1754LIBTOOL=
1755if test -f ../libtool; then
1756  coin_config_dir=..
1757  LIBTOOL='$(SHELL) $(top_builddir)/../libtool'
1758fi
1759if test "x$LIBTOOL" = x; then
1760  if test -f ../../libtool; then
1761    coin_config_dir=../..
1762    LIBTOOL='$(SHELL) $(top_builddir)/../../libtool'
1763  fi
1764fi
1765
1766if test "x$LIBTOOL" = x; then
1767# AC_MSG_NOTICE([Creating libtool script (calling COIN_PROG_LIBTOOL).])
1768  # Stuff for libtool
1769  AC_COIN_PROG_LIBTOOL
1770# AC_MSG_NOTICE([Finished COIN_PROG_LIBTOOL.])
1771  # set RPATH_FLAGS to the compiler link flags required to hardcode location
1772  # of the shared objects
1773  AC_COIN_RPATH_FLAGS([$abs_lib_dir])
1774
1775else
1776
1777  AC_MSG_NOTICE([Using libtool script in directory $coin_config_dir])
1778  # get all missing information from the config.log file
1779
1780  # output variables and defines
1781  as_save_IFS=$IFS
1782  IFS='
1783'
1784  for oneline in `cat $coin_config_dir/config.status`; do
1785    case "$oneline" in
1786         # First some automake conditionals
1787      s,@am__fastdep* | s,@AR@* | s,@CPP@*  | s,@CPPFLAGS@* | s,@CXXCPP@*  | \
1788      s,@RANLIB@* | s,@STRIP@* | s,@ac_ct_AR@* | s,@ac_ct_RANLIB@* | \
1789      s,@ac_ct_STRIP@* | s,@host* | s,@LN_S@* | s,@RPATH_FLAGS@* | \
1790      s,@ac_c_preproc_warn_flag@* |  s,@ac_cxx_preproc_warn_flag@* )
1791        command=`echo $oneline | sed -e 's/^s,@//' -e 's/@,/="/' -e 's/,;t t/"/'`
1792#        echo "$command"
1793        eval "$command"
1794        ;;
1795      s,@DEFS@* )
1796        command=`echo $oneline | sed -e 's/^s,@DEFS@,/defsline="/' -e 's/,;t t/"/'`
1797#        echo "$command"
1798        eval "$command"
1799        ;;
1800    esac
1801  done
1802  IFS=$as_save_IFS
1803
1804  # And some defines (assuming here that the packages base dir
1805  # doesn't have a config.h file
1806  for word in $defsline; do
1807#    echo word $word
1808    case $word in
1809      -DHAVE_@<:@A-Z_@:>@*_H=1 | -DSTDC_HEADERS=1 )
1810        i=`echo $word | sed -e 's/-D/#define /' -e 's/=/ /'`
1811#        echo dd $i
1812        echo $i >>confdefs.h
1813        ;;
1814    esac
1815  done
1816fi
1817
1818# AC_MSG_NOTICE([End of INIT_AUTO_TOOLS.])
1819
1820AC_ARG_ENABLE([dependency-linking],[],
1821  [dependency_linking="$enableval"],
1822  [dependency_linking=no])
1823
1824# ToDo
1825# For now, don't use the -no-undefined flag, since the Makefiles are
1826# not yet set up that way.  But we need to fix this, when we want
1827# to comile DLLs under Windows.
1828if test "$dependency_linking" = yes ;
1829then
1830  LT_LDFLAGS="-no-undefined"
1831else
1832  LT_LDFLAGS=
1833fi
1834
1835AM_CONDITIONAL(DEPENDENCY_LINKING, [test "$dependency_linking" = yes])
1836
1837# Check if we want to set the library version
1838AC_MSG_CHECKING([if library version is set])
1839if test x"$coin_libversion" != x; then
1840  LT_LDFLAGS="$LT_LDFLAGS -version-info $coin_libversion"
1841  AC_MSG_RESULT([$coin_libversion])
1842else
1843  AC_MSG_RESULT([no])
1844fi
1845
1846AC_SUBST(LT_LDFLAGS)
1847
1848#END
1849}])
1850
1851###########################################################################
1852#                      COIN_PATCH_LIBTOOL_CYGWIN                          #
1853###########################################################################
1854
1855# Patches to libtool for cygwin. Lots for cl, a few for GCC.
1856# For cl:
1857# - cygpath is not correctly quoted in fix_srcfile_path
1858# - paths generated for .lib files is not run through cygpath -w
1859
1860
1861AC_DEFUN([AC_COIN_PATCH_LIBTOOL_CYGWIN],
1862[ case "$CXX" in
1863    clang* )
1864      # we assume that libtool patches for CLANG are the same as for GNU compiler - correct???
1865      AC_MSG_NOTICE(Applying patches to libtool for CLANG compiler)
1866      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1867          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1868          -e 's|libext="lib"|libext="a"|' \
1869      libtool > conftest.bla
1870      ;;
1871    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1872      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1873      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1874          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1875          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1876          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1877          -e 's%lib /OUT:%lib -OUT:%' \
1878          -e "s%cygpath -w%$CYGPATH_W%" \
1879          -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%' \
1880          -e 's%$AR t "$f_ex_an_ar_oldlib"%lib -nologo -list \$('"$CYGPATH_W \$[]1"') '"$mydos2unix"'%' \
1881          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1882          -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1883          -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"%' \
1884      libtool > conftest.bla
1885      ;;
1886    *)
1887      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
1888      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1889          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1890          -e 's|libext="lib"|libext="a"|' \
1891      libtool > conftest.bla
1892      ;;
1893  esac
1894  mv conftest.bla libtool
1895  chmod 755 libtool
1896]) # COIN_PATCH_LIBTOOL_CYGWIN
1897
1898###########################################################################
1899#                    COIN_PATCH_LIBTOOL_SOLARIS                           #
1900###########################################################################
1901# If we want to do a 64-bit build with GCC on Solaris, the system search
1902# libraries need to point to 64-bit subdirectories. If they do not already do
1903# that, fix them. This patch is evolving, as are GCC compilers.  GCC 4.2.1
1904# reports the correct search list, given the correct call. GCC 4.1.1 does not.
1905# `Correct call' means -m64 is specified. `Correct search list' seems to amount
1906# to prepending the list of 64-bit subdirectories to the 32-bit directories.
1907# Both SPARC and x86 have this issue, but a different hardware id string is
1908# required depending on the underlying CPU. The macro executes isainfo to get
1909# the string. This will fail, of course, if we're cross-compiling. The
1910# alternative is to fail on a regular basis each time a new CPU identifier is
1911# needed. This macro will also fail if the search list reported with
1912# -print-search-dirs differs between the C, C++, and Fortran compilers; each
1913# have their own setting in libtool.  If GCC reports the correct search list
1914# given the -m64 flag, the best solution is to define CC='gcc -m64', and
1915# similarly for CXX, F77, so that libtool will make the correct call.
1916###########################################################################
1917AC_DEFUN([AC_COIN_PATCH_LIBTOOL_SOLARIS],
1918[ if test "$GCC" = yes && \
1919     (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm64' >/dev/null 2>&1) ; then
1920    hdwisa=`isainfo | sed -e 's/\(@<:@^ @:>@*\) .*$/\1/'`
1921    if `$EGREP 'sys_lib_search_path_spec=' libtool | $EGREP -v $hdwisa >/dev/null 2>&1` ; then
1922      AC_MSG_NOTICE([Applying patches to libtool for 64-bit GCC compilation])
1923      fixlibtmp=`$CC -m64 -print-search-dirs | $EGREP '^libraries:'`
1924      fixlibtmp=`echo $fixlibtmp | sed -e 's/libraries: =//' -e 's/:/ /g'`
1925      if `echo "$fixlibtmp" | $EGREP -v $hdwisa  >/dev/null 2>&1` ; then
1926        # AC_MSG_NOTICE(Compensating for broken gcc)
1927        for lib in $fixlibtmp ; do
1928          if test -d "${lib}${hdwisa}" ; then
1929            syslibpath64="$syslibpath64 ${lib}${hdwisa}/"
1930          fi
1931        done
1932        syslibpath64="${syslibpath64} ${fixlibtmp}"
1933      else
1934        syslibpath64="$fixlibtmp"
1935      fi
1936      sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="'"$syslibpath64"'"|' libtool > conftest.bla
1937      mv conftest.bla libtool
1938      chmod 755 libtool 
1939    fi
1940    # AC_MSG_NOTICE(Result is )
1941    # $EGREP 'sys_lib_search_path_spec=' libtool
1942  fi ]) # COIN_PATCH_LIBTOOL_SOLARIS
1943
1944###########################################################################
1945#                           COIN_PROG_LIBTOOL                             #
1946###########################################################################
1947
1948# Setup the libtool stuff together with any modifications to make it
1949# work on additional platforms
1950
1951AC_DEFUN([AC_COIN_PROG_LIBTOOL],
1952[# No longer needed now that CPPFLAGS is correctly set -- lh, 061214 --
1953 # AC_REQUIRE([AC_COIN_DLFCN_H])
1954
1955# NEW: If libtool exists in the directory higher up, we use that one
1956#      instead of creating a new one
1957
1958# It turns out that the code for AC_PROG_LIBTOOL is somehow AC_REQUIRED
1959# out in front of this macro body. You'll notice that LIBTOOL is already
1960# defined here.  We'll have to count on this macro not being called if libtool
1961# already exists, or at least move the libtool fixes outside the conditional.
1962# AC_MSG_NOTICE([Entering coin_prog_libtool, LIBTOOL = "$LIBTOOL".])
1963# This test is therefore removed.  -- lh, 061214 --
1964# if test "x$LIBTOOL" = x; then
1965
1966# AC_MSG_NOTICE([Calling PROG_LIBTOOL.])
1967  AC_PROG_LIBTOOL
1968# AC_MSG_NOTICE([Finished PROG_LIBTOOL.])
1969  AC_SUBST(ac_c_preproc_warn_flag)
1970  AC_SUBST(ac_cxx_preproc_warn_flag)
1971
1972  AC_MSG_NOTICE([Build is "$build".])
1973  mydos2unix='| dos2unix'
1974  case $build in
1975    *-mingw*)
1976      CYGPATH_W=echo
1977      mydos2unix=
1978      ;;
1979  esac
1980
1981  case $build in
1982    # Here we need to check if -m32 is specified.  If so, we need to correct
1983    # sys_lib_search_path_spec
1984    *-cygwin* | *-mingw*)
1985      AC_COIN_PATCH_LIBTOOL_CYGWIN
1986      ;;
1987    *x86_64-*)
1988      if test "$GCC" = yes && (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm32' >& /dev/null); then
1989        AC_MSG_NOTICE(Applying patches to libtool for 32bit compilation)
1990        sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="/lib /usr/lib"|' libtool > conftest.bla
1991        mv conftest.bla libtool
1992        chmod 755 libtool 
1993      fi
1994      ;;
1995
1996    *-solaris*)
1997      AC_COIN_PATCH_LIBTOOL_SOLARIS
1998      ;;
1999    # Cygwin. Ah, cygwin. Too big and ugly to inline; see the macro.
2000    *-darwin*)
2001      AC_MSG_NOTICE(Applying patches to libtool for Darwin)
2002      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"/' \
2003        -e 's/ -dynamiclib / -dynamiclib -single_module /g' \
2004      libtool > conftest.bla
2005
2006      mv conftest.bla libtool
2007      chmod 755 libtool
2008      ;;
2009  esac
2010# This fi matches the commented `if test "x$LIBTOOL" = x;' up at the head of
2011# the macro. -- lh, 061214 --
2012# fi
2013
2014# AC_MSG_NOTICE([End libtool initialisation.])
2015]) # AC_COIN_PROG_LIBTOOL
2016
2017# This is a trick to force the check for the dlfcn header to be done before
2018# the checks for libtool
2019# No longer needed now that CPPFLAGS is correctly set.  -- lh, 061214 --
2020# ACDEFUN([AC_COIN_DLFCN_H],
2021# [AC_LANG_PUSH(C)
2022# AC_COIN_CHECK_HEADER([dlfcn.h])
2023# AC_LANG_POP(C)
2024# ]) # AC_COIN_DLFCN_H
2025
2026###########################################################################
2027#                            COIN_RPATH_FLAGS                             #
2028###########################################################################
2029
2030# This macro, in case shared objects are used, defines a variable
2031# RPATH_FLAGS that can be used by the linker to hardwire the library
2032# search path for the given directories.  This is useful for example
2033# Makefiles
2034
2035AC_DEFUN([AC_COIN_RPATH_FLAGS],
2036[RPATH_FLAGS=
2037
2038if test $enable_shared = yes; then
2039  case $build in
2040    *-linux-*)
2041      if test "$GXX" = "yes"; then
2042        RPATH_FLAGS=
2043        for dir in $1; do
2044          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
2045        done
2046      fi ;;
2047    *-darwin*)
2048        RPATH_FLAGS=nothing ;;
2049    *-ibm-*)
2050      case "$CXX" in
2051      xlC* | */xlC* | mpxlC* | */mpxlC*)
2052        RPATH_FLAGS=nothing ;;
2053      esac ;;
2054    *-hp-*)
2055        RPATH_FLAGS=nothing ;;
2056    *-mingw32)
2057        RPATH_FLAGS=nothing ;;
2058    *-*-solaris*)
2059        RPATH_FLAGS=
2060        for dir in $1; do
2061          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
2062        done
2063  esac
2064
2065  if test "$RPATH_FLAGS" = ""; then
2066    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.])
2067  fi
2068  if test "$RPATH_FLAGS" = "nothing"; then
2069    RPATH_FLAGS=
2070  fi
2071fi
2072
2073AC_SUBST(RPATH_FLAGS)
2074]) # AC_COIN_RPATH_FLAGS
2075
2076###########################################################################
2077#                        COIN_LINK_INPUT_CMD                              #
2078###########################################################################
2079
2080# This macro determines which command should be used to "link" files
2081# that are input to the generated executables.  On Windows, the codes
2082# using the native Windows system libraries, cannot understand symbolic
2083# links, and a copy should be used instead of 'ln -s'.
2084# The result is stored in coin_link_input_cmd
2085
2086AC_DEFUN([AC_COIN_LINK_INPUT_CMD],
2087[AC_REQUIRE([AC_PROG_LN_S])
2088AC_BEFORE([AC_COIN_PROG_CC], [$0])
2089AC_BEFORE([AC_COIN_ENABLE_MSVC], [$0])
2090
2091AC_MSG_CHECKING([which command should be used to link input files])
2092coin_link_input_cmd="$LN_S"
2093case "$CC" in
2094  clang* ) ;;
2095  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2096    coin_link_input_cmd=cp ;;
2097esac
2098AC_MSG_RESULT($coin_link_input_cmd)
2099])
2100
2101###########################################################################
2102#                              COIN_FINALIZE                              #
2103###########################################################################
2104
2105# This macro should be called at the very end of the configure.ac file.
2106# It creates the output files (by using AC_OUTPUT), and might do some other
2107# things (such as generating links to data files in a VPATH configuration).
2108# It also prints the "success" message.
2109# Note: If the variable coin_skip_ac_output is set to yes, then no output
2110# files are written.
2111
2112AC_DEFUN([AC_COIN_FINALIZE],
2113[
2114AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2115if test x$coin_skip_ac_output != xyes; then
2116
2117  # library extension
2118  AC_SUBST(LIBEXT)
2119  case "$CC" in
2120    clang* )
2121         LIBEXT=a ;;
2122    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2123         LIBEXT=lib ;;
2124      *) LIBEXT=a ;;
2125  esac
2126
2127  # Define VPATH_DISTCLEANFILES to be everything that needs to be
2128  # cleaned for distclean in a vpath configuration
2129  AC_SUBST(VPATH_DISTCLEANFILES)
2130  VPATH_DISTCLEANFILES="$coin_vpath_link_files"
2131
2132  # Take out subdirectories if their configuration concluded that they
2133  # don't need to be compiled
2134  if test x"$coin_ac_skip_subdirs" != x; then
2135    new_subdirs=
2136    for i in $subdirs; do
2137      skipme=no
2138      for j in $coin_ac_skip_subdirs; do
2139        if test $i = $j; then
2140          skipme=yes;
2141        fi
2142      done
2143      if test $skipme = no; then
2144        new_subdirs="$new_subdirs $i"
2145      fi
2146    done
2147    subdirs="$new_subdirs"
2148  fi
2149
2150  # need to come before AC_OUTPUT
2151  if test x$coin_projectdir != xyes; then
2152    # write coin_subdirs to a file so that project configuration knows where to find uninstalled projects
2153    echo $coin_subdirs > coin_subdirs.txt
2154  else
2155    # substitute for OBJDIR, needed to setup .pc file for uninstalled project
2156    ABSBUILDDIR="`pwd`"
2157    AC_SUBST(ABSBUILDDIR)
2158  fi
2159 
2160  AC_OUTPUT
2161
2162  if test x"$coin_vpath_link_files" = x; then : ; else
2163    lnkcmd="$coin_link_input_cmd"
2164    if test "$lnkcmd" = cp; then
2165      AC_MSG_NOTICE(Copying data files for VPATH configuration)
2166    else
2167      AC_MSG_NOTICE(Creating VPATH links for data files)
2168    fi
2169    for file in $coin_vpath_link_files; do
2170      dir=`AS_DIRNAME(["./$file"])`
2171      if test -d $dir; then : ; else
2172        AS_MKDIR_P($dir)
2173      fi
2174      rm -f $file
2175      $lnkcmd $abs_source_dir/$file $file
2176    done
2177  fi
2178
2179  AC_MSG_NOTICE([In case of trouble, first consult the troubleshooting page at https://projects.coin-or.org/BuildTools/wiki/user-troubleshooting])
2180  if test x$coin_projectdir = xyes; then
2181    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
2182  else
2183    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
2184  fi
2185else
2186  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
2187fi
2188
2189]) #AC_COIN_FINALIZE
2190
2191###########################################################################
2192#                             COIN_VPATH_LINK                             #
2193###########################################################################
2194
2195# This macro queues source files that need to be available in the build
2196# directory. In a VPATH configuration, the files will be made available by
2197# symbolic link or copy (when the platform does not support links). The list
2198# is processed by COIN_FINALIZE. The parameter is a whitespace-separated
2199# list of files.
2200
2201AC_DEFUN([AC_COIN_VPATH_LINK],
2202[
2203AC_REQUIRE([AC_COIN_CHECK_VPATH])
2204# Allow for newlines in the parameter
2205if test $coin_vpath_config = yes; then
2206  cvl_tmp="$1"
2207  for file in $cvl_tmp ; do
2208    coin_vpath_link_files="$coin_vpath_link_files $file"
2209  done
2210fi
2211]) #AC_COIN_VPATH_LINK
2212
2213###########################################################################
2214#                       COIN_ENABLE_GNU_PACKAGES                          #
2215###########################################################################
2216
2217# This macro defined the --enable-gnu-packages flag.  This can be used
2218# to check if a user wants to compile GNU packges (such as readline)
2219# into the executable.  By default, GNU packages are disabled.
2220# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
2221
2222AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
2223[AC_ARG_ENABLE([gnu-packages],
2224               [AC_HELP_STRING([--enable-gnu-packages],
2225                               [compile with GNU packages (disabled by default)])],
2226               [coin_enable_gnu=$enableval],
2227               [coin_enable_gnu=no])
2228]) # AC_COIN_ENABLE_GNU_PACKAGES
2229
2230#######################################################################
2231#                           COIN_CHECK_LIBM                           #
2232#######################################################################
2233
2234# For a (space separated) list of arguments X, this macro adds the flags
2235# for linking against the math library to a X_LIBS and X_PCLIBS.
2236
2237AC_DEFUN([AC_COIN_CHECK_LIBM],
2238[AC_BEFORE([AC_COIN_PROG_CC],[$0])
2239
2240if test $coin_cc_is_cl != true ; then
2241  coin_foreach_w([myvar], [$1], [
2242    m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"
2243    m4_toupper(myvar)_PCLIBS="-lm $m4_toupper(myvar)_PCLIBS"
2244    m4_toupper(myvar)_LIBS_INSTALLED="-lm $m4_toupper(myvar)_LIBS_INSTALLED"
2245  ])
2246fi
2247
2248]) # AC_COIN_CHECK_LIBM
2249
2250###########################################################################
2251#                           COIN_CHECK_GNU_ZLIB                           #
2252###########################################################################
2253
2254# This macro checks for the libz library.  If found, it sets the automake
2255# conditional COIN_HAS_ZLIB and defines the C preprocessor variable
2256# COIN_HAS_ZLIB.  Further, for a (space separated) list of arguments X,
2257# it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2258
2259# TODO the macro name should be changed to AC_COIN_CHECK_ZLIB
2260
2261AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2262[
2263AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2264AC_BEFORE([AC_COIN_PROG_CC],[$0])
2265AC_BEFORE([AC_COIN_PROG_F77],[$0])
2266AC_BEFORE([$0],[AC_COIN_FINALIZE])
2267
2268coin_has_zlib=no
2269
2270AC_ARG_ENABLE([zlib],
2271              [AC_HELP_STRING([--disable-zlib],[do not compile with compression library zlib])],
2272              [coin_enable_zlib=$enableval],
2273              [coin_enable_zlib=yes])
2274
2275if test $coin_enable_zlib = yes; then
2276  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2277
2278  if test $coin_has_zlib = yes; then
2279    AC_CHECK_LIB([z],[gzopen],[:],[coin_has_zlib=no])
2280  fi
2281
2282  if test $coin_has_zlib = yes; then
2283    coin_foreach_w([myvar], [$1], [
2284                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
2285                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
2286                    m4_toupper(myvar)_LIBS_INSTALLED="-lz $m4_toupper(myvar)_LIBS_INSTALLED"
2287                   ])
2288    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2289  fi
2290fi
2291
2292AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2293]) # AC_COIN_CHECK_GNU_ZLIB
2294
2295
2296###########################################################################
2297#                          COIN_CHECK_GNU_BZLIB                           #
2298###########################################################################
2299
2300# This macro checks for the libbz2 library.  If found, it defines the C
2301# preprocessor variable COIN_HAS_BZLIB.  Further, for a (space separated) list
2302# of arguments X, it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2303
2304# TODO the macro name should be changed to AC_COIN_CHECK_BZLIB
2305
2306AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2307[
2308AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2309AC_BEFORE([AC_COIN_PROG_CC],[$0])
2310AC_BEFORE([AC_COIN_PROG_F77],[$0])
2311AC_BEFORE([$0],[AC_COIN_FINALIZE])
2312
2313AC_ARG_ENABLE([bzlib],
2314              [AC_HELP_STRING([--disable-bzlib],[do not compile with compression library bzlib])],
2315              [coin_enable_bzlib=$enableval],
2316              [coin_enable_bzlib=yes])
2317
2318coin_has_bzlib=no
2319if test $coin_enable_bzlib = yes; then
2320  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2321
2322  if test $coin_has_bzlib = yes; then
2323    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],[:],[coin_has_bzlib=no])
2324  fi
2325
2326  if test $coin_has_bzlib = yes; then
2327    coin_foreach_w([myvar], [$1], [
2328                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
2329                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
2330                    m4_toupper(myvar)_LIBS_INSTALLED="-lbz2 $m4_toupper(myvar)_LIBS_INSTALLED"
2331                  ])
2332    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2333  fi
2334fi
2335]) # AC_COIN_CHECK_GNU_BZLIB
2336
2337
2338###########################################################################
2339#                         COIN_CHECK_GNU_READLINE                         #
2340###########################################################################
2341
2342# This macro checks for GNU's readline.  It verifies that the header
2343# readline/readline.h is available, and that the -lreadline library
2344# contains "readline".  It is assumed that #include <stdio.h> is included
2345# in the source file before the #include<readline/readline.h>
2346# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
2347# Further, for a (space separated) list of arguments X, it adds the
2348# linker flag to the variable X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2349
2350AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2351[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2352AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2353AC_BEFORE([AC_COIN_PROG_CC],[$0])
2354AC_BEFORE([AC_COIN_PROG_F77],[$0])
2355AC_BEFORE([$0],[AC_COIN_FINALIZE])
2356
2357coin_has_readline=no
2358if test $coin_enable_gnu = yes; then
2359  AC_COIN_CHECK_HEADER([readline/readline.h],
2360                       [coin_has_readline=yes],[],
2361                       [#include <stdio.h>])
2362
2363  coin_save_LIBS="$LIBS"
2364  LIBS=
2365  # First we check if tputs and friends are available
2366  if test $coin_has_readline = yes; then
2367    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2368                   [coin_has_readline=no])
2369  fi
2370
2371  # Now we check for readline
2372  if test $coin_has_readline = yes; then
2373    AC_CHECK_LIB([readline],[readline],[:],[coin_has_readline=no])
2374  fi
2375
2376  if test $coin_has_readline = yes; then
2377    coin_foreach_w([myvar], [$1], [
2378                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
2379                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
2380                    m4_toupper(myvar)_LIBS_INSTALLED="-lreadline $LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
2381                   ])
2382    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2383  fi
2384
2385  LIBS="$coin_save_LIBS"
2386fi
2387]) # AC_COIN_CHECK_GNU_READLINE
2388
2389###########################################################################
2390#                              COIN_CHECK_GMP                             #
2391###########################################################################
2392
2393# This macro checks for the gmp library.  If found, it defines the C
2394# preprocessor variable COIN_HAS_GMP.  Further, for a (space separated) list
2395# of arguments X, it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2396
2397AC_DEFUN([AC_COIN_CHECK_GMP],
2398[
2399AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2400AC_BEFORE([AC_COIN_PROG_CC],[$0])
2401AC_BEFORE([AC_COIN_PROG_F77],[$0])
2402AC_BEFORE([$0],[AC_COIN_FINALIZE])
2403
2404AC_ARG_ENABLE([gmp],
2405              [AC_HELP_STRING([--disable-gmp],[do not compile with GNU multiple precision library])],
2406              [coin_enable_gmp=$enableval],
2407              [coin_enable_gmp=yes])
2408
2409coin_has_gmp=no
2410if test $coin_enable_gmp = yes; then
2411  AC_COIN_CHECK_HEADER([gmp.h],[AC_CHECK_LIB([gmp],[__gmpz_init],[coin_has_gmp=yes])])
2412 
2413  if test $coin_has_gmp = yes ; then
2414    coin_foreach_w([myvar], [$1], [
2415                    m4_toupper(myvar)_LIBS="-lgmp $m4_toupper(myvar)_LIBS"
2416                    m4_toupper(myvar)_PCLIBS="-lgmp $m4_toupper(myvar)_PCLIBS"
2417                    m4_toupper(myvar)_LIBS_INSTALLED="-lgmp $m4_toupper(myvar)_LIBS_INSTALLED"
2418                   ])
2419    AC_DEFINE([COIN_HAS_GMP],[1],[Define to 1 if GMP is available])
2420  fi
2421fi
2422]) # AC_COIN_CHECK_GMP
2423
2424###########################################################################
2425#                            COIN_CHECK_ISFINITE                          #
2426###########################################################################
2427
2428# This macro checks for a usable implementation of a function to check
2429# whether a given floating point number is finite.
2430# If a function is found, then the macro defines the symbol
2431# toupper($1)_C_FINITE to the name of this function.
2432
2433AC_DEFUN([AC_COIN_CHECK_ISFINITE],[
2434
2435AC_LANG_PUSH(C++)
2436
2437AC_COIN_CHECK_CXX_CHEADER(math)
2438AC_COIN_CHECK_CXX_CHEADER(float)
2439AC_COIN_CHECK_CXX_CHEADER(ieeefp)
2440
2441COIN_C_FINITE=
2442AC_CHECK_DECL([isfinite],[COIN_C_FINITE=isfinite],,[
2443#ifdef HAVE_CMATH
2444# include <cmath>
2445#else
2446# ifdef HAVE_MATH_H
2447#  include <math.h>
2448# endif
2449#endif
2450#ifdef HAVE_CFLOAT
2451# include <cfloat>
2452#else
2453# ifdef HAVE_FLOAT_H
2454#  include <float.h>
2455# endif
2456#endif
2457#ifdef HAVE_CIEEEFP
2458# include <cieeefp>
2459#else
2460# ifdef HAVE_IEEEFP_H
2461#  include <ieeefp.h>
2462# endif
2463#endif])
2464if test -z "$COIN_C_FINITE"; then
2465  AC_CHECK_DECL([finite],[COIN_C_FINITE=finite],,[
2466#ifdef HAVE_CMATH
2467# include <cmath>
2468#else
2469# ifdef HAVE_MATH_H
2470#  include <math.h>
2471# endif
2472#endif
2473#ifdef HAVE_CFLOAT
2474# include <cfloat>
2475#else
2476# ifdef HAVE_FLOAT_H
2477#  include <float.h>
2478# endif
2479#endif
2480#ifdef HAVE_CIEEEFP
2481# include <cieeefp>
2482#else
2483# ifdef HAVE_IEEEFP_H
2484#  include <ieeefp.h>
2485# endif
2486#endif])
2487  if test -z "$COIN_C_FINITE"; then
2488    AC_CHECK_DECL([_finite],[COIN_C_FINITE=_finite],,[
2489#ifdef HAVE_CMATH
2490# include <cmath>
2491#else
2492# ifdef HAVE_MATH_H
2493#  include <math.h>
2494# endif
2495#endif
2496#ifdef HAVE_CFLOAT
2497# include <cfloat>
2498#else
2499# ifdef HAVE_FLOAT_H
2500#  include <float.h>
2501# endif
2502#endif
2503#ifdef HAVE_CIEEEFP
2504# include <cieeefp>
2505#else
2506# ifdef HAVE_IEEEFP_H
2507#  include <ieeefp.h>
2508# endif
2509#endif])
2510  fi
2511fi
2512if test -z "$COIN_C_FINITE"; then
2513  AC_MSG_WARN(Cannot find C-function for checking Inf.)
2514else
2515  AC_DEFINE_UNQUOTED(COIN_C_FINITE,[$COIN_C_FINITE],
2516                     [Define to be the name of C-function for Inf check])
2517fi
2518
2519AC_LANG_POP(C++)
2520])
2521
2522###########################################################################
2523#                              COIN_CHECK_ISNAN                           #
2524###########################################################################
2525
2526# This macro checks for a usable implementation of a function to check
2527# whether a given floating point number represents NaN.
2528# If a function is found, then the macro defines the symbol COIN_C_ISNAN
2529# to the name of this function.
2530
2531AC_DEFUN([AC_COIN_CHECK_ISNAN],[
2532
2533AC_LANG_PUSH(C++)
2534
2535AC_COIN_CHECK_CXX_CHEADER(math)
2536AC_COIN_CHECK_CXX_CHEADER(float)
2537AC_COIN_CHECK_CXX_CHEADER(ieeefp)
2538
2539COIN_C_ISNAN=
2540AC_CHECK_DECL([isnan],[COIN_C_ISNAN=isnan],,[
2541#ifdef HAVE_CMATH
2542# include <cmath>
2543#else
2544# ifdef HAVE_MATH_H
2545#  include <math.h>
2546# endif
2547#endif
2548#ifdef HAVE_CFLOAT
2549# include <cfloat>
2550#else
2551# ifdef HAVE_FLOAT_H
2552#  include <float.h>
2553# endif
2554#endif
2555#ifdef HAVE_CIEEEFP
2556# include <cieeefp>
2557#else
2558# ifdef HAVE_IEEEFP_H
2559#  include <ieeefp.h>
2560# endif
2561#endif])
2562
2563# It appears that for some systems (e.g., Mac OSX), cmath will provide only
2564# std::isnan, and bare isnan will be unavailable. Typically we need a parameter
2565# in the test to allow C++ to do overload resolution.
2566
2567if test -z "$COIN_C_ISNAN"; then
2568  AC_CHECK_DECL([std::isnan(42.42)],[COIN_C_ISNAN=std::isnan],,[
2569#ifdef HAVE_CMATH
2570# include <cmath>
2571#else
2572# ifdef HAVE_MATH_H
2573#  include <math.h>
2574# endif
2575#endif
2576#ifdef HAVE_CFLOAT
2577# include <cfloat>
2578#else
2579# ifdef HAVE_FLOAT_H
2580#  include <float.h>
2581# endif
2582#endif
2583#ifdef HAVE_CIEEEFP
2584# include <cieeefp>
2585#else
2586# ifdef HAVE_IEEEFP_H
2587#  include <ieeefp.h>
2588# endif
2589#endif])
2590fi
2591
2592if test -z "$COIN_C_ISNAN"; then
2593  AC_CHECK_DECL([_isnan],[COIN_C_ISNAN=_isnan],,[
2594#ifdef HAVE_CMATH
2595# include <cmath>
2596#else
2597# ifdef HAVE_MATH_H
2598#  include <math.h>
2599# endif
2600#endif
2601#ifdef HAVE_CFLOAT
2602# include <cfloat>
2603#else
2604# ifdef HAVE_FLOAT_H
2605#  include <float.h>
2606# endif
2607#endif
2608#ifdef HAVE_CIEEEFP
2609# include <cieeefp>
2610#else
2611# ifdef HAVE_IEEEFP_H
2612#  include <ieeefp.h>
2613# endif
2614#endif])
2615fi
2616if test -z "$COIN_C_ISNAN"; then
2617  AC_CHECK_DECL([isnand],[COIN_C_ISNAN=isnand],,[
2618#ifdef HAVE_CMATH
2619# include <cmath>
2620#else
2621# ifdef HAVE_MATH_H
2622#  include <math.h>
2623# endif
2624#endif
2625#ifdef HAVE_CFLOAT
2626# include <cfloat>
2627#else
2628# ifdef HAVE_FLOAT_H
2629#  include <float.h>
2630# endif
2631#endif
2632#ifdef HAVE_CIEEEFP
2633# include <cieeefp>
2634#else
2635# ifdef HAVE_IEEEFP_H
2636#  include <ieeefp.h>
2637# endif
2638#endif])
2639fi
2640if test -z "$COIN_C_ISNAN"; then
2641  AC_MSG_WARN(Cannot find C-function for checking NaN.)
2642else
2643  AC_DEFINE_UNQUOTED(COIN_C_ISNAN,[$COIN_C_ISNAN],
2644                     [Define to be the name of C-function for NaN check])
2645fi
2646
2647AC_LANG_POP(C++)
2648])
2649
2650###########################################################################
2651#                             COIN_DATA_PATH                              #
2652###########################################################################
2653
2654# This macro defines a preprocessor macro with the absolute path to a
2655# subdirectory of Data.  The argument of this macro is the name of the
2656# subdirectory (in correct case), and the name of the macro is
2657# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2658# the directory.  The path ends with a separator ("/" for linux and
2659# '\\' for Windows).  The default value for this path can be
2660# overwritten with the input variable with the same name
2661# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2662# $srcdir/../Data subdirectory.
2663
2664AC_DEFUN([AC_COIN_DATA_PATH],
2665[AC_MSG_CHECKING([absolute path to data directory $1])
2666
2667AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2668
2669if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2670  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2671fi
2672
2673# Under Cygwin, use Windows path.  Add separator
2674case $build in
2675  *-cygwin*)
2676    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2677    ;;
2678  *)
2679    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2680    ;;
2681esac
2682
2683if test -d $m4_toupper(COIN_DATA_$1_PATH); then
2684  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2685            [Define to absolute path for Data subdirectory $1])
2686  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2687else
2688  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2689fi
2690]) # AC_COIN_DATA_PATH
2691
2692###########################################################################
2693#                       COIN_LINK_FROM_FILELIST                           #
2694###########################################################################
2695
2696# This macro creates links (or copies, if necessary) to files listed
2697# as content in a text file (second argument) into a target directory
2698# (first argument), which is created if it doesn't exist yet.  If s link
2699# already exists, nothing happens.
2700
2701AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
2702[cmd="$3"
2703if test -r $srcdir/$2 ; then
2704  my_target_dir="$1"
2705  my_link_files=`cat $srcdir/$2`
2706  my_dirname=`AS_DIRNAME($2)`
2707#  if test -e $my_target_dir; then : ; else
2708#    AS_MKDIR_P($my_target_dir)
2709#  fi
2710  for i in $my_link_files; do
2711    #rm -rf $my_target_dir/$i
2712    if test -e $my_target_dir/$i; then : ; else
2713      dirn2=`AS_DIRNAME($my_target_dir/$i)`
2714      if test -d $dirn2; then : ; else
2715        AS_MKDIR_P($dirn2)
2716      fi
2717      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
2718    fi
2719  done
2720else
2721  AC_MSG_WARN([File list file $2 missing!])
2722fi
2723])
2724
2725AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
2726[
2727AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2728echo Creating links in $1 ...
2729AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
2730])
2731
2732###########################################################################
2733#                       COIN_COPY_FROM_FILELIST                           #
2734###########################################################################
2735
2736# Like COIN_LINK_FROM_FILELIST, but copies the files.
2737
2738AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
2739[
2740echo Creating copies in $1 ...
2741AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
2742])
2743
2744###########################################################################
2745#                          COIN_EXAMPLE_FILES                             #
2746###########################################################################
2747
2748# This macro determines the names of the example files (using the
2749# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2750# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2751# creates soft links to the example files.
2752
2753AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2754[AC_REQUIRE([AC_COIN_CHECK_VPATH])
2755AC_REQUIRE([AC_COIN_ENABLE_MSVC])
2756AC_REQUIRE([AC_PROG_LN_S])
2757
2758files=`cd $srcdir; ls $1`
2759# We need to do the following loop to make sure that are no newlines
2760# in the variable
2761for file in $files; do
2762  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2763done
2764if test $coin_vpath_config = yes; then
2765  lnkcmd=
2766  if test "$enable_msvc" = yes; then
2767    lnkcmd=cp
2768  fi
2769  case "$CC" in
2770    clang* ) ;;
2771    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2772      lnkcmd=cp ;;
2773  esac
2774  if test "x$lnkcmd" = xcp; then
2775    AC_MSG_NOTICE([Copying example files ($1)])
2776  else
2777    AC_MSG_NOTICE([Creating links to the example files ($1)])
2778    lnkcmd="$LN_S"
2779  fi
2780  for file in $EXAMPLE_FILES; do
2781    rm -f $file
2782    $lnkcmd $srcdir/$file $file
2783  done
2784  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2785else
2786  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2787fi
2788
2789# In case there are compressed files, we create a variable with the
2790# uncompressed names
2791EXAMPLE_UNCOMPRESSED_FILES=
2792for file in $EXAMPLE_FILES; do
2793  case $file in
2794    *.gz)
2795      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2796      ;;
2797  esac
2798done
2799
2800AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2801AC_SUBST(EXAMPLE_FILES)
2802AC_SUBST(EXAMPLE_CLEAN_FILES)
2803]) #AC_COIN_EXAMPLE_FILES
2804
2805###########################################################################
2806#                      COIN_CHECK_USER_LIBRARY                            #
2807###########################################################################
2808# This macro sets up usage of a user library with header files. The assumption
2809# is that the header file(s) and library do not reside in standard system
2810# directories, hence both the include directory and link flags must be
2811# specified. There are two mandatory arguments and two optional arguments.
2812#
2813# The first argument (mandatory) should be a name (LibraryName) for the
2814# library.  The second argument (mandatory) should be an abbreviation in
2815# upper case letters (LBRY) for the library. Ultimately, the macro will
2816# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2817# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2818# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2819# directory containing include files for the library. LBRYLIB should specify
2820# the flags necessary to link to the library. A variable coin_has_lbry will
2821# be set to true or false, as appropriate. A variable lbry_libcheck will be
2822# be set to yes or no; no indicates link checks should not be attempted.
2823#
2824# The macro defines three configure arguments, --with-libraryname-incdir,
2825# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2826# LibraryName to lower case.
2827#
2828# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2829# part of the configure command using --with-libraryname-incdir and
2830# --with-libraryname-lib, respectively. Command line arguments override
2831# environment variables.
2832#
2833# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2834# macro will check for the presence of the file. If a fourth argument is given,
2835# it should specify a function name, `fname'.  The macro will attempt to link a
2836# trivial program containing a parameterless call to the function, `fname()',
2837# using the LBRYLIB flags. The link check uses C as the language; this has been
2838# adequate to date but has limitations. It is possible to disable the link
2839# check by specifying --disable-libraryname-libcheck. This is a workaround for
2840# instances where the link check does not work properly, for whatever reason.
2841# If you're trying to link to a Fortran library, consider using F77_FUNC or
2842# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2843# library, you're on your own unless the library declares some function with
2844# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2845# name.
2846# A fifth argument can be specified to include linker flags that may be required
2847# to sucessfully perform the linking check.
2848#
2849# An optional sixth argument can be given to specify a list of targets.
2850# For each target X, the variables X_LIBS and X_PCLIBS will be extended by $LBRYLIB,
2851# if the library has been found and seems to work.
2852
2853AC_DEFUN([AC_COIN_CHECK_USER_LIBRARY],
2854[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2855  AC_MSG_CHECKING(if user provides library for $1)
2856
2857# Check for header file directory
2858
2859  AC_ARG_WITH(m4_tolower($1)-incdir,
2860      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2861                     [specify the header file directory for library $1]),
2862      [$2INCDIR=`cd $withval; pwd`])
2863
2864# Check for library directory
2865
2866  AC_ARG_WITH(m4_tolower($1)-lib,
2867      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2868                     [specify the flags used to link with the library $1]),
2869      [$2LIB=$withval])
2870
2871# Switch to disable library check if requested
2872
2873  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2874      AS_HELP_STRING([--disable-m4_tolower($1)-libcheck],
2875                     [skip the link check at configuration time]),
2876      [m4_tolower($1)_libcheck=$enableval],
2877      [m4_tolower($1)_libcheck=yes])
2878
2879# At this point, if we're going to use the library, both LBRYINCDIR and
2880# LBRYLIB must be defined and not empty.
2881
2882  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2883    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2884      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.])
2885    fi
2886    m4_tolower(coin_has_$2)=true
2887    AC_MSG_RESULT(yes)
2888  else
2889    m4_tolower(coin_has_$2)=false
2890    AC_MSG_RESULT(no)
2891  fi
2892
2893# If we have instructions for use, consider header and link checks.
2894
2895  if test $m4_tolower(coin_has_$2) = true; then
2896
2897# If argument 3 (file) is given, check for the file. Typically this will be a
2898# header file, but that's not assumed.
2899
2900    m4_ifval([$3],
2901        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2902             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2903
2904# Now see if we can link the function. There are arguments for and against
2905# assuming argument 3 is a header file declaring the function. A correct
2906# function declaration is the main argument in favour. Having to cope with
2907# possible dependencies or other oddities are the main arguments against.
2908# Force the use of C as the best single choice amongst C++, C, and Fortran.
2909# Obviously, this has limits.
2910
2911    m4_ifvaln([$4],
2912        [if test x"$m4_tolower($1)_libcheck" != xno; then
2913           coin_save_LIBS="$LIBS"
2914           LIBS="$$2LIB $5"
2915           coin_$2_link=no
2916           AC_LANG_PUSH(C)
2917           for fnm in $4 ; do
2918             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2919             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2920                 [AC_MSG_RESULT(yes)
2921                  coin_$2_link=yes
2922                  break],
2923                 [AC_MSG_RESULT(no)])
2924           done
2925           AC_LANG_POP(C)
2926           LIBS="$coin_save_LIBS"
2927           if test x"$coin_$2_link" != xyes ; then
2928             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2929           fi
2930         fi])
2931
2932# If we make it this far, we've verified the file and linked the function. Add
2933# the necessary link flags to $6_{PC}LIBS and define the preprocessor symbol
2934# COIN_HAS_LBRY.
2935
2936    coin_foreach_w([myvar], [$6], [
2937      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
2938      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
2939      m4_toupper(myvar)_LIBS_INSTALLED="$$2LIB $m4_toupper(myvar)_LIBS_INSTALLED"
2940    ])
2941   
2942    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2943  fi
2944
2945# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2946# automake conditional. These actions must occur unconditionally.
2947
2948  AC_SUBST($2INCDIR)
2949  AC_SUBST($2LIB)
2950  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2951]) #AC_COIN_CHECK_USER_LIBRARY
2952
2953###########################################################################
2954#                            COIN_TRY_FLINK                               #
2955###########################################################################
2956
2957# Auxilliary macro to test if a Fortran function name can be linked,
2958# given the current settings of LIBS.  We determine from the context, what
2959# the currently active programming language is, and cast the name accordingly.
2960# The first argument is the name of the function/subroutine, in small letters,
2961# the second argument are the actions taken when the test works, and the
2962# third argument are the actions taken if the test fails.
2963
2964AC_DEFUN([AC_COIN_TRY_FLINK],
2965[case $ac_ext in
2966  f)
2967    AC_TRY_LINK(,[      call $1],[$2],[$3])
2968    ;;
2969  c)
2970    AC_F77_FUNC($1,cfunc$1)
2971    if test x"$coin_need_flibs" = xyes; then
2972      flink_try=no;
2973    else
2974      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2975                  [flink_try=yes],[flink_try=no])
2976    fi
2977    if test $flink_try = yes; then
2978      $2
2979    else
2980      if test x"$FLIBS" != x; then
2981        flink_save_libs="$LIBS"
2982        LIBS="$LIBS $FLIBS"
2983        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2984                    [LIBS="$flink_save_libs"
2985                     coin_need_flibs=yes
2986                     $2
2987                    ],
2988                    [LIBS="$flink_save_libs"
2989                     $3])
2990      else
2991        $3
2992      fi
2993    fi
2994    ;;
2995  cc|cpp)
2996    AC_F77_FUNC($1,cfunc$1)
2997    if test x"$coin_need_flibs" = xyes; then
2998      flink_try=no;
2999    else
3000      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
3001                  [flink_try=yes],[flink_try=no])
3002    fi
3003    if test $flink_try = yes; then
3004      $2
3005    else
3006      if test x"$FLIBS" != x; then
3007        flink_save_libs="$LIBS"
3008        LIBS="$LIBS $FLIBS"
3009        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
3010                    [LIBS="$flink_save_libs"
3011                     coin_need_flibs=yes
3012                     $2
3013                    ],
3014                    [LIBS="$flink_save_libs"
3015                     $3])
3016      else
3017        $3
3018      fi
3019    fi
3020    ;;
3021esac
3022]) # AC_COIN_TRY_FLINK
3023
3024###########################################################################
3025#                           COIN_DOXYGEN                                  #
3026###########################################################################
3027#
3028# This macro determines the configuration information for doxygen, the tool
3029# used to generate online documentation of COIN code. It takes one parameter,
3030# a list of projects (mixed-case, to match the directory names) that should
3031# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
3032#
3033# This macro will define the following variables:
3034#  coin_have_doxygen    Yes if doxygen is found, no otherwise
3035#  coin_doxy_usedot     Defaults to `yes'; --with-dot will still check to see
3036#                       if dot is available
3037#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
3038#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
3039#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
3040#                       doxygen documentation
3041#  coin_doxy_excludes   Directories to exclude from doxygen processing
3042
3043AC_DEFUN([AC_COIN_DOXYGEN],
3044[
3045
3046AC_MSG_NOTICE([configuring doxygen documentation options])
3047
3048# Check to see if doxygen is available.
3049
3050AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
3051
3052# Look for the dot tool from the graphviz package, unless the user has
3053# disabled it.
3054
3055AC_ARG_WITH([dot],
3056  AS_HELP_STRING([--with-dot],
3057                 [use dot (from graphviz) when creating documentation with
3058                  doxygen if available; --without-dot to disable]),
3059  [],[withval=yes])
3060if test x"$withval" = xno ; then
3061  coin_doxy_usedot=NO
3062  AC_MSG_CHECKING([for dot ])
3063  AC_MSG_RESULT([disabled])
3064else
3065  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
3066fi
3067
3068# Generate a tag file name and a log file name
3069
3070AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
3071AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
3072
3073# Process the list of project names and massage them into possible doxygen
3074# doc'n directories. Prefer 1) classic external, source processed using
3075# a project-specific doxygen.conf, we use the tag file; 2) classic
3076# external, source processed using package doxygen.conf; 3) installed
3077# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
3078# configured, which we can't know unless this is the package base configure,
3079# since coin_subdirs is only set there. Hence it's sufficient to check for
3080# membership. If we use a tag file from a classic external, exclude the
3081# source from doxygen processing when doxygen runs in the base directory.
3082
3083coin_doxy_tagfiles=
3084coin_doxy_excludes=
3085tmp="$1"
3086for proj in $tmp ; do
3087  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
3088  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
3089  doxytag=${lc_proj}_doxy.tag
3090  doxyfound=no
3091  for chkProj in $coin_subdirs ; do
3092    if test "$chkProj" = "$proj" ; then
3093      # proj will be configured, hence doxydoc present in build tree
3094      doxysrcdir="${srcdir}/${proj}"
3095      # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
3096      if test -d "$doxysrcdir" ; then
3097        # with a doxydoc directory?
3098        doxydir="$doxysrcdir/doxydoc"
3099        # AC_MSG_NOTICE([Considering $doxydir (base)])
3100        # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
3101        if test -d "$doxydir" ; then
3102          # use tag file; don't process source
3103          eval doxydir="`pwd`/${proj}/doxydoc"
3104          coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
3105          AC_MSG_RESULT([$doxydir (tag)])
3106          coin_doxy_excludes="$coin_doxy_excludes */${proj}"
3107        else
3108          # will process the source -- nothing further to be done here
3109          AC_MSG_RESULT([$doxysrcdir (src)])
3110        fi
3111        doxyfound=yes
3112      fi
3113    fi
3114  done
3115  # Not built, fall back to installed tag file
3116  if test $doxyfound = no ; then
3117    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
3118    # AC_MSG_NOTICE([Considering $doxydir (install)])
3119    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
3120    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
3121    AC_MSG_RESULT([$doxydir (tag)])
3122  fi
3123done
3124AC_SUBST([coin_doxy_tagfiles])
3125AC_SUBST([coin_doxy_excludes])
3126
3127]) # AC_COIN_DOXYGEN
3128
3129
3130###########################################################################
3131#                           COIN_HAS_PKGCONFIG                            #
3132###########################################################################
3133
3134# This macro checks whether a pkg-config tool with a minimal version number
3135# is available.  If so, then the variable PKGCONFIG is set to its path.
3136# If not, PKGCONFIG is set to "".  The minimal version number can be given
3137# as first parameter, by default it is 0.16.0, since COIN-OR .pc files now
3138# include an URL field, which breaks pkg-config version <= 0.15.
3139# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
3140# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
3141# AC_SUBST'ed.  Finally, if this setup belongs to a project directory, then
3142# the search path for .pc files is assembled from the value of
3143# $PKG_CONFIG_PATH, the values of --prefix, --coin-instdir, and the directories
3144# named in a file ../coin_subdirs.txt or ../../coin_subdirs.txt in a variable
3145# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed. For a path xxx given in the
3146# coin-subdirs.txt, also the directory xxx/pkgconfig is added, if existing.
3147
3148AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
3149[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
3150
3151AC_ARG_ENABLE([pkg-config],
3152  [AC_HELP_STRING([--disable-pkg-config],[disable use of pkg-config (if available)])],
3153  [use_pkgconfig="$enableval"],
3154  [if test x$coin_cc_is_cl = xtrue; then
3155     use_pkgconfig=no
3156   else
3157     use_pkgconfig=yes
3158   fi])
3159
3160if test $use_pkgconfig = yes ; then
3161  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
3162    AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
3163  fi
3164  if test -n "$PKG_CONFIG"; then
3165    _pkg_min_version=m4_default([$1], [0.16.0])
3166    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
3167    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
3168      AC_MSG_RESULT([yes])
3169    else
3170      AC_MSG_RESULT([no])
3171      PKG_CONFIG=""
3172    fi
3173  fi
3174
3175  # check if pkg-config supports the short-errors flag
3176  if test -n "$PKG_CONFIG" && \
3177    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
3178    pkg_short_errors=" --short-errors "
3179  else
3180    pkg_short_errors=""
3181  fi
3182fi
3183
3184AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
3185AC_SUBST(PKG_CONFIG)
3186
3187# assemble pkg-config search path for installed projects
3188COIN_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3189
3190# 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
3191# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
3192# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
3193if test "x${prefix}" = xNONE ; then
3194  COIN_PKG_CONFIG_PATH="${ac_default_prefix}/lib64/pkgconfig:${ac_default_prefix}/lib/pkgconfig:${ac_default_prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
3195else
3196  COIN_PKG_CONFIG_PATH="${prefix}/lib64/pkgconfig:${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
3197fi
3198
3199AC_ARG_WITH([coin-instdir],
3200  AC_HELP_STRING([--with-coin-instdir],
3201                 [prefix of installation directory for precompiled COIN packages]),
3202  [if test -d "$withval"; then : ; else
3203     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
3204   fi
3205   COIN_PKG_CONFIG_PATH="$withval/lib/pkgconfig:$withval/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
3206  ],[])
3207
3208AC_SUBST(COIN_PKG_CONFIG_PATH)
3209
3210# assemble additional pkg-config search paths for uninstalled projects
3211if test x$coin_projectdir = xyes ; then
3212  # if we are in a project setup, then in a classic setup, we want to find uninstalled projects
3213  # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
3214  # unfortunately, if the user set prefix, then we do not know where the project base directory is located
3215  # 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)
3216  COIN_PKG_CONFIG_PATH_UNINSTALLED=
3217  if test -f ../coin_subdirs.txt ; then
3218    for i in `cat ../coin_subdirs.txt` ; do
3219      if test -d ../$i ; then
3220        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3221      fi
3222      if test -d ../$i/pkgconfig ; then
3223        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3224      fi
3225    done
3226  fi
3227
3228  if test -f ../../coin_subdirs.txt ; then
3229    for i in `cat ../../coin_subdirs.txt` ; do
3230      if test -d ../../$i ; then
3231        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3232      fi
3233      if test -d ../../$i/pkgconfig ; then
3234        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3235      fi
3236    done
3237  fi
3238
3239  AC_SUBST(COIN_PKG_CONFIG_PATH_UNINSTALLED)
3240fi
3241
3242if test -n "$PKG_CONFIG" && test x$coin_cc_is_cl = xtrue; then
3243  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.])
3244fi
3245
3246])
3247
3248###########################################################################
3249#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
3250###########################################################################
3251
3252# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3253#
3254# Check to see whether a particular project exists.  Similar
3255# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
3256#
3257AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
3258[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3259if test -n "$PKG_CONFIG" ; then
3260  if $PKG_CONFIG --exists "m4_tolower($1)"; then
3261    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
3262    m4_ifval([$2], [$2], [:])
3263  else
3264    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
3265    $3
3266  fi
3267else
3268  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
3269fi
3270])
3271
3272###########################################################################
3273#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
3274###########################################################################
3275
3276# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3277#
3278# Check to see whether a particular set of packages exists.
3279# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
3280#
3281AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
3282[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3283if test -n "$PKG_CONFIG" ; then
3284  if $PKG_CONFIG --exists "$2"; then
3285    m4_toupper($1)[]_VERSIONS=`$PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`
3286    $3
3287  else
3288    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
3289    $4
3290  fi
3291else
3292  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
3293fi
3294])
3295
3296###########################################################################
3297#                           COIN_PKG_HAS_MODULE                           #
3298###########################################################################
3299
3300# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3301#
3302# Checks whether pkg-config files for a given set of packages is available.
3303# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
3304# If not, then ACTION-IF-NOT-FOUND is executed.
3305# A reason for not finding a package is stored in MODULE_PKG_ERRORS
3306#
3307# --------------------------------------------------------------
3308AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
3309[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3310
3311AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
3312  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
3313    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
3314        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
3315        # but only do this if is not trivial
3316    if test "$CYGPATH_W" != "echo" ; then
3317      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
3318      [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3319    fi
3320    m4_toupper($1)[]_CFLAGS="$cflags"
3321    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
3322    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
3323    $3
3324  ],
3325  [ $4 ])
3326
3327])# PKG_CHECK_MODULES
3328
3329###########################################################################
3330#                           COIN_MAIN_PACKAGEDIR                          #
3331###########################################################################
3332
3333# This macro substitutes COIN_MAIN_SUBDIR.
3334# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
3335# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
3336# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
3337#   If so, include this directory into the list of directories where configure and make recourse into.
3338# tolower(coin_has_$1) is set to "no" if the project source is not available or will not be compiled.
3339# Otherwise, it will be set to "yes".
3340
3341AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],[
3342AC_MSG_CHECKING([whether source of project $1 is available and should be compiled])
3343
3344m4_tolower(coin_has_$1)=notGiven
3345coin_reason=
3346
3347# check if user wants to skip project in any case
3348AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
3349if test x"$COIN_SKIP_PROJECTS" != x; then
3350  for dir in $COIN_SKIP_PROJECTS; do
3351    if test $dir = "$1"; then
3352      m4_tolower(coin_has_$1)="no"
3353      coin_reason="$1 has been specified in COIN_SKIP_PROJECTS"
3354    fi
3355    m4_ifval($2,[
3356    if test $dir = "$2/$1"; then
3357      m4_tolower(coin_has_$1)="no"
3358      coin_reason="$2/$1 has been specified in COIN_SKIP_PROJECTS"
3359    fi])
3360  done
3361fi
3362
3363if test "$m4_tolower(coin_has_$1)" != no; then
3364  AC_ARG_WITH([m4_tolower($1)],,
3365    [if test "$withval" = no ; then
3366       m4_tolower(coin_has_$1)="no"
3367       coin_reason="--without-m4_tolower($1) has been specified"
3368     fi
3369    ])
3370fi
3371
3372if test "$m4_tolower(coin_has_$1)" != no; then
3373  AC_ARG_WITH([m4_tolower($1)-lib],
3374    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3375                   [linker flags for using project $1]),
3376    [if test "$withval" = no ; then
3377       m4_tolower(coin_has_$1)="no"
3378       coin_reason="--without-m4_tolower($1)-lib has been specified"
3379     else
3380       m4_tolower(coin_has_$1)="no"
3381       coin_reason="--with-m4_tolower($1)-lib has been specified"
3382     fi],
3383    [])
3384fi
3385
3386if test "$m4_tolower(coin_has_$1)" != no; then
3387  AC_ARG_WITH([m4_tolower($1)-incdir],
3388    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3389                   [directory with header files for using project $1]),
3390    [if test "$withval" = no ; then
3391       m4_tolower(coin_has_$1)="no"
3392       coin_reason="--without-m4_tolower($1)-incdir has been specified"
3393     else
3394       m4_tolower(coin_has_$1)="no"
3395       coin_reason="--with-m4_tolower($1)-incdir has been specified"
3396     fi],
3397    [])
3398fi
3399
3400if test "$m4_tolower(coin_has_$1)" != no; then
3401  AC_ARG_WITH([m4_tolower($1)-datadir],
3402    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3403                   [directory with data files for using project $1]),
3404    [if test "$withval" = no ; then
3405       m4_tolower(coin_has_$1)="no"
3406       coin_reason="--without-m4_tolower($1)-datadir has been specified"
3407     else
3408       m4_tolower(coin_has_$1)="no"
3409       coin_reason="--with-m4_tolower($1)-datadir has been specified"
3410     fi],
3411    [])
3412fi
3413
3414m4_if(m4_tolower($1), blas, [
3415  if test $m4_tolower(coin_has_$1) != no; then
3416    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
3417    AC_ARG_WITH([blas],
3418      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
3419        [if test x"$withval" = "xno" ; then
3420           coin_has_blas="no"
3421           coin_reason="--without-blas has been specified"
3422         elif test x"$withval" != "xBUILD" ; then
3423           coin_has_blas="no"
3424           coin_reason="--with-blas has been specified"
3425         fi],
3426        [])
3427  fi
3428])
3429
3430m4_if(m4_tolower($1), lapack, [
3431  if test $m4_tolower(coin_has_$1) != skipping; then
3432    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
3433    AC_ARG_WITH([lapack],
3434      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
3435        [if test x"$withval" = "xno" ; then
3436           coin_has_lapack="no"
3437           coin_reason="--without-lapack has been specified"
3438         elif test x"$withval" != "xBUILD" ; then
3439           coin_has_lapack="no"
3440           coin_reason="--with-lapack has been specified"
3441         fi],
3442        [])
3443  fi
3444])
3445
3446# check if project is available in present directory
3447if test "$m4_tolower(coin_has_$1)" = notGiven; then
3448  m4_tolower(coin_has_$1)=no
3449  if test -d $srcdir/m4_ifval($2,[$2/],)$1; then
3450    coin_reason="source in m4_ifval($2,[$2/],)$1"
3451    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
3452    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
3453    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
3454    m4_ifvaln([$3],
3455      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
3456         if test -r $i; then
3457           m4_tolower(coin_has_$1)="yes"
3458         else
3459           m4_tolower(coin_has_$1)="no"
3460           coin_reason="source file $i not available"
3461           break
3462         fi
3463       done],
3464      [ m4_tolower(coin_has_$1)="yes" ])
3465  fi
3466fi
3467
3468if test -z "$coin_reason" ; then
3469  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3470else
3471  AC_MSG_RESULT([$m4_tolower(coin_has_$1), $coin_reason])
3472fi
3473
3474if test "$m4_tolower(coin_has_$1)" = yes ; then
3475  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
3476    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
3477    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
3478  fi
3479fi
3480])
3481
3482###########################################################################
3483#                            COIN_CHECK_PACKAGE                           #
3484###########################################################################
3485
3486# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
3487# A package can consists of one or more COIN-OR or other projects.
3488# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, PACKAGE_DEPENDENCIES, and PACKAGE_DATA variables, referring to the compiler and linker
3489# flags to use when linking against this module, the libraries the package depends on, and the directories where the module data resists.
3490# The difference between PACKAGE_LIBS and PACKAGE_DEPENDENCIES is that PACKAGE_DEPENDENCIES does not contain arguments starting with '-',
3491# so it can be used to setup the _DEPENDENCIES variable in a Makefile.am.
3492# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
3493# Further, tolower(coin_has_$1) is set to "yes".
3494# If a list of build targets using this projects is given in the third argument,
3495# then the compiler and linker variables and .pc file setup variable corresponding to this build target
3496# are extended with the values for this package.
3497# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_DEPENDENCIES, X_PCLIBS, X_PCREQUIRES are setup,
3498# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
3499#
3500# The first argument should be the name (PACKAGE) of the package (in correct lower
3501# and upper case).
3502# The second argument should be a (space separated) list of projects which this
3503# package consists of. Optionally, required version numbers can be added.
3504# The optional third argument should be a (space separated) list of build targets
3505# which use this package, if available.
3506#
3507# It is also possible to specify a preinstalled version of this package
3508# or to specify only the linker and compiler flags and data directory.
3509#
3510# If the user did not specify --with-$1-... flags and pkg-config is not available,
3511# COIN_CHECK_PACKAGE_FALLBACK($1, $2, $3) is called.
3512
3513AC_DEFUN([AC_COIN_CHECK_PACKAGE],
3514[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3515AC_MSG_CHECKING([for COIN-OR package $1])
3516
3517m4_tolower(coin_has_$1)=notGiven
3518
3519# check if user wants to skip package in any case
3520if test x"$COIN_SKIP_PROJECTS" != x; then
3521  for dir in $COIN_SKIP_PROJECTS; do
3522    if test $dir = "$1"; then
3523      m4_tolower(coin_has_$1)=skipping
3524    fi
3525  done
3526fi
3527
3528if test "$m4_tolower(coin_has_$1)" != skipping; then
3529  AC_ARG_WITH([m4_tolower($1)],,
3530    [if test "$withval" = no ; then
3531       m4_tolower(coin_has_$1)=skipping
3532     fi
3533    ])
3534fi
3535
3536m4_toupper($1_LIBS)=
3537m4_toupper($1_CFLAGS)=
3538m4_toupper($1_DATA)=
3539m4_toupper($1_DEPENDENCIES)=
3540m4_toupper($1_PCLIBS)=
3541m4_toupper($1_PCREQUIRES)=
3542m4_toupper($1_DATA)=
3543AC_SUBST(m4_toupper($1_LIBS))
3544AC_SUBST(m4_toupper($1_CFLAGS))
3545AC_SUBST(m4_toupper($1_DATA))
3546AC_SUBST(m4_toupper($1_DEPENDENCIES))
3547AC_SUBST(m4_toupper($1_LIBS_INSTALLED))
3548AC_SUBST(m4_toupper($1_CFLAGS_INSTALLED))
3549AC_SUBST(m4_toupper($1_DATA_INSTALLED))
3550coin_foreach_w([myvar], [$3], [
3551  AC_SUBST(m4_toupper(myvar)_CFLAGS)
3552  AC_SUBST(m4_toupper(myvar)_LIBS)
3553  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3554  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
3555  AC_SUBST(m4_toupper(myvar)_DEPENDENCIES)
3556  AC_SUBST(m4_toupper(myvar)_CFLAGS_INSTALLED)
3557  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3558])
3559
3560#check if user provided LIBS, CFLAGS, or DATA for package or disables use of package
3561if test $m4_tolower(coin_has_$1) != skipping; then
3562  AC_ARG_WITH([m4_tolower($1)-lib],
3563    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3564                   [linker flags for using package $1]),
3565    [if test "$withval" = no ; then
3566       m4_tolower(coin_has_$1)=skipping
3567     else
3568       m4_tolower(coin_has_$1)=yes
3569       m4_toupper($1_LIBS)="$withval"
3570       m4_toupper($1_PCLIBS)="$withval"
3571       coin_foreach_w([myvar], [$3], [
3572         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
3573         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
3574       ])
3575       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3576       if test -z "$PKG_CONFIG" ; then
3577         m4_toupper($1_LIBS_INSTALLED)="$withval"
3578         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_LIBS_INSTALLED="$withval $m4_toupper(myvar)_LIBS_INSTALLED"])
3579       fi
3580     fi
3581    ],
3582    [])
3583fi
3584
3585if test $m4_tolower(coin_has_$1) != skipping; then
3586  AC_ARG_WITH([m4_tolower($1)-incdir],
3587    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3588                   [directory with header files for using package $1]),
3589    [if test "$withval" = no ; then
3590       m4_tolower(coin_has_$1)=skipping
3591     else
3592       m4_tolower(coin_has_$1)=yes
3593       m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
3594       coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="-I`${CYGPATH_W} $withval` $m4_toupper(myvar)_CFLAGS"])
3595       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3596       if test -z "$PKG_CONFIG" ; then
3597         m4_toupper($1_CFLAGS_INSTALLED)="$m4_toupper($1_CFLAGS)"
3598         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1_CFLAGS) $m4_toupper(myvar)_CFLAGS_INSTALLED"])
3599       fi
3600     fi
3601    ],
3602    [])
3603fi
3604
3605if test $m4_tolower(coin_has_$1) != skipping; then
3606  AC_ARG_WITH([m4_tolower($1)-datadir],
3607    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3608                   [directory with data files for using package $1]),
3609    [if test "$withval" = no ; then
3610       m4_tolower(coin_has_$1)=skipping
3611     else
3612       m4_tolower(coin_has_$1)=yes
3613       m4_toupper($1_DATA)="$withval"
3614       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3615       if test -z "$PKG_CONFIG" ; then
3616         m4_toupper($1_DATA_INSTALLED)="$withval"
3617       fi
3618     fi
3619    ],
3620    [])
3621fi
3622
3623if test $m4_tolower(coin_has_$1) = notGiven; then
3624  if test -n "$PKG_CONFIG" ; then
3625    # set search path for pkg-config
3626    # need to export variable to be sure that the following pkg-config gets these values
3627    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3628    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
3629    export PKG_CONFIG_PATH
3630   
3631    # let pkg-config do it's magic
3632    AC_COIN_PKG_HAS_MODULE([$1],[$2],
3633      [ m4_tolower(coin_has_$1)=yes
3634        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
3635
3636        # adjust linker flags for (i)cl compiler
3637        # 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)
3638        if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3639        then
3640          m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3641        fi
3642        m4_toupper($1_PCREQUIRES)="$2"
3643   
3644        # augment X_PCREQUIRES, X_CFLAGS, and X_LIBS for each build target X in $3
3645        coin_foreach_w([myvar], [$3], [
3646          m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3647          m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3648          m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3649        ])
3650      ],
3651      [ m4_tolower(coin_has_$1)=notGiven
3652        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
3653      ])
3654
3655    # reset PKG_CONFIG_PATH variable
3656    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3657    export PKG_CONFIG_PATH
3658
3659  else
3660    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
3661    AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
3662  fi
3663
3664else
3665  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3666fi
3667
3668if test $m4_tolower(coin_has_$1) != skipping &&
3669   test $m4_tolower(coin_has_$1) != notGiven ; then
3670  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3671
3672  AC_ARG_ENABLE([interpackage-dependencies],
3673    AC_HELP_STRING([--disable-interpackage-dependencies], [disables deduction of Makefile dependencies from package linker flags]),
3674    [], [enable_interpackage_dependencies=yes])
3675   
3676  if test $enable_interpackage_dependencies = yes ; then
3677     # construct dependencies variables from LIBS variables
3678     # we add an extra space in LIBS so we can substitute out everything starting with " -"
3679     # remove everything of the form -framework xxx as used on Mac and mkl* and libiomp5* and wsock32.lib as used on Windows
3680     # then remove everything of the form -xxx
3681     # also remove everything of the form `xxx`yyy (may have been added for cygwin/cl)
3682     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']`
3683     coin_foreach_w([myvar], [$3], [
3684       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']`
3685     ])
3686  fi
3687
3688  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
3689    if test -n "$m4_toupper($1)_CFLAGS" ; then
3690      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3691    fi
3692    if test -n "$m4_toupper($1)_LIBS" ; then
3693      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
3694    fi
3695    if test -n "$m4_toupper($1)_DEPENDENCIES" ; then
3696      AC_MSG_NOTICE([$1 DEPENDENCIES are $m4_toupper($1)_DEPENDENCIES])
3697    fi
3698    if test -n "$m4_toupper($1)_DATA" ; then
3699      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
3700    fi
3701    if test -n "$m4_toupper($1)_PCLIBS" ; then
3702      AC_MSG_NOTICE([$1 PCLIBS are $m4_toupper($1)_PCLIBS])
3703    fi
3704    if test -n "$m4_toupper($1)_PCREQUIRES" ; then
3705      AC_MSG_NOTICE([$1 PCREQUIRES are $m4_toupper($1)_PCREQUIRES])
3706    fi
3707    coin_foreach_w([myvar], [$3], [
3708      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
3709      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
3710      AC_MSG_NOTICE([myvar DEPENDENCIES are $m4_toupper(myvar)_DEPENDENCIES])
3711    ])
3712  fi
3713fi
3714
3715# Define the Makefile conditional
3716AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3717               [test $m4_tolower(coin_has_$1) != notGiven &&
3718                test $m4_tolower(coin_has_$1) != skipping])
3719
3720]) # AC_COIN_CHECK_PACKAGE
3721
3722###########################################################################
3723#                       COIN_CHECK_PACKAGE_FALLBACK                       #
3724###########################################################################
3725
3726# This macro is used by COIN_CHECK_PACKAGE, if it fails to find a package
3727# because pkg-config was disabled or is not available.
3728#
3729# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc
3730# file in the directories specified in $COIN_PKG_CONFIG_PATH_UNINSTALLED. The
3731# latter variable is setup by COIN_HAS_PKGCONFIG and consists of the content
3732# of the coin_subdirs.txt file which has been created by configure in the
3733# base directory.  The content of xxx-uninstalled.pc is parsed in order
3734# to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
3735# referring to the compiler and linker flags to use when linking against this
3736# package and the directory where the package data resists.  Further, for each
3737# build target X specified in the third argument, the variables X_CFLAGS and
3738# X_LIBS are extended with the compiler and linker flags of this package and
3739# the variables X_PCLIBS and X_PCREQUIRES are extended by the list of linker
3740# flags and dependent projects as needed to setup a .pc file.  The macros
3741# checks also dependencies of $2.  Note that the PACKAGE_DATA variable is
3742# set to the content of datadir of the first .pc file that is parsed.
3743# Finally, for each X in the third argument, also variables
3744# X_CFLAGS_INSTALLED and X_LIBS_INSTALLED are setup. They contain the compiler
3745# and linker flags for X when all projects have been installed. Their content
3746# is assembled from the .pc files that correspond to installed projects. I.e.,
3747# whenever a file proj-uninstalled.pc is parsed, then also a corresponding
3748# proj.pc file is parsed for compiler and linker flags, if available in the
3749# same directory.
3750# Similar, a variable PACKAGE_DATA_INSTALLED is setup to the content of datadir
3751# of the first .pc file that is parsed.
3752#
3753# If .pc files for all projects in $2 and their dependencies is found,
3754# tolower(coin_has_$1) is set to "yes".  Otherwise, if some dependency
3755# is not found, tolower(coin_has_$1) is set to "notGiven".  Further, a
3756# COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
3757#
3758# The first argument should be the name (PACKAGE) of the package (in correct
3759# lower and upper case).  The second argument should be the base names of the
3760# projects .pc file which define this package.  The optional third argument
3761# should be a (space separated) list of build targets which use this package,
3762# if available.
3763#
3764# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into
3765# $COIN_PKG_CONFIG_PATH_UNINSTALLED.  When the content of this variable was
3766# setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
3767
3768AC_DEFUN([AC_COIN_CHECK_PACKAGE_FALLBACK],
3769[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3770AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
3771
3772m4_tolower(coin_has_$1)=notGiven
3773m4_toupper($1_LIBS)=
3774m4_toupper($1_LIBS_INSTALLED)=
3775m4_toupper($1_CFLAGS)=
3776m4_toupper($1_CFLAGS_INSTALLED)=
3777m4_toupper($1_DATA)=
3778m4_toupper($1_DATA_INSTALLED)=
3779m4_toupper($1_PCLIBS)=
3780m4_toupper($1_PCREQUIRES)=
3781
3782# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x, != x)
3783projtoprocess="m4_bpatsubsts([$2], [<?>?!?=[    ]*[^    ]+])"
3784
3785# we first expand the list of projects to process by adding all dependencies just behind the project which depends on it
3786# further, we collect the list of corresponding .pc files, but do this in reverse order, because we need this order afterwards
3787# the latter we also do with .pc files corresponding to the installed projects, which will be needed to setup Makefiles for examples
3788# also, we setup the DATA variable
3789allproj=""
3790allpcfiles=""
3791allpcifiles=""
3792while test "x$projtoprocess" != x ; do
3793
3794  for proj in $projtoprocess ; do
3795    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
3796    pcfile=""
3797    save_IFS="$IFS"
3798    IFS=":"
3799    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
3800      # 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
3801      if test -r "$dir/${proj}-uninstalled.pc" ; then
3802        pcfile="$dir/$proj-uninstalled.pc"
3803        if test -r "$dir/${proj}.pc" ; then
3804          pcifile="$dir/${proj}.pc"
3805        else
3806          AC_MSG_WARN([Found $pcfile, but $dir/${proj}.pc is not available. This may break Makefile's of examples.])
3807          pcifile=
3808        fi
3809        break
3810      fi
3811    done
3812    IFS="$save_IFS"
3813
3814    if test "x$pcfile" != x ; then
3815      # read dependencies from $pcfile and filter it
3816      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\{0,1\}>\{0,1\}=[       ]\{0,\}[^       ]\{1,\}//g'`]
3817
3818      # add projrequires to the front of the list of projects that have to be processed next
3819      # at the same time, remove $proj from this list
3820      projtoprocess=[`echo $projtoprocess | sed -e "s/$proj/$projrequires/"`]
3821
3822      # read DATA from $pcfile, if _DATA is still empty
3823      if test "x$m4_toupper($1_DATA)" = x ; then
3824        projdatadir=
3825        [pcfilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcfile`]
3826        eval `sh -c "$pcfilemod"`
3827        m4_toupper($1_DATA)="$projdatadir"
3828      fi
3829
3830      allproj="$allproj $proj"
3831      allpcfiles="$pcfile:$allpcfiles"
3832
3833    else
3834      AC_MSG_RESULT([no, dependency $proj not available])
3835      allproj=fail
3836      break 2
3837    fi
3838   
3839    if test "x$pcifile" != x ; then
3840      allpcifiles="$pcifile:$allpcifiles"
3841     
3842      # read DATA_INSTALLED from $pcifile, if _DATA_INSTALLED is still empty
3843      if test "x$m4_toupper($1_DATA_INSTALLED)" = x ; then
3844        projdatadir=
3845        [pcifilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcifile`]
3846        eval `sh -c "$pcifilemod"`
3847        if test "${CYGPATH_W}" != "echo"; then
3848          projdatadir="\`\$(CYGPATH_W) ${projdatadir} | sed -e 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g'\`"
3849        fi
3850        m4_toupper($1_DATA_INSTALLED)="$projdatadir"
3851      fi
3852     
3853    fi
3854
3855    break
3856  done
3857
3858  # remove spaces on begin of $projtoprocess
3859  projtoprocess=`echo $projtoprocess | sed -e 's/^[ ]*//'`
3860
3861done
3862
3863if test "$allproj" != fail ; then
3864
3865  # now go through the list of .pc files and assemble compiler and linker flags
3866  # important is here to obey the reverse order that has been setup before,
3867  # since then libraries that are required by several others should be after these other libraries
3868  pcfilesprocessed=""
3869
3870  save_IFS="$IFS"
3871  IFS=":"
3872  for pcfile in $allpcfiles ; do
3873
3874    # if $pcfile has been processed already, skip this round
3875    if test "x$pcfilesprocessed" != x ; then
3876      for pcfiledone in $pcfilesprocessed ; do
3877        if test "$pcfiledone" = "$pcfile" ; then
3878          continue 2
3879        fi
3880      done
3881    fi
3882
3883    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3884    #   replace "Libs:" by "echo projlibs="
3885    #   replace "Cflags:" by "echo projcflags="
3886    #   remove every line starting with <some word>:
3887    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
3888
3889    # set projcflags and projlibs variables by running $pcfilemod
3890    # 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
3891    projcflags=
3892    projlibs=
3893    IFS="$save_IFS"
3894    eval `sh -c "$pcfilemod"`
3895    IFS=":"
3896
3897    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3898    if test "${CYGPATH_W}" != "echo"; then
3899      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3900    fi
3901    m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
3902
3903    # set LIBS variable
3904    m4_toupper($1_LIBS)="$projlibs $m4_toupper($1_LIBS)"
3905
3906    # remember that we have processed $pcfile
3907    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3908
3909  done
3910  IFS="$save_IFS"
3911
3912
3913  # now go through the list of .pc files for installed projects and assemble compiler and linker flags
3914  # important is here again to obey the reverse order that has been setup before,
3915  # since then libraries that are required by several others should be after these other libraries
3916  pcfilesprocessed=""
3917
3918  save_IFS="$IFS"
3919  IFS=":"
3920  for pcfile in $allpcifiles ; do
3921
3922    # if $pcfile has been processed already, skip this round
3923    if test "x$pcfilesprocessed" != x ; then
3924      for pcfiledone in $pcfilesprocessed ; do
3925        if test "$pcfiledone" = "$pcfile" ; then
3926          continue 2
3927        fi
3928      done
3929    fi
3930
3931    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3932    #   replace "Libs:" by "echo projlibs="
3933    #   replace "Cflags:" by "echo projcflags="
3934    #   remove every line starting with <some word>:
3935    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
3936
3937    # set projcflags and projlibs variables by running $pcfilemod
3938    # 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
3939    projcflags=
3940    projlibs=
3941    IFS="$save_IFS"
3942    eval `sh -c "$pcfilemod"`
3943    IFS=":"
3944
3945    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3946    if test "${CYGPATH_W}" != "echo"; then
3947      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3948    fi
3949    m4_toupper($1_CFLAGS_INSTALLED)="$projcflags $m4_toupper($1_CFLAGS_INSTALLED)"
3950
3951    # set LIBS variable
3952    m4_toupper($1_LIBS_INSTALLED)="$projlibs $m4_toupper($1_LIBS_INSTALLED)"
3953   
3954    # remember that we have processed $pcfile
3955    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3956
3957  done
3958  IFS="$save_IFS"
3959
3960
3961  # finish up
3962  m4_tolower(coin_has_$1)=yes
3963  AC_MSG_RESULT([yes])
3964  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3965
3966  # adjust linker flags for (i)cl compiler
3967  # 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),
3968  # for the LIBS_INSTALLED, we replace everything of the form "/somepath/" by "`$(CYGPATH_W) /somepath/`",
3969  #    everything of the form "-lname" by "libname.lib", and
3970  #    everything of the form "-Lpath" by "-libpath:`$(CYGPATH_W) path`
3971  if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3972  then
3973    m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3974    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']`
3975  fi
3976
3977  m4_toupper($1_PCREQUIRES)="$2"
3978  coin_foreach_w([myvar], [$3], [
3979    m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3980    m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3981    m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3982    m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1)_CFLAGS_INSTALLED $m4_toupper(myvar)_CFLAGS_INSTALLED"
3983    m4_toupper(myvar)_LIBS_INSTALLED="$m4_toupper($1)_LIBS_INSTALLED $m4_toupper(myvar)_LIBS_INSTALLED"
3984  ])
3985
3986fi
3987
3988AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3989               [test $m4_tolower(coin_has_$1) != notGiven &&
3990                test $m4_tolower(coin_has_$1) != skipping])
3991
3992]) # AC_COIN_CHECK_PACKAGE_FALLBACK
3993
3994###########################################################################
3995#                         COIN_CHECK_PACKAGE_BLAS                         #
3996###########################################################################
3997
3998# This macro checks for a library containing the BLAS library.  It
3999# 1. checks the --with-blas argument
4000# 2. if --with-blas=BUILD has been specified goes to point 5
4001# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
4002#    to its value
4003# 4. tries standard libraries
4004# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
4005#    ThirdParty/Blas
4006# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
4007# BLAS_LIBS is set to the flags required to link with a Blas library.
4008# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
4009# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
4010# In case 5, Blas is added to X_PCREQUIRES.
4011
4012AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
4013[
4014AC_ARG_WITH([blas],
4015            AC_HELP_STRING([--with-blas],
4016                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
4017            [use_blas="$withval"], [use_blas=])
4018
4019# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
4020# preference
4021AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
4022
4023# Check if user supplied option makes sense
4024if test x"$use_blas" != x; then
4025  if test "$use_blas" = "BUILD"; then
4026    # we come to this later
4027    :
4028  elif test "$use_blas" != "no"; then
4029    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
4030    coin_need_flibs=no
4031    coin_save_LIBS="$LIBS"
4032    LIBS="$use_blas $LIBS"
4033    AC_COIN_TRY_FLINK([daxpy],
4034                      [if test $coin_need_flibs = yes ; then
4035                         use_blas="$use_blas $FLIBS"
4036                       fi
4037                       AC_MSG_RESULT([yes: $use_blas])],
4038                      [AC_MSG_RESULT([no])
4039                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
4040    LIBS="$coin_save_LIBS"
4041  fi
4042else
4043# Try to autodetect the library for blas based on build system
4044  #AC_MSG_CHECKING([default locations for BLAS])
4045  case $build in
4046    *-sgi-*)
4047      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
4048      coin_need_flibs=no
4049      coin_save_LIBS="$LIBS"
4050      LIBS="-lcomplib.sgimath $LIBS"
4051      AC_COIN_TRY_FLINK([daxpy],
4052                        [use_blas="-lcomplib.sgimath"
4053                         if test $coin_need_flibs = yes ; then
4054                           use_blas="$use_blas $FLIBS"
4055                         fi
4056                         AC_MSG_RESULT([yes: $use_blas])
4057                        ],
4058                        [AC_MSG_RESULT([no])])
4059      LIBS="$coin_save_LIBS"
4060      ;;
4061
4062# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
4063# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
4064# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
4065# that CC and cc will understand -library in Studio 13. The main extra
4066# function of -xlic_lib and -library is to arrange for the Fortran run-time
4067# libraries to be linked for C++ and C. We can arrange that explicitly.
4068    *-*-solaris*)
4069      AC_MSG_CHECKING([for BLAS in libsunperf])
4070      coin_need_flibs=no
4071      coin_save_LIBS="$LIBS"
4072      LIBS="-lsunperf $FLIBS $LIBS"
4073      AC_COIN_TRY_FLINK([daxpy],
4074                        [use_blas='-lsunperf'
4075                         if test $coin_need_flibs = yes ; then
4076                           use_blas="$use_blas $FLIBS"
4077                         fi
4078                         AC_MSG_RESULT([yes: $use_blas])
4079                        ],
4080                        [AC_MSG_RESULT([no])])
4081      LIBS="$coin_save_LIBS"
4082      ;;
4083     
4084    *-cygwin* | *-mingw*)
4085      case "$CC" in
4086        clang* ) ;;
4087        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
4088          coin_save_LIBS="$LIBS"
4089          AC_MSG_CHECKING([for BLAS in MKL (32bit)])
4090          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
4091          AC_COIN_TRY_FLINK([daxpy],
4092                            [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
4093                             AC_MSG_RESULT([yes: $use_blas])
4094                            ],
4095                            [AC_MSG_RESULT([no])])
4096          LIBS="$coin_save_LIBS"
4097         
4098          if test "x$use_blas" = x ; then
4099            AC_MSG_CHECKING([for BLAS in MKL (64bit)])
4100            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
4101            AC_COIN_TRY_FLINK([daxpy],
4102                              [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
4103                               AC_MSG_RESULT([yes: $use_blas])
4104                              ],
4105                              [AC_MSG_RESULT([no])])
4106            LIBS="$coin_save_LIBS"
4107          fi
4108          ;;
4109      esac
4110      ;;
4111     
4112     *-darwin*)
4113      AC_MSG_CHECKING([for BLAS in Veclib])
4114      coin_need_flibs=no
4115      coin_save_LIBS="$LIBS"
4116      LIBS="-framework vecLib $LIBS"
4117      AC_COIN_TRY_FLINK([daxpy],
4118                        [use_blas='-framework vecLib'
4119                         if test $coin_need_flibs = yes ; then
4120                           use_blas="$use_blas $FLIBS"
4121                         fi
4122                         AC_MSG_RESULT([yes: $use_blas])
4123                        ],
4124                        [AC_MSG_RESULT([no])])
4125      LIBS="$coin_save_LIBS"
4126      ;;
4127  esac
4128
4129  if test -z "$use_blas" ; then
4130    AC_MSG_CHECKING([whether -lblas has BLAS])
4131    coin_need_flibs=no
4132    coin_save_LIBS="$LIBS"
4133    LIBS="-lblas $LIBS"
4134    AC_COIN_TRY_FLINK([daxpy],
4135                      [use_blas='-lblas'
4136                       if test $coin_need_flibs = yes ; then
4137                         use_blas="$use_blas $FLIBS"
4138                       fi
4139                       AC_MSG_RESULT([yes: $use_blas])
4140                      ],
4141                      [AC_MSG_RESULT([no])])
4142    LIBS="$coin_save_LIBS"
4143  fi
4144
4145  # If we have no other ideas, consider building BLAS.
4146  if test -z "$use_blas" ; then
4147    use_blas=BUILD
4148  fi
4149fi
4150
4151if test "x$use_blas" = xBUILD ; then
4152  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
4153 
4154elif test "x$use_blas" != x && test "$use_blas" != no; then
4155  coin_has_blas=yes
4156  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
4157  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
4158  BLAS_LIBS="$use_blas"
4159  BLAS_CFLAGS=
4160  BLAS_DATA=
4161  AC_SUBST(BLAS_LIBS)
4162  AC_SUBST(BLAS_CFLAGS)
4163  AC_SUBST(BLAS_DATA)
4164  coin_foreach_w([myvar], [$1], [
4165    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
4166    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
4167    m4_toupper(myvar)_LIBS_INSTALLED="$BLAS_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
4168  ])
4169 
4170else
4171  coin_has_blas=no
4172  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
4173fi
4174
4175coin_foreach_w([myvar], [$1], [
4176  AC_SUBST(m4_toupper(myvar)_PCLIBS)
4177  AC_SUBST(m4_toupper(myvar)_LIBS)
4178  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
4179])
4180
4181]) # AC_COIN_CHECK_PACKAGE_BLAS
4182
4183###########################################################################
4184#                       COIN_CHECK_PACKAGE_LAPACK                         #
4185###########################################################################
4186
4187# This macro checks for a library containing the LAPACK library.  It
4188# 1. checks the --with-lapack argument
4189# 2. if --with-lapack=BUILD has been specified goes to point 5
4190# 3. if --with-lapack has been specified to a working library, sets
4191#    LAPACK_LIBS to its value
4192# 4. tries standard libraries
4193# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
4194#    ThirdParty/Lapack
4195# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
4196# LAPACK_LIBS is set to the flags required to link with a Lapack library.
4197# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
4198# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
4199# In case 5, Lapack is added to X_PCREQUIRES.
4200#
4201# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
4202#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
4203#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
4204#   then we will get Blas as dependency of coinlapack.
4205
4206AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
4207[
4208AC_ARG_WITH([lapack],
4209            AC_HELP_STRING([--with-lapack],
4210                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
4211            [use_lapack=$withval], [use_lapack=])
4212
4213#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
4214AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
4215
4216# Check if user supplied option makes sense
4217if test x"$use_lapack" != x; then
4218  if test "$use_lapack" = "BUILD"; then
4219    # we come to this later
4220    :
4221  elif test "$use_lapack" != no; then
4222    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
4223    coin_need_flibs=no
4224    use_lapack="$use_lapack $BLAS_LIBS"
4225    coin_save_LIBS="$LIBS"
4226    LIBS="$use_lapack $LIBS"
4227    AC_COIN_TRY_FLINK([dsyev],
4228                      [if test $coin_need_flibs = yes ; then
4229                         use_lapack="$use_lapack $FLIBS"
4230                       fi
4231                       AC_MSG_RESULT([yes: $use_lapack])
4232                      ],
4233                      [AC_MSG_RESULT([no])
4234                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
4235    LIBS="$coin_save_LIBS"
4236  fi
4237else
4238  if test x$coin_has_blas = xyes; then
4239    # First try to see if LAPACK is already available with BLAS library
4240    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
4241    coin_save_LIBS="$LIBS"
4242    coin_need_flibs=no
4243    LIBS="$BLAS_LIBS $LIBS"
4244    AC_COIN_TRY_FLINK([dsyev],
4245                      [use_lapack="$BLAS_LIBS"
4246                       if test $coin_need_flibs = yes ; then
4247                         use_lapack="$use_lapack $FLIBS"
4248                       fi
4249                       AC_MSG_RESULT([yes: $use_lapack])
4250                      ],
4251                      [AC_MSG_RESULT([no])])
4252    LIBS="$coin_save_LIBS"
4253  fi
4254  if test -z "$use_lapack"; then
4255    # Try to autodetect the library for lapack based on build system
4256    case $build in
4257      # TODO: Is this check actually needed here, since -lcomplib.sigmath should have been recognized as Blas library,
4258      #       and above it is checked whether the Blas library already contains Lapack
4259      *-sgi-*)
4260        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
4261        coin_save_LIBS="$LIBS"
4262        coin_need_flibs=no
4263        LIBS="-lcomplib.sgimath $BLAS_LIBS $LIBS"
4264        AC_COIN_TRY_FLINK([dsyev],
4265                          [use_lapack="-lcomplib.sgimath $BLAS_LIBS"
4266                           if test $coin_need_flibs = yes ; then
4267                             use_lapack="$use_lapack $FLIBS"
4268                           fi
4269                           AC_MSG_RESULT([yes: $use_lapack])
4270                          ],
4271                          [AC_MSG_RESULT([no])])
4272        LIBS="$coin_save_LIBS"
4273        ;;
4274
4275      # See comments in COIN_CHECK_PACKAGE_BLAS.
4276      # TODO: Is this check actually needed here, since -lsunperf should have been recognized as Blas library,
4277      #       and above it is checked whether the Blas library already contains Lapack
4278      *-*-solaris*)
4279        AC_MSG_CHECKING([for LAPACK in libsunperf])
4280        coin_need_flibs=no
4281        coin_save_LIBS="$LIBS"
4282        LIBS="-lsunperf $BLAS_LIBS $FLIBS $LIBS"
4283        AC_COIN_TRY_FLINK([dsyev],
4284                          [use_lapack='-lsunperf $BLAS_LIBS'
4285                           if test $coin_need_flibs = yes ; then
4286                             use_lapack="$use_lapack $FLIBS"
4287                           fi
4288                           AC_MSG_RESULT([yes: $use_lapack])
4289                          ],
4290                          [AC_MSG_RESULT([no])])
4291        LIBS="$coin_save_LIBS"
4292        ;;
4293        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
4294        # will want to link with cygwin, hence won't run standalone in DOS.
4295    esac
4296  fi
4297
4298  if test -z "$use_lapack" ; then
4299    AC_MSG_CHECKING([whether -llapack has LAPACK])
4300    coin_need_flibs=no
4301    coin_save_LIBS="$LIBS"
4302    LIBS="-llapack $BLAS_LIBS $LIBS"
4303    AC_COIN_TRY_FLINK([dsyev],
4304                      [use_lapack='-llapack'
4305                       if test $coin_need_flibs = yes ; then
4306                         use_lapack="$use_lapack $FLIBS"
4307                       fi
4308                       AC_MSG_RESULT([yes: $use_lapack])
4309                      ],
4310                      [AC_MSG_RESULT([no])])
4311    LIBS="$coin_save_LIBS"
4312  fi
4313
4314  # If we have no other ideas, consider building LAPACK.
4315  if test -z "$use_lapack" ; then
4316    use_lapack=BUILD
4317  fi
4318fi
4319
4320if test "x$use_lapack" = xBUILD ; then
4321  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
4322
4323elif test "x$use_lapack" != x && test "$use_lapack" != no; then
4324  coin_has_lapack=yes
4325  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
4326  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
4327  LAPACK_LIBS="$use_lapack"
4328  LAPACK_CFLAGS=
4329  LAPACK_DATA=
4330  AC_SUBST(LAPACK_LIBS)
4331  AC_SUBST(LAPACK_CFLAGS)
4332  AC_SUBST(LAPACK_DATA)
4333  coin_foreach_w([myvar], [$1], [
4334    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
4335    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
4336    m4_toupper(myvar)_LIBS_INSTALLED="$LAPACK_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
4337  ])
4338 
4339else
4340  coin_has_lapack=no
4341  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
4342fi
4343
4344coin_foreach_w([myvar], [$1], [
4345  AC_SUBST(m4_toupper(myvar)_PCLIBS)
4346  AC_SUBST(m4_toupper(myvar)_LIBS)
4347  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
4348])
4349
4350]) # AC_COIN_CHECK_PACKAGE_LAPACK
Note: See TracBrowser for help on using the repository browser.