source: trunk/coin.m4 @ 2861

Last change on this file since 2861 was 2861, checked in by tkr, 6 years ago

Quoting PKG_CONFIG and setting CYGPATH_W to echo for gcc

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