source: stable/BSPsplit/coin.m4 @ 1313

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

more incldir changes

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