source: stable/0.5/coin.m4 @ 1236

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

synchronize with trunk rev 1234

  • Property svn:keywords set to Author Date Id Revision
File size: 110.5 KB
Line 
1# Copyright (C) 2006, 2007 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Common Public License.
4#
5## $Id: coin.m4 1236 2009-02-21 19:17:22Z stefan $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_PREREQ(2.59)
14
15###########################################################################
16#                           COIN_MAIN_SUBDIRS                             #
17###########################################################################
18
19# This macro sets up the recursion into configure scripts into
20# subdirectories.  Each possible subdirectory should be provided as a
21# new argument to this macro.  The current limit is 10 subdirectories.
22# This automatically also checks for the Data subdirectory.
23
24AC_DEFUN([AC_COIN_MAIN_SUBDIRS],
25[AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
26
27m4_ifvaln([$1],[AC_MSG_CHECKING(whether directory $1 is available)
28                coin_skip=no
29                if test x"$COIN_SKIP_PROJECTS" != x; then
30                  for dir in $COIN_SKIP_PROJECTS; do
31                    if test $dir = $1; then
32                      coin_skip=yes
33                    fi
34                  done
35                fi
36                if test $coin_skip = yes; then
37                  AC_MSG_RESULT(skipping)
38                elif test -r $srcdir/$1/configure; then
39                  coin_subdirs="$coin_subdirs $1"
40                  AC_MSG_RESULT(yes)
41                  AC_CONFIG_SUBDIRS($1)
42                else
43                  AC_MSG_RESULT(no)
44                fi])
45m4_ifvaln([$2],[AC_MSG_CHECKING(whether directory $2 is available)
46                coin_skip=no
47                if test x"$COIN_SKIP_PROJECTS" != x; then
48                  for dir in $COIN_SKIP_PROJECTS; do
49                    if test $dir = $2; then
50                      coin_skip=yes
51                    fi
52                  done
53                fi
54                if test $coin_skip = yes; then
55                  AC_MSG_RESULT(skipping)
56                elif test -r $srcdir/$2/configure; then
57                  coin_subdirs="$coin_subdirs $2"
58                  AC_MSG_RESULT(yes)
59                  AC_CONFIG_SUBDIRS($2)
60                else
61                  AC_MSG_RESULT(no)
62                fi])
63m4_ifvaln([$3],[AC_MSG_CHECKING(whether directory $3 is available)
64                coin_skip=no
65                if test x"$COIN_SKIP_PROJECTS" != x; then
66                  for dir in $COIN_SKIP_PROJECTS; do
67                    if test $dir = $3; then
68                      coin_skip=yes
69                    fi
70                  done
71                fi
72                if test $coin_skip = yes; then
73                  AC_MSG_RESULT(skipping)
74                elif test -r $srcdir/$3/configure; then
75                  coin_subdirs="$coin_subdirs $3"
76                  AC_MSG_RESULT(yes)
77                  AC_CONFIG_SUBDIRS($3)
78                else
79                  AC_MSG_RESULT(no)
80                fi])
81m4_ifvaln([$4],[AC_MSG_CHECKING(whether directory $4 is available)
82                coin_skip=no
83                if test x"$COIN_SKIP_PROJECTS" != x; then
84                  for dir in $COIN_SKIP_PROJECTS; do
85                    if test $dir = $4; then
86                      coin_skip=yes
87                    fi
88                  done
89                fi
90                if test $coin_skip = yes; then
91                  AC_MSG_RESULT(skipping)
92                elif test -r $srcdir/$4/configure; then
93                  coin_subdirs="$coin_subdirs $4"
94                  AC_MSG_RESULT(yes)
95                  AC_CONFIG_SUBDIRS($4)
96                else
97                  AC_MSG_RESULT(no)
98                fi])
99m4_ifvaln([$5],[AC_MSG_CHECKING(whether directory $5 is available)
100                coin_skip=no
101                if test x"$COIN_SKIP_PROJECTS" != x; then
102                  for dir in $COIN_SKIP_PROJECTS; do
103                    if test $dir = $5; then
104                      coin_skip=yes
105                    fi
106                  done
107                fi
108                if test $coin_skip = yes; then
109                  AC_MSG_RESULT(skipping)
110                elif test -r $srcdir/$5/configure; then
111                  coin_subdirs="$coin_subdirs $5"
112                  AC_MSG_RESULT(yes)
113                  AC_CONFIG_SUBDIRS($5)
114                else
115                  AC_MSG_RESULT(no)
116                fi])
117m4_ifvaln([$6],[AC_MSG_CHECKING(whether directory $6 is available)
118                coin_skip=no
119                if test x"$COIN_SKIP_PROJECTS" != x; then
120                  for dir in $COIN_SKIP_PROJECTS; do
121                    if test $dir = $6; then
122                      coin_skip=yes
123                    fi
124                  done
125                fi
126                if test $coin_skip = yes; then
127                  AC_MSG_RESULT(skipping)
128                elif test -r $srcdir/$6/configure; then
129                  coin_subdirs="$coin_subdirs $6"
130                  AC_MSG_RESULT(yes)
131                  AC_CONFIG_SUBDIRS($6)
132                else
133                  AC_MSG_RESULT(no)
134                fi])
135m4_ifvaln([$7],[AC_MSG_CHECKING(whether directory $7 is available)
136                coin_skip=no
137                if test x"$COIN_SKIP_PROJECTS" != x; then
138                  for dir in $COIN_SKIP_PROJECTS; do
139                    if test $dir = $7; then
140                      coin_skip=yes
141                    fi
142                  done
143                fi
144                if test $coin_skip = yes; then
145                  AC_MSG_RESULT(skipping)
146                elif test -r $srcdir/$7/configure; then
147                  coin_subdirs="$coin_subdirs $7"
148                  AC_MSG_RESULT(yes)
149                  AC_CONFIG_SUBDIRS($7)
150                else
151                  AC_MSG_RESULT(no)
152                fi])
153m4_ifvaln([$8],[AC_MSG_CHECKING(whether directory $8 is available)
154                coin_skip=no
155                if test x"$COIN_SKIP_PROJECTS" != x; then
156                  for dir in $COIN_SKIP_PROJECTS; do
157                    if test $dir = $8; then
158                      coin_skip=yes
159                    fi
160                  done
161                fi
162                if test $coin_skip = yes; then
163                  AC_MSG_RESULT(skipping)
164                elif test -r $srcdir/$8/configure; then
165                  coin_subdirs="$coin_subdirs $8"
166                  AC_MSG_RESULT(yes)
167                  AC_CONFIG_SUBDIRS($8)
168                else
169                  AC_MSG_RESULT(no)
170                fi])
171m4_ifvaln([$9],[AC_MSG_CHECKING(whether directory $9 is available)
172                coin_skip=no
173                if test x"$COIN_SKIP_PROJECTS" != x; then
174                  for dir in $COIN_SKIP_PROJECTS; do
175                    if test $dir = $9; then
176                      coin_skip=yes
177                    fi
178                  done
179                fi
180                if test $coin_skip = yes; then
181                  AC_MSG_RESULT(skipping)
182                elif test -r $srcdir/$9/configure; then
183                  coin_subdirs="$coin_subdirs $9"
184                  AC_MSG_RESULT(yes)
185                  AC_CONFIG_SUBDIRS($9)
186                else
187                  AC_MSG_RESULT(no)
188                fi])
189m4_ifvaln([$10],[AC_MSG_CHECKING(whether directory $10 is available)
190                coin_skip=no
191                if test x"$COIN_SKIP_PROJECTS" != x; then
192                  for dir in $COIN_SKIP_PROJECTS; do
193                    if test $dir = $10; then
194                      coin_skip=yes
195                    fi
196                  done
197                fi
198                if test $coin_skip = yes; then
199                  AC_MSG_RESULT(skipping)
200                elif test -r $srcdir/$10/configure; then
201                  coin_subdirs="$coin_subdirs $10"
202                  AC_MSG_RESULT(yes)
203                  AC_CONFIG_SUBDIRS($10)
204                else
205                  AC_MSG_RESULT(no)
206                fi])
207]) # AC_COIN_MAIN_SUBDIRS
208
209###########################################################################
210#                            COIN_CHECK_FILE                              #
211###########################################################################
212
213# A simple replacement for AC_CHECK_FILE that works for cross compilation
214
215AC_DEFUN([AC_COIN_CHECK_FILE],
216[if test -r $1; then
217  $2
218  :
219else
220  $3
221  :
222fi
223])
224
225###########################################################################
226#                        COIN_THIRDPARTY_SUBDIRS                          #
227###########################################################################
228
229# This macro sets up the recursion into the configure script in a
230# subdirectory for compilation of third party code.  The first
231# argument is just the string that appears in the configure output.
232# The second argument is the directory with the configure script, and
233# the third one is a file that should exists in that directory.  If
234# this file does not exist, we assume that the user has not downloaded
235# the code, and we are not going to compile it
236
237AC_DEFUN([AC_COIN_THIRDPARTY_SUBDIRS],
238[AC_MSG_CHECKING(whether code for third party package $1 is available)
239coin_skip=no
240if test x"$COIN_SKIP_PROJECTS" != x; then
241  for dir in $COIN_SKIP_PROJECTS; do
242    if test $dir = $2; then
243      coin_skip=yes
244    fi
245  done
246fi
247if test $coin_skip = yes; then
248  AC_MSG_RESULT(skipping)
249else
250  coin_tmp=`echo $srcdir/$2/$3`
251  # There is probably a more elegant way to get the first thing out here...
252  for i in $coin_tmp; do
253    coin_tmp2=$i
254    #break 1
255  done
256  if test -r $coin_tmp2; then
257    coin_subdirs="$coin_subdirs $2"
258    AC_MSG_RESULT(yes)
259    AC_CONFIG_SUBDIRS($2)
260  else
261    AC_MSG_RESULT(no)
262  fi
263fi
264]) # AC_COIN_THIRDPARTY_SUBDIRS
265
266###########################################################################
267#                           COIN_CHECK_VPATH                              #
268###########################################################################
269
270# This macro sets the variable coin_vpath_config to true if this is a
271# VPATH configuration, otherwise it sets it to false.
272AC_DEFUN([AC_COIN_CHECK_VPATH],
273[AC_MSG_CHECKING(whether this is a VPATH configuration)
274if test `cd $srcdir; pwd` != `pwd`; then
275  coin_vpath_config=yes;
276else
277  coin_vpath_config=no;
278fi
279AC_MSG_RESULT($coin_vpath_config)
280]) # AC_COIN_CHECK_VPATH
281
282###########################################################################
283#                         COIN_PROJECTDIR_INIT                            #
284###########################################################################
285
286# This macro does everything that is required in the early part in the
287# configure script, such as defining a few variables.  This should only
288# be used in the main directory of a project directory (the one under
289# which src is)
290
291AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
292[# Initialize the ADDLIBS variable
293ADDLIBS="-lm $LIBS"
294AC_SUBST(ADDLIBS)
295
296# Initialize the FADDLIBS variable (which is to be used with a fortran
297# compiler and will not include FLIBS)
298FADDLIBS="$LIBS"
299AC_SUBST(FADDLIBS)
300
301# A useful makefile conditional that is always false
302AM_CONDITIONAL(ALWAYS_FALSE, false)
303
304# We set the following variable so that we know later in AC_COIN_FINALIZE
305# that we are in a project main directory
306coin_projectdir=yes
307]) # AC_COIN_PROJECTDIR_INIT
308
309###########################################################################
310#                          COIN_DEBUG_COMPILE                             #
311###########################################################################
312
313# enable the configure flags --enable-debug and --enable-debug-prjct
314# (where prcjt is the name of the project in lower case) and set the
315# variable coin_debug_compile to true or false This is used by
316# COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77 to determine the
317# compilation flags.  This macro also makes the switches
318# --with-prjct-verbosity and --with-prjct-checklevel available, which
319# define the preprocessor macros COIN_PRJCT_VERBOSITY and
320# COIN_PRJCT_CHECKLEVEL to the specified value (default is 0).
321#
322# The project specific flags are only made available, if one gives the
323# name of the project as first argument to this macro.
324
325AC_DEFUN([AC_COIN_DEBUG_COMPILE],
326[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
327AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
328AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
329
330AC_MSG_CHECKING([whether we want to compile in debug mode])
331
332AC_ARG_ENABLE([debug],
333[AC_HELP_STRING([--enable-debug],
334                [compile all projects with debug options tests])],
335[case "${enableval}" in
336   yes) coin_debug_compile=true
337        if test "${enable_shared+set}" = set; then :; else
338          enable_shared=no
339        fi
340        ;;
341   no)  coin_debug_compile=false
342        ;;
343   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
344        ;;
345esac],
346[coin_debug_compile=false])
347
348m4_ifvaln([$1],
349[AC_ARG_ENABLE(debug-m4_tolower($1),
350 [AC_HELP_STRING([--enable-debug-m4_tolower($1)],
351                 [compile this project ($1) with debug options])],
352 [case "${enableval}" in
353    yes) coin_debug_compile=true
354         enable_shared=no
355         ;;
356    no)  coin_debug_compile=false
357         ;;
358    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
359         ;;
360 esac],[:])
361]) # m4_ifvaln([$1],
362
363if test $coin_debug_compile = true; then
364  AC_MSG_RESULT([yes])
365else
366  AC_MSG_RESULT([no])
367fi
368
369m4_ifvaln([$1],
370[AC_ARG_WITH(m4_tolower($1)-verbosity,
371             AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
372                            [specify the debug verbosity level for project $1]),
373             [if test "$withval" = yes; then
374                withval=1
375              fi
376              m4_tolower(coin_$1_verbosity)=$withval],
377             [m4_tolower(coin_$1_verbosity)=0])
378 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
379                    m4_tolower($coin_$1_verbosity),
380                    [Define to the debug verbosity level (0 is no output)])
381
382 AC_ARG_WITH(m4_tolower($1)-checklevel,
383             AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
384                            [specify the sanity check level for project $1]),
385             [if test "$withval" = yes; then
386                withval=1
387              fi
388              m4_tolower(coin_$1_checklevel)=$withval],
389             [m4_tolower(coin_$1_checklevel)=0])
390 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
391                    m4_tolower($coin_$1_checklevel),
392                    [Define to the debug sanity check level (0 is no test)])
393
394# We use the following variable to have a string with the upper case
395# version of the project name
396COIN_PRJCT=m4_toupper($1)
397
398]) # m4_ifvaln([$1],
399 
400]) # AC_COIN_DEBUG_COMPILE
401
402###########################################################################
403#                          COIN_MINGW_LD_FIX                              #
404###########################################################################
405
406# This macro is included by any PROG_compiler macro, to set the LD
407# environment variable on MinGW to the correct value (link). But note that
408# if we're building in cygwin with -mno-cygwin, we still want ld! If we're
409# building from cygwin with MSVC tools (cl/link), then we do want link and
410# you'd better have your PATH variable straight, else you'll be doing file
411# links instead of code links! Arguably, LDFLAGS should include -mno-cygwin
412# but in practice all linking seems to be handled through the compilers, so
413# CFLAGS and CXXFLAGS suffice.
414
415AC_DEFUN([AC_COIN_MINGW_LD_FIX],
416[case $build in
417  *-mingw*)
418    if test "${LD+set}" = set; then :; else
419      LD=link
420    fi
421    ;;
422 esac
423 case $enable_doscompile in
424   msvc)
425     if test "x${LD+set}" = xset; then :; else
426       LD=link
427     fi
428     ;;
429 esac
430])
431
432###########################################################################
433#                        COIN_ENABLE_DOSCOMPILE                           #
434###########################################################################
435
436# This macro is invoked by any PROG_compiler macro to establish the
437# --enable-doscompile option, used when one wants to compile an executable
438# under Cygwin which also runs directly under DOS (without requiring
439# Cygwin1.dll). The job of this macro is to make sure the option is correct and
440# to set enable_doscompile. Legal values are mingw, msvc, and no (disabled).
441# mingw: Fake mingw under cygwin, using GCC tools and -mno-cygwin. The most
442#        important thing here is that preprocess, compile, and link steps
443#        *all* see -mno-cygwin.
444# msvc:  Assume the presence of cl/link. It's the user's responsibility to
445#        make sure their PATH is correct. In particular, that MSVC link is
446#        found and not cygwin link (we want to do code linking, not file
447#        linking).
448# It's the responsibility of individual PROG_compiler macros to ensure that
449# they correctly set the compiler search list and preprocess, compile, and
450# link flags. This is tied to compiler setup because in practice invocations
451# of the preprocessor and linker are made through the compiler.
452
453AC_DEFUN([AC_COIN_ENABLE_DOSCOMPILE],
454[AC_REQUIRE([AC_CANONICAL_BUILD])
455 AC_ARG_ENABLE([doscompile],
456  [AC_HELP_STRING([--enable-doscompile],
457                  [Under Cygwin, compile so that executables run under DOS.
458                   Set to mingw to use gcc/g++/ld with -mno-cygwin.
459                   Set to msvc to use cl/link (or icl/link).
460                   Default when mentioned: mingw.
461                   Default when not mentioned: disabled.])],
462  [if test "$enable_doscompile" != no; then
463     case $build in
464       *-cygwin* | *-mingw*) ;;
465       *) AC_MSG_ERROR([--enable-doscompile option makes sense only under Cygwin or MinGW]) ;;
466     esac
467   fi],
468  [enable_doscompile=no])
469 case "$enable_doscompile" in
470   mingw)
471     case $build in
472       *-mingw*) enable_doscompile=no ;;
473     esac
474     ;;
475   msvc|no) ;;
476   yes) enable_doscompile=mingw ;;
477   *) AC_MSG_ERROR([Invalid value $enable_doscompile for --enable-doscompile.
478                    Try configure --help=recursive.])
479      ;;
480  esac
481  if test "$enable_doscompile" != no ; then
482    AC_MSG_NOTICE([DOS compile style is: $enable_doscompile])
483  fi
484])
485
486###########################################################################
487#                             COIN_PROG_CXX                               #
488###########################################################################
489
490# Find the compile command by running AC_PROG_CXX (with compiler names for
491# different operating systems) and put it into CXX (unless it was given by the
492# user). Then find an appropriate value for CXXFLAGS. If either of CXXFLAGS or
493# PRJCT_CXXFLAGS is defined, that value is used (replace PRJCT with the upper
494# case name of this project).  It is possible to provide additional -D flags
495# in the variable CXXDEFS, and additional compilation flags with ADD_CXXFLAGS.
496
497AC_DEFUN([AC_COIN_PROG_CXX],
498[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
499AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
500AC_LANG_PUSH(C++)
501
502AC_ARG_VAR(CXXDEFS,[Additional -D flags to be used when compiling C++ code.])
503AC_ARG_VAR(ADD_CXXFLAGS,[Additional C++ compiler options])
504AC_ARG_VAR(DBG_CXXFLAGS,[Debug C++ compiler options])
505AC_ARG_VAR(OPT_CXXFLAGS,[Optimize C++ compiler options])
506
507coin_has_cxx=yes
508
509save_cxxflags="$CXXFLAGS"
510# For *-*-solaris*, promote Studio/Workshop compiler to front of list.
511case $build in
512  *-cygwin* | *-mingw*)
513             if test "$enable_doscompile" = msvc ; then
514               comps="icl cl"
515             else
516               comps="g++ cl"
517             fi ;;
518  *-*-solaris*)
519             comps="CC xlC_r aCC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
520  *-darwin*) comps="g++ c++ CC" ;;
521          *) comps="xlC_r aCC CC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
522esac
523
524# We delete the cached value, since the test might not have been
525# performed with our choice of compilers earlier
526$as_unset ac_cv_prog_CXX || test "${ac_cv_prog_CXX+set}" != set || { ac_cv_prog_CXX=; export ac_cv_prog_CXX; }
527# AC_MSG_NOTICE([C++ compiler candidates: $comps])
528AC_PROG_CXX([$comps])
529
530#AC_PROG_CXX sets CXX to g++ if it cannot find a working C++ compiler
531#thus, we test here whether $CXX is actually working
532AC_LANG_PUSH(C++)
533AC_MSG_CHECKING([whether C++ compiler $CXX works]);
534AC_COMPILE_IFELSE(
535  [AC_LANG_PROGRAM(, [int i=0;])],
536  [AC_MSG_RESULT(yes)],
537  [AC_MSG_RESULT(no)
538   AC_MSG_ERROR(failed to find a C++ compiler or C++ compiler $CXX does not work)]
539)
540AC_LANG_POP(C++)
541
542# It seems that we need to cleanup something here for the Windows
543case "$CXX" in
544  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
545    sed -e 's/^void exit (int);//' confdefs.h >> confdefs.hh
546    mv confdefs.hh confdefs.h
547    ;;
548esac
549
550# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
551case "$CXX" in
552  cl* | */cl* | CL* | */CL* )
553    if test "$ac_cv_prog_cxx_g" = yes ; then
554      ac_cv_prog_cxx_g=no
555      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
556    fi ;;
557esac
558CXXFLAGS="$save_cxxflags"
559
560# Check if a project specific CXXFLAGS variable has been set
561if test x$COIN_PRJCT != x; then
562  eval coin_tmp=\${${COIN_PRJCT}_CXXFLAGS+set}
563  if test x$coin_tmp = xset; then
564    eval CXXFLAGS=\${${COIN_PRJCT}_CXXFLAGS}
565  fi
566fi
567
568if test x"$CXXFLAGS" = x; then
569
570# ToDo decide whether we want -DNDEBUG for optimization
571  coin_add_cxxflags=
572  coin_opt_cxxflags=
573  coin_dbg_cxxflags=
574  coin_warn_cxxflags=
575
576  if test "$GXX" = "yes"; then
577    case "$CXX" in
578      icpc* | */icpc*)
579        ;;
580      *)
581# ToDo decide about unroll-loops
582        coin_opt_cxxflags="-O3 -fomit-frame-pointer"
583        coin_add_cxxflags="-pipe"
584        coin_dbg_cxxflags="-g"
585        coin_warn_cxxflags="-Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas"
586        case $build in
587          *-darwin*)
588            ;;
589          *)
590            coin_warn_cxxflags="-pedantic-errors $coin_warn_cxxflags"
591            ;;
592        esac
593
594        case $enable_doscompile in
595          mingw)
596            CXXFLAGS="-mno-cygwin"
597            AC_TRY_LINK(,[int i=0; i++;],[coin_add_cxxflags="-mno-cygwin $coin_add_cxxflags"])
598            CXXFLAGS=
599          ;;
600        esac
601    esac
602  fi
603
604# Note that we do not need to cover GCC in the following tests.
605
606  if test -z "$coin_opt_cxxflags"; then
607    case $build in
608      *-cygwin* | *-mingw*)
609        case "$CXX" in
610          cl* | */cl* | CL* | */CL*)
611            # The MT and MTd options are mutually exclusive
612            coin_opt_cxxflags='-MT -O2'
613            coin_add_cxxflags='-nologo -EHsc -GR -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
614            coin_dbg_cxxflags='-MTd'
615            ;;
616          icl* | */icl* | ICL* | */ICL*)
617            # The MT and MTd options are mutually exclusive
618            coin_opt_cxxflags='-MT -Ox'
619            coin_add_cxxflags='-nologo -EHsc -GR -D_CRT_SECURE_NO_DEPRECATE'
620            coin_dbg_cxxflags='-MTd -debug'
621            ;;
622        esac
623        ;;
624      *-linux-*)
625        case "$CXX" in
626          icpc* | */icpc*)
627            coin_opt_cxxflags="-O3 -ip -mp1"
628            coin_add_cxxflags=""
629            coin_dbg_cxxflags="-g"
630            # Check if -i_dynamic is necessary (for new glibc library)
631            CXXFLAGS=
632            AC_TRY_LINK(,[int i=0; i++;],[],
633                        [coin_add_cxxflags="-i_dynamic $coin_add_cxxflags"])
634            ;;
635          pgCC* | */pgCC*)
636            coin_opt_cxxflags="-fast"
637            coin_add_cxxflags="-Kieee -pc 64"
638            coin_dbg_cxxflags="-g"
639            ;;
640        esac
641        ;;
642      *-ibm-*)
643        case "$CXX" in
644          xlC* | */xlC* | mpxlC* | */mpxlC*)
645            coin_opt_cxxflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
646            coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna -qsuppress=1500-036 -qsuppress=1500-029 -qsourcetype=c++"
647            coin_dbg_cxxflags="-g"
648            ;;
649        esac
650        ;;
651      *-hp-*)
652        case "$CXX" in
653          aCC* | */aCC* )
654            coin_opt_cxxflags="-O"
655            coin_add_cxxflags="-AA"
656            coin_dbg_cxxflags="-g"
657            ;;
658        esac
659        ;;
660      *-*-solaris*)
661          coin_opt_cxxflags="-O4"
662          coin_dbg_cxxflags="-g"
663        ;;
664    esac
665  fi
666
667# Generic flag settings. If these don't work, add a case above.
668
669  if test "$ac_cv_prog_cxx_g" = yes && test -z "$coin_dbg_cxxflags" ; then
670    coin_dbg_cxxflags="-g"
671  fi
672
673  if test -z "$coin_opt_cxxflags"; then
674    # Try if -O option works if nothing else is set
675    CXXFLAGS=-O
676    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cxxflags="-O"])
677  fi
678
679  # if PM doesn't want the warning messages, take them out
680  if test x"$coin_skip_warn_cxxflags" = xyes; then
681    coin_warn_cxxflags=
682  fi
683
684# Do final setup of flags based on values determined above.
685
686  if test x${DBG_CXXFLAGS+set} != xset; then
687    DBG_CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
688  fi
689  if test x${OPT_CXXFLAGS+set} != xset; then
690    OPT_CXXFLAGS="$coin_opt_cxxflags $coin_add_cxxflags -DNDEBUG $coin_warn_cxxflags"
691  fi
692
693  DBG_CXXFLAGS="$DBG_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
694  OPT_CXXFLAGS="$OPT_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
695
696  if test "$coin_debug_compile" = "true"; then
697    CXXFLAGS="$DBG_CXXFLAGS"
698  else
699    CXXFLAGS="$OPT_CXXFLAGS"
700  fi
701
702# Handle the case where CXXFLAGS was set externally.
703else
704  CXXFLAGS="$CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
705  if test x${DBG_CXXFLAGS+set} != xset; then
706    DBG_CXXFLAGS="$CXXFLAGS"
707  fi
708  if test x${OPT_CXXFLAGS+set} != xset; then
709    OPT_CXXFLAGS="$CXXFLAGS"
710  fi
711fi
712
713# If CXXFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
714
715case "$CXXFLAGS" in
716  *-mno-cygwin*)
717    if test x${CPPFLAGS+set} != xset ; then
718      CPPFLAGS="-mno-cygwin"
719    else
720      case "$CPPFLAGS" in
721        *-mno-cygwin*)
722          ;;
723        *)
724          CPPFLAGS="$CPPFLAGS -mno-cygwin"
725          ;;
726      esac
727    fi ;;
728esac
729
730# Try if CXXFLAGS works
731save_CXXFLAGS="$CXXFLAGS"
732AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
733if test -z "$CXXFLAGS"; then
734  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.])
735  CXXFLAGS='-O'
736  AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
737  if test -z "$CXXFLAGS"; then
738    AC_MSG_WARN([This value for CXXFLAGS does not work.  I will continue with empty CXXFLAGS, but you might want to set CXXFLAGS manually.])
739  fi
740fi
741
742AC_MSG_NOTICE([C++ compiler options are: $CXXFLAGS])
743
744AC_ARG_VAR(MPICXX,[C++ MPI Compiler])
745if test x"$MPICXX" = x; then :; else
746  AC_MSG_NOTICE([Will use MPI C++ compiler $MPICXX])
747  CXX="$MPICXX"
748fi
749
750case "$CXX" in
751  cl* | */cl* | CL* | */CL* )
752    AC_COIN_MINGW_LD_FIX
753    ;;
754esac
755
756AC_LANG_POP(C++)
757]) # AC_COIN_PROG_CXX
758
759
760###########################################################################
761#                             COIN_CXXLIBS                                #
762###########################################################################
763
764# Determine the C++ runtime libraries required for linking a C++ library
765# with a Fortran or C compiler.  The result is available in CXXLIBS.
766
767AC_DEFUN([AC_COIN_CXXLIBS],
768[AC_REQUIRE([AC_PROG_CXX])dnl
769AC_LANG_PUSH(C++)
770AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with Fortran compiler])
771if test -z "$CXXLIBS"; then
772  if test "$GXX" = "yes"; then
773    case "$CXX" in
774      icpc* | */icpc*)
775        CXXLIBS="-lstdc++"
776        ;;
777      *)
778        CXXLIBS="-lstdc++ -lm" # -lgcc"
779        ;;
780    esac
781  else
782    case $build in
783     *-mingw32 | *-cygwin* )
784      case "$CXX" in
785      cl* | */cl* | CL* | */CL*)
786        CXXLIBS=nothing;;
787      esac;;
788     *-linux-*)
789      case "$CXX" in
790      icpc* | */icpc*)
791        CXXLIBS="-lstdc++"
792             ;;
793      pgCC* | */pgCC*)
794        CXXLIBS="-lstd -lC -lc"
795             ;;
796      esac;;
797    *-ibm-*)
798      CXXLIBS="-lC -lc"
799      ;;
800    *-hp-*)
801      CXXLIBS="-L/opt/aCC/lib -l++ -lstd_v2 -lCsup_v2 -lm -lcl -lc"
802      ;;
803    *-*-solaris*)
804      CXXLIBS="-lCstd -lCrun"
805    esac
806  fi
807fi
808if test -z "$CXXLIBS"; then
809  AC_MSG_WARN([Could not automatically determine CXXLIBS (C++ link libraries; necessary if main program is in Fortran or C).])
810else
811  AC_MSG_NOTICE([Assuming that CXXLIBS is \"$CXXLIBS\".])
812fi
813if test x"$CXXLIBS" = xnothing; then
814  CXXLIBS=
815fi
816AC_LANG_POP(C++)
817]) # AC_COIN_CXXLIBS
818
819###########################################################################
820#                           COIN_CHECK_HEADER                             #
821###########################################################################
822
823# This macro checks for a header file, but it does so without the
824# standard header.  This avoids warning messages like:
825#
826# configure: WARNING: dlfcn.h: present but cannot be compiled
827# configure: WARNING: dlfcn.h:     check for missing prerequisite headers?
828# configure: WARNING: dlfcn.h: see the Autoconf documentation
829# configure: WARNING: dlfcn.h:     section "Present But Cannot Be Compiled"
830# configure: WARNING: dlfcn.h: proceeding with the preprocessor's result
831# configure: WARNING: dlfcn.h: in the future, the compiler will take precedence
832
833# My guess that the problem lay with CPPFLAGS seems to be correct. With this
834# macro reduced to a direct call to AC_CHECK_HEADERS, there are no warnings
835# now that CPPFLAGS contains -mno-cygwin when it needs it. -- lh, 061214 --
836
837# AW 070609: I restored the previous version, since otherwise the warnings
838# still pop up for the cl compiler
839
840AC_DEFUN([AC_COIN_CHECK_HEADER],
841[#if test x"$4" = x; then
842#  hdr="#include <$1>"
843#else
844#  hdr="$4"
845#fi
846#AC_CHECK_HEADERS([$1],[$2],[$3],[$hdr])
847AC_CHECK_HEADERS([$1],[$2],[$3],[$4])
848]) # AC_COIN_CHECK_HEADER
849
850###########################################################################
851#                       COIN_CHECK_CXX_CHEADER                             #
852###########################################################################
853
854# This macro checks for C header files that are used from C++.  For a give
855# stub (e.g., math), it first checks if the C++ library (cmath) is available.
856# If it is, it defines HAVE_CMATH (or whatever the stub is).  If it is not
857# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
858# if that one exists.
859
860AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
861[AC_LANG_PUSH(C++)
862AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
863if test "$ac_cv_header_c$1" != "yes"; then
864  AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
865fi
866AC_LANG_POP(C++)
867]) # AC_COIN_CHECK_CXX_CHEADER
868
869###########################################################################
870#                             COIN_PROG_CC                                #
871###########################################################################
872
873# Find the compile command by running AC_PROG_CC (with compiler names
874# for different operating systems) and put it into CC (unless it was
875# given my the user), and find an appropriate value for CFLAGS.  It is
876# possible to provide additional -D flags in the variable CDEFS.
877
878AC_DEFUN([AC_COIN_PROG_CC],
879[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
880AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
881AC_LANG_PUSH(C)
882
883# For consistency, we set the C compiler to the same value of the C++
884# compiler, if the C++ is set, but the C compiler isn't (only for CXX=cl)
885if test x"$CXX" != x; then
886  case "$CXX" in
887    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
888      if test x"$CC" = x; then
889        CC="$CXX"
890        AC_MSG_WARN([C++ compiler name provided as $CXX, but CC is unset. Setting CC to $CXX])
891      fi
892      ;;
893  esac
894fi
895
896AC_ARG_VAR(CDEFS,[Additional -D flags to be used when compiling C code.])
897AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options])
898AC_ARG_VAR(DBG_CFLAGS,[Debug C compiler options])
899AC_ARG_VAR(OPT_CFLAGS,[Optimize C compiler options])
900
901coin_has_cc=yes
902
903save_cflags="$CFLAGS"
904
905# For *-*-solaris*, promote Studio/Workshop cc compiler to front of list.
906# Depending on the user's PATH, when Studio/Workshop cc is not present we may
907# find /usr/ucb/cc, which is almost certainly not a good choice for the C
908# compiler. In this case, put cc after gcc.
909
910case $build in
911  *-cygwin* | *-mingw*)
912             if test "$enable_doscompile" = msvc ; then
913               comps="icl cl"
914             else
915               comps="gcc cl"
916             fi ;;
917  *-*-solaris*)
918             AC_CHECK_PROG(sol_cc_compiler,cc,cc,[],[],/usr/ucb/cc)
919             if test "$sol_cc_compiler" = "cc" ; then
920               comps="cc xlc gcc pgcc icc"
921             else
922               comps="xlc gcc pgcc icc cc"
923             fi
924             ;;
925  *-linux-*) comps="xlc gcc cc pgcc icc" ;;
926  *)         comps="xlc_r xlc cc gcc pgcc icc" ;;
927esac
928
929# We delete the cached value, since the test might not have been
930# performed with our choice of compilers earlier
931$as_unset ac_cv_prog_CC || test "${ac_cv_prog_CC+set}" != set || { ac_cv_prog_CC=; export ac_cv_prog_CC; }
932# AC_MSG_NOTICE([C compiler candidates: $comps])
933AC_PROG_CC([$comps])
934if test -z "$CC" ; then
935  AC_MSG_ERROR([Failed to find a C compiler!])
936fi
937# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
938case "$CC" in
939  cl* | */cl* | CL* | */CL* )
940    if test "$ac_cv_prog_cc_g" = yes ; then
941      ac_cv_prog_cc_g=no
942      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
943    fi ;;
944esac
945CFLAGS="$save_cflags"
946
947# Check if a project specific CFLAGS variable has been set
948if test x$COIN_PRJCT != x; then
949  eval coin_tmp=\${${COIN_PRJCT}_CFLAGS+set}
950  if test x$coin_tmp = xset; then
951    eval CFLAGS=\${${COIN_PRJCT}_CFLAGS}
952  fi
953fi
954
955if test x"$CFLAGS" = x; then
956
957  coin_add_cflags=
958  coin_opt_cflags=
959  coin_dbg_cflags=
960  coin_warn_cflags=
961
962  if test "$GCC" = "yes"; then
963    case "$CC" in
964      icc* | */icc*)
965        ;;
966      *)
967        coin_opt_cflags="-O3 -fomit-frame-pointer"
968        coin_add_cflags="-pipe"
969        coin_dbg_cflags="-g"
970        coin_warn_cflags="-Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall -Wno-unknown-pragmas"
971        case $build in
972          *-darwin*)
973            ;;
974          *)
975            coin_warn_cflags="-pedantic-errors $coin_warn_cflags"
976            ;;
977        esac
978        case $enable_doscompile in
979          mingw)
980            CFLAGS="-mno-cygwin"
981            AC_TRY_LINK([],[int i=0; i++;],
982                        [coin_add_cflags="-mno-cygwin $coin_add_cflags"])
983            CFLAGS=
984          ;;
985        esac
986    esac
987  fi
988  if test -z "$coin_opt_cflags"; then
989    case $build in
990      *-cygwin* | *-mingw*)
991        case "$CC" in
992          cl* | */cl* | CL* | */CL*)
993            coin_opt_cflags='-MT -O2'
994            coin_add_cflags='-nologo -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
995            coin_dbg_cflags='-MTd'
996            ;;
997          icl* | */icl* | ICL* | */ICL*)
998            coin_opt_cflags='-MT -Ox'
999            coin_add_cflags='-nologo -D_CRT_SECURE_NO_DEPRECATE'
1000            coin_dbg_cflags='-MTd -debug'
1001            ;;
1002        esac
1003        ;;
1004      *-linux-*)
1005        case "$CC" in
1006          icc* | */icc*)
1007            coin_opt_cflags="-O3 -ip -mp1"
1008            coin_add_cflags=""
1009            coin_dbg_cflags="-g"
1010            # Check if -i_dynamic is necessary (for new glibc library)
1011            CFLAGS=
1012            AC_TRY_LINK([],[int i=0; i++;],[],
1013                        [coin_add_cflags="-i_dynamic $coin_add_cflags"])
1014            ;;
1015          pgcc* | */pgcc*)
1016            coin_opt_cflags="-fast"
1017            coin_add_cflags="-Kieee -pc 64"
1018            coin_dbg_cflags="-g"
1019            ;;
1020        esac
1021        ;;
1022      *-ibm-*)
1023        case "$CC" in
1024          xlc* | */xlc* | mpxlc* | */mpxlc*)
1025            coin_opt_cflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
1026            coin_add_cflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
1027            coin_dbg_cflags="-g"
1028          ;;
1029        esac
1030        ;;
1031      *-hp-*)
1032        coin_opt_cflags="-O"
1033        coin_add_cflags="-Ae"
1034        coin_dbg_cflags="-g"
1035        ;;
1036      *-*-solaris*)
1037        coin_opt_cflags="-xO4"
1038        coin_dbg_cflags="-g"
1039        ;;
1040      *-sgi-*)
1041        coin_opt_cflags="-O -OPT:Olimit=0"
1042        coin_dbg_cflags="-g"
1043        ;;
1044    esac
1045  fi
1046
1047  if test "$ac_cv_prog_cc_g" = yes && test -z "$coin_dbg_cflags" ; then
1048    coin_dbg_cflags="-g"
1049  fi
1050
1051  if test -z "$coin_opt_cflags"; then
1052    # Try if -O option works if nothing else is set
1053    CFLAGS="-O"
1054    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cflags="-O"])
1055  fi
1056
1057  # if PM doesn't want the warning messages, take them out
1058  if test x"$coin_skip_warn_cflags" = xyes; then
1059    coin_warn_cflags=
1060  fi
1061
1062  if test x${DBG_CFLAGS+set} != xset; then
1063    DBG_CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
1064  fi
1065  if test x${OPT_CFLAGS+set} != xset; then
1066    OPT_CFLAGS="$coin_opt_cflags $coin_add_cflags -DNDEBUG $coin_warn_cflags"
1067  fi
1068
1069  DBG_CFLAGS="$DBG_CFLAGS $ADD_CFLAGS $CDEFS"
1070  OPT_CFLAGS="$OPT_CFLAGS $ADD_CFLAGS $CDEFS"
1071
1072  if test "$coin_debug_compile" = "true"; then
1073    CFLAGS="$DBG_CFLAGS"
1074  else
1075    CFLAGS="$OPT_CFLAGS"
1076  fi
1077else
1078  CFLAGS="$CFLAGS $ADD_CFLAGS $CDEFS"
1079  if test x${DBG_CFLAGS+set} != xset; then
1080    DBG_CFLAGS="$CFLAGS"
1081  fi
1082  if test x${OPT_CFLAGS+set} != xset; then
1083    OPT_CFLAGS="$CFLAGS"
1084  fi
1085fi
1086
1087# If CFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
1088
1089case "$CFLAGS" in
1090  *-mno-cygwin*)
1091    if test x${CPPFLAGS+set} != xset ; then
1092      CPPFLAGS="-mno-cygwin"
1093    else
1094      case "$CPPFLAGS" in
1095        *-mno-cygwin*)
1096          ;;
1097        *)
1098          CPPFLAGS="$CPPFLAGS -mno-cygwin"
1099          ;;
1100      esac
1101    fi ;;
1102esac
1103
1104# Try if CFLAGS works
1105save_CFLAGS="$CFLAGS"
1106AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
1107if test -z "$CFLAGS"; then
1108  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.])
1109  CFLAGS='-O'
1110  AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
1111  if test -z "$CFLAGS"; then
1112    AC_MSG_WARN([This value for CFLAGS does not work.  I will continue with empty CFLAGS, but you might want to set CFLAGS manually.])
1113  fi
1114fi
1115
1116AC_MSG_NOTICE([C compiler options are: $CFLAGS])
1117
1118AC_ARG_VAR(MPICC,[C MPI Compiler])
1119if test x"$MPICC" = x; then :; else
1120  AC_MSG_NOTICE([Will use MPI C compiler $MPICC])
1121  CC="$MPICC"
1122fi
1123
1124# Correct ADDLIBS initialization if we are using the MS compiler
1125case "$CC" in
1126  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1127    ADDLIBS=
1128    AC_COIN_MINGW_LD_FIX
1129    ;;
1130esac
1131
1132AC_LANG_POP(C)
1133]) # AC_COIN_PROG_CC
1134
1135###########################################################################
1136#                             COIN_PROG_F77                               #
1137###########################################################################
1138
1139# Find the compile command by running AC_PROG_F77 (with compiler names
1140# for different operating systems) and put it into F77 (unless it was
1141# given by the user), and find an appropriate value for FFLAGS
1142
1143AC_DEFUN([AC_COIN_PROG_F77],
1144[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
1145AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1146AC_REQUIRE([AC_COIN_PROG_CC])
1147AC_REQUIRE([AC_COIN_F77_COMPS])
1148AC_LANG_PUSH([Fortran 77])
1149
1150AC_ARG_VAR(ADD_FFLAGS,[Additional Fortran compiler options])
1151AC_ARG_VAR(DBG_FFLAGS,[Debug Fortran compiler options])
1152AC_ARG_VAR(OPT_FFLAGS,[Optimize Fortran compiler options])
1153
1154coin_has_f77=yes
1155
1156save_fflags="$FFLAGS"
1157
1158# We delete the cached value, since the test might not have been
1159# performed with our choice of compilers earlier
1160$as_unset ac_cv_prog_F77 || test "${ac_cv_prog_F77+set}" != set || { ac_cv_prog_F77=; export ac_cv_prog_F77; }
1161
1162# This is a real belt-and-suspenders approach. AC_COIN_FIND_F77 will use
1163# coin_f77_comps to see if there's a program that matches one of the names.
1164# If there's no such program, F77 = unavailable. If we match the name,
1165# feed AC_PROG_F77 the same search list, just to be sure it's a functioning
1166# compiler.
1167# AC_MSG_NOTICE([Fortran compiler candidates: $coin_f77_comps])
1168AC_COIN_FIND_F77
1169if test "$F77" != "unavailable" ; then
1170  AC_PROG_F77($coin_f77_comps)
1171else
1172  AC_MSG_WARN([Failed to find a Fortran compiler!])
1173fi
1174
1175FFLAGS="$save_fflags"
1176
1177# Check if a project specific FFLAGS variable has been set
1178if test x$COIN_PRJCT != x; then
1179  eval coin_tmp=\${${COIN_PRJCT}_FFLAGS+set}
1180  if test x$coin_tmp = xset; then
1181    eval FFLAGS=\${${COIN_PRJCT}_FFLAGS}
1182  fi
1183fi
1184
1185if test "$F77" != "unavailable" && test x"$FFLAGS" = x ; then
1186
1187  coin_add_fflags=
1188  coin_opt_fflags=
1189  coin_dbg_fflags=
1190  coin_warn_fflags=
1191
1192  if test "$G77" = "yes"; then
1193    coin_opt_fflags="-O3 -fomit-frame-pointer"
1194    coin_add_fflags="-pipe"
1195    coin_dbg_fflags="-g"
1196    case $enable_doscompile in
1197      mingw)
1198        FFLAGS="-mno-cygwin"
1199        AC_TRY_LINK(,[      write(*,*) 'Hello world'],
1200                    [coin_add_fflags="-mno-cygwin $coin_add_fflags"])
1201        FFLAGS=
1202      ;;
1203    esac
1204  else
1205    case $build in
1206      *-cygwin* | *-mingw*)
1207        case $F77 in
1208          ifort* | */ifort* | IFORT* | */IFORT* )
1209            coin_opt_fflags='-MT -O3'
1210            coin_add_fflags='-fpp -nologo'
1211            coin_dbg_fflags='-MTd -debug'
1212          ;;
1213          compile_f2c*)
1214            coin_opt_fflags='-MT -O2'
1215            coin_add_fflags='-nologo -wd4996'
1216            coin_dbg_fflags='-MTd'
1217          ;;
1218        esac
1219        ;;
1220      *-linux-*)
1221        case $F77 in
1222          ifc* | */ifc* | ifort* | */ifort*)
1223            coin_opt_fflags="-O3 -ip"
1224            coin_add_fflags="-cm -w90 -w95"
1225            coin_dbg_fflags="-g -CA -CB -CS"
1226            # Check if -i_dynamic is necessary (for new glibc library)
1227            FFLAGS=
1228            AC_TRY_LINK(,[      write(*,*) 'Hello world'],[],
1229                        [coin_add_fflags="-i_dynamic $coin_add_fflags"])
1230            ;;
1231          pgf77* | */pgf77* | pgf90* | */pgf90*)
1232            coin_opt_fflags="-fast"
1233            coin_add_fflags="-Kieee -pc 64"
1234            coin_dbg_fflags="-g"
1235          ;;
1236        esac
1237        ;;
1238      *-ibm-*)
1239        case "$F77" in
1240          xlf* | */xlf* | mpxlf* | */mpxlf* )
1241            coin_opt_fflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
1242            coin_add_fflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
1243            coin_dbg_fflags="-g -C"
1244            ;;
1245        esac
1246        ;;
1247      *-hp-*)
1248        coin_opt_fflags="+O3"
1249        coin_add_fflags="+U77"
1250        coin_dbg_fflags="-C -g"
1251        ;;
1252      *-*-solaris*)
1253        coin_opt_fflags="-O4"
1254        coin_dbg_fflags="-g"
1255        ;;
1256      *-sgi-*)
1257        coin_opt_fflags="-O5 -OPT:Olimit=0"
1258        coin_dbg_fflags="-g"
1259        ;;
1260    esac
1261  fi
1262
1263  if test "$ac_cv_prog_f77_g" = yes && test -z "$coin_dbg_fflags" ; then
1264    coin_dbg_fflags="-g"
1265  fi
1266
1267  if test -z "$coin_opt_fflags"; then
1268    # Try if -O option works if nothing else is set
1269    FFLAGS=-O
1270    AC_TRY_LINK(,[      integer i], [coin_opt_fflags="-O"])
1271  fi
1272
1273  # if PM doesn't want the warning messages, take them out
1274  if test x"$coin_skip_warn_fflags" = xyes; then
1275    coin_warn_fflags=
1276  fi
1277
1278  if test x${DBG_FFLAGS+set} != xset; then
1279    DBG_FFLAGS="$coin_dbg_fflags $coin_add_fflags $coin_warn_fflags"
1280  fi
1281  if test x${OPT_FFLAGS+set} != xset; then
1282    OPT_FFLAGS="$coin_opt_fflags $coin_add_fflags $coin_warn_fflags"
1283  fi
1284
1285  DBG_FFLAGS="$DBG_FFLAGS $ADD_FFLAGS"
1286  OPT_FFLAGS="$OPT_FFLAGS $ADD_FFLAGS"
1287
1288  if test "$coin_debug_compile" = "true"; then
1289    FFLAGS="$DBG_FFLAGS"
1290  else
1291    FFLAGS="$OPT_FFLAGS"
1292  fi
1293else
1294  FFLAGS="$FFLAGS $ADD_FFLAGS"
1295  if test x${DBG_FFLAGS+set} != xset; then
1296    DBG_FFLAGS="$FFLAGS"
1297  fi
1298  if test x${OPT_FFLAGS+set} != xset; then
1299    OPT_FFLAGS="$FFLAGS"
1300  fi
1301fi
1302
1303# If FFLAGS contains -mno-cygwin, CPPFLAGS must have it.
1304case "$FFLAGS" in
1305  *-mno-cygwin*)
1306    if test x${CPPFLAGS+set} != xset ; then
1307      CPPFLAGS="-mno-cygwin"
1308    else
1309      case "$CPPFLAGS" in
1310        *-mno-cygwin*)
1311          ;;
1312        *)
1313          CPPFLAGS="$CPPFLAGS -mno-cygwin"
1314          ;;
1315      esac
1316    fi ;;
1317esac
1318
1319# Try if FFLAGS works
1320if test "$F77" != "unavailable" ; then
1321  AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1322  if test -z "$FFLAGS"; then
1323    AC_MSG_WARN([The flags FFLAGS="$FFLAGS" do not work.  I will now just try '-O', but you might want to set FFLAGS manually.])
1324    FFLAGS='-O'
1325    AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1326    if test -z "$FFLAGS"; then
1327      AC_MSG_WARN([This value for FFLAGS does not work.  I will continue with empty FFLAGS, but you might want to set FFLAGS manually.])
1328    fi
1329  fi
1330fi
1331
1332AC_MSG_NOTICE([Fortran compiler options are: $FFLAGS])
1333
1334AC_ARG_VAR(MPIF77,[Fortran MPI Compiler])
1335if test x"$MPIF77" = x; then :; else
1336  AC_MSG_NOTICE([Will use MPI Fortran compiler $MPIF77])
1337  F77="$MPIF77"
1338fi
1339
1340case "$F77" in
1341  ifort* | */ifort* | IFORT* | */IFORT*)
1342    AC_COIN_MINGW_LD_FIX
1343    ;;
1344esac
1345
1346AC_LANG_POP([Fortran 77])
1347]) # AC_COIN_PROG_F77
1348
1349###########################################################################
1350#                           COIN_F77_WRAPPERS                             #
1351###########################################################################
1352
1353# Calls autoconfs AC_F77_WRAPPERS and does additional corrections to FLIBS
1354
1355AC_DEFUN([AC_COIN_F77_WRAPPERS],
1356[AC_BEFORE([AC_COIN_PROG_F77],[$0])dnl
1357AC_BEFORE([AC_PROG_F77],[$0])dnl
1358
1359AC_LANG_PUSH([Fortran 77])
1360
1361save_FLIBS="$FLIBS"
1362
1363AC_F77_WRAPPERS
1364
1365if test x"$save_FLIBS" != x; then
1366  FLIBS="$save_FLIBS"
1367else
1368  # This is to correct a missing exclusion in autoconf 2.59
1369  if test x"$FLIBS" != x; then
1370    my_flibs=
1371    for flag in $FLIBS; do
1372      case $flag in
1373        -lcrt*.o) ;;
1374               *) my_flibs="$my_flibs $flag" ;;
1375      esac
1376    done
1377    FLIBS="$my_flibs"
1378  fi
1379
1380  case $build in
1381  # The following is a fix to define FLIBS for ifort on Windows
1382  # In its original version, it linked in libifcorert.lib or libifcorertd.lib on Windows/ifort explicitly.
1383  # However, this seem to create a dependency on libifcorert.dll (or libifcorertd.dll) in the executables.
1384  # This is seem to be unnecessary, libifcorert(d).lib has been removed from the link line.
1385     *-cygwin* | *-mingw*)
1386       case "$F77" in
1387         ifort* | */ifort* | IFORT* | */IFORT*)
1388           FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib"
1389#           if "$coin_debug_compile" = true ; then
1390#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib"
1391#           else
1392#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib"
1393#           fi
1394           ;;
1395         compile_f2c*)
1396           FLIBS=`$F77 -FLIBS` ;;
1397       esac;;
1398     *-hp-*)
1399         FLIBS="$FLIBS -lm";;
1400     *-ibm-*)
1401         FLIBS=`echo $FLIBS | sed 's/-lc)/-lc/g'` ;;
1402     *-linux-*)
1403       case "$F77" in
1404         pgf77* | */pgf77* | pgf90* | */pgf90*)
1405# ask linker to go through the archives multiple times
1406# (the Fortran compiler seems to do that automatically...
1407           FLIBS="-Wl,--start-group $FLIBS -Wl,--end-group" ;;
1408       esac
1409  esac
1410  ac_cv_f77_libs="$FLIBS"
1411fi
1412
1413AC_LANG_POP([Fortran 77])
1414
1415]) # AC_COIN_F77_WRAPPERS
1416
1417###########################################################################
1418#                             COIN_FIND_F77                               #
1419###########################################################################
1420
1421# Attempt to preempt autoconf by locating an appropriate F77 program. This
1422# macro will not trigger a fatal error if a suitable compiler cannot be
1423# found. It should be called before COIN_PROG_F77 or COIN_TRY_FLINK.
1424
1425AC_DEFUN([AC_COIN_FIND_F77],
1426[AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1427AC_REQUIRE([AC_COIN_F77_COMPS])
1428AC_MSG_NOTICE([Trying to determine Fortran compiler name])
1429AC_CHECK_PROGS([F77],[$coin_f77_comps],[unavailable])
1430])
1431
1432# Auxilliary macro to make sure both COIN_PROG_F77 and COIN_FIND_F77 use
1433# the same search lists for compiler names.
1434# For *-*-solaris*, promote Studio/Workshop compilers to front of list.
1435AC_DEFUN([AC_COIN_F77_COMPS],
1436[case $build in
1437  *-cygwin* | *-mingw*)
1438     if test "$enable_doscompile" = msvc ; then
1439       coin_f77_comps="ifort fl32 compile_f2c"
1440     else
1441       coin_f77_comps="gfortran g77 ifort fl32 compile_f2c"
1442     fi ;;
1443  *-*-solaris*)
1444     coin_f77_comps="f95 f90 f77 xlf_r fort77 gfortran g77 pgf90 pgf77 ifort ifc frt af77" ;;
1445  *) coin_f77_comps="xlf_r fort77 gfortran f77 g77 pgf90 pgf77 ifort ifc frt af77" ;;
1446 esac
1447])
1448
1449###########################################################################
1450#                          COIN_INIT_AUTOMAKE                             #
1451###########################################################################
1452
1453# This macro calls the regular INIT_AUTOMAKE and MAINTAINER_MODE
1454# macros, and defines additional variables and makefile conditionals,
1455# that are used in the maintainer parts of the makfile.  It also
1456# checks if the correct versions of the autotools are used.
1457#
1458# This also defines the AC_SUBST variables:
1459# abs_source_dir     absolute path to source code for this package
1460# abs_bin_dir        absolute path to the directory where binaries are
1461#                    going to be installed (prefix/bin)
1462# abs_lib_dir        absolute path to the directory where libraries are
1463#                    going to be installed (prefix/lib)
1464# abs_include_dir    absolute path to the directory where the header files
1465#                    are installed (prefix/include)
1466
1467AC_DEFUN([AC_COIN_INIT_AUTOMAKE],
1468[AC_REQUIRE([AC_PROG_EGREP])
1469
1470# AC_MSG_NOTICE([Beginning automake initialisation.])
1471# Stuff for automake
1472AM_INIT_AUTOMAKE
1473AM_MAINTAINER_MODE
1474
1475coin_have_externals=no
1476if test "$enable_maintainer_mode" = yes; then
1477
1478  # If maintainer mode is chosen, we make sure that the correct versions
1479  # of the tools are used, and that we know where libtool.m4 is (to
1480  # recreate acinclude.m4)
1481
1482  AC_SUBST(LIBTOOLM4)
1483  LIBTOOLM4=
1484  # Normally, $HOME
1485  AUTOTOOLS_DFLT=$HOME
1486
1487  AC_CACHE_CHECK([whether we are using the correct autotools],
1488                 [ac_cv_use_correct_autotools],
1489                 [ac_cv_use_correct_autotools=check])
1490
1491  if test $ac_cv_use_correct_autotools = check; then
1492    ac_cv_use_correct_autotools=yes
1493    # Check if we have autoconf
1494    AC_CHECK_PROG([have_autoconf],[autoconf],[yes],[no])
1495    if test $have_autoconf = no; then
1496      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find autoconf in your path.])
1497    fi
1498
1499    # Check whether autoconf is the correct version
1500    correct_version='2.59'
1501    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1502    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of autoconf])
1503    autoconf --version > confauto.out 2>&1
1504    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1505      AC_MSG_RESULT([yes])
1506    else
1507      rm -f confauto.out
1508      AC_MSG_RESULT([no])
1509      AC_MSG_ERROR([You don't have the correct version of autoconf as the first one in your path.])
1510    fi
1511    rm -f confauto.out
1512
1513    # Check if the executable autoconf is picked up from the correct location
1514    AC_MSG_CHECKING([whether autoconf is coming from the correct location])
1515    autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
1516    autoconf_dir=`cd $autoconf_dir; pwd`
1517    if test x$AUTOTOOLS_DIR = x; then
1518      want_dir=$AUTOTOOLS_DFLT/bin
1519    else
1520      want_dir=$AUTOTOOLS_DIR/bin
1521    fi
1522    if test $autoconf_dir = `cd $want_dir; pwd`; then
1523      AC_MSG_RESULT([yes])
1524    else
1525      rm -f confauto.out
1526      AC_MSG_RESULT([no])
1527      AC_MSG_ERROR([The autoconf executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1528    fi
1529
1530    # Check if we have automake
1531    AC_CHECK_PROG([have_automake],[automake],[yes],[no])
1532    if test $have_automake = no; then
1533      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find automake in your path.])
1534    fi
1535 
1536    # Check whether automake is the correct version
1537    correct_version='1.9.6'
1538    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1539    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of automake])
1540    automake --version > confauto.out 2>&1
1541    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1542      AC_MSG_RESULT([yes])
1543    else
1544      rm -f confauto.out
1545      AC_MSG_RESULT([no])
1546      AC_MSG_ERROR([You don't have the correct version of automake as the first one in your path.])
1547    fi
1548    rm -f confauto.out
1549
1550    # Check if the executable automake is picked up from the correct location
1551    AC_MSG_CHECKING([whether automake is coming from the correct location])
1552    automake_dir=`which automake | sed -e 's=/automake=='`
1553    automake_dir=`cd $automake_dir; pwd`
1554    if test x$AUTOTOOLS_DIR = x; then
1555      want_dir=$AUTOTOOLS_DFLT/bin
1556    else
1557      want_dir=$AUTOTOOLS_DIR/bin
1558    fi
1559    if test $automake_dir = `cd $want_dir; pwd`; then
1560      AC_MSG_RESULT([yes])
1561    else
1562      rm -f confauto.out
1563      AC_MSG_RESULT([no])
1564      AC_MSG_ERROR([The automake executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1565    fi
1566
1567    # Check if this is the correct version of libtool (with escaped dots)
1568    if test x$AUTOTOOLS_DIR = x; then
1569      want_dir=$AUTOTOOLS_DFLT/share
1570    else
1571      want_dir=$AUTOTOOLS_DIR/share
1572    fi
1573    correct_version='1.5.22'
1574    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1575    AC_COIN_CHECK_FILE([$want_dir/libtool/ltmain.sh],
1576                       [have_ltmain=yes],
1577                       [have_ltmain=no])
1578    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of libtool.])
1579    if test $have_ltmain = yes; then
1580    if $EGREP $grep_version $want_dir/libtool/ltmain.sh >/dev/null 2>&1; then
1581        AC_MSG_RESULT([yes])
1582      else
1583        AC_MSG_RESULT([no])
1584        AC_MSG_ERROR([You don't have the correct version of libtool.])
1585      fi
1586    else
1587      AC_MSG_RESULT([no])
1588      AC_MSG_ERROR([I cannot find the ltmain.sh file.])
1589    fi
1590  fi
1591
1592  # Check if we can find the libtool file
1593  if test x$AUTOTOOLS_DIR = x; then
1594    want_dir=$AUTOTOOLS_DFLT/share
1595  else
1596    want_dir=$AUTOTOOLS_DIR/share
1597  fi
1598  AC_COIN_CHECK_FILE([$want_dir/aclocal/libtool.m4],
1599                     [LIBTOOLM4="$want_dir/aclocal/libtool.m4"],
1600                     [AC_MSG_ERROR([I cannot find the libtool.m4 file.])])
1601
1602  # Check if we have an Externals file
1603  if test -r $srcdir/Externals; then
1604    coin_have_externals=yes
1605  fi
1606  # Check if subversion is installed and understands https
1607  AC_CHECK_PROG([have_svn],[svn],[yes],[no])
1608  if test x$have_svn = xyes; then
1609    AC_CACHE_CHECK([whether svn understands https],
1610                   [ac_cv_svn_understands_https],
1611                   [svn --version > confauto.out 2>&1
1612                    if $EGREP https confauto.out >/dev/null 2>&1; then
1613                      ac_cv_svn_understands_https=yes
1614                    else
1615                      ac_cv_svn_understands_https=no
1616                      have_svn=no
1617                      ac_cv_prog_have_svn=no
1618                    fi
1619                    rm -f confauto.out])
1620  fi
1621
1622  # Find the location of the BuildTools directory
1623  BUILDTOOLSDIR=
1624  if test -r $srcdir/BuildTools/coin.m4; then
1625    BUILDTOOLSDIR=$srcdir/BuildTools
1626  else
1627    if test -r $srcdir/../BuildTools/coin.m4; then
1628      BUILDTOOLSDIR=$srcdir/../BuildTools
1629    else
1630      if test -r $srcdir/../../BuildTools/coin.m4; then
1631        BUILDTOOLSDIR=$srcdir/../../BuildTools
1632      else
1633        AC_MSG_ERROR(Cannot find the BuildTools directory)
1634      fi
1635    fi
1636  fi
1637  AC_SUBST(BUILDTOOLSDIR)
1638
1639  # The following variable is set to the name of the directory where
1640  # the autotool scripts are located
1641  AC_SUBST(AUX_DIR)
1642  AUX_DIR=$ac_aux_dir
1643fi
1644
1645# helpful variable for the base directory of this package
1646abs_source_dir=`cd $srcdir; pwd`
1647AC_SUBST(abs_source_dir)
1648
1649# Stuff for example Makefiles
1650if test x$prefix = xNONE; then
1651  full_prefix=$ac_default_prefix
1652else
1653  full_prefix=$prefix
1654fi
1655full_prefix=`cd $full_prefix ; pwd`
1656AC_SUBST(abs_lib_dir)
1657abs_lib_dir=$full_prefix/lib
1658AC_SUBST(abs_include_dir)
1659abs_include_dir=$full_prefix/include
1660AC_SUBST(abs_bin_dir)
1661abs_bin_dir=$full_prefix/bin
1662
1663AM_CONDITIONAL(HAVE_EXTERNALS,
1664               test $coin_have_externals = yes && test x$have_svn = xyes)
1665
1666# AC_MSG_NOTICE([End automake initialisation.])
1667
1668]) # AC_COIN_INIT_AUTOMAKE
1669
1670###########################################################################
1671#                          COIN_CREATE_LIBTOOL                            #
1672###########################################################################
1673
1674# This does all the tests necessary to create the libtool script in the
1675# package base directory.  If this is used, then the COIN_INIT_AUTO_TOOLS
1676# test in the subdirectories will be able to skip the libtool tests and
1677# just use the one in the package base directory.
1678
1679m4_define([AC_COIN_CREATE_LIBTOOL],
1680[AC_CANONICAL_BUILD
1681
1682# Check if user wants to produce debugging code
1683AC_COIN_DEBUG_COMPILE
1684
1685# Get the name of the C compiler and appropriate compiler options
1686AC_COIN_PROG_CC
1687
1688# Get the name of the C++ compiler and appropriate compiler options
1689AC_COIN_PROG_CXX
1690
1691# Get the name of the Fortran compiler and appropriate compiler options
1692AC_COIN_PROG_F77
1693
1694# Initialize automake and libtool
1695# AC_MSG_NOTICE([Calling INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1696AC_COIN_INIT_AUTO_TOOLS
1697# AC_MSG_NOTICE([Finished INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1698])
1699
1700###########################################################################
1701#                         COIN_INIT_AUTO_TOOLS                            #
1702###########################################################################
1703
1704# Initialize the auto tools automake and libtool, with all
1705# modifications we want for COIN packages.
1706#
1707# RPATH_FLAGS        link flags for hardcoding path to shared objects
1708
1709# This is a trick to have this code before AC_COIN_PROG_LIBTOOL
1710AC_DEFUN([AC_COIN_DISABLE_STATIC],
1711[
1712# Test if force_shared has been set
1713if test "x$1" = xforce_shared; then
1714  if test x$enable_shared = xno; then
1715    AC_MSG_ERROR([Shared libraries are disabled by user, but this is not feasible with the given options])
1716  fi
1717  enable_shared=yes;
1718else
1719  # On Cygwin and AIX, building DLLs doesn't work
1720  case $build in
1721    *-cygwin*)
1722      coin_disable_shared=yes
1723      platform=Cygwin
1724    ;;
1725    *-aix*)
1726      coin_disable_shared=yes
1727      platform=AIX
1728    ;;
1729    *-mingw*)
1730      coin_disable_shared=yes
1731      platform="Msys"
1732#      case "$CXX" in
1733#        cl*)
1734#          coin_disable_shared=yes
1735#          platform="Msys with cl"
1736#      ;;
1737#      esac
1738    ;;
1739  esac
1740fi
1741if test x"$coin_disable_shared" = xyes; then
1742  if test x"$enable_shared" = xyes; then
1743    AC_MSG_WARN([On $platform, shared objects are not supported. I'm disabling your choice.])
1744  fi
1745  enable_shared=no
1746fi
1747# By default, we only want the shared objects to be compiled
1748AC_DISABLE_STATIC
1749])
1750
1751m4_define([AC_COIN_INIT_AUTO_TOOLS],
1752[{AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1753AC_BEFORE([AC_COIN_PROG_CC],[$0])
1754AC_BEFORE([AC_COIN_PROG_F77],[$0])
1755
1756# START
1757AC_COIN_DISABLE_STATIC([$1])
1758
1759# Initialize automake
1760AC_COIN_INIT_AUTOMAKE
1761
1762LIBTOOL=
1763if test -r ../libtool; then
1764  coin_config_dir=..
1765  LIBTOOL='$(SHELL) $(top_builddir)/../libtool'
1766fi
1767if test "x$LIBTOOL" = x; then
1768  if test -r ../../libtool; then
1769    coin_config_dir=../..
1770    LIBTOOL='$(SHELL) $(top_builddir)/../../libtool'
1771  fi
1772fi
1773
1774if test "x$LIBTOOL" = x; then
1775# AC_MSG_NOTICE([Creating libtool script (calling COIN_PROG_LIBTOOL).])
1776  # Stuff for libtool
1777  AC_COIN_PROG_LIBTOOL
1778# AC_MSG_NOTICE([Finished COIN_PROG_LIBTOOL.])
1779  # set RPATH_FLAGS to the compiler link flags required to hardcode location
1780  # of the shared objects
1781  AC_COIN_RPATH_FLAGS($abs_lib_dir)
1782
1783else
1784
1785  AC_MSG_NOTICE([Using libtool script in directory $coin_config_dir])
1786  # get all missing information from the config.log file
1787
1788  # output variables and defines
1789  as_save_IFS=$IFS
1790  IFS='
1791'
1792  for oneline in `cat $coin_config_dir/config.status`; do
1793    case "$oneline" in
1794         # First some automake conditionals
1795      s,@am__fastdep* | s,@AR@* | s,@CPP@*  | s,@CPPFLAGS@* | s,@CXXCPP@*  | \
1796      s,@RANLIB@* | s,@STRIP@* | s,@ac_ct_AR@* | s,@ac_ct_RANLIB@* | \
1797      s,@ac_ct_STRIP@* | s,@host* | s,@LN_S@* | s,@RPATH_FLAGS@* | \
1798      s,@ac_c_preproc_warn_flag@* |  s,@ac_cxx_preproc_warn_flag@* )
1799        command=`echo $oneline | sed -e 's/^s,@//' -e 's/@,/="/' -e 's/,;t t/"/'`
1800#        echo "$command"
1801        eval "$command"
1802        ;;
1803      s,@DEFS@* )
1804        command=`echo $oneline | sed -e 's/^s,@DEFS@,/defsline="/' -e 's/,;t t/"/'`
1805#        echo "$command"
1806        eval "$command"
1807        ;;
1808    esac
1809  done
1810  IFS=$as_save_IFS
1811
1812  # And some defines (assuming here that the packages base dir
1813  # doesn't have a config.h file
1814  for word in $defsline; do
1815#    echo word $word
1816    case $word in
1817      -DHAVE_@<:@A-Z_@:>@*_H=1 | -DSTDC_HEADERS=1 )
1818        i=`echo $word | sed -e 's/-D/#define /' -e 's/=/ /'`
1819#        echo dd $i
1820        echo $i >>confdefs.h
1821        ;;
1822    esac
1823  done
1824fi
1825
1826# AC_MSG_NOTICE([End of INIT_AUTO_TOOLS.])
1827
1828# ToDo
1829# For now, don't use the -no-undefined flag, since the Makefiles are
1830# not yet set up that way.  But we need to fix this, when we want
1831# to comile DLLs under Windows.
1832LT_LDFLAGS=
1833AC_SUBST(LT_LDFLAGS)
1834
1835#END
1836}])
1837
1838
1839###########################################################################
1840#                      COIN_PATCH_LIBTOOL_CYGWIN                          #
1841###########################################################################
1842
1843# Patches to libtool for cygwin. Lots for cl, a few for GCC.
1844# For cl:
1845# - cygpath is not correctly quoted in fix_srcfile_path
1846# - paths generated for .lib files is not run through cygpath -w
1847
1848
1849AC_DEFUN([AC_COIN_PATCH_LIBTOOL_CYGWIN],
1850[ case "$CXX" in
1851    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1852      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1853      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1854          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1855          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1856          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1857          -e 's%lib /OUT:%lib -OUT:%' \
1858          -e "s%cygpath -w%$CYGPATH_W%" \
1859          -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%' \
1860          -e 's/$AR t/lib -nologo -list/' \
1861          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1862          -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1863          -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"%' \
1864      libtool > conftest.bla
1865
1866      mv conftest.bla libtool
1867      chmod 755 libtool
1868      ;;
1869    *)
1870      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
1871      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1872          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1873          -e 's|libext="lib"|libext="a"|' \
1874      libtool > conftest.bla
1875
1876      mv conftest.bla libtool
1877      chmod 755 libtool
1878      ;;
1879  esac ]) # COIN_PATCH_LIBTOOL_CYGWIN
1880
1881###########################################################################
1882#                    COIN_PATCH_LIBTOOL_SOLARIS                           #
1883###########################################################################
1884# If we want to do a 64-bit build with GCC on Solaris, the system search
1885# libraries need to point to 64-bit subdirectories. If they do not already do
1886# that, fix them. This patch is evolving, as are GCC compilers.  GCC 4.2.1
1887# reports the correct search list, given the correct call. GCC 4.1.1 does not.
1888# `Correct call' means -m64 is specified. `Correct search list' seems to amount
1889# to prepending the list of 64-bit subdirectories to the 32-bit directories.
1890# Both SPARC and x86 have this issue, but a different hardware id string is
1891# required depending on the underlying CPU. The macro executes isainfo to get
1892# the string. This will fail, of course, if we're cross-compiling. The
1893# alternative is to fail on a regular basis each time a new CPU identifier is
1894# needed. This macro will also fail if the search list reported with
1895# -print-search-dirs differs between the C, C++, and Fortran compilers; each
1896# have their own setting in libtool.  If GCC reports the correct search list
1897# given the -m64 flag, the best solution is to define CC='gcc -m64', and
1898# similarly for CXX, F77, so that libtool will make the correct call.
1899###########################################################################
1900AC_DEFUN([AC_COIN_PATCH_LIBTOOL_SOLARIS],
1901[ if test "$GCC" = yes && \
1902     (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm64' >/dev/null 2>&1) ; then
1903    hdwisa=`isainfo | sed -e 's/\(@<:@^ @:>@*\) .*$/\1/'`
1904    if `$EGREP 'sys_lib_search_path_spec=' libtool | $EGREP -v $hdwisa >/dev/null 2>&1` ; then
1905      AC_MSG_NOTICE([Applying patches to libtool for 64-bit GCC compilation])
1906      fixlibtmp=`$CC -m64 -print-search-dirs | $EGREP '^libraries:'`
1907      fixlibtmp=`echo $fixlibtmp | sed -e 's/libraries: =//' -e 's/:/ /g'`
1908      if `echo "$fixlibtmp" | $EGREP -v $hdwisa  >/dev/null 2>&1` ; then
1909        # AC_MSG_NOTICE(Compensating for broken gcc)
1910        for lib in $fixlibtmp ; do
1911          if test -d "${lib}${hdwisa}" ; then
1912            syslibpath64="$syslibpath64 ${lib}${hdwisa}/"
1913          fi
1914        done
1915        syslibpath64="${syslibpath64} ${fixlibtmp}"
1916      else
1917        syslibpath64="$fixlibtmp"
1918      fi
1919      sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="'"$syslibpath64"'"|' libtool > conftest.bla
1920      mv conftest.bla libtool
1921      chmod 755 libtool 
1922    fi
1923    # AC_MSG_NOTICE(Result is )
1924    # $EGREP 'sys_lib_search_path_spec=' libtool
1925  fi ]) # COIN_PATCH_LIBTOOL_SOLARIS
1926
1927###########################################################################
1928#                           COIN_PROG_LIBTOOL                             #
1929###########################################################################
1930
1931# Setup the libtool stuff together with any modifications to make it
1932# work on additional platforms
1933
1934AC_DEFUN([AC_COIN_LIBTOOL_WRAPPER],
1935[AC_BEFORE([AC_COIN_BLA],[$0])
1936AC_PROG_LIBTOOL])
1937
1938AC_DEFUN([AC_COIN_BLA],[echo bla])
1939
1940AC_DEFUN([AC_COIN_PROG_LIBTOOL],
1941[# No longer needed now that CPPFLAGS is correctly set -- lh, 061214 --
1942 # AC_REQUIRE([AC_COIN_DLFCN_H])
1943
1944# NEW: If libtool exists in the directory higher up, we use that one
1945#      instead of creating a new one
1946
1947# It turns out that the code for AC_PROG_LIBTOOL is somehow AC_REQUIRED
1948# out in front of this macro body. You'll notice that LIBTOOL is already
1949# defined here.  We'll have to count on this macro not being called if libtool
1950# already exists, or at least move the libtool fixes outside the conditional.
1951# AC_MSG_NOTICE([Entering coin_prog_libtool, LIBTOOL = "$LIBTOOL".])
1952# This test is therefore removed.  -- lh, 061214 --
1953# if test "x$LIBTOOL" = x; then
1954
1955# AC_MSG_NOTICE([Calling PROG_LIBTOOL.])
1956  AC_PROG_LIBTOOL
1957# AC_MSG_NOTICE([Finished PROG_LIBTOOL.])
1958  AC_SUBST(ac_c_preproc_warn_flag)
1959  AC_SUBST(ac_cxx_preproc_warn_flag)
1960
1961  AC_MSG_NOTICE([Build is "$build".])
1962  mydos2unix='| dos2unix'
1963  case $build in
1964    *-mingw*)
1965      CYGPATH_W=echo
1966      mydos2unix=
1967      ;;
1968  esac
1969
1970  case $build in
1971    # Here we need to check if -m32 is specified.  If so, we need to correct
1972    # sys_lib_search_path_spec
1973    *x86_64-*)
1974      if test "$GCC" = yes && (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm32' >& /dev/null); then
1975        AC_MSG_NOTICE(Applying patches to libtool for 32bit compilation)
1976        sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="/lib /usr/lib"|' libtool > conftest.bla
1977        mv conftest.bla libtool
1978        chmod 755 libtool 
1979      fi
1980      ;;
1981
1982    *-solaris*)
1983      AC_COIN_PATCH_LIBTOOL_SOLARIS
1984      ;;
1985    # Cygwin. Ah, cygwin. Too big and ugly to inline; see the macro.
1986    *-cygwin* | *-mingw*)
1987      AC_COIN_PATCH_LIBTOOL_CYGWIN
1988      ;;
1989    *-darwin*)
1990      AC_MSG_NOTICE(Applying patches to libtool for Darwin)
1991      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"/' \
1992        -e 's/ -dynamiclib / -dynamiclib -single_module /g' \
1993      libtool > conftest.bla
1994
1995      mv conftest.bla libtool
1996      chmod 755 libtool
1997      ;;
1998  esac
1999# This fi matches the commented `if test "x$LIBTOOL" = x;' up at the head of
2000# the macro. -- lh, 061214 --
2001# fi
2002
2003# AC_MSG_NOTICE([End libtool initialisation.])
2004]) # AC_COIN_PROG_LIBTOOL
2005
2006# This is a trick to force the check for the dlfcn header to be done before
2007# the checks for libtool
2008# No longer needed now that CPPFLAGS is correctly set.  -- lh, 061214 --
2009# ACDEFUN([AC_COIN_DLFCN_H],
2010# [AC_LANG_PUSH(C)
2011# AC_COIN_CHECK_HEADER([dlfcn.h])
2012# AC_LANG_POP(C)
2013# ]) # AC_COIN_DLFCN_H
2014
2015###########################################################################
2016#                            COIN_RPATH_FLAGS                             #
2017###########################################################################
2018
2019# This macro, in case shared objects are used, defines a variable
2020# RPATH_FLAGS that can be used by the linker to hardwire the library
2021# search path for the given directories.  This is useful for example
2022# Makefiles
2023
2024AC_DEFUN([AC_COIN_RPATH_FLAGS],
2025[RPATH_FLAGS=
2026
2027if test $enable_shared = yes; then
2028  case $build in
2029    *-linux-*)
2030      if test "$GXX" = "yes"; then
2031        RPATH_FLAGS=
2032        for dir in $1; do
2033          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
2034        done
2035      fi ;;
2036    *-darwin*)
2037        RPATH_FLAGS=nothing ;;
2038    *-ibm-*)
2039      case "$CXX" in
2040      xlC* | */xlC* | mpxlC* | */mpxlC*)
2041        RPATH_FLAGS=nothing ;;
2042      esac ;;
2043    *-hp-*)
2044        RPATH_FLAGS=nothing ;;
2045    *-mingw32)
2046        RPATH_FLAGS=nothing ;;
2047    *-*-solaris*)
2048        RPATH_FLAGS=
2049        for dir in $1; do
2050          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
2051        done
2052  esac
2053
2054  if test "$RPATH_FLAGS" = ""; then
2055    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.])
2056  fi
2057  if test "$RPATH_FLAGS" = "nothing"; then
2058    RPATH_FLAGS=
2059  fi
2060fi
2061
2062AC_SUBST(RPATH_FLAGS)
2063]) # AC_COIN_RPATH_FLAGS
2064
2065###########################################################################
2066#                        COIN_LINK_INPUT_CMD                              #
2067###########################################################################
2068
2069# This macro determines which command should be used to "link" files
2070# that are input to the generated executables.  On Windows, the codes
2071# using the native Windows system libraries, cannot understand symbolic
2072# links, and a copy should be used instead of 'ln -s'.
2073# The result is stored in coin_link_input_cmd
2074
2075AC_DEFUN([AC_COIN_LINK_INPUT_CMD],
2076[AC_REQUIRE([AC_PROG_LN_S])
2077AC_BEFORE([AC_COIN_PROG_CC], [$0])
2078AC_BEFORE([AC_COIN_ENABLE_DOSCOMPILE], [$0])
2079
2080AC_MSG_CHECKING([which command should be used to link input files])
2081coin_link_input_cmd="$LN_S"
2082if test "$enable_doscompile" = mingw; then
2083  coin_link_input_cmd=cp
2084fi
2085case "$CC" in
2086  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2087    coin_link_input_cmd=cp ;;
2088esac
2089AC_MSG_RESULT($coin_link_input_cmd)
2090])
2091
2092###########################################################################
2093#                              COIN_FINALIZE                              #
2094###########################################################################
2095
2096# This macro should be called at the very end of the configure.ac file.
2097# It creates the output files (by using AC_OUTPUT), and might do some other
2098# things (such as generating links to data files in a VPATH configuration).
2099# It also prints the "success" message.
2100# Note: If the variable coin_skip_ac_output is set to yes, then no output
2101# files are written.
2102
2103AC_DEFUN([AC_COIN_FINALIZE],
2104[
2105AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2106if test x$coin_skip_ac_output != xyes; then
2107
2108  FADDLIBS="$ADDLIBS"
2109  if test x"$coin_need_flibs" = xyes; then
2110    ADDLIBS="$ADDLIBS $FLIBS"
2111  fi
2112
2113  # library extension
2114  AC_SUBST(LIBEXT)
2115  case "$CC" in
2116    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2117         LIBEXT=lib ;;
2118      *) LIBEXT=a ;;
2119  esac
2120
2121  # Define VPATH_DISTCLEANFILES to be everything that needs to be
2122  # cleaned for distclean in a vpath configuration
2123  AC_SUBST(VPATH_DISTCLEANFILES)
2124  VPATH_DISTCLEANFILES="$coin_vpath_link_files"
2125
2126  # Take out subdirectories if their configuration concluded that they
2127  # don't need to be compiled
2128  if test x"$coin_ac_skip_subdirs" != x; then
2129    new_subdirs=
2130    for i in $subdirs; do
2131      skipme=no
2132      for j in $coin_ac_skip_subdirs; do
2133        if test $i = $j; then
2134          skipme=yes;
2135        fi
2136      done
2137      if test $skipme = no; then
2138        new_subdirs="$new_subdirs $i"
2139      fi
2140    done
2141    subdirs="$new_subdirs"
2142  fi
2143
2144  AC_OUTPUT
2145
2146  if test x"$coin_vpath_link_files" = x; then : ; else
2147    lnkcmd="$coin_link_input_cmd"
2148    if test "$lnkcmd" = cp; then
2149      AC_MSG_NOTICE(Copying data files for VPATH configuration)
2150    else
2151      AC_MSG_NOTICE(Creating VPATH links for data files)
2152    fi
2153    for file in $coin_vpath_link_files; do
2154      dir=`AS_DIRNAME(["./$file"])`
2155      if test -d $dir; then : ; else
2156        AS_MKDIR_P($dir)
2157      fi
2158      rm -f $file
2159      $lnkcmd $abs_source_dir/$file $file
2160    done
2161  fi
2162
2163  if test x$coin_projectdir = xyes; then
2164    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
2165  else
2166    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
2167  fi
2168else
2169  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
2170fi
2171
2172]) #AC_COIN_FINALIZE
2173
2174###########################################################################
2175#                             COIN_VPATH_LINK                             #
2176###########################################################################
2177
2178# This macro makes sure that a symbolic link is created to a file in
2179# the source code directory tree if we are in a VPATH compilation, and
2180# if this package is the main package to be installed
2181
2182AC_DEFUN([AC_COIN_VPATH_LINK],
2183[AC_REQUIRE([AC_COIN_CHECK_VPATH])
2184if test $coin_vpath_config = yes; then
2185  coin_vpath_link_files="$coin_vpath_link_files $1"
2186fi
2187]) #AC_COIN_VPATH_LINK
2188
2189###########################################################################
2190#                       COIN_ENABLE_GNU_PACKAGES                          #
2191###########################################################################
2192
2193# This macro defined the --enable-gnu-packages flag.  This can be used
2194# to check if a user wants to compile GNU packges (such as readline or
2195# zlib) into the executable.  By default, GNU packages are disabled.
2196# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
2197
2198AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
2199[AC_ARG_ENABLE([gnu-packages],
2200               [AC_HELP_STRING([--enable-gnu-packages],
2201                               [compile with GNU packages (disabled by default)])],
2202               [coin_enable_gnu=$enableval],
2203               [coin_enable_gnu=no])
2204]) # AC_COIN_ENABLE_GNU_PACKAGES
2205
2206###########################################################################
2207#                           COIN_CHECK_GNU_ZLIB                           #
2208###########################################################################
2209
2210# This macro checks for the libz library.
2211
2212AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2213[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2214AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2215AC_BEFORE([AC_COIN_PROG_CC],[$0])
2216AC_BEFORE([AC_COIN_PROG_F77],[$0])
2217AC_BEFORE([$0],[AC_COIN_FINALIZE])
2218
2219coin_has_zlib=no
2220if test $coin_enable_gnu = yes; then
2221  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2222
2223  if test $coin_has_zlib = yes; then
2224    AC_CHECK_LIB([z],[gzopen],
2225                 [ADDLIBS="-lz $ADDLIBS"],
2226                 [coin_has_zlib=no])
2227  fi
2228
2229  if test $coin_has_zlib = yes; then
2230    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2231  fi
2232fi
2233
2234AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2235]) # AC_COIN_CHECK_GNU_ZLIB
2236
2237
2238###########################################################################
2239#                          COIN_CHECK_GNU_BZLIB                           #
2240###########################################################################
2241
2242# This macro checks for the libbz2 library.
2243
2244AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2245[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2246AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2247AC_BEFORE([AC_COIN_PROG_CC],[$0])
2248AC_BEFORE([AC_COIN_PROG_F77],[$0])
2249AC_BEFORE([$0],[AC_COIN_FINALIZE])
2250
2251coin_has_bzlib=no
2252if test $coin_enable_gnu = yes; then
2253  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2254
2255  if test $coin_has_bzlib = yes; then
2256    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2257                 [ADDLIBS="-lbz2 $ADDLIBS"],
2258                 [coin_has_bzlib=no])
2259  fi
2260
2261  if test $coin_has_bzlib = yes; then
2262    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2263  fi
2264fi
2265]) # AC_COIN_CHECK_GNU_BZLIB
2266
2267
2268###########################################################################
2269#                         COIN_CHECK_GNU_READLINE                         #
2270###########################################################################
2271
2272# This macro checks for GNU's readline.  It verifies that the header
2273# readline/readline.h is available, and that the -lreadline library
2274# contains "readline".  It is assumed that #include <stdio.h> is included
2275# in the source file before the #include<readline/readline.h>
2276
2277AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2278[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2279AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2280AC_BEFORE([AC_COIN_PROG_CC],[$0])
2281AC_BEFORE([AC_COIN_PROG_F77],[$0])
2282AC_BEFORE([$0],[AC_COIN_FINALIZE])
2283
2284coin_has_readline=no
2285if test $coin_enable_gnu = yes; then
2286  AC_COIN_CHECK_HEADER([readline/readline.h],
2287                       [coin_has_readline=yes],[],
2288                       [#include <stdio.h>])
2289
2290  coin_save_LIBS="$LIBS"
2291  LIBS=
2292  # First we check if tputs and friends are available
2293  if test $coin_has_readline = yes; then
2294    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2295                   [coin_has_readline=no])
2296  fi
2297
2298  # Now we check for readline
2299  if test $coin_has_readline = yes; then
2300    AC_CHECK_LIB([readline],[readline],
2301                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
2302                 [coin_has_readline=no])
2303  fi
2304
2305  if test $coin_has_readline = yes; then
2306    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2307  fi
2308
2309  LIBS="$coin_save_LIBS"
2310fi
2311]) # AC_COIN_CHECK_GNU_READLINE
2312
2313###########################################################################
2314#                             COIN_DATA_PATH                              #
2315###########################################################################
2316
2317# This macro defines a preprocessor macro with the absolute path to a
2318# subdirectory of Data.  The argument of this macro is the name of the
2319# subdirectory (in correct case), and the name of the macro is
2320# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2321# the directory.  The path ends with a separator ("/" for linux and
2322# '\\' for Windows).  The default value for this path can be
2323# overwritten with the input variable with the same name
2324# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2325# $srcdir/../Data subdirectory.
2326
2327AC_DEFUN([AC_COIN_DATA_PATH],
2328[AC_MSG_CHECKING([absolute path to data directory $1])
2329
2330AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2331
2332if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2333  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2334fi
2335
2336# Under Cygwin, use Windows path.  Add separator
2337case $build in
2338  *-cygwin*)
2339    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2340    ;;
2341  *)
2342    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2343    ;;
2344esac
2345
2346if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2347  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2348            [Define to absolute path for Data subdirectory $1])
2349  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2350else
2351  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2352fi
2353]) # AC_COIN_HAS_DATA
2354
2355###########################################################################
2356#                       COIN_LINK_FROM_FILELIST                           #
2357###########################################################################
2358
2359# This macro creates links (or copies, if necessary) to files listed
2360# as content in a text file (second argument) into a target directory
2361# (first argument), which is created if it doesn't exist yet.  If s link
2362# already exists, nothing happens.
2363
2364AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
2365[cmd="$3"
2366if test -e $srcdir/$2 ; then
2367  my_target_dir="$1"
2368  my_link_files=`cat $srcdir/$2`
2369  my_dirname=`AS_DIRNAME($2)`
2370#  if test -e $my_target_dir; then : ; else
2371#    AS_MKDIR_P($my_target_dir)
2372#  fi
2373  for i in $my_link_files; do
2374    #rm -rf $my_target_dir/$i
2375    if test -e $my_target_dir/$i; then : ; else
2376      dirn2=`AS_DIRNAME($my_target_dir/$i)`
2377      if test -e $dirn2; then : ; else
2378        AS_MKDIR_P($dirn2)
2379      fi
2380      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
2381    fi
2382  done
2383else
2384  AC_MSG_WARN([File list file $2 missing!])
2385fi
2386])
2387
2388AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
2389[
2390AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2391echo Creating links in $1 ...
2392AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
2393])
2394
2395###########################################################################
2396#                       COIN_COPY_FROM_FILELIST                           #
2397###########################################################################
2398
2399# Like COIN_LINK_FROM_FILELIST, but copies the files.
2400
2401AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
2402[
2403echo Creating copies in $1 ...
2404AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
2405])
2406
2407###########################################################################
2408#                          COIN_EXAMPLE_FILES                             #
2409###########################################################################
2410
2411# This macro determines the names of the example files (using the
2412# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2413# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2414# creates soft links to the example files.
2415
2416AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2417[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
2418AC_REQUIRE([AC_COIN_CHECK_VPATH])
2419files=`cd $srcdir; ls $1`
2420# We need to do the following loop to make sure that are no newlines
2421# in the variable
2422for file in $files; do
2423  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2424done
2425if test $coin_vpath_config = yes; then
2426  lnkcmd=
2427  if test "$enable_doscompile" != no; then
2428    lnkcmd=cp
2429  fi
2430  case "$CC" in
2431    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2432      lnkcmd=cp ;;
2433  esac
2434  if test "$lnkcmd" = cp; then
2435    AC_MSG_NOTICE([Copying example files ($1)])
2436  else
2437    AC_PROG_LN_S
2438    AC_MSG_NOTICE([Creating links to the example files ($1)])
2439    lnkcmd="$LN_S"
2440  fi
2441  for file in $EXAMPLE_FILES; do
2442    rm -f $file
2443    $lnkcmd $srcdir/$file $file
2444  done
2445  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2446else
2447  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2448fi
2449
2450# In case there are compressed files, we create a variable with the
2451# uncompressed names
2452EXAMPLE_UNCOMPRESSED_FILES=
2453for file in $EXAMPLE_FILES; do
2454  case $file in
2455    *.gz)
2456      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2457      ;;
2458  esac
2459done
2460
2461AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2462AC_SUBST(EXAMPLE_FILES)
2463AC_SUBST(EXAMPLE_CLEAN_FILES)
2464]) #AC_COIN_EXAMPLE_FILES
2465
2466###########################################################################
2467#                            COIN_HAS_PROJECT                             #
2468###########################################################################
2469
2470# This macro sets up usage of a Coin package.  It defines the
2471# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
2472# object directory of the package, respectively.  It also defines
2473# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
2474# argument should be the name (Pkg) of the project (in correct lower
2475# and upper case)
2476
2477AC_DEFUN([AC_COIN_HAS_PROJECT],
2478[AC_MSG_CHECKING([for COIN project $1])
2479
2480# First check, if the sub-project is actually available (ToDo: allow
2481# other locations)
2482
2483m4_tolower(coin_has_$1)=unavailable
2484if test x"$COIN_SKIP_PROJECTS" != x; then
2485  for dir in $COIN_SKIP_PROJECTS; do
2486    if test $dir = $1; then
2487      m4_tolower(coin_has_$1)=skipping
2488    fi
2489  done
2490fi
2491
2492if test $m4_tolower(coin_has_$1) != skipping; then
2493  if test $PACKAGE_TARNAME = m4_tolower($1); then
2494    m4_tolower(coin_has_$1)=.
2495  else
2496    if test -d $srcdir/../$1; then
2497      m4_tolower(coin_has_$1)=../$1
2498    fi
2499  fi
2500fi
2501
2502if test $m4_tolower(coin_has_$1) != unavailable &&
2503   test $m4_tolower(coin_has_$1) != skipping; then
2504  # Set the #define if the component is available
2505  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
2506
2507  # Set the variables for source and object code location
2508  AC_SUBST(m4_toupper($1SRCDIR))
2509  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
2510  AC_SUBST(m4_toupper($1OBJDIR))
2511  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
2512  AC_SUBST(m4_toupper($1DOCDIR))
2513  m4_toupper($1DOCDIR)=$abs_lib_dir/../share/doc/coin/$1
2514fi
2515
2516  # Define the Makefile conditional
2517AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2518               [test $m4_tolower(coin_has_$1) != unavailable &&
2519                test $m4_tolower(coin_has_$1) != skipping])
2520AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2521]) # AC_COIN_HAS_PROJECT
2522
2523###########################################################################
2524#                        COIN_HAS_USER_LIBRARY                            #
2525###########################################################################
2526# This macro sets up usage of a user library with header files. The assumption
2527# is that the header file(s) and library do not reside in standard system
2528# directories, hence both the include directory and link flags must be
2529# specified. There are two mandatory arguments and two optional arguments.
2530#
2531# The first argument (mandatory) should be a name (LibraryName) for the
2532# library.  The second argument (mandatory) should be an abbreviation in
2533# upper case letters (LBRY) for the library. Ultimately, the macro will
2534# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2535# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2536# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2537# directory containing include files for the library. LBRYLIB should specify
2538# the flags necessary to link to the library. A variable coin_has_lbry will
2539# be set to true or false, as appropriate. A variable lbry_libcheck will be
2540# be set to yes or no; no indicates link checks should not be attempted.
2541#
2542# The macro defines three configure arguments, --with-libraryname-incdir,
2543# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2544# LibraryName to lower case.
2545#
2546# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2547# part of the configure command using --with-libraryname-incdir and
2548# --with-libraryname-lib, respectively. Command line arguments override
2549# environment variables.
2550#
2551# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2552# macro will check for the presence of the file. If a fourth argument is given,
2553# it should specify a function name, `fname'.  The macro will attempt to link a
2554# trivial program containing a parameterless call to the function, `fname()',
2555# using the LBRYLIB flags. The link check uses C as the language; this has been
2556# adequate to date but has limitations. It is possible to disable the link
2557# check by specifying --disable-libraryname-libcheck. This is a workaround for
2558# instances where the link check does not work properly, for whatever reason.
2559# If you're trying to link to a Fortran library, consider using F77_FUNC or
2560# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2561# library, you're on your own unless the library declares some function with
2562# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2563# name.
2564
2565AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
2566[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2567  AC_MSG_CHECKING(if user provides library for $1)
2568
2569# Check for header file directory
2570
2571  AC_ARG_WITH(m4_tolower($1)-incdir,
2572      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2573                     [specify the header file directory for library $1]),
2574      [$2INCDIR=`cd $withval; pwd`])
2575
2576# Check for library directory
2577
2578  AC_ARG_WITH(m4_tolower($1)-lib,
2579      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2580                     [specify the flags used to link with the library $1]),
2581      [$2LIB=$withval])
2582
2583# Switch to disable library check if requested
2584
2585  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2586      AS_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2587                     [use disable-m4_tolower($1)-libcheck to skip the link
2588                      check at configuration time]),
2589      [m4_tolower($1)_libcheck=$enableval],
2590      [m4_tolower($1)_libcheck=yes])
2591
2592# At this point, if we're going to use the library, both LBRYINCDIR and
2593# LBRYLIB must be defined and not empty.
2594
2595  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2596    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2597      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.])
2598    fi
2599    m4_tolower(coin_has_$2)=true
2600    AC_MSG_RESULT(yes)
2601  else
2602    m4_tolower(coin_has_$2)=false
2603    AC_MSG_RESULT(no)
2604  fi
2605
2606# If we have instructions for use, consider header and link checks.
2607
2608  if test $m4_tolower(coin_has_$2) = true; then
2609
2610# If argument 3 (file) is given, check for the file. Typically this will be a
2611# header file, but that's not assumed.
2612
2613    m4_ifval([$3],
2614        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2615             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2616
2617# Now see if we can link the function. There are arguments for and against
2618# assuming argument 3 is a header file declaring the function. A correct
2619# function declaration is the main argument in favour. Having to cope with
2620# possible dependencies or other oddities are the main arguments against.
2621# Force the use of C as the best single choice amongst C++, C, and Fortran.
2622# Obviously, this has limits.
2623
2624    m4_ifvaln([$4],
2625        [if test x"$m4_tolower($1)_libcheck" != xno; then
2626           coin_save_LIBS="$LIBS"
2627           LIBS="$$2LIB $ADDLIBS"
2628           coin_$2_link=no
2629           AC_LANG_PUSH(C)
2630           for fnm in $4 ; do
2631             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2632             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2633                 [AC_MSG_RESULT(yes)
2634                  coin_$2_link=yes
2635                  break],
2636                 [AC_MSG_RESULT(no)])
2637           done
2638           AC_LANG_POP(C)
2639           if test x"$coin_$2_link" = xyes ; then
2640             LIBS="$coin_save_LIBS"
2641           else
2642             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2643           fi
2644         fi])
2645
2646# If we make it this far, we've verified the file and linked the function. Add
2647# the necessary link flags to ADDLIBS and define the preprocessor symbol
2648# COIN_HAS_LBRY.
2649
2650    ADDLIBS="$$2LIB $ADDLIBS"
2651    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2652  fi
2653
2654# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2655# automake conditional. These actions must occur unconditionally.
2656
2657  AC_SUBST($2INCDIR)
2658  AC_SUBST($2LIB)
2659  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2660]) #AC_COIN_HAS_USER_LIBRARY
2661
2662###########################################################################
2663#                               COIN_HAS_ASL                              #
2664###########################################################################
2665
2666# This macro checks if the user has provide arguments that say where
2667# the precompiled ASL files should be found (with the --with-asldir
2668# flag).  If this is not the case, we check if the ThirdParty/ASL
2669# directory has been configured, which indicates that the files will
2670# be in that directory and can be used.
2671
2672AC_DEFUN([AC_COIN_HAS_ASL],
2673[coin_aslobjdir=../ThirdParty/ASL
2674coin_aslsrcdir=$srcdir/$coin_aslobjdir
2675
2676# Determine the name of the ASL library
2677case "$CC" in
2678  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2679    ampllib=amplsolv.lib ;;
2680  *)
2681    ampllib=amplsolver.a ;;
2682esac
2683
2684AC_ARG_WITH([asldir],
2685            AC_HELP_STRING([--with-asldir],
2686                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
2687            [use_asldir=$withval], [use_asldir=])
2688
2689if test "$use_asldir" = BUILD; then
2690  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2691    # If we are configuring ThirdParty/ASL, don't check
2692    if test -r $coin_aslobjdir/.MakeOk; then :; else
2693      AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])
2694    fi
2695  fi
2696elif test -z "$use_asldir"; then
2697 # try to find sources - if not given don't compile
2698  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2699    if test -r $coin_aslobjdir/.MakeOk; then
2700      use_asldir=BUILD
2701    else
2702      use_asldir=no
2703    fi
2704  else
2705    use_asldir=no
2706  fi
2707elif test "$use_asldir" != "no"; then
2708  AC_COIN_CHECK_FILE([$use_asldir/$ampllib],[],
2709                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
2710  AC_COIN_CHECK_FILE([$use_asldir/asl.h],[],
2711                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
2712  use_asldir=`cd $use_asldir; pwd`
2713  case $build in
2714    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
2715  esac
2716fi
2717
2718# Variable containing ASL library (including full path)
2719AC_SUBST(ASLLIB)
2720# Variable containing flags for including ASL header files
2721AC_SUBST(ASL_CPPFLAGS)
2722
2723if test "$use_asldir" = BUILD; then
2724  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
2725  ASLLIB=`$CYGPATH_W $coin_aslobjdir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2726  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
2727  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir | sed -e sX\\\\\\\\X/Xg`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers | sed -e sX\\\\\\\\X/Xg`
2728elif test "$use_asldir" != no; then
2729  ASLLIB=`$CYGPATH_W $use_asldir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2730  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir | sed -e sX\\\\\\\\X/Xg`
2731fi
2732
2733if test "$use_asldir" != no; then
2734  AC_LANG_PUSH(C)
2735  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
2736  coin_has_asl=yes
2737  AC_DEFINE([COIN_HAS_ASL],[1],
2738            [If defined, the Ampl Solver Library is available.])
2739  AC_LANG_POP(C)
2740else
2741  coin_has_asl=no
2742fi
2743AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
2744]) # AC_COIN_HAS_ASL
2745
2746###########################################################################
2747#                            COIN_TRY_FLINK                               #
2748###########################################################################
2749
2750# Auxilliary macro to test if a Fortran function name can be linked,
2751# given the current settings of LIBS.  We determine from the context, what
2752# the currently active programming language is, and cast the name accordingly.
2753# The first argument is the name of the function/subroutine, in small letters,
2754# the second argument are the actions taken when the test works, and the
2755# third argument are the actions taken if the test fails.
2756
2757AC_DEFUN([AC_COIN_TRY_FLINK],
2758[case $ac_ext in
2759  f)
2760    AC_TRY_LINK(,[      call $1],[$2],[$3])
2761    ;;
2762  c)
2763    AC_F77_FUNC($1,cfunc$1)
2764    if test x"$coin_need_flibs" = xyes; then
2765      flink_try=no;
2766    else
2767      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2768                  [flink_try=yes],[flink_try=no])
2769    fi
2770    if test $flink_try = yes; then
2771      $2
2772    else
2773      if test x"$FLIBS" != x; then
2774        flink_save_libs="$LIBS"
2775        LIBS="$LIBS $FLIBS"
2776        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2777                    [LIBS="$flink_save_libs"
2778                     $2
2779                     coin_need_flibs=yes],
2780                    [LIBS="$flink_save_libs"
2781                     $3])
2782      else
2783        $3
2784      fi
2785    fi
2786    ;;
2787  cc|cpp)
2788    AC_F77_FUNC($1,cfunc$1)
2789    if test x"$coin_need_flibs" = xyes; then
2790      flink_try=no;
2791    else
2792      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2793                  [flink_try=yes],[flink_try=no])
2794    fi
2795    if test $flink_try = yes; then
2796      $2
2797    else
2798      if test x"$FLIBS" != x; then
2799        flink_save_libs="$LIBS"
2800        LIBS="$LIBS $FLIBS"
2801        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2802                    [LIBS="$flink_save_libs"
2803                     $2
2804                     coin_need_flibs=yes],
2805                    [LIBS="$flink_save_libs"
2806                     $3])
2807      else
2808        $3
2809      fi
2810    fi
2811    ;;
2812esac
2813]) # AC_COIN_TRY_FLINK
2814
2815###########################################################################
2816#                             COIN_HAS_BLAS                               #
2817###########################################################################
2818
2819# This macro checks for a library containing the BLAS library.  It
2820# tries standard libraries, and if none is found to be working, it
2821# checks whether the BLAS ThirdParty/Blas directory has been configured.
2822# It adds to ADDLIBS any flags required to link with an externally provided
2823# BLAS.  It defines the makefile conditional and preprocessor macro
2824# COIN_HAS_BLAS, if blas is available, and it defines the makefile conditional
2825# COIN_BUILD_BLAS, if blas is compiled within COIN.
2826
2827AC_DEFUN([AC_COIN_HAS_BLAS],
2828[if test "$PACKAGE_NAME" = ThirdPartyBlas || test "$PACKAGE_NAME" = ThirdPartyLapack || test "$PACKAGE_NAME" = ThirdPartyMumps; then
2829  coin_blasobjdir=../Blas
2830else
2831  coin_blasobjdir=../ThirdParty/Blas
2832fi
2833coin_blassrcdir=$srcdir/$coin_blasobjdir
2834
2835AC_ARG_WITH([blas],
2836            AC_HELP_STRING([--with-blas],
2837                           [specify BLAS library (or BUILD for compilation)]),
2838            [use_blas=$withval], [use_blas=])
2839
2840MAKEOKFILE=.MakeOk
2841# Check if user supplied option makes sense
2842if test x"$use_blas" != x; then
2843  if test "$use_blas" = "BUILD"; then
2844    # Don't check for course code if this is executed in ThirdParty/Blas
2845    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2846      if test -r $coin_blasobjdir/.MakeOk; then :; else
2847        AC_MSG_ERROR([option \"BUILD\" specified for Blas, but $coin_blasobjdir directory is not properly configured])
2848      fi
2849    fi
2850  elif test "$use_blas" != no ; then
2851    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2852    LIBS="$use_blas $LIBS"
2853    ADDLIBS="$use_blas $ADDLIBS"
2854    AC_COIN_TRY_FLINK([daxpy],
2855                      [AC_MSG_RESULT([yes])],
2856                      [AC_MSG_RESULT([no])
2857                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2858  fi
2859else
2860# Try to autodetect the library for blas based on build system
2861  #AC_MSG_CHECKING([default locations for BLAS])
2862  skip_lblas_check=no
2863  case $build in
2864    *-sgi-*)
2865      SAVE_LIBS="$LIBS"
2866      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2867      LIBS="-lcomplib.sgimath $LIBS"
2868      AC_COIN_TRY_FLINK([daxpy],
2869                        [AC_MSG_RESULT([yes])
2870                         use_blas=-lcomplib.sgimath;
2871                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2872                        [AC_MSG_RESULT([no])
2873                         SAVE_LIBS="$LIBS"])
2874      ;;
2875
2876# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
2877# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
2878# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
2879# that CC and cc will understand -library in Studio 13. The main extra
2880# function of -xlic_lib and -library is to arrange for the Fortran run-time
2881# libraries to be linked for C++ and C. We can arrange that explicitly.
2882    *-*-solaris*)
2883      SAVE_LIBS="$LIBS"
2884      AC_MSG_CHECKING([for BLAS in libsunperf])
2885      LIBS="-lsunperf $FLIBS $LIBS"
2886      AC_COIN_TRY_FLINK([daxpy],
2887                        [AC_MSG_RESULT([yes])
2888                         use_blas='-lsunperf'
2889                         ADDLIBS="-lsunperf $ADDLIBS"
2890                         coin_need_flibs=yes],
2891                        [AC_MSG_RESULT([no])
2892                         LIBS="$SAVE_LIBS"])
2893      ;;
2894    *-cygwin* | *-mingw*)
2895# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
2896# library will want to link with cygwin, hence won't run standalone in DOS.
2897      if test "$enable_doscompile" = mingw; then
2898        skip_lblas_check=yes
2899      fi
2900      case "$CC" in
2901        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2902          SAVE_LIBS="$LIBS"
2903          AC_MSG_CHECKING([for BLAS in MKL])
2904          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
2905          AC_COIN_TRY_FLINK([daxpy],
2906                            [AC_MSG_RESULT([yes])
2907                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
2908                             ADDLIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $ADDLIBS"],
2909                            [AC_MSG_RESULT([no])
2910                             LIBS="$SAVE_LIBS"])
2911          ;;
2912      esac
2913      ;;
2914  esac
2915
2916  if test -z "$use_blas" && test $skip_lblas_check = no; then
2917    SAVE_LIBS="$LIBS"
2918    AC_MSG_CHECKING([whether -lblas has BLAS])
2919    LIBS="-lblas $LIBS"
2920    AC_COIN_TRY_FLINK([daxpy],
2921                      [AC_MSG_RESULT([yes])
2922                       ADDLIBS="-lblas $ADDLIBS"
2923                       use_blas='-lblas'],
2924                      [AC_MSG_RESULT([no])
2925                       LIBS="$SAVE_LIBS"])
2926  fi
2927
2928# If we have no other ideas, consider building BLAS.
2929  if test -z "$use_blas"; then
2930    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2931      if test -r $coin_blasobjdir/.MakeOk; then
2932        use_blas=BUILD
2933      fi
2934    fi
2935  fi
2936fi
2937
2938if test "$use_blas" = BUILD; then
2939  coin_need_flibs=yes
2940fi
2941
2942AM_CONDITIONAL([COIN_HAS_BLAS],[test x"$use_blas" != x])
2943AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
2944
2945if test x"$use_blas" = x || test "$use_blas" = no; then
2946  coin_has_blas=no
2947else
2948  coin_has_blas=yes
2949  AC_DEFINE([COIN_HAS_BLAS],[1],
2950            [If defined, the BLAS Library is available.])
2951fi
2952]) # AC_COIN_HAS_BLAS
2953
2954###########################################################################
2955#                            COIN_HAS_LAPACK                              #
2956###########################################################################
2957
2958# This macro checks for a library containing the LAPACK library.  It
2959# tries standard libraries, and if none is found to be working, it
2960# checks whether the LAPACK ThirdParty/Lapack directory has been
2961# configured.  It adds to ADDLIBS any flags required to link with an
2962# externally provided LAPACK.  It defines the makefile conditional and
2963# preprocessor macro COIN_HAS_LAPACK, if lapack is available, and it
2964# defines the makefile conditional COIN_BUILD_LAPACK, if lapack is
2965# compiled within COIN.
2966
2967AC_DEFUN([AC_COIN_HAS_LAPACK],
2968[coin_lapackobjdir=../ThirdParty/Lapack
2969coin_lapacksrcdir=$srcdir/$coin_lapackobjdir
2970
2971AC_ARG_WITH([lapack],
2972            AC_HELP_STRING([--with-lapack],
2973                           [specify LAPACK library (or BUILD for compilation)]),
2974            [use_lapack=$withval], [use_lapack=])
2975
2976# Check if user supplied option makes sense
2977if test x"$use_lapack" != x; then
2978  if test "$use_lapack" = "BUILD"; then
2979    # Don't check for course code if this is executed in ThirdParty/Lapack
2980    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
2981      if test -r $coin_lapackobjdir/.MakeOk; then :; else
2982        AC_MSG_ERROR([option \"BUILD\" specified for LAPACK, but $coin_lapackobjdir directory is not configured])
2983      fi
2984    fi
2985  else
2986    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
2987    LIBS="$use_lapack $LIBS"
2988    ADDLIBS="$use_lapack $ADDLIBS"
2989    AC_COIN_TRY_FLINK([dsyev],
2990                      [AC_MSG_RESULT([yes])],
2991                      [AC_MSG_RESULT([no])
2992                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
2993  fi
2994else
2995  if test x$coin_has_blas = xyes; then
2996    # First try to see if LAPACK is already available with BLAS library
2997    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
2998    AC_COIN_TRY_FLINK([dsyev],
2999                      [AC_MSG_RESULT([yes]); use_lapack=ok],
3000                      [AC_MSG_RESULT([no])])
3001  fi
3002  skip_llapack_check=no
3003  if test -z "$use_lapack"; then
3004    # Try to autodetect the library for lapack based on build system
3005    case $build in
3006      *-sgi-*)
3007        SAVE_LIBS="$LIBS"
3008        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
3009        LIBS="-lcomplib.sgimath $LIBS"
3010        AC_COIN_TRY_FLINK([dsyev],
3011                          [AC_MSG_RESULT([yes])
3012                           use_lapack=-lcomplib.sgimath;
3013                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
3014                          [AC_MSG_RESULT([no])
3015                           SAVE_LIBS="$LIBS"])
3016        ;;
3017
3018# See comments in COIN_HAS_BLAS.
3019      *-*-solaris*)
3020      SAVE_LIBS="$LIBS"
3021      AC_MSG_CHECKING([for LAPACK in libsunperf])
3022      LIBS="-lsunperf $FLIBS $LIBS"
3023      AC_COIN_TRY_FLINK([dsyev],
3024                        [AC_MSG_RESULT([yes])
3025                         use_blas='-lsunperf'
3026                         ADDLIBS="-lsunperf $ADDLIBS"
3027                         coin_need_flibs=yes],
3028                        [AC_MSG_RESULT([no])
3029                         LIBS="$SAVE_LIBS"])
3030        ;;
3031# On cygwin, do this check only if doscompile is disabled. The prebuilt library
3032# will want to link with cygwin, hence won't run standalone in DOS.
3033      *-cygwin*)
3034        if test "$enable_doscompile" = mingw; then
3035          skip_llapack_check=yes
3036        fi
3037        ;;
3038    esac
3039  fi
3040
3041  if test -z "$use_lapack" && test $skip_llapack_check = no; then
3042    SAVE_LIBS="$LIBS"
3043    AC_MSG_CHECKING([whether -llapack has LAPACK])
3044    LIBS="-llapack $LIBS"
3045    AC_COIN_TRY_FLINK([dsyev],
3046                      [AC_MSG_RESULT([yes])
3047                       ADDLIBS="-llapack $ADDLIBS"
3048                       use_lapack='-llapack'],
3049                      [AC_MSG_RESULT([no])
3050                       LIBS="$SAVE_LIBS"])
3051  fi
3052
3053# If we have no other ideas, consider building LAPACK.
3054  if test -z "$use_lapack"; then
3055    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
3056      if test -r $coin_lapackobjdir/.MakeOk; then
3057        use_lapack=BUILD
3058      fi
3059    fi
3060  fi
3061fi
3062
3063if test "$use_lapack" = BUILD; then
3064  coin_need_flibs=yes
3065fi
3066
3067AM_CONDITIONAL([COIN_HAS_LAPACK],[test x"$use_lapack" != x])
3068AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
3069
3070if test x"$use_lapack" = x; then
3071  coin_has_lapack=no
3072else
3073  coin_has_lapack=yes
3074  AC_DEFINE([COIN_HAS_LAPACK],[1],
3075            [If defined, the LAPACK Library is available.])
3076fi
3077]) # AC_COIN_HAS_LAPACK
3078
3079###########################################################################
3080#                            COIN_HAS_MUMPS                               #
3081###########################################################################
3082
3083# This macro checks for a library containing the MUMPS library.  It
3084# checks if the user has provided an argument for the MUMPS library,
3085# and if not, it checks whether the MUMPS ThirdParty/Mumps directory has
3086# been configured.  It adds to ADDLIBS any flags required to link with
3087# an externally provided MUMPS.  It defines the makefile conditional
3088# and preprocessor macro COIN_HAS_MUMPS, if MUMPS is available, and it
3089# defines the makefile conditional COIN_BUILD_MUMPS, if MUMPS is
3090# compiled within COIN.
3091
3092AC_DEFUN([AC_COIN_HAS_MUMPS],
3093[
3094if test "$PACKAGE_NAME" = ThirdPartyMumps; then
3095  coin_mumpsobjdir=../Mumps
3096else
3097  coin_mumpsobjdir=../ThirdParty/Mumps
3098fi
3099coin_mumpssrcdir=$abs_source_dir/$coin_mumpsobjdir/MUMPS
3100
3101MAKEOKFILE=.MakeOk
3102
3103#check if user provides a MUMPS library (that works)
3104AC_LANG_PUSH(C)
3105SAVE_ADDLIBS="$ADDLIBS"
3106ADDLIBS="$ADDLIBS $FLIBS"
3107AC_COIN_HAS_USER_LIBRARY(mumps, MUMPS, dmumps_c.h, dmumps_c)
3108ADDLIBS="$SAVE_ADDLIBS"
3109AC_LANG_POP(C)
3110
3111if test "$coin_has_mumps" = "true"; then  # user provided mumps library
3112  use_mumps=yes
3113  coin_has_mumps=yes
3114
3115  MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $MUMPSINCDIR\`"
3116  ADDLIBS="$MUMPSLIB $ADDLIBS"
3117
3118else # no user provided library, so we try to build our own
3119  use_mumps=BUILD
3120
3121  # Check if the MUMPS' ThirdParty project has been configured
3122  if test "$PACKAGE_NAME" != ThirdPartyMumps; then
3123    if test -r $coin_mumpsobjdir/.MakeOk; then
3124      use_mumps=BUILD
3125      # Mumps needs pthreads
3126      AC_LANG_PUSH(C)
3127      save_LIBS="$LIBS"
3128      LIBS="$LIBS $FLIBS"
3129      AC_CHECK_LIB([pthread],[pthread_create],[LIBS="-lpthread $save_LIBS"; ADDLIBS="-lpthread $ADDLIBS"],[LIBS="save_LIBS"])
3130      AC_LANG_POP(C)
3131 
3132      MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $coin_mumpssrcdir/libseq\` -I\`\$(CYGPATH_W) $coin_mumpssrcdir/include\`"
3133    else
3134      use_mumps=
3135    fi
3136  fi
3137
3138  # if a user provided library is used, then COIN_HAS_USER_LIBRARY takes care of the COIN_HAS_MUMPS conditional and preprocessor symbol
3139  AM_CONDITIONAL([COIN_HAS_MUMPS],[test x"$use_mumps" != x])
3140  if test x"$use_mumps" != x; then
3141    AC_DEFINE([COIN_HAS_MUMPS],[1],[If defined, the MUMPS Library is available.])
3142    coin_has_mumps=yes
3143  else
3144    coin_has_mumps=no
3145  fi
3146  AC_MSG_CHECKING([whether MUMPS is available])
3147  AC_MSG_RESULT([$coin_has_mumps])
3148fi
3149
3150if test x"$use_mumps" != x; then
3151  # we need the Fortran runtime libraries if we want to link with C/C++
3152  coin_need_flibs=yes
3153
3154  AC_SUBST(MUMPS_INCFLAGS)
3155fi
3156
3157AM_CONDITIONAL([COIN_BUILD_MUMPS],[test "$use_mumps" = BUILD])
3158
3159]) # AC_COIN_HAS_MUMPS
3160
3161###########################################################################
3162#                             COIN_HAS_GLPK                               #
3163###########################################################################
3164#
3165# This macro checks for the GLPK package. GLPK provides two capabilities,
3166# an LP and MIP solver (GLPK) and the GNU Mathprog modelling language (GMPL).
3167# The macro checks for either Glpk or Gmpl, according to the value specified as
3168# the parameter. Use one of Glpk or Gmpl. Use *exactly* these strings, eh?
3169#
3170#
3171# The macro first uses COIN_HAS_USER_LIBRARY to see if the user has specified
3172# a preexisting library (this allows the use of any glpk version, if the user
3173# is fussy). The macro then checks for ThirdParty/Glpk.
3174#
3175# This macro will define the following variables for Glpk:
3176#   coin_has_glpk       true or false
3177#   GLPKLIB             link flags for GLPK (if user supplied)
3178#   GLPKINCDIR          location of glpk include files
3179#   COIN_HAS_GLPK       Preprocessor symbol, defined to 1
3180#   COIN_HAS_GLPK       Automake conditional
3181#   COIN_BUILD_GLPK     Automake conditional, defined only if Glpk is to be
3182#                       built in ThirdParty/Glpk
3183#
3184# With the exception of COIN_BUILD_GLPK, an identical set of variables is
3185# defined for Gmpl.
3186
3187AC_DEFUN([AC_COIN_HAS_GLPK],
3188[
3189if test "$PACKAGE_NAME" = ThirdPartyGlpk; then
3190  coin_glpkobjdir=../Glpk
3191else
3192  coin_glpkobjdir=../ThirdParty/Glpk
3193fi
3194coin_glpksrcdir=$abs_source_dir/$coin_glpkobjdir
3195
3196use_thirdpartyglpk=no
3197
3198# Check for the requested component. If the user specified an external glpk
3199# library don't force a ThirdParty build, let the error propagate.
3200
3201m4_if([$1],[Glpk],
3202[AC_COIN_HAS_USER_LIBRARY([Glpk],[GLPK],[glpk.h],
3203    [_glp_lpx_simplex glp_lpx_simplex])
3204 if test x"$coin_has_glpk" = xfalse && test x"$GLPKLIB" = x ; then
3205   use_thirdpartyglpk=try
3206 fi])
3207m4_if([$1],[Gmpl],
3208[AC_COIN_HAS_USER_LIBRARY([Gmpl],[GMPL],[glpmpl.h],
3209    [_glp_mpl_initialize glp_mpl_initialize])
3210 if test x"$coin_has_gmpl" = xfalse && test x"$GMPLLIB" = x ; then
3211   use_thirdpartyglpk=try
3212 fi])
3213
3214# If the user has supplied an external library, use it. Otherwise, consider
3215# a build in ThirdParty/Glpk. If we build, assume we get both glpk and gmpl.
3216
3217if test x"$use_thirdpartyglpk" = xtry ; then
3218  MAKEOKFILE=.MakeOk
3219  # Check if the Glpk's ThirdParty project has been configured
3220  if test "$PACKAGE_NAME" != ThirdPartyGlpk; then
3221    if test -r $coin_glpkobjdir/.MakeOk; then
3222      use_thirdpartyglpk=build
3223    else
3224      use_thirdpartyglpk=no
3225    fi
3226  else
3227    use_thirdpartyglpk=build
3228  fi
3229
3230# If we're building, set the library and include directory variables, create a
3231# preprocessor symbol, define a variable that says we're using glpk/gmpl, and
3232# another to indicate a link check is a bad idea (hard to do before the library
3233# exists).
3234
3235  if test x"$use_thirdpartyglpk" = xbuild ; then
3236    m4_toupper($1INCDIR)="$coin_glpksrcdir/glpk/include"
3237    AC_SUBST(m4_toupper($1INCDIR))
3238    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],
3239              [Define to 1 if $1 package is available])
3240    m4_tolower(coin_has_$1)=true
3241    m4_tolower($1_libcheck)=no
3242    AC_MSG_NOTICE([Using $1 in ThirdParty/Glpk])
3243  fi
3244fi
3245
3246# Define the necessary automake conditionals.
3247
3248AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3249               [test x"$m4_tolower(coin_has_$1)" = xtrue])
3250AM_CONDITIONAL([COIN_BUILD_GLPK],[test x"$use_thirdpartyglpk" = xbuild])
3251
3252]) # AC_COIN_HAS_GLPK
Note: See TracBrowser for help on using the repository browser.