source: trunk/coin.m4 @ 332

Last change on this file since 332 was 332, checked in by andreasw, 13 years ago

some fixes for MSys

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