source: stable/BSPsplit/coin.m4 @ 1455

Last change on this file since 1455 was 1455, checked in by stefan, 11 years ago

some cleanup

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