source: stable/0.6/coin.m4 @ 1824

Last change on this file since 1824 was 1824, checked in by tkr, 9 years ago

Merging r1823

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