source: stable/BSPsplit/coin.m4 @ 1312

Last change on this file since 1312 was 1312, checked in by andreasw, 12 years ago

more --with-proj-instdir changes

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