source: trunk/coin.m4 @ 1608

Last change on this file since 1608 was 1608, checked in by stefan, 10 years ago

augment ADDLIBS variable at the beginning

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