source: trunk/coin.m4 @ 2238

Last change on this file since 2238 was 2238, checked in by stefan, 9 years ago

explicitly disable optimization in debug mode, since MPI compiler wrapper seem to need it

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