source: trunk/coin.m4 @ 2963

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

fixup --enable-msvc

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