source: trunk/coin.m4 @ 1831

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

put argument into quotes in case it contains a >

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