source: trunk/coin.m4 @ 289

Last change on this file since 289 was 289, checked in by andreasw, 14 years ago

added automatic fix of libtool script for Darwin

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