source: stable/0.7/coin.m4 @ 2287

Last change on this file since 2287 was 2287, checked in by stefan, 10 years ago

sync with trunk rev2286

  • Property svn:keywords set to Author Date Id Revision
File size: 143.1 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 2287 2011-06-15 12:07:45Z 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  AC_MSG_NOTICE([In case of trouble, first consult the troubleshooting page at https://projects.coin-or.org/BuildTools/wiki/user-troubleshooting])
2037  if test x$coin_projectdir = xyes; then
2038    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
2039  else
2040    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
2041  fi
2042else
2043  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
2044fi
2045
2046]) #AC_COIN_FINALIZE
2047
2048###########################################################################
2049#                             COIN_VPATH_LINK                             #
2050###########################################################################
2051
2052# This macro queues source files that need to be available in the build
2053# directory. In a VPATH configuration, the files will be made available by
2054# symbolic link or copy (when the platform does not support links). The list
2055# is processed by COIN_FINALIZE. The parameter is a whitespace-separated
2056# list of files.
2057
2058AC_DEFUN([AC_COIN_VPATH_LINK],
2059[
2060AC_REQUIRE([AC_COIN_CHECK_VPATH])
2061# Allow for newlines in the parameter
2062if test $coin_vpath_config = yes; then
2063  cvl_tmp="$1"
2064  for file in $cvl_tmp ; do
2065    coin_vpath_link_files="$coin_vpath_link_files $file"
2066  done
2067fi
2068]) #AC_COIN_VPATH_LINK
2069
2070###########################################################################
2071#                       COIN_ENABLE_GNU_PACKAGES                          #
2072###########################################################################
2073
2074# This macro defined the --enable-gnu-packages flag.  This can be used
2075# to check if a user wants to compile GNU packges (such as readline or
2076# zlib) into the executable.  By default, GNU packages are disabled.
2077# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
2078
2079AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
2080[AC_ARG_ENABLE([gnu-packages],
2081               [AC_HELP_STRING([--enable-gnu-packages],
2082                               [compile with GNU packages (disabled by default)])],
2083               [coin_enable_gnu=$enableval],
2084               [coin_enable_gnu=no])
2085]) # AC_COIN_ENABLE_GNU_PACKAGES
2086
2087#######################################################################
2088#                           COIN_CHECK_LIBM                           #
2089#######################################################################
2090
2091# For a (space separated) list of arguments X, this macro adds the flags
2092# for linking against the math library to a X_LIBS and X_PCLIBS.
2093
2094AC_DEFUN([AC_COIN_CHECK_LIBM],
2095[AC_BEFORE([AC_COIN_PROG_CC],[$0])
2096
2097case "$CC" in
2098  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2099    ;;
2100  *)
2101    coin_foreach_w([myvar], [$1], [
2102      m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"
2103      m4_toupper(myvar)_PCLIBS="-lm $m4_toupper(myvar)_PCLIBS"
2104      m4_toupper(myvar)_LIBS_INSTALLED="-lm $m4_toupper(myvar)_LIBS_INSTALLED"
2105    ])
2106  ;;
2107esac
2108
2109]) # AC_COIN_CHECK_LIBM
2110
2111###########################################################################
2112#                           COIN_CHECK_GNU_ZLIB                           #
2113###########################################################################
2114
2115# This macro checks for the libz library.  If found, it sets the automake
2116# conditional COIN_HAS_ZLIB and defines the C preprocessor variable
2117# COIN_HAS_ZLIB.  Further, for a (space separated) list of arguments X,
2118# it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2119
2120AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2121[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2122AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2123AC_BEFORE([AC_COIN_PROG_CC],[$0])
2124AC_BEFORE([AC_COIN_PROG_F77],[$0])
2125AC_BEFORE([$0],[AC_COIN_FINALIZE])
2126
2127coin_has_zlib=no
2128if test $coin_enable_gnu = yes; then
2129  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2130
2131  if test $coin_has_zlib = yes; then
2132    AC_CHECK_LIB([z],[gzopen],
2133                 [coin_foreach_w([myvar], [$1], [
2134                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
2135                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
2136                    m4_toupper(myvar)_LIBS_INSTALLED="-lz $m4_toupper(myvar)_LIBS_INSTALLED"
2137                  ])
2138                 :],
2139                 [coin_has_zlib=no])
2140  fi
2141
2142  if test $coin_has_zlib = yes; then
2143    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2144  fi
2145fi
2146
2147AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2148]) # AC_COIN_CHECK_GNU_ZLIB
2149
2150
2151###########################################################################
2152#                          COIN_CHECK_GNU_BZLIB                           #
2153###########################################################################
2154
2155# This macro checks for the libbz2 library.  If found, it defines the C
2156# preprocessor variable COIN_HAS_BZLIB.  Further, for a (space separated) list
2157# of arguments X, it adds the linker flag to the variables X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2158
2159AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2160[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2161AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2162AC_BEFORE([AC_COIN_PROG_CC],[$0])
2163AC_BEFORE([AC_COIN_PROG_F77],[$0])
2164AC_BEFORE([$0],[AC_COIN_FINALIZE])
2165
2166coin_has_bzlib=no
2167if test $coin_enable_gnu = yes; then
2168  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2169
2170  if test $coin_has_bzlib = yes; then
2171    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2172                 [coin_foreach_w([myvar], [$1], [
2173                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
2174                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
2175                    m4_toupper(myvar)_LIBS_INSTALLED="-lbz2 $m4_toupper(myvar)_LIBS_INSTALLED"
2176                  ])
2177                 :],
2178                 [coin_has_bzlib=no])
2179  fi
2180
2181  if test $coin_has_bzlib = yes; then
2182    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2183  fi
2184fi
2185]) # AC_COIN_CHECK_GNU_BZLIB
2186
2187
2188###########################################################################
2189#                         COIN_CHECK_GNU_READLINE                         #
2190###########################################################################
2191
2192# This macro checks for GNU's readline.  It verifies that the header
2193# readline/readline.h is available, and that the -lreadline library
2194# contains "readline".  It is assumed that #include <stdio.h> is included
2195# in the source file before the #include<readline/readline.h>
2196# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
2197# Further, for a (space separated) list of arguments X, it adds the
2198# linker flag to the variable X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
2199
2200AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2201[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2202AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2203AC_BEFORE([AC_COIN_PROG_CC],[$0])
2204AC_BEFORE([AC_COIN_PROG_F77],[$0])
2205AC_BEFORE([$0],[AC_COIN_FINALIZE])
2206
2207coin_has_readline=no
2208if test $coin_enable_gnu = yes; then
2209  AC_COIN_CHECK_HEADER([readline/readline.h],
2210                       [coin_has_readline=yes],[],
2211                       [#include <stdio.h>])
2212
2213  coin_save_LIBS="$LIBS"
2214  LIBS=
2215  # First we check if tputs and friends are available
2216  if test $coin_has_readline = yes; then
2217    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2218                   [coin_has_readline=no])
2219  fi
2220
2221  # Now we check for readline
2222  if test $coin_has_readline = yes; then
2223    AC_CHECK_LIB([readline],[readline],
2224                 [coin_foreach_w([myvar], [$1], [
2225                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
2226                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
2227                    m4_toupper(myvar)_LIBS_INSTALLED="-lreadline $LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
2228                  ])
2229                 :],
2230                 [coin_has_readline=no])
2231  fi
2232
2233  if test $coin_has_readline = yes; then
2234    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2235  fi
2236
2237  LIBS="$coin_save_LIBS"
2238fi
2239]) # AC_COIN_CHECK_GNU_READLINE
2240
2241###########################################################################
2242#                             COIN_DATA_PATH                              #
2243###########################################################################
2244
2245# This macro defines a preprocessor macro with the absolute path to a
2246# subdirectory of Data.  The argument of this macro is the name of the
2247# subdirectory (in correct case), and the name of the macro is
2248# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2249# the directory.  The path ends with a separator ("/" for linux and
2250# '\\' for Windows).  The default value for this path can be
2251# overwritten with the input variable with the same name
2252# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2253# $srcdir/../Data subdirectory.
2254
2255AC_DEFUN([AC_COIN_DATA_PATH],
2256[AC_MSG_CHECKING([absolute path to data directory $1])
2257
2258AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2259
2260if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2261  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2262fi
2263
2264# Under Cygwin, use Windows path.  Add separator
2265case $build in
2266  *-cygwin*)
2267    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2268    ;;
2269  *)
2270    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2271    ;;
2272esac
2273
2274if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2275  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2276            [Define to absolute path for Data subdirectory $1])
2277  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2278else
2279  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2280fi
2281]) # AC_COIN_DATA_PATH
2282
2283###########################################################################
2284#                       COIN_LINK_FROM_FILELIST                           #
2285###########################################################################
2286
2287# This macro creates links (or copies, if necessary) to files listed
2288# as content in a text file (second argument) into a target directory
2289# (first argument), which is created if it doesn't exist yet.  If s link
2290# already exists, nothing happens.
2291
2292AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
2293[cmd="$3"
2294if test -e $srcdir/$2 ; then
2295  my_target_dir="$1"
2296  my_link_files=`cat $srcdir/$2`
2297  my_dirname=`AS_DIRNAME($2)`
2298#  if test -e $my_target_dir; then : ; else
2299#    AS_MKDIR_P($my_target_dir)
2300#  fi
2301  for i in $my_link_files; do
2302    #rm -rf $my_target_dir/$i
2303    if test -e $my_target_dir/$i; then : ; else
2304      dirn2=`AS_DIRNAME($my_target_dir/$i)`
2305      if test -e $dirn2; then : ; else
2306        AS_MKDIR_P($dirn2)
2307      fi
2308      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
2309    fi
2310  done
2311else
2312  AC_MSG_WARN([File list file $2 missing!])
2313fi
2314])
2315
2316AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
2317[
2318AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2319echo Creating links in $1 ...
2320AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
2321])
2322
2323###########################################################################
2324#                       COIN_COPY_FROM_FILELIST                           #
2325###########################################################################
2326
2327# Like COIN_LINK_FROM_FILELIST, but copies the files.
2328
2329AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
2330[
2331echo Creating copies in $1 ...
2332AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
2333])
2334
2335###########################################################################
2336#                          COIN_EXAMPLE_FILES                             #
2337###########################################################################
2338
2339# This macro determines the names of the example files (using the
2340# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2341# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2342# creates soft links to the example files.
2343
2344AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2345[AC_REQUIRE([AC_COIN_CHECK_VPATH])
2346AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
2347AC_REQUIRE([AC_PROG_LN_S])
2348
2349files=`cd $srcdir; ls $1`
2350# We need to do the following loop to make sure that are no newlines
2351# in the variable
2352for file in $files; do
2353  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2354done
2355if test $coin_vpath_config = yes; then
2356  lnkcmd=
2357  if test "$enable_doscompile" != no; then
2358    lnkcmd=cp
2359  fi
2360  case "$CC" in
2361    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2362      lnkcmd=cp ;;
2363  esac
2364  if test "x$lnkcmd" = xcp; then
2365    AC_MSG_NOTICE([Copying example files ($1)])
2366  else
2367    AC_MSG_NOTICE([Creating links to the example files ($1)])
2368    lnkcmd="$LN_S"
2369  fi
2370  for file in $EXAMPLE_FILES; do
2371    rm -f $file
2372    $lnkcmd $srcdir/$file $file
2373  done
2374  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2375else
2376  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2377fi
2378
2379# In case there are compressed files, we create a variable with the
2380# uncompressed names
2381EXAMPLE_UNCOMPRESSED_FILES=
2382for file in $EXAMPLE_FILES; do
2383  case $file in
2384    *.gz)
2385      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2386      ;;
2387  esac
2388done
2389
2390AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2391AC_SUBST(EXAMPLE_FILES)
2392AC_SUBST(EXAMPLE_CLEAN_FILES)
2393]) #AC_COIN_EXAMPLE_FILES
2394
2395###########################################################################
2396#                      COIN_CHECK_USER_LIBRARY                            #
2397###########################################################################
2398# This macro sets up usage of a user library with header files. The assumption
2399# is that the header file(s) and library do not reside in standard system
2400# directories, hence both the include directory and link flags must be
2401# specified. There are two mandatory arguments and two optional arguments.
2402#
2403# The first argument (mandatory) should be a name (LibraryName) for the
2404# library.  The second argument (mandatory) should be an abbreviation in
2405# upper case letters (LBRY) for the library. Ultimately, the macro will
2406# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2407# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2408# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2409# directory containing include files for the library. LBRYLIB should specify
2410# the flags necessary to link to the library. A variable coin_has_lbry will
2411# be set to true or false, as appropriate. A variable lbry_libcheck will be
2412# be set to yes or no; no indicates link checks should not be attempted.
2413#
2414# The macro defines three configure arguments, --with-libraryname-incdir,
2415# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2416# LibraryName to lower case.
2417#
2418# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2419# part of the configure command using --with-libraryname-incdir and
2420# --with-libraryname-lib, respectively. Command line arguments override
2421# environment variables.
2422#
2423# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2424# macro will check for the presence of the file. If a fourth argument is given,
2425# it should specify a function name, `fname'.  The macro will attempt to link a
2426# trivial program containing a parameterless call to the function, `fname()',
2427# using the LBRYLIB flags. The link check uses C as the language; this has been
2428# adequate to date but has limitations. It is possible to disable the link
2429# check by specifying --disable-libraryname-libcheck. This is a workaround for
2430# instances where the link check does not work properly, for whatever reason.
2431# If you're trying to link to a Fortran library, consider using F77_FUNC or
2432# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2433# library, you're on your own unless the library declares some function with
2434# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2435# name.
2436# A fifth argument can be specified to include linker flags that may be required
2437# to sucessfully perform the linking check.
2438#
2439# An optional sixth argument can be given to specify a list of targets.
2440# For each target X, the variables X_LIBS and X_PCLIBS will be extended by $LBRYLIB,
2441# if the library has been found and seems to work.
2442
2443AC_DEFUN([AC_COIN_CHECK_USER_LIBRARY],
2444[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2445  AC_MSG_CHECKING(if user provides library for $1)
2446
2447# Check for header file directory
2448
2449  AC_ARG_WITH(m4_tolower($1)-incdir,
2450      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2451                     [specify the header file directory for library $1]),
2452      [$2INCDIR=`cd $withval; pwd`])
2453
2454# Check for library directory
2455
2456  AC_ARG_WITH(m4_tolower($1)-lib,
2457      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2458                     [specify the flags used to link with the library $1]),
2459      [$2LIB=$withval])
2460
2461# Switch to disable library check if requested
2462
2463  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2464      AS_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2465                     [use disable-m4_tolower($1)-libcheck to skip the link
2466                      check at configuration time]),
2467      [m4_tolower($1)_libcheck=$enableval],
2468      [m4_tolower($1)_libcheck=yes])
2469
2470# At this point, if we're going to use the library, both LBRYINCDIR and
2471# LBRYLIB must be defined and not empty.
2472
2473  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2474    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2475      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.])
2476    fi
2477    m4_tolower(coin_has_$2)=true
2478    AC_MSG_RESULT(yes)
2479  else
2480    m4_tolower(coin_has_$2)=false
2481    AC_MSG_RESULT(no)
2482  fi
2483
2484# If we have instructions for use, consider header and link checks.
2485
2486  if test $m4_tolower(coin_has_$2) = true; then
2487
2488# If argument 3 (file) is given, check for the file. Typically this will be a
2489# header file, but that's not assumed.
2490
2491    m4_ifval([$3],
2492        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2493             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2494
2495# Now see if we can link the function. There are arguments for and against
2496# assuming argument 3 is a header file declaring the function. A correct
2497# function declaration is the main argument in favour. Having to cope with
2498# possible dependencies or other oddities are the main arguments against.
2499# Force the use of C as the best single choice amongst C++, C, and Fortran.
2500# Obviously, this has limits.
2501
2502    m4_ifvaln([$4],
2503        [if test x"$m4_tolower($1)_libcheck" != xno; then
2504           coin_save_LIBS="$LIBS"
2505           LIBS="$$2LIB $5"
2506           coin_$2_link=no
2507           AC_LANG_PUSH(C)
2508           for fnm in $4 ; do
2509             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2510             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2511                 [AC_MSG_RESULT(yes)
2512                  coin_$2_link=yes
2513                  break],
2514                 [AC_MSG_RESULT(no)])
2515           done
2516           AC_LANG_POP(C)
2517           LIBS="$coin_save_LIBS"
2518           if test x"$coin_$2_link" != xyes ; then
2519             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2520           fi
2521         fi])
2522
2523# If we make it this far, we've verified the file and linked the function. Add
2524# the necessary link flags to $6_{PC}LIBS and define the preprocessor symbol
2525# COIN_HAS_LBRY.
2526
2527    coin_foreach_w([myvar], [$6], [
2528      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
2529      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
2530      m4_toupper(myvar)_LIBS_INSTALLED="$$2LIB $m4_toupper(myvar)_LIBS_INSTALLED"
2531    ])
2532   
2533    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2534  fi
2535
2536# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2537# automake conditional. These actions must occur unconditionally.
2538
2539  AC_SUBST($2INCDIR)
2540  AC_SUBST($2LIB)
2541  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2542]) #AC_COIN_CHECK_USER_LIBRARY
2543
2544###########################################################################
2545#                            COIN_TRY_FLINK                               #
2546###########################################################################
2547
2548# Auxilliary macro to test if a Fortran function name can be linked,
2549# given the current settings of LIBS.  We determine from the context, what
2550# the currently active programming language is, and cast the name accordingly.
2551# The first argument is the name of the function/subroutine, in small letters,
2552# the second argument are the actions taken when the test works, and the
2553# third argument are the actions taken if the test fails.
2554
2555AC_DEFUN([AC_COIN_TRY_FLINK],
2556[case $ac_ext in
2557  f)
2558    AC_TRY_LINK(,[      call $1],[$2],[$3])
2559    ;;
2560  c)
2561    AC_F77_FUNC($1,cfunc$1)
2562    if test x"$coin_need_flibs" = xyes; then
2563      flink_try=no;
2564    else
2565      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2566                  [flink_try=yes],[flink_try=no])
2567    fi
2568    if test $flink_try = yes; then
2569      $2
2570    else
2571      if test x"$FLIBS" != x; then
2572        flink_save_libs="$LIBS"
2573        LIBS="$LIBS $FLIBS"
2574        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2575                    [LIBS="$flink_save_libs"
2576                     coin_need_flibs=yes
2577                     $2
2578                    ],
2579                    [LIBS="$flink_save_libs"
2580                     $3])
2581      else
2582        $3
2583      fi
2584    fi
2585    ;;
2586  cc|cpp)
2587    AC_F77_FUNC($1,cfunc$1)
2588    if test x"$coin_need_flibs" = xyes; then
2589      flink_try=no;
2590    else
2591      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2592                  [flink_try=yes],[flink_try=no])
2593    fi
2594    if test $flink_try = yes; then
2595      $2
2596    else
2597      if test x"$FLIBS" != x; then
2598        flink_save_libs="$LIBS"
2599        LIBS="$LIBS $FLIBS"
2600        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2601                    [LIBS="$flink_save_libs"
2602                     coin_need_flibs=yes
2603                     $2
2604                    ],
2605                    [LIBS="$flink_save_libs"
2606                     $3])
2607      else
2608        $3
2609      fi
2610    fi
2611    ;;
2612esac
2613]) # AC_COIN_TRY_FLINK
2614
2615###########################################################################
2616#                           COIN_DOXYGEN                                  #
2617###########################################################################
2618#
2619# This macro determines the configuration information for doxygen, the tool
2620# used to generate online documentation of COIN code. It takes one parameter,
2621# a list of projects (mixed-case, to match the directory names) that should
2622# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
2623#
2624# This macro will define the following variables:
2625#  coin_have_doxygen    Yes if doxygen is found, no otherwise
2626#  coin_doxy_usedot     Defaults to `yes'; --with-dot will still check to see
2627#                       if dot is available
2628#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
2629#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
2630#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
2631#                       doxygen documentation
2632#  coin_doxy_excludes   Directories to exclude from doxygen processing
2633
2634AC_DEFUN([AC_COIN_DOXYGEN],
2635[
2636
2637AC_MSG_NOTICE([configuring doxygen documentation options])
2638
2639# Check to see if doxygen is available.
2640
2641AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
2642
2643# Look for the dot tool from the graphviz package, unless the user has
2644# disabled it.
2645
2646AC_ARG_WITH([dot],
2647  AS_HELP_STRING([--with-dot],
2648                 [use dot (from graphviz) when creating documentation with
2649                  doxygen if available; --without-dot to disable]),
2650  [],[withval=yes])
2651if test x"$withval" = xno ; then
2652  coin_doxy_usedot=NO
2653  AC_MSG_CHECKING([for dot ])
2654  AC_MSG_RESULT([disabled])
2655else
2656  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
2657fi
2658
2659# Generate a tag file name and a log file name
2660
2661AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
2662AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
2663
2664# Process the list of project names and massage them into possible doxygen
2665# doc'n directories. Prefer 1) classic external, source processed using
2666# a project-specific doxygen.conf, we use the tag file; 2) classic
2667# external, source processed using package doxygen.conf; 3) installed
2668# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
2669# configured, which we can't know unless this is the package base configure,
2670# since coin_subdirs is only set there. Hence it's sufficient to check for
2671# membership. If we use a tag file from a classic external, exclude the
2672# source from doxygen processing when doxygen runs in the base directory.
2673
2674coin_doxy_tagfiles=
2675coin_doxy_excludes=
2676tmp="$1"
2677for proj in $tmp ; do
2678  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
2679  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
2680  doxytag=${lc_proj}_doxy.tag
2681  doxyfound=no
2682  for chkProj in $coin_subdirs ; do
2683    if test "$chkProj" = "$proj" ; then
2684      # proj will be configured, hence doxydoc present in build tree
2685      doxysrcdir="${srcdir}/${proj}"
2686      # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
2687      if test -d "$doxysrcdir" ; then
2688        # with a doxydoc directory?
2689        doxydir="$doxysrcdir/doxydoc"
2690        # AC_MSG_NOTICE([Considering $doxydir (base)])
2691        # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
2692        if test -d "$doxydir" ; then
2693          # use tag file; don't process source
2694          eval doxydir="`pwd`/${proj}/doxydoc"
2695          coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
2696          AC_MSG_RESULT([$doxydir (tag)])
2697          coin_doxy_excludes="$coin_doxy_excludes */${proj}"
2698        else
2699          # will process the source -- nothing further to be done here
2700          AC_MSG_RESULT([$doxysrcdir (src)])
2701        fi
2702        doxyfound=yes
2703      fi
2704    fi
2705  done
2706  # Not built, fall back to installed tag file
2707  if test $doxyfound = no ; then
2708    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
2709    # AC_MSG_NOTICE([Considering $doxydir (install)])
2710    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
2711    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
2712    AC_MSG_RESULT([$doxydir (tag)])
2713  fi
2714done
2715AC_SUBST([coin_doxy_tagfiles])
2716AC_SUBST([coin_doxy_excludes])
2717
2718]) # AC_COIN_DOXYGEN
2719
2720
2721###########################################################################
2722#                           COIN_HAS_PKGCONFIG                            #
2723###########################################################################
2724
2725# This macro checks whether a pkg-config tool with a minimal version number
2726# is available.  If so, then the variable PKGCONFIG is set to its path.
2727# If not, PKGCONFIG is set to "".  The minimal version number can be given
2728# as first parameter, by default it is 0.16.0, since COIN-OR .pc files now
2729# include an URL field, which breaks pkg-config version <= 0.15.
2730# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
2731# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
2732# AC_SUBST'ed.  Finally, if this setup belongs to a project directory, then
2733# the search path for .pc files is assembled from the value of
2734# $PKG_CONFIG_PATH, the values of --prefix, --coin-instdir, and the directories
2735# named in a file ../coin_subdirs.txt or ../../coin_subdirs.txt in a variable
2736# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed. For a path xxx given in the
2737# coin-subdirs.txt, also the directory xxx/pkgconfig is added, if existing.
2738
2739AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
2740[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
2741
2742AC_ARG_ENABLE([pkg-config],
2743  [AC_HELP_STRING([--enable-pkg-config],[use pkg-config if available (default is yes)])],
2744  [use_pkgconfig="$enableval"],
2745  [use_pkgconfig=yes])
2746
2747if test $use_pkgconfig = yes ; then
2748  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
2749    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
2750  fi
2751  if test -n "$PKG_CONFIG"; then
2752    _pkg_min_version=m4_default([$1], [0.16.0])
2753    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
2754    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
2755      AC_MSG_RESULT([yes])
2756    else
2757      AC_MSG_RESULT([no])
2758      PKG_CONFIG=""
2759    fi
2760  fi
2761
2762  # check if pkg-config supports the short-errors flag
2763  if test -n "$PKG_CONFIG" && \
2764    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
2765    pkg_short_errors=" --short-errors "
2766  else
2767    pkg_short_errors=""
2768  fi
2769fi
2770
2771AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
2772AC_SUBST(PKG_CONFIG)
2773
2774# assemble pkg-config search path for installed projects
2775COIN_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
2776
2777# 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
2778# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
2779# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
2780if test "x${prefix}" = xNONE ; then
2781  COIN_PKG_CONFIG_PATH="${ac_default_prefix}/lib/pkgconfig:${ac_default_prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2782else
2783  COIN_PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2784fi
2785
2786AC_ARG_WITH([coin-instdir],
2787  AC_HELP_STRING([--with-coin-instdir],
2788                 [prefix of installation directory for precompiled COIN packages]),
2789  [if test -d "$withval"; then : ; else
2790     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
2791   fi
2792   COIN_PKG_CONFIG_PATH="$withval/lib/pkgconfig:$withval/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
2793  ],[])
2794
2795AC_SUBST(COIN_PKG_CONFIG_PATH)
2796
2797# assemble additional pkg-config search paths for uninstalled projects
2798if test x$coin_projectdir = xyes ; then
2799  # if we are in a project setup, then in a classic setup, we want to find uninstalled projects
2800  # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
2801  # unfortunately, if the user set prefix, then we do not know where the project base directory is located
2802  # 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)
2803  COIN_PKG_CONFIG_PATH_UNINSTALLED=
2804  if test -e ../coin_subdirs.txt ; then
2805    for i in `cat ../coin_subdirs.txt` ; do
2806      if test -d ../$i ; then
2807        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2808      fi
2809      if test -d ../$i/pkgconfig ; then
2810        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2811      fi
2812    done
2813  fi
2814
2815  if test -e ../../coin_subdirs.txt ; then
2816    for i in `cat ../../coin_subdirs.txt` ; do
2817      if test -d ../../$i ; then
2818        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2819      fi
2820      if test -d ../../$i/pkgconfig ; then
2821        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i/pkgconfig; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
2822      fi
2823    done
2824  fi
2825
2826  AC_SUBST(COIN_PKG_CONFIG_PATH_UNINSTALLED)
2827fi
2828
2829if test -n "$PKG_CONFIG" && test x$coin_cc_is_cl = xtrue; then
2830  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.])
2831fi
2832
2833])
2834
2835###########################################################################
2836#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
2837###########################################################################
2838
2839# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2840#
2841# Check to see whether a particular project exists.  Similar
2842# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
2843#
2844AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
2845[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2846if test -n "$PKG_CONFIG" ; then
2847  if $PKG_CONFIG --exists "m4_tolower($1)"; then
2848    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
2849    m4_ifval([$2], [$2], [:])
2850  else
2851    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
2852    $3
2853  fi
2854else
2855  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
2856fi
2857])
2858
2859###########################################################################
2860#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
2861###########################################################################
2862
2863# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2864#
2865# Check to see whether a particular set of packages exists.
2866# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
2867#
2868AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
2869[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2870if test -n "$PKG_CONFIG" ; then
2871  if $PKG_CONFIG --exists "$2"; then
2872    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`"
2873    $3
2874  else
2875    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
2876    $4
2877  fi
2878else
2879  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
2880fi
2881])
2882
2883###########################################################################
2884#                           COIN_PKG_HAS_MODULE                           #
2885###########################################################################
2886
2887# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2888#
2889# Checks whether pkg-config files for a given set of packages is available.
2890# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
2891# If not, then ACTION-IF-NOT-FOUND is executed.
2892# A reason for not finding a package is stored in MODULE_PKG_ERRORS
2893#
2894# --------------------------------------------------------------
2895AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
2896[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
2897
2898AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
2899  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
2900    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
2901        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
2902        # but only do this if is not trivial
2903    if test "$CYGPATH_W" != "echo" ; then
2904      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
2905      [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
2906    fi
2907    m4_toupper($1)[]_CFLAGS="$cflags"
2908    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
2909    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
2910    $3
2911  ],
2912  [ $4 ])
2913
2914])# PKG_CHECK_MODULES
2915
2916###########################################################################
2917#                           COIN_MAIN_PACKAGEDIR                          #
2918###########################################################################
2919
2920# This macro substitutes COIN_MAIN_SUBDIR.
2921# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
2922# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
2923# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
2924#   If so, include this directory into the list of directories where configure and make recourse into.
2925# tolower(coin_has_$1) is set to "no" if the project source is not available or will not be compiled.
2926# Otherwise, it will be set to "yes".
2927
2928AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],[
2929AC_MSG_CHECKING([whether source of project $1 is available and should be compiled])
2930
2931m4_tolower(coin_has_$1)=notGiven
2932coin_reason=
2933
2934# check if user wants to skip project in any case
2935AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
2936if test x"$COIN_SKIP_PROJECTS" != x; then
2937  for dir in $COIN_SKIP_PROJECTS; do
2938    if test $dir = "$1"; then
2939      m4_tolower(coin_has_$1)="no"
2940      coin_reason="$1 has been specified in COIN_SKIP_PROJECTS"
2941    fi
2942    m4_ifval($2,[
2943    if test $dir = "$2/$1"; then
2944      m4_tolower(coin_has_$1)="no"
2945      coin_reason="$2/$1 has been specified in COIN_SKIP_PROJECTS"
2946    fi])
2947  done
2948fi
2949
2950if test "$m4_tolower(coin_has_$1)" != no; then
2951  AC_ARG_WITH([m4_tolower($1)],,
2952    [if test "$withval" = no ; then
2953       m4_tolower(coin_has_$1)="no"
2954       coin_reason="--without-m4_tolower($1) has been specified"
2955     fi
2956    ])
2957fi
2958
2959if test "$m4_tolower(coin_has_$1)" != no; then
2960  AC_ARG_WITH([m4_tolower($1)-lib],
2961    AC_HELP_STRING([--with-m4_tolower($1)-lib],
2962                   [linker flags for using project $1]),
2963    [if test "$withval" = no ; then
2964       m4_tolower(coin_has_$1)="no"
2965       coin_reason="--without-m4_tolower($1)-lib has been specified"
2966     else
2967       m4_tolower(coin_has_$1)="no"
2968       coin_reason="--with-m4_tolower($1)-lib has been specified"
2969     fi],
2970    [])
2971fi
2972
2973if test "$m4_tolower(coin_has_$1)" != no; then
2974  AC_ARG_WITH([m4_tolower($1)-incdir],
2975    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
2976                   [directory with header files for using project $1]),
2977    [if test "$withval" = no ; then
2978       m4_tolower(coin_has_$1)="no"
2979       coin_reason="--without-m4_tolower($1)-incdir has been specified"
2980     else
2981       m4_tolower(coin_has_$1)="no"
2982       coin_reason="--with-m4_tolower($1)-incdir has been specified"
2983     fi],
2984    [])
2985fi
2986
2987if test "$m4_tolower(coin_has_$1)" != no; then
2988  AC_ARG_WITH([m4_tolower($1)-datadir],
2989    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
2990                   [directory with data files for using project $1]),
2991    [if test "$withval" = no ; then
2992       m4_tolower(coin_has_$1)="no"
2993       coin_reason="--without-m4_tolower($1)-datadir has been specified"
2994     else
2995       m4_tolower(coin_has_$1)="no"
2996       coin_reason="--with-m4_tolower($1)-datadir has been specified"
2997     fi],
2998    [])
2999fi
3000
3001m4_if(m4_tolower($1), blas, [
3002  if test $m4_tolower(coin_has_$1) != no; then
3003    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
3004    AC_ARG_WITH([blas],
3005      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
3006        [if test x"$withval" = "xno" ; then
3007           coin_has_blas="no"
3008           coin_reason="--without-blas has been specified"
3009         elif test x"$withval" != "xBUILD" ; then
3010           coin_has_blas="no"
3011           coin_reason="--with-blas has been specified"
3012         fi],
3013        [])
3014  fi
3015])
3016
3017m4_if(m4_tolower($1), lapack, [
3018  if test $m4_tolower(coin_has_$1) != skipping; then
3019    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
3020    AC_ARG_WITH([lapack],
3021      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
3022        [if test x"$withval" = "xno" ; then
3023           coin_has_lapack="no"
3024           coin_reason="--without-lapack has been specified"
3025         elif test x"$withval" != "xBUILD" ; then
3026           coin_has_lapack="no"
3027           coin_reason="--with-lapack has been specified"
3028         fi],
3029        [])
3030  fi
3031])
3032
3033# check if project is available in present directory
3034if test "$m4_tolower(coin_has_$1)" = notGiven; then
3035  m4_tolower(coin_has_$1)=no
3036  if test -d $srcdir/m4_ifval($2,[$2/],)$1; then
3037    coin_reason="source in m4_ifval($2,[$2/],)$1"
3038    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
3039    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
3040    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
3041    m4_ifvaln([$3],
3042      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
3043         if test -r $i; then
3044           m4_tolower(coin_has_$1)="yes"
3045         else
3046           m4_tolower(coin_has_$1)="no"
3047           coin_reason="source file $i not available"
3048           break
3049         fi
3050       done],
3051      [ m4_tolower(coin_has_$1)="yes" ])
3052  fi
3053fi
3054
3055if test -z "$coin_reason" ; then
3056  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3057else
3058  AC_MSG_RESULT([$m4_tolower(coin_has_$1), $coin_reason])
3059fi
3060
3061if test "$m4_tolower(coin_has_$1)" = yes ; then
3062  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
3063    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
3064    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
3065  fi
3066fi
3067])
3068
3069###########################################################################
3070#                            COIN_CHECK_PACKAGE                           #
3071###########################################################################
3072
3073# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
3074# A package can consists of one or more COIN-OR or other projects.
3075# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, PACKAGE_DEPENDENCIES, and PACKAGE_DATA variables, referring to the compiler and linker
3076# flags to use when linking against this module, the libraries the package depends on, and the directories where the module data resists.
3077# The difference between PACKAGE_LIBS and PACKAGE_DEPENDENCIES is that PACKAGE_DEPENDENCIES does not contain arguments starting with '-',
3078# so it can be used to setup the _DEPENDENCIES variable in a Makefile.am.
3079# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
3080# Further, tolower(coin_has_$1) is set to "yes".
3081# If a list of build targets using this projects is given in the third argument,
3082# then the compiler and linker variables and .pc file setup variable corresponding to this build target
3083# are extended with the values for this package.
3084# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_DEPENDENCIES, X_PCLIBS, X_PCREQUIRES are setup,
3085# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
3086#
3087# The first argument should be the name (PACKAGE) of the package (in correct lower
3088# and upper case).
3089# The second argument should be a (space separated) list of projects which this
3090# package consists of. Optionally, required version numbers can be added.
3091# The optional third argument should be a (space separated) list of build targets
3092# which use this package, if available.
3093#
3094# It is also possible to specify a preinstalled version of this package
3095# or to specify only the linker and compiler flags and data directory.
3096#
3097# If the user did not specify --with-$1-... flags and pkg-config is not available,
3098# COIN_CHECK_PACKAGE_FALLBACK($1, $2, $3) is called.
3099
3100AC_DEFUN([AC_COIN_CHECK_PACKAGE],
3101[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3102AC_MSG_CHECKING([for COIN-OR package $1])
3103
3104m4_tolower(coin_has_$1)=notGiven
3105
3106# check if user wants to skip package in any case
3107if test x"$COIN_SKIP_PROJECTS" != x; then
3108  for dir in $COIN_SKIP_PROJECTS; do
3109    if test $dir = "$1"; then
3110      m4_tolower(coin_has_$1)=skipping
3111    fi
3112  done
3113fi
3114
3115if test "$m4_tolower(coin_has_$1)" != skipping; then
3116  AC_ARG_WITH([m4_tolower($1)],,
3117    [if test "$withval" = no ; then
3118       m4_tolower(coin_has_$1)=skipping
3119     fi
3120    ])
3121fi
3122
3123m4_toupper($1_LIBS)=
3124m4_toupper($1_CFLAGS)=
3125m4_toupper($1_DATA)=
3126m4_toupper($1_DEPENDENCIES)=
3127m4_toupper($1_PCLIBS)=
3128m4_toupper($1_PCREQUIRES)=
3129m4_toupper($1_DATA)=
3130AC_SUBST(m4_toupper($1_LIBS))
3131AC_SUBST(m4_toupper($1_CFLAGS))
3132AC_SUBST(m4_toupper($1_DATA))
3133AC_SUBST(m4_toupper($1_DEPENDENCIES))
3134AC_SUBST(m4_toupper($1_LIBS_INSTALLED))
3135AC_SUBST(m4_toupper($1_CFLAGS_INSTALLED))
3136AC_SUBST(m4_toupper($1_DATA_INSTALLED))
3137coin_foreach_w([myvar], [$3], [
3138  AC_SUBST(m4_toupper(myvar)_CFLAGS)
3139  AC_SUBST(m4_toupper(myvar)_LIBS)
3140  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3141  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
3142  AC_SUBST(m4_toupper(myvar)_DEPENDENCIES)
3143  AC_SUBST(m4_toupper(myvar)_CFLAGS_INSTALLED)
3144  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3145])
3146
3147#check if user provided LIBS, CFLAGS, or DATA for package or disables use of package
3148if test $m4_tolower(coin_has_$1) != skipping; then
3149  AC_ARG_WITH([m4_tolower($1)-lib],
3150    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3151                   [linker flags for using package $1]),
3152    [if test "$withval" = no ; then
3153       m4_tolower(coin_has_$1)=skipping
3154     else
3155       m4_tolower(coin_has_$1)=yes
3156       m4_toupper($1_LIBS)="$withval"
3157       m4_toupper($1_PCLIBS)="$withval"
3158       coin_foreach_w([myvar], [$3], [
3159         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
3160         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
3161       ])
3162       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3163       if test -z "$PKG_CONFIG" ; then
3164         m4_toupper($1_LIBS_INSTALLED)="$withval"
3165         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_LIBS_INSTALLED="$withval $m4_toupper(myvar)_LIBS_INSTALLED"])
3166       fi
3167     fi
3168    ],
3169    [])
3170fi
3171
3172if test $m4_tolower(coin_has_$1) != skipping; then
3173  AC_ARG_WITH([m4_tolower($1)-incdir],
3174    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3175                   [directory with header files for using package $1]),
3176    [if test "$withval" = no ; then
3177       m4_tolower(coin_has_$1)=skipping
3178     else
3179       m4_tolower(coin_has_$1)=yes
3180       m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
3181       coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="-I`${CYGPATH_W} $withval` $m4_toupper(myvar)_CFLAGS"])
3182       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3183       if test -z "$PKG_CONFIG" ; then
3184         m4_toupper($1_CFLAGS_INSTALLED)="$m4_toupper($1_CFLAGS)"
3185         coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1_CFLAGS) $m4_toupper(myvar)_CFLAGS_INSTALLED"])
3186       fi
3187     fi
3188    ],
3189    [])
3190fi
3191
3192if test $m4_tolower(coin_has_$1) != skipping; then
3193  AC_ARG_WITH([m4_tolower($1)-datadir],
3194    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3195                   [directory with data files for using package $1]),
3196    [if test "$withval" = no ; then
3197       m4_tolower(coin_has_$1)=skipping
3198     else
3199       m4_tolower(coin_has_$1)=yes
3200       m4_toupper($1_DATA)="$withval"
3201       # if project flags are given by user and we build without pkg-config, then we need to setup the _INSTALLED variables
3202       if test -z "$PKG_CONFIG" ; then
3203         m4_toupper($1_DATA_INSTALLED)="$withval"
3204       fi
3205     fi
3206    ],
3207    [])
3208fi
3209
3210if test $m4_tolower(coin_has_$1) = notGiven; then
3211  if test -n "$PKG_CONFIG" ; then
3212    # set search path for pkg-config
3213    # need to export variable to be sure that the following pkg-config gets these values
3214    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3215    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
3216    export PKG_CONFIG_PATH
3217   
3218    # let pkg-config do it's magic
3219    AC_COIN_PKG_HAS_MODULE([$1],[$2],
3220      [ m4_tolower(coin_has_$1)=yes
3221        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
3222
3223        # adjust linker flags for (i)cl compiler
3224        # 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)
3225        if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3226        then
3227          m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3228        fi
3229        m4_toupper($1_PCREQUIRES)="$2"
3230   
3231        # augment X_PCREQUIRES, X_CFLAGS, and X_LIBS for each build target X in $3
3232        coin_foreach_w([myvar], [$3], [
3233          m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3234          m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3235          m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3236        ])
3237      ],
3238      [ m4_tolower(coin_has_$1)=notGiven
3239        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
3240      ])
3241
3242    # reset PKG_CONFIG_PATH variable
3243    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3244    export PKG_CONFIG_PATH
3245
3246  else
3247    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
3248    AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
3249  fi
3250
3251else
3252  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3253fi
3254
3255if test $m4_tolower(coin_has_$1) != skipping &&
3256   test $m4_tolower(coin_has_$1) != notGiven ; then
3257  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3258
3259  AC_ARG_ENABLE([interpackage-dependencies],
3260    AC_HELP_STRING([--enable-interpackage-dependencies], [whether to deduce Makefile dependencies from package linker flags (default: yes)]),
3261    [], [enable_interpackage_dependencies=yes])
3262   
3263  if test $enable_interpackage_dependencies = yes ; then
3264     # construct dependencies variables from LIBS variables
3265     # we add an extra space in LIBS so we can substitute out everything starting with " -"
3266     # remove everything of the form -framework xxx as used on Mac and mklxxx as used on Windows
3267     # then remove everything of the form -xxx
3268     # also remove everything of the form `xxx`yyy (may have been added for cygwin/cl)
3269     m4_toupper($1)_DEPENDENCIES=`echo " $m4_toupper($1)_LIBS" | [sed -e 's/ mkl[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
3270     coin_foreach_w([myvar], [$3], [
3271       m4_toupper(myvar)_DEPENDENCIES=`echo " $m4_toupper(myvar)_LIBS " | [sed -e 's/ mkl[^ ]*//g' -e 's/ -framework  *[^ ]*//g' -e 's/ -[^ ]*//g' -e 's/\`[^\`]*\`[^ ]* //g']`
3272     ])
3273  fi
3274
3275  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
3276    if test -n "$m4_toupper($1)_CFLAGS" ; then
3277      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3278    fi
3279    if test -n "$m4_toupper($1)_LIBS" ; then
3280      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
3281    fi
3282    if test -n "$m4_toupper($1)_DEPENDENCIES" ; then
3283      AC_MSG_NOTICE([$1 DEPENDENCIES are $m4_toupper($1)_DEPENDENCIES])
3284    fi
3285    if test -n "$m4_toupper($1)_DATA" ; then
3286      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
3287    fi
3288    if test -n "$m4_toupper($1)_PCLIBS" ; then
3289      AC_MSG_NOTICE([$1 PCLIBS are $m4_toupper($1)_PCLIBS])
3290    fi
3291    if test -n "$m4_toupper($1)_PCREQUIRES" ; then
3292      AC_MSG_NOTICE([$1 PCREQUIRES are $m4_toupper($1)_PCREQUIRES])
3293    fi
3294    coin_foreach_w([myvar], [$3], [
3295      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
3296      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
3297      AC_MSG_NOTICE([myvar DEPENDENCIES are $m4_toupper(myvar)_DEPENDENCIES])
3298    ])
3299  fi
3300fi
3301
3302# Define the Makefile conditional
3303AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3304               [test $m4_tolower(coin_has_$1) != notGiven &&
3305                test $m4_tolower(coin_has_$1) != skipping])
3306
3307]) # AC_COIN_CHECK_PACKAGE
3308
3309###########################################################################
3310#                       COIN_CHECK_PACKAGE_FALLBACK                       #
3311###########################################################################
3312
3313# This macro is used by COIN_CHECK_PACKAGE, if it fails to find a package
3314# because pkg-config was disabled or is not available.
3315#
3316# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc
3317# file in the directories specified in $COIN_PKG_CONFIG_PATH_UNINSTALLED. The
3318# latter variable is setup by COIN_HAS_PKGCONFIG and consists of the content
3319# of the coin_subdirs.txt file which has been created by configure in the
3320# base directory.  The content of xxx-uninstalled.pc is parsed in order
3321# to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
3322# referring to the compiler and linker flags to use when linking against this
3323# package and the directory where the package data resists.  Further, for each
3324# build target X specified in the third argument, the variables X_CFLAGS and
3325# X_LIBS are extended with the compiler and linker flags of this package and
3326# the variables X_PCLIBS and X_PCREQUIRES are extended by the list of linker
3327# flags and dependent projects as needed to setup a .pc file.  The macros
3328# checks also dependencies of $2.  Note that the PACKAGE_DATA variable is
3329# set to the content of datadir of the first .pc file that is parsed.
3330# Finally, for each X in the third argument, also variables
3331# X_CFLAGS_INSTALLED and X_LIBS_INSTALLED are setup. They contain the compiler
3332# and linker flags for X when all projects have been installed. Their content
3333# is assembled from the .pc files that correspond to installed projects. I.e.,
3334# whenever a file proj-uninstalled.pc is parsed, then also a corresponding
3335# proj.pc file is parsed for compiler and linker flags, if available in the
3336# same directory.
3337# Similar, a variable PACKAGE_DATA_INSTALLED is setup to the content of datadir
3338# of the first .pc file that is parsed.
3339#
3340# If .pc files for all projects in $2 and their dependencies is found,
3341# tolower(coin_has_$1) is set to "yes".  Otherwise, if some dependency
3342# is not found, tolower(coin_has_$1) is set to "notGiven".  Further, a
3343# COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
3344#
3345# The first argument should be the name (PACKAGE) of the package (in correct
3346# lower and upper case).  The second argument should be the base names of the
3347# projects .pc file which define this package.  The optional third argument
3348# should be a (space separated) list of build targets which use this package,
3349# if available.
3350#
3351# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into
3352# $COIN_PKG_CONFIG_PATH_UNINSTALLED.  When the content of this variable was
3353# setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
3354
3355AC_DEFUN([AC_COIN_CHECK_PACKAGE_FALLBACK],
3356[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3357AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
3358
3359m4_tolower(coin_has_$1)=notGiven
3360m4_toupper($1_LIBS)=
3361m4_toupper($1_LIBS_INSTALLED)=
3362m4_toupper($1_CFLAGS)=
3363m4_toupper($1_CFLAGS_INSTALLED)=
3364m4_toupper($1_DATA)=
3365m4_toupper($1_DATA_INSTALLED)=
3366m4_toupper($1_PCLIBS)=
3367m4_toupper($1_PCREQUIRES)=
3368
3369# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x, != x)
3370projtoprocess="m4_bpatsubsts([$2], [<?>?!?=[    ]*[^    ]+])"
3371
3372# we first expand the list of projects to process by adding all dependencies just behind the project which depends on it
3373# further, we collect the list of corresponding .pc files, but do this in reverse order, because we need this order afterwards
3374# the latter we also do with .pc files corresponding to the installed projects, which will be needed to setup Makefiles for examples
3375# also, we setup the DATA variable
3376allproj=""
3377allpcfiles=""
3378allpcifiles=""
3379while test "x$projtoprocess" != x ; do
3380
3381  for proj in $projtoprocess ; do
3382    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
3383    pcfile=""
3384    save_IFS="$IFS"
3385    IFS=":"
3386    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
3387      # 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
3388      if test -r "$dir/${proj}-uninstalled.pc" ; then
3389        pcfile="$dir/$proj-uninstalled.pc"
3390        if test -r "$dir/${proj}.pc" ; then
3391          pcifile="$dir/${proj}.pc"
3392        else
3393          AC_MSG_WARN([Found $pcfile, but $dir/${proj}.pc is not available. This may break Makefile's of examples.])
3394          pcifile=
3395        fi
3396        break
3397      fi
3398    done
3399    IFS="$save_IFS"
3400
3401    if test "x$pcfile" != x ; then
3402      # read dependencies from $pcfile and filter it
3403      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\{0,1\}>\{0,1\}=[       ]\{0,\}[^       ]\{1,\}//g'`]
3404
3405      # add projrequires to the front of the list of projects that have to be processed next
3406      # at the same time, remove $proj from this list
3407      projtoprocess=[`echo $projtoprocess | sed -e "s/$proj/$projrequires/"`]
3408
3409      # read DATA from $pcfile, if _DATA is still empty
3410      if test "x$m4_toupper($1_DATA)" = x ; then
3411        projdatadir=
3412        [pcfilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcfile`]
3413        eval `sh -c "$pcfilemod"`
3414        m4_toupper($1_DATA)="$projdatadir"
3415      fi
3416
3417      allproj="$allproj $proj"
3418      allpcfiles="$pcfile:$allpcfiles"
3419
3420    else
3421      AC_MSG_RESULT([no, dependency $proj not available])
3422      allproj=fail
3423      break 2
3424    fi
3425   
3426    if test "x$pcifile" != x ; then
3427      allpcifiles="$pcifile:$allpcifiles"
3428     
3429      # read DATA_INSTALLED from $pcifile, if _DATA_INSTALLED is still empty
3430      if test "x$m4_toupper($1_DATA_INSTALLED)" = x ; then
3431        projdatadir=
3432        [pcifilemod=`sed -e '/[a-zA-Z]:/d' -e 's/datadir=\(.*\)/echo projdatadir=\\\\"\1\\\\"/g' $pcifile`]
3433        eval `sh -c "$pcifilemod"`
3434        if test "${CYGPATH_W}" != "echo"; then
3435          projdatadir="\`\$(CYGPATH_W) ${projdatadir} | sed -e 's/\\\\\\\\/\\\\\\\\\\\\\\\\/g'\`"
3436        fi
3437        m4_toupper($1_DATA_INSTALLED)="$projdatadir"
3438      fi
3439     
3440    fi
3441
3442    break
3443  done
3444
3445  # remove spaces on begin of $projtoprocess
3446  projtoprocess=`echo $projtoprocess | sed -e 's/^[ ]*//'`
3447
3448done
3449
3450if test "$allproj" != fail ; then
3451
3452  # now go through the list of .pc files and assemble compiler and linker flags
3453  # important is here to obey the reverse order that has been setup before,
3454  # since then libraries that are required by several others should be after these other libraries
3455  pcfilesprocessed=""
3456
3457  save_IFS="$IFS"
3458  IFS=":"
3459  for pcfile in $allpcfiles ; do
3460
3461    # if $pcfile has been processed already, skip this round
3462    if test "x$pcfilesprocessed" != x ; then
3463      for pcfiledone in $pcfilesprocessed ; do
3464        if test "$pcfiledone" = "$pcfile" ; then
3465          continue 2
3466        fi
3467      done
3468    fi
3469
3470    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3471    #   replace "Libs:" by "echo projlibs="
3472    #   replace "Cflags:" by "echo projcflags="
3473    #   remove every line starting with <some word>:
3474    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
3475
3476    # set projcflags and projlibs variables by running $pcfilemod
3477    # under mingw, the current IFS seem to make the : in the paths of the gfortran libs go away, so we temporarily set IFS back to its default
3478    projcflags=
3479    projlibs=
3480    IFS="$save_IFS"
3481    eval `sh -c "$pcfilemod"`
3482    IFS=":"
3483
3484    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3485    if test "${CYGPATH_W}" != "echo"; then
3486      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3487    fi
3488    m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
3489
3490    # set LIBS variable
3491    m4_toupper($1_LIBS)="$projlibs $m4_toupper($1_LIBS)"
3492
3493    # remember that we have processed $pcfile
3494    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3495
3496  done
3497  IFS="$save_IFS"
3498
3499
3500  # now go through the list of .pc files for installed projects and assemble compiler and linker flags
3501  # important is here again to obey the reverse order that has been setup before,
3502  # since then libraries that are required by several others should be after these other libraries
3503  pcfilesprocessed=""
3504
3505  save_IFS="$IFS"
3506  IFS=":"
3507  for pcfile in $allpcifiles ; do
3508
3509    # if $pcfile has been processed already, skip this round
3510    if test "x$pcfilesprocessed" != x ; then
3511      for pcfiledone in $pcfilesprocessed ; do
3512        if test "$pcfiledone" = "$pcfile" ; then
3513          continue 2
3514        fi
3515      done
3516    fi
3517
3518    # modify .pc file to a shell script that prints shell commands for setting the compiler and library flags:
3519    #   replace "Libs:" by "echo projlibs="
3520    #   replace "Cflags:" by "echo projcflags="
3521    #   remove every line starting with <some word>:
3522    [pcfilemod=`sed -e 's/Libs:\(.*\)$/echo projlibs=\\\\"\1\\\\"/g' -e 's/Cflags:\(.*\)/echo projcflags=\\\\"\1\\\\"/g' -e '/^[a-zA-Z]*:/d' $pcfile`]
3523
3524    # set projcflags and projlibs variables by running $pcfilemod
3525    # under mingw, the current IFS seem to make the : in the paths of the gfortran libs go away, so we temporarily set IFS back to its default
3526    projcflags=
3527    projlibs=
3528    IFS="$save_IFS"
3529    eval `sh -c "$pcfilemod"`
3530    IFS=":"
3531
3532    # add CYGPATH_W cludge into include flags and set CFLAGS variable
3533    if test "${CYGPATH_W}" != "echo"; then
3534      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3535    fi
3536    m4_toupper($1_CFLAGS_INSTALLED)="$projcflags $m4_toupper($1_CFLAGS_INSTALLED)"
3537
3538    # set LIBS variable
3539    m4_toupper($1_LIBS_INSTALLED)="$projlibs $m4_toupper($1_LIBS_INSTALLED)"
3540   
3541    # remember that we have processed $pcfile
3542    pcfilesprocessed="$pcfilesprocessed:$pcfile"
3543
3544  done
3545  IFS="$save_IFS"
3546
3547
3548  # finish up
3549  m4_tolower(coin_has_$1)=yes
3550  AC_MSG_RESULT([yes])
3551  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
3552
3553  # adjust linker flags for (i)cl compiler
3554  # 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),
3555  # for the LIBS_INSTALLED, we replace everything of the form "/somepath/" by "`$(CYGPATH_W) /somepath/`",
3556  #    everything of the form "-lname" by "libname.lib", and
3557  #    everything of the form "-Lpath" by "-libpath:`$(CYGPATH_W) path`
3558  if test x$coin_cxx_is_cl = xtrue || test x$coin_cc_is_cl = xtrue ;
3559  then
3560    m4_toupper($1_LIBS)=`echo " $m4_toupper($1_LIBS) " | [sed -e 's/ \(\/[^ ]*\/\)\([^ ]*\)\.lib / \`$(CYGPATH_W) \1 | sed -e "s|\\\\\\\\\\\\\\\\\\\\|\/|g"\`\2.lib /g']`
3561    m4_toupper($1_LIBS_INSTALLED)=`echo " $m4_toupper($1_LIBS_INSTALLED)" | [sed -e 's/ \(\/[^ ]*\/\)/ \`$(CYGPATH_W) \1\`/g' -e 's/ -l\([^ ]*\)/ lib\1.lib/g' -e 's/ -L\([^ ]*\)/ -libpath:\`$(CYGPATH_W) \1\`/g']`
3562  fi
3563
3564  m4_toupper($1_PCREQUIRES)="$2"
3565  coin_foreach_w([myvar], [$3], [
3566    m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
3567    m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
3568    m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
3569    m4_toupper(myvar)_CFLAGS_INSTALLED="$m4_toupper($1)_CFLAGS_INSTALLED $m4_toupper(myvar)_CFLAGS_INSTALLED"
3570    m4_toupper(myvar)_LIBS_INSTALLED="$m4_toupper($1)_LIBS_INSTALLED $m4_toupper(myvar)_LIBS_INSTALLED"
3571  ])
3572
3573fi
3574
3575AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3576               [test $m4_tolower(coin_has_$1) != notGiven &&
3577                test $m4_tolower(coin_has_$1) != skipping])
3578
3579]) # AC_COIN_CHECK_PACKAGE_FALLBACK
3580
3581###########################################################################
3582#                         COIN_CHECK_PACKAGE_BLAS                         #
3583###########################################################################
3584
3585# This macro checks for a library containing the BLAS library.  It
3586# 1. checks the --with-blas argument
3587# 2. if --with-blas=BUILD has been specified goes to point 5
3588# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
3589#    to its value
3590# 4. tries standard libraries
3591# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
3592#    ThirdParty/Blas
3593# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
3594# BLAS_LIBS is set to the flags required to link with a Blas library.
3595# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
3596# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
3597# In case 5, Blas is added to X_PCREQUIRES.
3598
3599AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
3600[
3601AC_ARG_WITH([blas],
3602            AC_HELP_STRING([--with-blas],
3603                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
3604            [use_blas="$withval"], [use_blas=])
3605
3606# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
3607# preference
3608AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
3609
3610# Check if user supplied option makes sense
3611if test x"$use_blas" != x; then
3612  if test "$use_blas" = "BUILD"; then
3613    # we come to this later
3614    :
3615  elif test "$use_blas" != "no"; then
3616    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
3617    coin_need_flibs=no
3618    coin_save_LIBS="$LIBS"
3619    LIBS="$use_blas $LIBS"
3620    AC_COIN_TRY_FLINK([daxpy],
3621                      [if test $coin_need_flibs = yes ; then
3622                         use_blas="$use_blas $FLIBS"
3623                       fi
3624                       AC_MSG_RESULT([yes: $use_blas])],
3625                      [AC_MSG_RESULT([no])
3626                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
3627    LIBS="$coin_save_LIBS"
3628  fi
3629else
3630# Try to autodetect the library for blas based on build system
3631  #AC_MSG_CHECKING([default locations for BLAS])
3632  skip_lblas_check=no
3633  case $build in
3634    *-sgi-*)
3635      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
3636      coin_need_flibs=no
3637      coin_save_LIBS="$LIBS"
3638      LIBS="-lcomplib.sgimath $LIBS"
3639      AC_COIN_TRY_FLINK([daxpy],
3640                        [use_blas="-lcomplib.sgimath"
3641                         if test $coin_need_flibs = yes ; then
3642                           use_blas="$use_blas $FLIBS"
3643                         fi
3644                         AC_MSG_RESULT([yes: $use_blas])
3645                        ],
3646                        [AC_MSG_RESULT([no])])
3647      LIBS="$coin_save_LIBS"
3648      ;;
3649
3650# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
3651# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
3652# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
3653# that CC and cc will understand -library in Studio 13. The main extra
3654# function of -xlic_lib and -library is to arrange for the Fortran run-time
3655# libraries to be linked for C++ and C. We can arrange that explicitly.
3656    *-*-solaris*)
3657      AC_MSG_CHECKING([for BLAS in libsunperf])
3658      coin_need_flibs=no
3659      coin_save_LIBS="$LIBS"
3660      LIBS="-lsunperf $FLIBS $LIBS"
3661      AC_COIN_TRY_FLINK([daxpy],
3662                        [use_blas='-lsunperf'
3663                         if test $coin_need_flibs = yes ; then
3664                           use_blas="$use_blas $FLIBS"
3665                         fi
3666                         AC_MSG_RESULT([yes: $use_blas])
3667                        ],
3668                        [AC_MSG_RESULT([no])])
3669      LIBS="$coin_save_LIBS"
3670      ;;
3671     
3672    *-cygwin* | *-mingw*)
3673# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
3674# library will want to link with cygwin, hence won't run standalone in DOS.
3675      if test "$enable_doscompile" = mingw; then
3676        skip_lblas_check=yes
3677      fi
3678      case "$CC" in
3679        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
3680          coin_save_LIBS="$LIBS"
3681          AC_MSG_CHECKING([for BLAS in MKL (32bit)])
3682          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
3683          AC_COIN_TRY_FLINK([daxpy],
3684                            [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
3685                             AC_MSG_RESULT([yes: $use_blas])
3686                            ],
3687                            [AC_MSG_RESULT([no])])
3688          LIBS="$coin_save_LIBS"
3689         
3690          if test "x$use_blas" = x ; then
3691            AC_MSG_CHECKING([for BLAS in MKL (64bit)])
3692            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
3693            AC_COIN_TRY_FLINK([daxpy],
3694                              [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
3695                               AC_MSG_RESULT([yes: $use_blas])
3696                              ],
3697                              [AC_MSG_RESULT([no])])
3698            LIBS="$coin_save_LIBS"
3699          fi
3700          ;;
3701      esac
3702      ;;
3703     
3704     *-darwin*)
3705      AC_MSG_CHECKING([for BLAS in Veclib])
3706      coin_need_flibs=no
3707      coin_save_LIBS="$LIBS"
3708      LIBS="-framework vecLib $LIBS"
3709      AC_COIN_TRY_FLINK([daxpy],
3710                        [use_blas='-framework vecLib'
3711                         if test $coin_need_flibs = yes ; then
3712                           use_blas="$use_blas $FLIBS"
3713                         fi
3714                         AC_MSG_RESULT([yes: $use_blas])
3715                        ],
3716                        [AC_MSG_RESULT([no])])
3717      LIBS="$coin_save_LIBS"
3718      ;;
3719  esac
3720
3721  if test -z "$use_blas" && test $skip_lblas_check = no; then
3722    AC_MSG_CHECKING([whether -lblas has BLAS])
3723    coin_need_flibs=no
3724    coin_save_LIBS="$LIBS"
3725    LIBS="-lblas $LIBS"
3726    AC_COIN_TRY_FLINK([daxpy],
3727                      [use_blas='-lblas'
3728                       if test $coin_need_flibs = yes ; then
3729                         use_blas="$use_blas $FLIBS"
3730                       fi
3731                       AC_MSG_RESULT([yes: $use_blas])
3732                      ],
3733                      [AC_MSG_RESULT([no])])
3734    LIBS="$coin_save_LIBS"
3735  fi
3736
3737  # If we have no other ideas, consider building BLAS.
3738  if test -z "$use_blas" ; then
3739    use_blas=BUILD
3740  fi
3741fi
3742
3743if test "x$use_blas" = xBUILD ; then
3744  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
3745 
3746elif test "x$use_blas" != x && test "$use_blas" != no; then
3747  coin_has_blas=yes
3748  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
3749  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
3750  BLAS_LIBS="$use_blas"
3751  BLAS_CFLAGS=
3752  BLAS_DATA=
3753  AC_SUBST(BLAS_LIBS)
3754  AC_SUBST(BLAS_CFLAGS)
3755  AC_SUBST(BLAS_DATA)
3756  coin_foreach_w([myvar], [$1], [
3757    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
3758    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
3759    m4_toupper(myvar)_LIBS_INSTALLED="$BLAS_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
3760  ])
3761 
3762else
3763  coin_has_blas=no
3764  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
3765fi
3766
3767coin_foreach_w([myvar], [$1], [
3768  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3769  AC_SUBST(m4_toupper(myvar)_LIBS)
3770  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3771])
3772
3773]) # AC_COIN_CHECK_PACKAGE_BLAS
3774
3775###########################################################################
3776#                       COIN_CHECK_PACKAGE_LAPACK                         #
3777###########################################################################
3778
3779# This macro checks for a library containing the LAPACK library.  It
3780# 1. checks the --with-lapack argument
3781# 2. if --with-lapack=BUILD has been specified goes to point 5
3782# 3. if --with-lapack has been specified to a working library, sets
3783#    LAPACK_LIBS to its value
3784# 4. tries standard libraries
3785# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
3786#    ThirdParty/Lapack
3787# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
3788# LAPACK_LIBS is set to the flags required to link with a Lapack library.
3789# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
3790# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
3791# In case 5, Lapack is added to X_PCREQUIRES.
3792#
3793# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
3794#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
3795#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
3796#   then we will get Blas as dependency of coinlapack.
3797
3798AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
3799[
3800AC_ARG_WITH([lapack],
3801            AC_HELP_STRING([--with-lapack],
3802                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
3803            [use_lapack=$withval], [use_lapack=])
3804
3805#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
3806AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
3807
3808# Check if user supplied option makes sense
3809if test x"$use_lapack" != x; then
3810  if test "$use_lapack" = "BUILD"; then
3811    # we come to this later
3812    :
3813  elif test "$use_lapack" != no; then
3814    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
3815    coin_need_flibs=no
3816    use_lapack="$use_lapack $BLAS_LIBS"
3817    coin_save_LIBS="$LIBS"
3818    LIBS="$use_lapack $LIBS"
3819    AC_COIN_TRY_FLINK([dsyev],
3820                      [if test $coin_need_flibs = yes ; then
3821                         use_lapack="$use_lapack $FLIBS"
3822                       fi
3823                       AC_MSG_RESULT([yes: $use_lapack])
3824                      ],
3825                      [AC_MSG_RESULT([no])
3826                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
3827    LIBS="$coin_save_LIBS"
3828  fi
3829else
3830  if test x$coin_has_blas = xyes; then
3831    # First try to see if LAPACK is already available with BLAS library
3832    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
3833    coin_save_LIBS="$LIBS"
3834    coin_need_flibs=no
3835    LIBS="$BLAS_LIBS $LIBS"
3836    AC_COIN_TRY_FLINK([dsyev],
3837                      [use_lapack="$BLAS_LIBS"
3838                       if test $coin_need_flibs = yes ; then
3839                         use_lapack="$use_lapack $FLIBS"
3840                       fi
3841                       AC_MSG_RESULT([yes: $use_lapack])
3842                      ],
3843                      [AC_MSG_RESULT([no])])
3844    LIBS="$coin_save_LIBS"
3845  fi
3846  skip_llapack_check=no
3847  if test -z "$use_lapack"; then
3848    # Try to autodetect the library for lapack based on build system
3849    case $build in
3850      # TODO: Is this check actually needed here, since -lcomplib.sigmath should have been recognized as Blas library,
3851      #       and above it is checked whether the Blas library already contains Lapack
3852      *-sgi-*)
3853        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
3854        coin_save_LIBS="$LIBS"
3855        coin_need_flibs=no
3856        LIBS="-lcomplib.sgimath $BLAS_LIBS $LIBS"
3857        AC_COIN_TRY_FLINK([dsyev],
3858                          [use_lapack="-lcomplib.sgimath $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
3868      # See comments in COIN_CHECK_PACKAGE_BLAS.
3869      # TODO: Is this check actually needed here, since -lsunperf should have been recognized as Blas library,
3870      #       and above it is checked whether the Blas library already contains Lapack
3871      *-*-solaris*)
3872        AC_MSG_CHECKING([for LAPACK in libsunperf])
3873        coin_need_flibs=no
3874        coin_save_LIBS="$LIBS"
3875        LIBS="-lsunperf $BLAS_LIBS $FLIBS $LIBS"
3876        AC_COIN_TRY_FLINK([dsyev],
3877                          [use_lapack='-lsunperf $BLAS_LIBS'
3878                           if test $coin_need_flibs = yes ; then
3879                             use_lapack="$use_lapack $FLIBS"
3880                           fi
3881                           AC_MSG_RESULT([yes: $use_lapack])
3882                          ],
3883                          [AC_MSG_RESULT([no])])
3884        LIBS="$coin_save_LIBS"
3885        ;;
3886        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
3887        # will want to link with cygwin, hence won't run standalone in DOS.
3888       
3889      *-cygwin*)
3890        if test "$enable_doscompile" = mingw; then
3891          skip_llapack_check=yes
3892        fi
3893        ;;
3894       
3895    esac
3896  fi
3897
3898  if test -z "$use_lapack" && test $skip_llapack_check = no; then
3899    AC_MSG_CHECKING([whether -llapack has LAPACK])
3900    coin_need_flibs=no
3901    coin_save_LIBS="$LIBS"
3902    LIBS="-llapack $BLAS_LIBS $LIBS"
3903    AC_COIN_TRY_FLINK([dsyev],
3904                      [use_lapack='-llapack'
3905                       if test $coin_need_flibs = yes ; then
3906                         use_lapack="$use_lapack $FLIBS"
3907                       fi
3908                       AC_MSG_RESULT([yes: $use_lapack])
3909                      ],
3910                      [AC_MSG_RESULT([no])])
3911    LIBS="$coin_save_LIBS"
3912  fi
3913
3914  # If we have no other ideas, consider building LAPACK.
3915  if test -z "$use_lapack" ; then
3916    use_lapack=BUILD
3917  fi
3918fi
3919
3920if test "x$use_lapack" = xBUILD ; then
3921  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
3922
3923elif test "x$use_lapack" != x && test "$use_lapack" != no; then
3924  coin_has_lapack=yes
3925  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
3926  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
3927  LAPACK_LIBS="$use_lapack"
3928  LAPACK_CFLAGS=
3929  LAPACK_DATA=
3930  AC_SUBST(LAPACK_LIBS)
3931  AC_SUBST(LAPACK_CFLAGS)
3932  AC_SUBST(LAPACK_DATA)
3933  coin_foreach_w([myvar], [$1], [
3934    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
3935    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
3936    m4_toupper(myvar)_LIBS_INSTALLED="$LAPACK_LIBS $m4_toupper(myvar)_LIBS_INSTALLED"
3937  ])
3938 
3939else
3940  coin_has_lapack=no
3941  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
3942fi
3943
3944coin_foreach_w([myvar], [$1], [
3945  AC_SUBST(m4_toupper(myvar)_PCLIBS)
3946  AC_SUBST(m4_toupper(myvar)_LIBS)
3947  AC_SUBST(m4_toupper(myvar)_LIBS_INSTALLED)
3948])
3949
3950]) # AC_COIN_CHECK_PACKAGE_LAPACK
Note: See TracBrowser for help on using the repository browser.