source: trunk/coin.m4 @ 1622

Last change on this file since 1622 was 1622, checked in by lou, 10 years ago

Small tweak to make COIN_VPATH_LINK insensitive to newlines in list of files
supplied as a parameter.

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