source: trunk/coin.m4 @ 1551

Last change on this file since 1551 was 1551, checked in by stefan, 11 years ago

do not set FLIBS to -link /NODEFAULTLIB:libc.lib, since it seem to be not necessary with VS >= 8 and breaks builds where linker flags are reordered at the linkline (or where someone does not take special care that gets to the end

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