source: stable/BSP/coin.m4 @ 1097

Last change on this file since 1097 was 1097, checked in by stefan, 12 years ago

take pedantic-errors out of cflags and cxxflags for darwin, because 1. some system file would not compile because gcc says it uses nonstandard bitfields, and 2. because the test for std::isnan(42.42) generates a compiler error due to an unusual #ifndef std::isnan(42.42) in the conftest program; turn off warnings on unknown pragmas, e.g., when SYMPHONY is compiled by a compiler that dos not understand omp

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