source: stable/0.5/coin.m4 @ 242

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

use test -r to check for existence of libtool script, not AC_CHECK_FILE since that does not work for cross compilation

  • Property svn:keywords set to Author Date Id Revision
File size: 90.0 KB
Line 
1# Copyright (C) 2006 International Business Machines..
2# All Rights Reserved.
3# This file is distributed under the Common Public License.
4#
5## $Id: coin.m4 242 2007-03-06 16:04:14Z 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='-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    *-cygwin* | *-mingw*)
1781    case "$CXX" in
1782      cl* | */cl* | CL* | */CL*)
1783        AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1784        sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1785            -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1786            -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1787            -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1788            -e 's%lib /OUT:%lib -OUT:%' \
1789            -e "s%cygpath -w%$CYGPATH_W%" \
1790            -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%' \
1791            -e 's/$AR t/lib -nologo -list/' \
1792            -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1793            -e  's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1794        libtool > conftest.bla
1795
1796        mv conftest.bla libtool
1797        chmod 755 libtool
1798        ;;
1799      *)
1800        AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
1801        sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1802            -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1803            -e 's|libext="lib"|libext="a"|' \
1804        libtool > conftest.bla
1805
1806        mv conftest.bla libtool
1807        chmod 755 libtool
1808        ;;
1809    esac
1810  esac
1811# This fi matches the commented `if test "x$LIBTOOL" = x;' up at the head of
1812# the macro. -- lh, 061214 --
1813# fi
1814
1815# AC_MSG_NOTICE([End libtool initialisation.])
1816]) # AC_COIN_PROG_LIBTOOL
1817
1818# This is a trick to force the check for the dlfcn header to be done before
1819# the checks for libtool
1820# No longer needed now that CPPFLAGS is correctly set.  -- lh, 061214 --
1821# ACDEFUN([AC_COIN_DLFCN_H],
1822# [AC_LANG_PUSH(C)
1823# AC_COIN_CHECK_HEADER([dlfcn.h])
1824# AC_LANG_POP(C)
1825# ]) # AC_COIN_DLFCN_H
1826
1827###########################################################################
1828#                            COIN_RPATH_FLAGS                             #
1829###########################################################################
1830
1831# This macro, in case shared objects are used, defines a variable
1832# RPATH_FLAGS that can be used by the linker to hardwire the library
1833# search path for the given directories.  This is useful for example
1834# Makefiles
1835
1836AC_DEFUN([AC_COIN_RPATH_FLAGS],
1837[RPATH_FLAGS=
1838
1839if test $enable_shared = yes; then
1840  case $build in
1841    *-linux-*)
1842      if test "$GXX" = "yes"; then
1843        RPATH_FLAGS=
1844        for dir in $1; do
1845          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1846        done
1847      fi ;;
1848    *-darwin*)
1849        RPATH_FLAGS=nothing ;;
1850    *-ibm-*)
1851      case "$CXX" in
1852      xlC* | */xlC* | mpxlC* | */mpxlC*)
1853        RPATH_FLAGS=nothing ;;
1854      esac ;;
1855    *-hp-*)
1856        RPATH_FLAGS=nothing ;;
1857    *-mingw32)
1858        RPATH_FLAGS=nothing ;;
1859    *-sun-*)
1860        RPATH_FLAGS=
1861        for dir in $1; do
1862          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
1863        done
1864  esac
1865
1866  if test "$RPATH_FLAGS" = ""; then
1867    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.])
1868  fi
1869  if test "$RPATH_FLAGS" = "nothing"; then
1870    RPATH_FLAGS=
1871  fi
1872fi
1873
1874AC_SUBST(RPATH_FLAGS)
1875]) # AC_COIN_RPATH_FLAGS
1876
1877###########################################################################
1878#                              COIN_FINALIZE                              #
1879###########################################################################
1880
1881# This macro should be called at the very end of the configure.ac file.
1882# It creates the output files (by using AC_OUTPUT), and might do some other
1883# things (such as generating links to data files in a VPATH configuration).
1884# It also prints the "success" message.
1885
1886AC_DEFUN([AC_COIN_FINALIZE],
1887[
1888FADDLIBS="$ADDLIBS"
1889if test x"$coin_need_flibs" = xyes; then
1890  ADDLIBS="$ADDLIBS $FLIBS"
1891fi
1892
1893# library extension
1894AC_SUBST(LIBEXT)
1895case "$CC" in
1896  cl* | */cl* | CL* | */CL*)
1897       LIBEXT=lib ;;
1898    *) LIBEXT=a ;;
1899esac
1900
1901# Define VPATH_DISTCLEANFILES to be everything that needs to be
1902# cleaned for distclean in a vpath configuration
1903AC_SUBST(VPATH_DISTCLEANFILES)
1904VPATH_DISTCLEANFILES="$coin_vpath_link_files"
1905
1906AC_OUTPUT
1907
1908if test x"$coin_vpath_link_files" = x; then : ; else
1909  lnkcmd=
1910  if test "$enable_doscompile" = yes; then
1911    lnkcmd=cp
1912  fi
1913  case "$CC" in
1914    cl* | */cl* | CL* | */CL*)
1915      lnkcmd=cp ;;
1916  esac
1917  if test "$lnkcmd" = cp; then
1918    AC_MSG_NOTICE(Copying data files for VPATH configuration)
1919  else
1920    AC_PROG_LN_S
1921    AC_MSG_NOTICE(Creating VPATH links for data files)
1922    lnkcmd="$LN_S"
1923  fi
1924  for file in $coin_vpath_link_files; do
1925    dir=`AS_DIRNAME(["./$file"])`
1926    if test -d $dir; then : ; else
1927      AS_MKDIR_P($dir)
1928    fi
1929    rm -f $file
1930    $lnkcmd $abs_source_dir/$file $file
1931  done
1932fi
1933
1934if test x$coin_projectdir = xyes; then
1935  AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
1936else
1937  AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
1938fi
1939]) #AC_COIN_FINALIZE
1940
1941###########################################################################
1942#                             COIN_VPATH_LINK                             #
1943###########################################################################
1944
1945# This macro makes sure that a symbolic link is created to a file in
1946# the source code directory tree if we are in a VPATH compilation, and
1947# if this package is the main package to be installed
1948
1949AC_DEFUN([AC_COIN_VPATH_LINK],
1950[AC_REQUIRE([AC_COIN_CHECK_VPATH])
1951if test $coin_vpath_config = yes; then
1952  coin_vpath_link_files="$coin_vpath_link_files $1"
1953fi
1954]) #AC_COIN_VPATH_LINK
1955
1956###########################################################################
1957#                       COIN_ENABLE_GNU_PACKAGES                          #
1958###########################################################################
1959
1960# This macro defined the --enable-gnu-packages flag.  This can be used
1961# to check if a user wants to compile GNU packges (such as readline or
1962# zlib) into the executable.  By default, GNU packages are disabled.
1963# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
1964
1965AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
1966[AC_ARG_ENABLE([gnu-packages],
1967               [AC_HELP_STRING([--enable-gnu-packages],
1968                               [compile with GNU packages (disabled by default)])],
1969               [coin_enable_gnu=$enableval],
1970               [coin_enable_gnu=no])
1971]) # AC_COIN_ENABLE_GNU_PACKAGES
1972
1973###########################################################################
1974#                           COIN_CHECK_GNU_ZLIB                           #
1975###########################################################################
1976
1977# This macro checks for the libz library.
1978
1979AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
1980[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1981AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1982AC_BEFORE([AC_COIN_PROG_CC],[$0])
1983AC_BEFORE([AC_COIN_PROG_F77],[$0])
1984AC_BEFORE([$0],[AC_COIN_FINISH])
1985
1986coin_has_zlib=no
1987if test $coin_enable_gnu = yes; then
1988  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
1989
1990  if test $coin_has_zlib = yes; then
1991    AC_CHECK_LIB([z],[gzopen],
1992                 [ADDLIBS="-lz $ADDLIBS"],
1993                 [coin_has_zlib=no])
1994  fi
1995
1996  if test $coin_has_zlib = yes; then
1997    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
1998  fi
1999fi
2000
2001AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2002]) # AC_COIN_CHECK_GNU_ZLIB
2003
2004
2005###########################################################################
2006#                          COIN_CHECK_GNU_BZLIB                           #
2007###########################################################################
2008
2009# This macro checks for the libbz2 library.
2010
2011AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2012[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2013AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2014AC_BEFORE([AC_COIN_PROG_CC],[$0])
2015AC_BEFORE([AC_COIN_PROG_F77],[$0])
2016AC_BEFORE([$0],[AC_COIN_FINISH])
2017
2018coin_has_bzlib=no
2019if test $coin_enable_gnu = yes; then
2020  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2021
2022  if test $coin_has_bzlib = yes; then
2023    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2024                 [ADDLIBS="-lbz2 $ADDLIBS"],
2025                 [coin_has_bzlib=no])
2026  fi
2027
2028  if test $coin_has_bzlib = yes; then
2029    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2030  fi
2031fi
2032]) # AC_COIN_CHECK_GNU_BZLIB
2033
2034
2035###########################################################################
2036#                         COIN_CHECK_GNU_READLINE                         #
2037###########################################################################
2038
2039# This macro checks for GNU's readline.  It verifies that the header
2040# readline/readline.h is available, and that the -lreadline library
2041# contains "readline".  It is assumed that #include <stdio.h> is included
2042# in the source file before the #include<readline/readline.h>
2043
2044AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2045[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2046AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2047AC_BEFORE([AC_COIN_PROG_CC],[$0])
2048AC_BEFORE([AC_COIN_PROG_F77],[$0])
2049AC_BEFORE([$0],[AC_COIN_FINISH])
2050
2051coin_has_readline=no
2052if test $coin_enable_gnu = yes; then
2053  AC_COIN_CHECK_HEADER([readline/readline.h],
2054                       [coin_has_readline=yes],[],
2055                       [#include <stdio.h>])
2056
2057  coin_save_LIBS="$LIBS"
2058  LIBS=
2059  # First we check if tputs and friends are available
2060  if test $coin_has_readline = yes; then
2061    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2062                   [coin_has_readline=no])
2063  fi
2064
2065  # Now we check for readline
2066  if test $coin_has_readline = yes; then
2067    AC_CHECK_LIB([readline],[readline],
2068                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
2069                 [coin_has_readline=no])
2070  fi
2071
2072  if test $coin_has_readline = yes; then
2073    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2074  fi
2075
2076  LIBS="$coin_save_LIBS"
2077fi
2078]) # AC_COIN_CHECK_GNU_READLINE
2079
2080###########################################################################
2081#                             COIN_DATA_PATH                              #
2082###########################################################################
2083
2084# This macro defines a preprocessor macro with the absolute path to a
2085# subdirectory of Data.  The argument of this macro is the name of the
2086# subdirectory (in correct case), and the name of the macro is
2087# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2088# the directory.  The path ends with a separator ("/" for linux and
2089# '\\' for Windows).  The default value for this path can be
2090# overwritten with the input variable with the same name
2091# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2092# $srcdir/../Data subdirectory.
2093
2094AC_DEFUN([AC_COIN_DATA_PATH],
2095[AC_MSG_CHECKING([absolute path to data directory $1])
2096
2097AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2098
2099if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2100  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2101fi
2102
2103# Under Cygwin, use Windows path.  Add separator
2104case $build in
2105  *-cygwin*)
2106    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2107    ;;
2108  *)
2109    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2110    ;;
2111esac
2112
2113if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2114  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2115            [Define to absolute path for Data subdirectory $1])
2116  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2117else
2118  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2119fi
2120]) # AC_COIN_HAS_DATA
2121
2122###########################################################################
2123#                          COIN_EXAMPLE_FILES                             #
2124###########################################################################
2125
2126# This macro determines the names of the example files (using the
2127# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2128# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2129# creates soft links to the example files.
2130
2131AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2132[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
2133AC_REQUIRE([AC_COIN_CHECK_VPATH])
2134files=`cd $srcdir; ls $1`
2135# We need to do the following loop to make sure that are no newlines
2136# in the variable
2137for file in $files; do
2138  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2139done
2140if test $coin_vpath_config = yes; then
2141  lnkcmd=
2142  if test "$enable_doscompile" != no; then
2143    lnkcmd=cp
2144  fi
2145  case "$CC" in
2146    cl* | */cl* | CL* | */CL*)
2147      lnkcmd=cp ;;
2148  esac
2149  if test "$lnkcmd" = cp; then
2150    AC_MSG_NOTICE([Copying example files ($1)])
2151  else
2152    AC_PROG_LN_S
2153    AC_MSG_NOTICE([Creating links to the example files ($1)])
2154    lnkcmd="$LN_S"
2155  fi
2156  for file in $EXAMPLE_FILES; do
2157    rm -f $file
2158    $lnkcmd $srcdir/$file $file
2159  done
2160  EXAMPLE_CLEAN_FILES='$1'
2161else
2162  EXAMPLE_CLEAN_FILES=
2163fi
2164
2165# In case there are compressed files, we create a variable with the
2166# uncompressed names
2167EXAMPLE_UNCOMPRESSED_FILES=
2168for file in $EXAMPLE_FILES; do
2169  case $file in
2170    *.gz)
2171      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2172      ;;
2173  esac
2174done
2175
2176AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2177AC_SUBST(EXAMPLE_FILES)
2178AC_SUBST(EXAMPLE_CLEAN_FILES)
2179]) #AC_COIN_EXAMPLE_FILES
2180
2181###########################################################################
2182#                            COIN_HAS_PROJECT                             #
2183###########################################################################
2184
2185# This macro sets up usage of a Coin package.  It defines the
2186# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
2187# object directory of the package, respectively.  It also defines
2188# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
2189# argument should be the name (Pkg) of the project (in correct lower
2190# and upper case)
2191
2192AC_DEFUN([AC_COIN_HAS_PROJECT],
2193[AC_MSG_CHECKING([for COIN project $1])
2194
2195# First check, if the sub-project is actually available (ToDo: allow
2196# other locations)
2197
2198m4_tolower(coin_has_$1)=unavailable
2199if test x"$COIN_SKIP_PROJECTS" != x; then
2200  for dir in $COIN_SKIP_PROJECTS; do
2201    if test $dir = $1; then
2202      m4_tolower(coin_has_$1)=skipping
2203    fi
2204  done
2205fi
2206
2207if test $m4_tolower(coin_has_$1) != skipping; then
2208  if test $PACKAGE_TARNAME = m4_tolower($1); then
2209    m4_tolower(coin_has_$1)=.
2210  else
2211    if test -d $srcdir/../$1; then
2212      m4_tolower(coin_has_$1)=../$1
2213    fi
2214  fi
2215fi
2216
2217if test $m4_tolower(coin_has_$1) != unavailable &&
2218   test $m4_tolower(coin_has_$1) != skipping; then
2219  # Set the #define if the component is available
2220  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
2221
2222  # Set the variables for source and object code location
2223  AC_SUBST(m4_toupper($1SRCDIR))
2224  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
2225  AC_SUBST(m4_toupper($1OBJDIR))
2226  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
2227fi
2228
2229  # Define the Makefile conditional
2230AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2231               [test $m4_tolower(coin_has_$1) != unavailable &&
2232                test $m4_tolower(coin_has_$1) != skipping])
2233AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2234]) # AC_COIN_HAS
2235
2236###########################################################################
2237#                        COIN_HAS_USER_LIBRARY                            #
2238###########################################################################
2239
2240# This macro sets up usage of a library with header files.  It defines
2241# the LBRYINCDIR variable, and it defines COIN_HAS_LBRY preprocessor
2242# macro and makefile conditional.  The first argument should be the
2243# full name (LibraryName) of the library, and the second argument (in
2244# upper case letters) the abbreviation (LBRY).  This macro also
2245# introduces the configure arguments --with-libraryname-incdir and
2246# --with-libraryname-lib which have to be both given by a user to use
2247# this solver to tell the configure script where the include files and
2248# the library are located.  Those arguments can also be given as
2249# environement variables LBRYINCDIR and LBRYLIB, but a --with-*
2250# argument overwrites an environment variable.  If a third argument is
2251# given, it is assumed that this is the name of a header file that can
2252# be checked for in the given include directory, and if a fourth
2253# argument is given, it is assumed to be the name of a C function
2254# which is given and defined in the library, and a test is done to
2255# check if that symbol is defined in the library.
2256# If it possible to disable the check, by specifying
2257# --disable-libraryname-libcheck - this is a workaround for platforms
2258# where checks don't work (yet) properly.
2259
2260AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
2261[AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2262AC_MSG_CHECKING(if user provides library for $1)
2263
2264# Check for header file directory
2265AC_ARG_WITH(m4_tolower($1)-incdir,
2266            AC_HELP_STRING([--with-m4_tolower($1)-incdir],
2267                           [specify the directory with the header files for library $1]),
2268                           [$2INCDIR=`cd $withval; pwd`])
2269# Check for library directory
2270AC_ARG_WITH(m4_tolower($1)-lib,
2271            AC_HELP_STRING([--with-m4_tolower($1)-lib],
2272                           [specify the flags to link with the library $1]),
2273                           [$2LIB=$withval])
2274# Switch to disable library check if requested
2275AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2276              AC_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2277                             [use disable-m4_tolower($1)-libcheck to skip the link check at configuration time]),
2278              [m4_tolower($1)_libcheck=$enableval],
2279              [m4_tolower($1)_libcheck=yes])
2280
2281if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2282  m4_tolower(coin_has_$2)=true
2283else
2284  m4_tolower(coin_has_$2)=false
2285fi
2286
2287if test $m4_tolower(coin_has_$2) = true; then
2288# Check either both arguments or none are given
2289  if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2290    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])
2291  fi
2292  AC_MSG_RESULT(yes)
2293  # Check if the given header file is there
2294  m4_ifvaln([$3],[AC_CHECK_FILE([$$2INCDIR/$3],[],
2295                 [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2296  # Check if the symbol is provided in the library
2297  # ToDo: FOR NOW WE ASSUME THAT WE ARE USING THE C++ COMPILER
2298  m4_ifvaln([$4],[if test x"$m4_tolower($1)_libcheck" != xno; then
2299                    coin_save_LIBS="$LIBS"
2300                    LIBS="$$2LIB $ADDLIBS"
2301                    AC_MSG_CHECKING([whether symbol $4 is available with $2])
2302                    AC_LANG_PUSH(C)
2303# ToDo find out what to do about extern "C"
2304#                    AC_TRY_LINK([extern "C" {void $4();}],[$4()],
2305                    AC_TRY_LINK([void $4();],[$4()],
2306                                [AC_MSG_RESULT(yes)],
2307                                [AC_MSG_RESULT(no)
2308                                 AC_MSG_ERROR([Cannot find symbol $4 with $2])])
2309                    AC_LANG_POP(C)
2310                    LIBS="$coin_save_LIBS"
2311                  fi])
2312  ADDLIBS="$$2LIB $ADDLIBS"
2313  AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is used])
2314else
2315  AC_MSG_RESULT(no)
2316fi
2317
2318AC_SUBST($2INCDIR)
2319AC_SUBST($2LIB)
2320AM_CONDITIONAL(COIN_HAS_$2,
2321               test $m4_tolower(coin_has_$2) = true)
2322]) #AC_COIN_HAS_SOLVER
2323
2324###########################################################################
2325#                               COIN_HAS_ASL                              #
2326###########################################################################
2327
2328# This macro checks if the user has provide arguments that say where
2329# the precompiled ASL files should be found (with the --with-asldir
2330# flag).  If this is not the case, we check if the ThirdParty/ASL
2331# directory has been configured, which indicates that the files will
2332# be in that directory and can be used.
2333
2334AC_DEFUN([AC_COIN_HAS_ASL],
2335[coin_aslobjdir=../ThirdParty/ASL
2336coin_aslsrcdir=$srcdir/$coin_aslobjdir
2337
2338# Determine the name of the ASL library
2339case "$CXX" in
2340  cl* | */cl* | CL* | */CL*)
2341    ampllib=amplsolv.lib ;;
2342  *)
2343    ampllib=amplsolver.a ;;
2344esac
2345
2346AC_ARG_WITH([asldir],
2347            AC_HELP_STRING([--with-asldir],
2348                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
2349            [use_asldir=$withval], [use_asldir=])
2350
2351if test "$use_asldir" = BUILD; then
2352  AC_CHECK_FILE([$coin_aslobjdir/Makefile],[],
2353                [AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])])
2354elif test -z "$use_asldir"; then
2355 # try to find sources - if not given don't compile
2356  AC_CHECK_FILE([$coin_aslobjdir/Makefile],[use_asldir=BUILD],[use_asldir=no])
2357elif test "$use_asldir" != "no"; then
2358  AC_CHECK_FILE([$use_asldir/$ampllib],[],
2359                [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
2360  AC_CHECK_FILE([$use_asldir/asl.h],[],
2361                [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
2362  use_asldir=`cd $use_asldir; pwd`
2363  case $build in
2364    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
2365  esac
2366fi
2367
2368# Variable containing ASL library (including full path)
2369AC_SUBST(ASLLIB)
2370# Variable containing flags for including ASL header files
2371AC_SUBST(ASL_CPPFLAGS)
2372
2373if test "$use_asldir" = BUILD; then
2374  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
2375  ASLLIB=`$CYGPATH_W $coin_aslobjdir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2376  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
2377  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir | sed -e sX\\\\\\\\X/Xg`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers | sed -e sX\\\\\\\\X/Xg`
2378elif test "$use_asldir" != no; then
2379  ASLLIB=`$CYGPATH_W $use_asldir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2380  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir | sed -e sX\\\\\\\\X/Xg`
2381fi
2382
2383if test "$use_asldir" != no; then
2384  AC_LANG_PUSH(C)
2385  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
2386  coin_has_asl=yes
2387  AC_DEFINE([COIN_HAS_ASL],[1],
2388            [If defined, the Ampl Solver Library is available.])
2389  AC_LANG_POP(C)
2390else
2391  coin_has_asl=no
2392fi
2393AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
2394]) # AC_COIN_HAS_ASL
2395
2396###########################################################################
2397#                            COIN_TRY_FLINK                               #
2398###########################################################################
2399
2400# Auxilliary macro to test if a Fortran function name can be linked,
2401# given the current settings of LIBS.  We determine from the context, what
2402# the currently active programming language is, and cast the name accordingly.
2403# The first argument is the name of the function/subroutine, in small letters,
2404# the second argument are the actions taken when the test works, and the
2405# third argument are the actions taken if the test fails.
2406
2407AC_DEFUN([AC_COIN_TRY_FLINK],
2408[case $ac_ext in
2409  f)
2410    AC_TRY_LINK(,[      call $1],[$2],[$3])
2411    ;;
2412  c)
2413    AC_F77_FUNC($1,cfunc$1)
2414    if test x"$coin_need_flibs" = xyes; then
2415      flink_try=no;
2416    else
2417      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2418                  [flink_try=yes],[flink_try=no])
2419    fi
2420    if test $flink_try = yes; then
2421      $2
2422    else
2423      if test x"$FLIBS" != x; then
2424        flink_save_libs="$LIBS"
2425        LIBS="$LIBS $FLIBS"
2426        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2427                    [LIBS="$flink_save_libs"
2428                     $2
2429                     coin_need_flibs=yes],
2430                    [LIBS="$flink_save_libs"
2431                     $3])
2432      else
2433        $3
2434      fi
2435    fi
2436    ;;
2437  cc|cpp)
2438    AC_F77_FUNC($1,cfunc$1)
2439    if test x"$coin_need_flibs" = xyes; then
2440      flink_try=no;
2441    else
2442      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2443                  [flink_try=yes],[flink_try=no])
2444    fi
2445    if test $flink_try = yes; then
2446      $2
2447    else
2448      if test x"$FLIBS" != x; then
2449        flink_save_libs="$LIBS"
2450        LIBS="$LIBS $FLIBS"
2451        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2452                    [LIBS="$flink_save_libs"
2453                     $2
2454                     coin_need_flibs=yes],
2455                    [LIBS="$flink_save_libs"
2456                     $3])
2457      else
2458        $3
2459      fi
2460    fi
2461    ;;
2462esac
2463]) # AC_COIN_TRY_FLINK
2464
2465###########################################################################
2466#                             COIN_HAS_BLAS                               #
2467###########################################################################
2468
2469# This macro checks for a library containing the BLAS library.  It
2470# tries standard libraries, and if none is found to be working, it
2471# checks whether the BLAS ThirdParty/Blas directory has been configured.
2472# It adds to ADDLIBS any flags required to link with an externally provided
2473# BLAS.  It defines the makefile conditional and preprocessor macro
2474# COIN_HAS_BLAS, if blas is available, and it defines the makefile conditional
2475# COIN_BUILD_BLAS, if blas is compiled within COIN.
2476
2477AC_DEFUN([AC_COIN_HAS_BLAS],
2478[coin_blasobjdir=../ThirdParty/Blas
2479coin_blassrcdir=$srcdir/$coin_blasobjdir
2480
2481AC_ARG_WITH([blas],
2482            AC_HELP_STRING([--with-blas],
2483                           [specify BLAS library (or BUILD for compilation)]),
2484            [use_blas=$withval], [use_blas=])
2485
2486# Check if user supplied option makes sense
2487if test x"$use_blas" != x; then
2488  if test "$use_blas" = "BUILD"; then
2489    AC_CHECK_FILE([$coin_blasobjdir/Makefile],[],
2490                  [AC_MSG_ERROR([option \"BUILD\" specified for Blas, but $coin_blasobjdir directory is not configured])])
2491  elif test "$use_blas" != no ; then
2492    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2493    LIBS="$use_blas $LIBS"
2494    ADDLIBS="$use_blas $ADDLIBS"
2495    AC_COIN_TRY_FLINK([daxpy],
2496                      [AC_MSG_RESULT([yes])],
2497                      [AC_MSG_RESULT([no])
2498                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2499  fi
2500else
2501# Try to autodetect the library for blas based on build system
2502  AC_MSG_CHECKING([default locations for BLAS])
2503  case $build in
2504    *-sgi-*)
2505      SAVE_LIBS="$LIBS"
2506      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2507      LIBS="-lcomplib.sgimath $LIBS"
2508      AC_COIN_TRY_FLINK([daxpy],
2509                        [AC_MSG_RESULT([yes])
2510                         use_blas=-lcomplib.sgimath;
2511                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2512                        [AC_MSG_RESULT([no])
2513                         SAVE_LIBS="$LIBS"])
2514      ;;
2515    *-sun-*)
2516      SAVE_LIBS="$LIBS"
2517      AC_MSG_CHECKING([whether -xlic_lib=sunperf has BLAS])
2518      LIBS="-xlic_lib=sunperf $LIBS"
2519      AC_COIN_TRY_FLINK([daxpy],
2520                        [AC_MSG_RESULT([yes])
2521                         use_blas='-xlic_lib=sunperf'
2522                         ADDLIBS="-xlic_lib=sunperf $ADDLIBS"],
2523                        [AC_MSG_RESULT([no])
2524                         LIBS="$SAVE_LIBS"])
2525      ;;
2526# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
2527# library will want to link with cygwin, hence won't run standalone in DOS.
2528    *-cygwin*)
2529      if test "$enable_doscompile" = no; then
2530        if test -z "$use_blas"; then
2531          SAVE_LIBS="$LIBS"
2532          AC_MSG_CHECKING([whether -lblas has BLAS])
2533          LIBS="-lblas $LIBS"
2534          AC_COIN_TRY_FLINK([daxpy],
2535                            [AC_MSG_RESULT([yes])
2536                             ADDLIBS="-lblas $ADDLIBS"
2537                             use_blas='-lblas'],
2538                            [AC_MSG_RESULT([no])
2539                             LIBS="$SAVE_LIBS"])
2540        fi
2541      fi
2542      ;;
2543    esac
2544
2545# If we have no other ideas, consider building BLAS.
2546  if test -z "$use_blas"; then
2547    AC_MSG_CHECKING([if BLAS can be built.])
2548    AC_CHECK_FILE([$coin_blasobjdir/Makefile],[use_blas=BUILD])
2549  fi
2550fi
2551
2552if test "$use_blas" = BUILD; then
2553  coin_need_flibs=yes
2554fi
2555
2556AM_CONDITIONAL([COIN_HAS_BLAS],[test x"$use_blas" != x])
2557AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
2558
2559if test x"$use_blas" = x || test "$use_blas" = no; then
2560  coin_has_blas=no
2561else
2562  coin_has_blas=yes
2563  AC_DEFINE([COIN_HAS_BLAS],[1],
2564            [If defined, the BLAS Library is available.])
2565fi
2566]) # AC_COIN_HAS_BLAS
2567
2568###########################################################################
2569#                            COIN_HAS_LAPACK                              #
2570###########################################################################
2571
2572# This macro checks for a library containing the LAPACK library.  It
2573# tries standard libraries, and if none is found to be working, it
2574# checks whether the LAPACK ThirdParty/Lapack directory has been
2575# configured.  It adds to ADDLIBS any flags required to link with an
2576# externally provided LAPACK.  It defines the makefile conditional and
2577# preprocessor macro COIN_HAS_LAPACK, if lapack is available, and it
2578# defines the makefile conditional COIN_BUILD_LAPACK, if lapack is
2579# compiled within COIN.
2580
2581AC_DEFUN([AC_COIN_HAS_LAPACK],
2582[coin_lapackobjdir=../ThirdParty/Lapack
2583coin_lapacksrcdir=$srcdir/$coin_lapackobjdir
2584
2585AC_ARG_WITH([lapack],
2586            AC_HELP_STRING([--with-lapack],
2587                           [specify LAPACK library (or BUILD for compilation)]),
2588            [use_lapack=$withval], [use_lapack=])
2589
2590# Check if user supplied option makes sense
2591if test x"$use_lapack" != x; then
2592  if test "$use_lapack" = "BUILD"; then
2593    AC_CHECK_FILE([$coin_lapackobjdir/Makefile],[],
2594                  [AC_MSG_ERROR([option \"BUILD\" specified for LAPACK, but $coin_lapackobjdir directory is not configured])])
2595  else
2596    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
2597    LIBS="$use_lapack $LIBS"
2598    ADDLIBS="$use_lapack $ADDLIBS"
2599    AC_COIN_TRY_FLINK([dsyev],
2600                      [AC_MSG_RESULT([yes])],
2601                      [AC_MSG_RESULT([no])
2602                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
2603  fi
2604else
2605  if test x$coin_has_blas = xyes; then
2606    # First try to see if LAPACK is already available with BLAS library
2607    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
2608    AC_COIN_TRY_FLINK([dsyev],
2609                      [AC_MSG_RESULT([yes]); use_lapack=ok],
2610                      [AC_MSG_RESULT([no])])
2611  fi
2612  if test -z "$use_lapack"; then
2613    # Try to autodetect the library for lapack based on build system
2614    case $build in
2615      *-sgi-*)
2616        SAVE_LIBS="$LIBS"
2617        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
2618        LIBS="-lcomplib.sgimath $LIBS"
2619        AC_COIN_TRY_FLINK([dsyev],
2620                          [AC_MSG_RESULT([yes])
2621                           use_lapack=-lcomplib.sgimath;
2622                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2623                          [AC_MSG_RESULT([no])
2624                           SAVE_LIBS="$LIBS"])
2625        ;;
2626      *-sun-*)
2627        SAVE_LIBS="$LIBS"
2628        AC_MSG_CHECKING([whether -xlic_lib=sunperf has LAPACK])
2629        LIBS="-xlic_lib=sunperf $LIBS"
2630        AC_COIN_TRY_FLINK([dsyev],
2631                          [AC_MSG_RESULT([yes])
2632                           use_lapack='-xlic_lib=sunperf'
2633                           ADDLIBS="-xlic_lib=sunperf $ADDLIBS"],
2634                          [AC_MSG_RESULT([no])
2635                           LIBS="$SAVE_LIBS"])
2636        ;;
2637# On cygwin, do this check only if doscompile is disabled. The prebuilt library
2638# will want to link with cygwin, hence won't run standalone in DOS.
2639      *-cygwin*)
2640        if test "$enable_doscompile" = no; then
2641          if test -z "$use_lapack"; then
2642            SAVE_LIBS="$LIBS"
2643            AC_MSG_CHECKING([whether -llapack has LAPACK])
2644            LIBS="-llapack $LIBS"
2645            AC_COIN_TRY_FLINK([dsyev],
2646                              [AC_MSG_RESULT([yes])
2647                               ADDLIBS="-llapack $ADDLIBS"
2648                               use_lapack='-llapack'],
2649                              [AC_MSG_RESULT([no])
2650                               LIBS="$SAVE_LIBS"])
2651          fi
2652        fi
2653        ;;
2654    esac
2655  fi
2656# If we have no other ideas, consider building LAPACK.
2657  if test -z "$use_lapack"; then
2658    AC_CHECK_FILE([$coin_lapackobjdir/Makefile],[use_lapack=BUILD])
2659  fi
2660fi
2661
2662if test "$use_lapack" = BUILD; then
2663  coin_need_flibs=yes
2664fi
2665
2666AM_CONDITIONAL([COIN_HAS_LAPACK],[test x"$use_lapack" != x])
2667AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
2668
2669if test x"$use_lapack" = x; then
2670  coin_has_lapack=no
2671else
2672  coin_has_lapack=yes
2673  AC_DEFINE([COIN_HAS_LAPACK],[1],
2674            [If defined, the LAPACK Library is available.])
2675fi
2676]) # AC_COIN_HAS_LAPACK
Note: See TracBrowser for help on using the repository browser.