source: trunk/coin.m4 @ 2800

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

move project versioning stuff into extra macro

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