source: stable/0.5/coin.m4 @ 215

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

making trunk (rev 214) the new stable version, still in 0.5

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