source: trunk/coin.m4 @ 1689

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

add AC_SUBST for CFLAGS in COIN_HAS_PACKAGE; make abs_lib_dir point to lib/coin

  • Property svn:keywords set to Author Date Id Revision
File size: 177.9 KB
Line 
1# Copyright (C) 2006, 2009 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Common Public License.
4#
5## $Id: coin.m4 1689 2010-10-16 08:21:27Z stefan $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_PREREQ(2.59)
14
15###########################################################################
16#                           coin_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                             #
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                          #
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.
2310# If found, it sets the automake conditional COIN_HAS_ZLIB and defines the C preprocessor variable COIN_HAS_ZLIB.
2311# Further, for a (space separated) list of arguments X, it adds the linker flag to the variables X_LIBS and X_PCLIBS.
2312
2313AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2314[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2315AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2316AC_BEFORE([AC_COIN_PROG_CC],[$0])
2317AC_BEFORE([AC_COIN_PROG_F77],[$0])
2318AC_BEFORE([$0],[AC_COIN_FINALIZE])
2319
2320coin_has_zlib=no
2321if test $coin_enable_gnu = yes; then
2322  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2323
2324  if test $coin_has_zlib = yes; then
2325    AC_CHECK_LIB([z],[gzopen],
2326                 [ADDLIBS="-lz $ADDLIBS"
2327                  coin_foreach_w([myvar], [$1], [
2328                    m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"
2329                    m4_toupper(myvar)_PCLIBS="-lz $m4_toupper(myvar)_PCLIBS"
2330                  ])
2331                 ],
2332                 [coin_has_zlib=no])
2333  fi
2334
2335  if test $coin_has_zlib = yes; then
2336    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2337  fi
2338fi
2339
2340AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2341]) # AC_COIN_CHECK_GNU_ZLIB
2342
2343
2344###########################################################################
2345#                          COIN_CHECK_GNU_BZLIB                           #
2346###########################################################################
2347
2348# This macro checks for the libbz2 library.
2349# If found, it defines the C preprocessor variable COIN_HAS_BZLIB.
2350# Further, for a (space separated) list of arguments X, it adds the linker flag to the variables X_LIBS and X_PCLIBS.
2351
2352AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2353[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2354AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2355AC_BEFORE([AC_COIN_PROG_CC],[$0])
2356AC_BEFORE([AC_COIN_PROG_F77],[$0])
2357AC_BEFORE([$0],[AC_COIN_FINALIZE])
2358
2359coin_has_bzlib=no
2360if test $coin_enable_gnu = yes; then
2361  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2362
2363  if test $coin_has_bzlib = yes; then
2364    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2365                 [ADDLIBS="-lbz2 $ADDLIBS"
2366                  coin_foreach_w([myvar], [$1], [
2367                    m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"
2368                    m4_toupper(myvar)_PCLIBS="-lbz2 $m4_toupper(myvar)_PCLIBS"
2369                  ])
2370                 ],
2371                 [coin_has_bzlib=no])
2372  fi
2373
2374  if test $coin_has_bzlib = yes; then
2375    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2376  fi
2377fi
2378]) # AC_COIN_CHECK_GNU_BZLIB
2379
2380
2381###########################################################################
2382#                         COIN_CHECK_GNU_READLINE                         #
2383###########################################################################
2384
2385# This macro checks for GNU's readline.  It verifies that the header
2386# readline/readline.h is available, and that the -lreadline library
2387# contains "readline".  It is assumed that #include <stdio.h> is included
2388# in the source file before the #include<readline/readline.h>
2389# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
2390# Further, for a (space separated) list of arguments X, it adds the linker flag to the variable X_LIBS and X_PCLIBS.
2391
2392AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2393[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2394AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2395AC_BEFORE([AC_COIN_PROG_CC],[$0])
2396AC_BEFORE([AC_COIN_PROG_F77],[$0])
2397AC_BEFORE([$0],[AC_COIN_FINALIZE])
2398
2399coin_has_readline=no
2400if test $coin_enable_gnu = yes; then
2401  AC_COIN_CHECK_HEADER([readline/readline.h],
2402                       [coin_has_readline=yes],[],
2403                       [#include <stdio.h>])
2404
2405  coin_save_LIBS="$LIBS"
2406  LIBS=
2407  # First we check if tputs and friends are available
2408  if test $coin_has_readline = yes; then
2409    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2410                   [coin_has_readline=no])
2411  fi
2412
2413  # Now we check for readline
2414  if test $coin_has_readline = yes; then
2415    AC_CHECK_LIB([readline],[readline],
2416                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"
2417                  coin_foreach_w([myvar], [$1], [
2418                    m4_toupper(myvar)_LIBS="-lreadline $LIBS $m4_toupper(myvar)_LIBS"
2419                    m4_toupper(myvar)_PCLIBS="-lreadline $LIBS $m4_toupper(myvar)_PCLIBS"
2420                  ])
2421                 ],
2422                 [coin_has_readline=no])
2423  fi
2424
2425  if test $coin_has_readline = yes; then
2426    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2427  fi
2428
2429  LIBS="$coin_save_LIBS"
2430fi
2431]) # AC_COIN_CHECK_GNU_READLINE
2432
2433###########################################################################
2434#                             COIN_DATA_PATH                              #
2435###########################################################################
2436
2437# This macro defines a preprocessor macro with the absolute path to a
2438# subdirectory of Data.  The argument of this macro is the name of the
2439# subdirectory (in correct case), and the name of the macro is
2440# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2441# the directory.  The path ends with a separator ("/" for linux and
2442# '\\' for Windows).  The default value for this path can be
2443# overwritten with the input variable with the same name
2444# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2445# $srcdir/../Data subdirectory.
2446
2447AC_DEFUN([AC_COIN_DATA_PATH],
2448[AC_MSG_CHECKING([absolute path to data directory $1])
2449
2450AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2451
2452if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2453  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2454fi
2455
2456# Under Cygwin, use Windows path.  Add separator
2457case $build in
2458  *-cygwin*)
2459    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2460    ;;
2461  *)
2462    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2463    ;;
2464esac
2465
2466if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2467  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2468            [Define to absolute path for Data subdirectory $1])
2469  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2470else
2471  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2472fi
2473]) # AC_COIN_HAS_DATA
2474
2475###########################################################################
2476#                       COIN_LINK_FROM_FILELIST                           #
2477###########################################################################
2478
2479# This macro creates links (or copies, if necessary) to files listed
2480# as content in a text file (second argument) into a target directory
2481# (first argument), which is created if it doesn't exist yet.  If s link
2482# already exists, nothing happens.
2483
2484AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
2485[cmd="$3"
2486if test -e $srcdir/$2 ; then
2487  my_target_dir="$1"
2488  my_link_files=`cat $srcdir/$2`
2489  my_dirname=`AS_DIRNAME($2)`
2490#  if test -e $my_target_dir; then : ; else
2491#    AS_MKDIR_P($my_target_dir)
2492#  fi
2493  for i in $my_link_files; do
2494    #rm -rf $my_target_dir/$i
2495    if test -e $my_target_dir/$i; then : ; else
2496      dirn2=`AS_DIRNAME($my_target_dir/$i)`
2497      if test -e $dirn2; then : ; else
2498        AS_MKDIR_P($dirn2)
2499      fi
2500      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
2501    fi
2502  done
2503else
2504  AC_MSG_WARN([File list file $2 missing!])
2505fi
2506])
2507
2508AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
2509[
2510AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2511echo Creating links in $1 ...
2512AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
2513])
2514
2515###########################################################################
2516#                       COIN_COPY_FROM_FILELIST                           #
2517###########################################################################
2518
2519# Like COIN_LINK_FROM_FILELIST, but copies the files.
2520
2521AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
2522[
2523echo Creating copies in $1 ...
2524AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
2525])
2526
2527###########################################################################
2528#                          COIN_EXAMPLE_FILES                             #
2529###########################################################################
2530
2531# This macro determines the names of the example files (using the
2532# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2533# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2534# creates soft links to the example files.
2535
2536AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2537[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
2538AC_REQUIRE([AC_COIN_CHECK_VPATH])
2539AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
2540AC_REQUIRE([AC_PROG_LN_S])
2541
2542files=`cd $srcdir; ls $1`
2543# We need to do the following loop to make sure that are no newlines
2544# in the variable
2545for file in $files; do
2546  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2547done
2548if test $coin_vpath_config = yes; then
2549  lnkcmd=
2550  if test "$enable_doscompile" != no; then
2551    lnkcmd=cp
2552  fi
2553  case "$CC" in
2554    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2555      lnkcmd=cp ;;
2556  esac
2557  if test "x$lnkcmd" = xcp; then
2558    AC_MSG_NOTICE([Copying example files ($1)])
2559  else
2560    AC_MSG_NOTICE([Creating links to the example files ($1)])
2561    lnkcmd="$LN_S"
2562  fi
2563  for file in $EXAMPLE_FILES; do
2564    rm -f $file
2565    $lnkcmd $srcdir/$file $file
2566  done
2567  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2568else
2569  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2570fi
2571
2572# In case there are compressed files, we create a variable with the
2573# uncompressed names
2574EXAMPLE_UNCOMPRESSED_FILES=
2575for file in $EXAMPLE_FILES; do
2576  case $file in
2577    *.gz)
2578      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2579      ;;
2580  esac
2581done
2582
2583AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2584AC_SUBST(EXAMPLE_FILES)
2585AC_SUBST(EXAMPLE_CLEAN_FILES)
2586]) #AC_COIN_EXAMPLE_FILES
2587
2588###########################################################################
2589#                            COIN_HAS_PROJECT (deprecated)                #
2590###########################################################################
2591
2592# This macro sets up usage of a Coin package.  It defines the PKGSRCDIR,
2593# PKGOBJDIR, and PKGDOCDIR variables, referring to the main source, object, and
2594# documentation directories of the package, respectively.  It also defines a
2595# COIN_HAS_PKG preprocessor macro and makefile conditional.  The argument
2596# should be the name (Pkg) of the project (in correct lower and upper case)
2597
2598AC_DEFUN([AC_COIN_HAS_PROJECT],
2599[AC_MSG_CHECKING([for COIN project $1])
2600
2601# First check, if the sub-project is actually available (ToDo: allow
2602# other locations)
2603
2604m4_tolower(coin_has_$1)=unavailable
2605if test x"$COIN_SKIP_PROJECTS" != x; then
2606  for dir in $COIN_SKIP_PROJECTS; do
2607    if test $dir = $1; then
2608      m4_tolower(coin_has_$1)=skipping
2609    fi
2610  done
2611fi
2612
2613if test $m4_tolower(coin_has_$1) != skipping; then
2614  if test $PACKAGE_TARNAME = m4_tolower($1); then
2615    m4_tolower(coin_has_$1)=.
2616  else
2617    if test -d $srcdir/../$1; then
2618      m4_tolower(coin_has_$1)=../$1
2619    fi
2620  fi
2621fi
2622
2623if test $m4_tolower(coin_has_$1) != unavailable &&
2624   test $m4_tolower(coin_has_$1) != skipping; then
2625  # Set the #define if the component is available
2626  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
2627
2628  # Set the variables for source and object code location
2629  AC_SUBST(m4_toupper($1SRCDIR))
2630  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
2631  AC_SUBST(m4_toupper($1OBJDIR))
2632  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
2633  AC_SUBST(m4_toupper($1DOCDIR))
2634  m4_toupper($1DOCDIR)=$abs_lib_dir/../../share/doc/coin/$1
2635fi
2636
2637  # Define the Makefile conditional
2638AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2639               [test $m4_tolower(coin_has_$1) != unavailable &&
2640                test $m4_tolower(coin_has_$1) != skipping])
2641AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2642]) # AC_COIN_HAS_PROJECT
2643
2644###########################################################################
2645#                        COIN_HAS_USER_LIBRARY                            #
2646###########################################################################
2647# This macro sets up usage of a user library with header files. The assumption
2648# is that the header file(s) and library do not reside in standard system
2649# directories, hence both the include directory and link flags must be
2650# specified. There are two mandatory arguments and two optional arguments.
2651#
2652# The first argument (mandatory) should be a name (LibraryName) for the
2653# library.  The second argument (mandatory) should be an abbreviation in
2654# upper case letters (LBRY) for the library. Ultimately, the macro will
2655# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2656# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2657# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2658# directory containing include files for the library. LBRYLIB should specify
2659# the flags necessary to link to the library. A variable coin_has_lbry will
2660# be set to true or false, as appropriate. A variable lbry_libcheck will be
2661# be set to yes or no; no indicates link checks should not be attempted.
2662#
2663# The macro defines three configure arguments, --with-libraryname-incdir,
2664# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2665# LibraryName to lower case.
2666#
2667# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2668# part of the configure command using --with-libraryname-incdir and
2669# --with-libraryname-lib, respectively. Command line arguments override
2670# environment variables.
2671#
2672# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2673# macro will check for the presence of the file. If a fourth argument is given,
2674# it should specify a function name, `fname'.  The macro will attempt to link a
2675# trivial program containing a parameterless call to the function, `fname()',
2676# using the LBRYLIB flags. The link check uses C as the language; this has been
2677# adequate to date but has limitations. It is possible to disable the link
2678# check by specifying --disable-libraryname-libcheck. This is a workaround for
2679# instances where the link check does not work properly, for whatever reason.
2680# If you're trying to link to a Fortran library, consider using F77_FUNC or
2681# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2682# library, you're on your own unless the library declares some function with
2683# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2684# name.
2685# A fifth argument can be specified to include linker flags that may be required
2686# to sucessfully perform the linking check.
2687#
2688# An optional sixth argument can be given to specify a list of targets.
2689# For each target X, the variables X_LIBS and X_PCLIBS will be extended by $LBRYLIB,
2690# if the library has been found and seems to work.
2691
2692AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
2693[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2694  AC_MSG_CHECKING(if user provides library for $1)
2695
2696# Check for header file directory
2697
2698  AC_ARG_WITH(m4_tolower($1)-incdir,
2699      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2700                     [specify the header file directory for library $1]),
2701      [$2INCDIR=`cd $withval; pwd`])
2702
2703# Check for library directory
2704
2705  AC_ARG_WITH(m4_tolower($1)-lib,
2706      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2707                     [specify the flags used to link with the library $1]),
2708      [$2LIB=$withval])
2709
2710# Switch to disable library check if requested
2711
2712  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2713      AS_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2714                     [use disable-m4_tolower($1)-libcheck to skip the link
2715                      check at configuration time]),
2716      [m4_tolower($1)_libcheck=$enableval],
2717      [m4_tolower($1)_libcheck=yes])
2718
2719# At this point, if we're going to use the library, both LBRYINCDIR and
2720# LBRYLIB must be defined and not empty.
2721
2722  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2723    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2724      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.])
2725    fi
2726    m4_tolower(coin_has_$2)=true
2727    AC_MSG_RESULT(yes)
2728  else
2729    m4_tolower(coin_has_$2)=false
2730    AC_MSG_RESULT(no)
2731  fi
2732
2733# If we have instructions for use, consider header and link checks.
2734
2735  if test $m4_tolower(coin_has_$2) = true; then
2736
2737# If argument 3 (file) is given, check for the file. Typically this will be a
2738# header file, but that's not assumed.
2739
2740    m4_ifval([$3],
2741        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2742             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2743
2744# Now see if we can link the function. There are arguments for and against
2745# assuming argument 3 is a header file declaring the function. A correct
2746# function declaration is the main argument in favour. Having to cope with
2747# possible dependencies or other oddities are the main arguments against.
2748# Force the use of C as the best single choice amongst C++, C, and Fortran.
2749# Obviously, this has limits.
2750
2751    m4_ifvaln([$4],
2752        [if test x"$m4_tolower($1)_libcheck" != xno; then
2753           coin_save_LIBS="$LIBS"
2754           LIBS="$$2LIB $ADDLIBS $5"
2755           coin_$2_link=no
2756           AC_LANG_PUSH(C)
2757           for fnm in $4 ; do
2758             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2759             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2760                 [AC_MSG_RESULT(yes)
2761                  coin_$2_link=yes
2762                  break],
2763                 [AC_MSG_RESULT(no)])
2764           done
2765           AC_LANG_POP(C)
2766           LIBS="$coin_save_LIBS"
2767           if test x"$coin_$2_link" != xyes ; then
2768             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2769           fi
2770         fi])
2771
2772# If we make it this far, we've verified the file and linked the function. Add
2773# the necessary link flags to ADDLIBS and $6_{PC}LIBS and define the preprocessor symbol
2774# COIN_HAS_LBRY.
2775
2776    ADDLIBS="$$2LIB $ADDLIBS"
2777    coin_foreach_w([myvar], [$6], [
2778      m4_toupper(myvar)_LIBS="$$2LIB $m4_toupper(myvar)_LIBS"
2779      m4_toupper(myvar)_PCLIBS="$$2LIB $m4_toupper(myvar)_PCLIBS"
2780    ])
2781   
2782    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2783  fi
2784
2785# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2786# automake conditional. These actions must occur unconditionally.
2787
2788  AC_SUBST($2INCDIR)
2789  AC_SUBST($2LIB)
2790  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2791]) #AC_COIN_HAS_USER_LIBRARY
2792
2793###########################################################################
2794#                               COIN_HAS_ASL                              #
2795###########################################################################
2796
2797# This macro checks if the user has provide arguments that say where
2798# the precompiled ASL files should be found (with the --with-asldir
2799# flag).  If this is not the case, we check if the ThirdParty/ASL
2800# directory has been configured, which indicates that the files will
2801# be in that directory and can be used.
2802
2803AC_DEFUN([AC_COIN_HAS_ASL],
2804[coin_aslobjdir=../ThirdParty/ASL
2805coin_aslsrcdir=$srcdir/$coin_aslobjdir
2806
2807# Determine the name of the ASL library
2808case "$CC" in
2809  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2810    ampllib=amplsolv.lib ;;
2811  *)
2812    ampllib=amplsolver.a ;;
2813esac
2814
2815AC_ARG_WITH([asldir],
2816            AC_HELP_STRING([--with-asldir],
2817                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
2818            [use_asldir=$withval], [use_asldir=])
2819
2820if test "$use_asldir" = BUILD; then
2821  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2822    # If we are configuring ThirdParty/ASL, don't check
2823    if test -r $coin_aslobjdir/.MakeOk; then :; else
2824      AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])
2825    fi
2826  fi
2827elif test -z "$use_asldir"; then
2828 # try to find sources - if not given don't compile
2829  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2830    if test -r $coin_aslobjdir/.MakeOk; then
2831      use_asldir=BUILD
2832    else
2833      use_asldir=no
2834    fi
2835  else
2836    use_asldir=no
2837  fi
2838elif test "$use_asldir" != "no"; then
2839  AC_COIN_CHECK_FILE([$use_asldir/$ampllib],[],
2840                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
2841  AC_COIN_CHECK_FILE([$use_asldir/asl.h],[],
2842                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
2843  use_asldir=`cd $use_asldir; pwd`
2844  case $build in
2845    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
2846  esac
2847fi
2848
2849# Variable containing ASL library (including full path)
2850AC_SUBST(ASLLIB)
2851# Variable containing flags for including ASL header files
2852AC_SUBST(ASL_CPPFLAGS)
2853
2854if test "$use_asldir" = BUILD; then
2855  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
2856  ASLLIB=`$CYGPATH_W $coin_aslobjdir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2857  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
2858  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir | sed -e sX\\\\\\\\X/Xg`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers | sed -e sX\\\\\\\\X/Xg`
2859elif test "$use_asldir" != no; then
2860  ASLLIB=`$CYGPATH_W $use_asldir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2861  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir | sed -e sX\\\\\\\\X/Xg`
2862fi
2863
2864if test "$use_asldir" != no; then
2865  AC_LANG_PUSH(C)
2866  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
2867  coin_has_asl=yes
2868  AC_DEFINE([COIN_HAS_ASL],[1],
2869            [If defined, the Ampl Solver Library is available.])
2870  AC_LANG_POP(C)
2871else
2872  coin_has_asl=no
2873fi
2874AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
2875]) # AC_COIN_HAS_ASL
2876
2877###########################################################################
2878#                            COIN_TRY_FLINK                               #
2879###########################################################################
2880
2881# Auxilliary macro to test if a Fortran function name can be linked,
2882# given the current settings of LIBS.  We determine from the context, what
2883# the currently active programming language is, and cast the name accordingly.
2884# The first argument is the name of the function/subroutine, in small letters,
2885# the second argument are the actions taken when the test works, and the
2886# third argument are the actions taken if the test fails.
2887
2888AC_DEFUN([AC_COIN_TRY_FLINK],
2889[case $ac_ext in
2890  f)
2891    AC_TRY_LINK(,[      call $1],[$2],[$3])
2892    ;;
2893  c)
2894    AC_F77_FUNC($1,cfunc$1)
2895    if test x"$coin_need_flibs" = xyes; then
2896      flink_try=no;
2897    else
2898      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2899                  [flink_try=yes],[flink_try=no])
2900    fi
2901    if test $flink_try = yes; then
2902      $2
2903    else
2904      if test x"$FLIBS" != x; then
2905        flink_save_libs="$LIBS"
2906        LIBS="$LIBS $FLIBS"
2907        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2908                    [LIBS="$flink_save_libs"
2909                     $2
2910                     coin_need_flibs=yes],
2911                    [LIBS="$flink_save_libs"
2912                     $3])
2913      else
2914        $3
2915      fi
2916    fi
2917    ;;
2918  cc|cpp)
2919    AC_F77_FUNC($1,cfunc$1)
2920    if test x"$coin_need_flibs" = xyes; then
2921      flink_try=no;
2922    else
2923      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2924                  [flink_try=yes],[flink_try=no])
2925    fi
2926    if test $flink_try = yes; then
2927      $2
2928    else
2929      if test x"$FLIBS" != x; then
2930        flink_save_libs="$LIBS"
2931        LIBS="$LIBS $FLIBS"
2932        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2933                    [LIBS="$flink_save_libs"
2934                     $2
2935                     coin_need_flibs=yes],
2936                    [LIBS="$flink_save_libs"
2937                     $3])
2938      else
2939        $3
2940      fi
2941    fi
2942    ;;
2943esac
2944]) # AC_COIN_TRY_FLINK
2945
2946###########################################################################
2947#                             COIN_HAS_BLAS                               #
2948###########################################################################
2949
2950# This macro checks for a library containing the BLAS library.  It
2951# tries standard libraries, and if none is found to be working, it
2952# checks whether the BLAS ThirdParty/Blas directory has been configured.
2953# It adds to ADDLIBS any flags required to link with an externally provided
2954# BLAS.  It defines the makefile conditional and preprocessor macro
2955# COIN_HAS_BLAS, if blas is available, and it defines the makefile conditional
2956# COIN_BUILD_BLAS, if blas is compiled within COIN.
2957
2958AC_DEFUN([AC_COIN_HAS_BLAS],
2959[if test "$PACKAGE_NAME" = ThirdPartyBlas || test "$PACKAGE_NAME" = ThirdPartyLapack || test "$PACKAGE_NAME" = ThirdPartyMumps; then
2960  coin_blasobjdir=../Blas
2961else
2962  coin_blasobjdir=../ThirdParty/Blas
2963fi
2964coin_blassrcdir=$srcdir/$coin_blasobjdir
2965
2966AC_ARG_WITH([blas],
2967            AC_HELP_STRING([--with-blas],
2968                           [specify BLAS library (or BUILD for compilation)]),
2969            [use_blas=$withval], [use_blas=])
2970
2971MAKEOKFILE=.MakeOk
2972# Check if user supplied option makes sense
2973if test x"$use_blas" != x; then
2974  if test "$use_blas" = "BUILD"; then
2975    # Don't check for course code if this is executed in ThirdParty/Blas
2976    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2977      if test -r $coin_blasobjdir/.MakeOk; then :; else
2978        AC_MSG_ERROR([option \"BUILD\" specified for Blas, but $coin_blasobjdir directory is not properly configured])
2979      fi
2980    fi
2981  elif test "$use_blas" != no ; then
2982    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2983    LIBS="$use_blas $LIBS"
2984    ADDLIBS="$use_blas $ADDLIBS"
2985    AC_COIN_TRY_FLINK([daxpy],
2986                      [AC_MSG_RESULT([yes])],
2987                      [AC_MSG_RESULT([no])
2988                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2989  fi
2990else
2991# Try to autodetect the library for blas based on build system
2992  #AC_MSG_CHECKING([default locations for BLAS])
2993  skip_lblas_check=no
2994  case $build in
2995    *-sgi-*)
2996      SAVE_LIBS="$LIBS"
2997      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2998      LIBS="-lcomplib.sgimath $LIBS"
2999      AC_COIN_TRY_FLINK([daxpy],
3000                        [AC_MSG_RESULT([yes])
3001                         use_blas=-lcomplib.sgimath;
3002                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
3003                        [AC_MSG_RESULT([no])
3004                         SAVE_LIBS="$LIBS"])
3005      ;;
3006
3007# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
3008# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
3009# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
3010# that CC and cc will understand -library in Studio 13. The main extra
3011# function of -xlic_lib and -library is to arrange for the Fortran run-time
3012# libraries to be linked for C++ and C. We can arrange that explicitly.
3013    *-*-solaris*)
3014      SAVE_LIBS="$LIBS"
3015      AC_MSG_CHECKING([for BLAS in libsunperf])
3016      LIBS="-lsunperf $FLIBS $LIBS"
3017      AC_COIN_TRY_FLINK([daxpy],
3018                        [AC_MSG_RESULT([yes])
3019                         use_blas='-lsunperf'
3020                         ADDLIBS="-lsunperf $ADDLIBS"
3021                         coin_need_flibs=yes],
3022                        [AC_MSG_RESULT([no])
3023                         LIBS="$SAVE_LIBS"])
3024      ;;
3025    *-cygwin* | *-mingw*)
3026# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
3027# library will want to link with cygwin, hence won't run standalone in DOS.
3028      if test "$enable_doscompile" = mingw; then
3029        skip_lblas_check=yes
3030      fi
3031      case "$CC" in
3032        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
3033          SAVE_LIBS="$LIBS"
3034          AC_MSG_CHECKING([for BLAS in MKL])
3035          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
3036          AC_COIN_TRY_FLINK([daxpy],
3037                            [AC_MSG_RESULT([yes])
3038                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
3039                             ADDLIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $ADDLIBS"],
3040                            [AC_MSG_RESULT([no])
3041                             LIBS="$SAVE_LIBS"])
3042          ;;
3043      esac
3044      ;;
3045  esac
3046
3047  if test -z "$use_blas" && test $skip_lblas_check = no; then
3048    SAVE_LIBS="$LIBS"
3049    AC_MSG_CHECKING([whether -lblas has BLAS])
3050    LIBS="-lblas $LIBS"
3051    AC_COIN_TRY_FLINK([daxpy],
3052                      [AC_MSG_RESULT([yes])
3053                       ADDLIBS="-lblas $ADDLIBS"
3054                       use_blas='-lblas'],
3055                      [AC_MSG_RESULT([no])
3056                       LIBS="$SAVE_LIBS"])
3057  fi
3058
3059# If we have no other ideas, consider building BLAS.
3060  if test -z "$use_blas"; then
3061    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
3062      if test -r $coin_blasobjdir/.MakeOk; then
3063        use_blas=BUILD
3064      fi
3065    fi
3066  fi
3067fi
3068
3069if test "$use_blas" = BUILD; then
3070  coin_need_flibs=yes
3071fi
3072
3073AM_CONDITIONAL([COIN_HAS_BLAS],[test x"$use_blas" != x])
3074AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
3075
3076if test x"$use_blas" = x || test "$use_blas" = no; then
3077  coin_has_blas=no
3078else
3079  coin_has_blas=yes
3080  AC_DEFINE([COIN_HAS_BLAS],[1],
3081            [If defined, the BLAS Library is available.])
3082fi
3083]) # AC_COIN_HAS_BLAS
3084
3085###########################################################################
3086#                            COIN_HAS_LAPACK                              #
3087###########################################################################
3088
3089# This macro checks for a library containing the LAPACK library.  It
3090# tries standard libraries, and if none is found to be working, it
3091# checks whether the LAPACK ThirdParty/Lapack directory has been
3092# configured.  It adds to ADDLIBS any flags required to link with an
3093# externally provided LAPACK.  It defines the makefile conditional and
3094# preprocessor macro COIN_HAS_LAPACK, if lapack is available, and it
3095# defines the makefile conditional COIN_BUILD_LAPACK, if lapack is
3096# compiled within COIN.
3097
3098AC_DEFUN([AC_COIN_HAS_LAPACK],
3099[coin_lapackobjdir=../ThirdParty/Lapack
3100coin_lapacksrcdir=$srcdir/$coin_lapackobjdir
3101
3102AC_ARG_WITH([lapack],
3103            AC_HELP_STRING([--with-lapack],
3104                           [specify LAPACK library (or BUILD for compilation)]),
3105            [use_lapack=$withval], [use_lapack=])
3106
3107# Check if user supplied option makes sense
3108if test x"$use_lapack" != x; then
3109  if test "$use_lapack" = "BUILD"; then
3110    # Don't check for course code if this is executed in ThirdParty/Lapack
3111    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
3112      if test -r $coin_lapackobjdir/.MakeOk; then :; else
3113        AC_MSG_ERROR([option \"BUILD\" specified for LAPACK, but $coin_lapackobjdir directory is not configured])
3114      fi
3115    fi
3116  elif test "$use_lapack" != no; then
3117    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
3118    LIBS="$use_lapack $LIBS"
3119    ADDLIBS="$use_lapack $ADDLIBS"
3120    AC_COIN_TRY_FLINK([dsyev],
3121                      [AC_MSG_RESULT([yes])],
3122                      [AC_MSG_RESULT([no])
3123                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
3124  fi
3125else
3126  if test x$coin_has_blas = xyes; then
3127    # First try to see if LAPACK is already available with BLAS library
3128    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
3129    AC_COIN_TRY_FLINK([dsyev],
3130                      [AC_MSG_RESULT([yes]); use_lapack=ok],
3131                      [AC_MSG_RESULT([no])])
3132  fi
3133  skip_llapack_check=no
3134  if test -z "$use_lapack"; then
3135    # Try to autodetect the library for lapack based on build system
3136    case $build in
3137      *-sgi-*)
3138        SAVE_LIBS="$LIBS"
3139        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
3140        LIBS="-lcomplib.sgimath $LIBS"
3141        AC_COIN_TRY_FLINK([dsyev],
3142                          [AC_MSG_RESULT([yes])
3143                           use_lapack=-lcomplib.sgimath;
3144                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
3145                          [AC_MSG_RESULT([no])
3146                           SAVE_LIBS="$LIBS"])
3147        ;;
3148
3149# See comments in COIN_HAS_BLAS.
3150      *-*-solaris*)
3151      SAVE_LIBS="$LIBS"
3152      AC_MSG_CHECKING([for LAPACK in libsunperf])
3153      LIBS="-lsunperf $FLIBS $LIBS"
3154      AC_COIN_TRY_FLINK([dsyev],
3155                        [AC_MSG_RESULT([yes])
3156                         use_blas='-lsunperf'
3157                         ADDLIBS="-lsunperf $ADDLIBS"
3158                         coin_need_flibs=yes],
3159                        [AC_MSG_RESULT([no])
3160                         LIBS="$SAVE_LIBS"])
3161        ;;
3162# On cygwin, do this check only if doscompile is disabled. The prebuilt library
3163# will want to link with cygwin, hence won't run standalone in DOS.
3164      *-cygwin*)
3165        if test "$enable_doscompile" = mingw; then
3166          skip_llapack_check=yes
3167        fi
3168        ;;
3169    esac
3170  fi
3171
3172  if test -z "$use_lapack" && test $skip_llapack_check = no; then
3173    SAVE_LIBS="$LIBS"
3174    AC_MSG_CHECKING([whether -llapack has LAPACK])
3175    LIBS="-llapack $LIBS"
3176    AC_COIN_TRY_FLINK([dsyev],
3177                      [AC_MSG_RESULT([yes])
3178                       ADDLIBS="-llapack $ADDLIBS"
3179                       use_lapack='-llapack'],
3180                      [AC_MSG_RESULT([no])
3181                       LIBS="$SAVE_LIBS"])
3182  fi
3183
3184# If we have no other ideas, consider building LAPACK.
3185  if test -z "$use_lapack"; then
3186    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
3187      if test -r $coin_lapackobjdir/.MakeOk; then
3188        use_lapack=BUILD
3189      fi
3190    fi
3191  fi
3192fi
3193
3194if test "$use_lapack" = BUILD; then
3195  coin_need_flibs=yes
3196fi
3197
3198AM_CONDITIONAL([COIN_HAS_LAPACK],[test x"$use_lapack" != x])
3199AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
3200
3201if test x"$use_lapack" = x || test "$use_lapack" = no; then
3202  coin_has_lapack=no
3203else
3204  coin_has_lapack=yes
3205  AC_DEFINE([COIN_HAS_LAPACK],[1],
3206            [If defined, the LAPACK Library is available.])
3207fi
3208]) # AC_COIN_HAS_LAPACK
3209
3210###########################################################################
3211#                            COIN_HAS_MUMPS                               #
3212###########################################################################
3213
3214# This macro checks for a library containing the MUMPS library.  It
3215# checks if the user has provided an argument for the MUMPS library,
3216# and if not, it checks whether the MUMPS ThirdParty/Mumps directory has
3217# been configured.  It adds to ADDLIBS any flags required to link with
3218# an externally provided MUMPS.  It defines the makefile conditional
3219# and preprocessor macro COIN_HAS_MUMPS, if MUMPS is available, and it
3220# defines the makefile conditional COIN_BUILD_MUMPS, if MUMPS is
3221# compiled within COIN.
3222
3223AC_DEFUN([AC_COIN_HAS_MUMPS],
3224[
3225if test "$PACKAGE_NAME" = ThirdPartyMumps; then
3226  coin_mumpsobjdir=../Mumps
3227else
3228  coin_mumpsobjdir=../ThirdParty/Mumps
3229fi
3230coin_mumpssrcdir=$abs_source_dir/$coin_mumpsobjdir/MUMPS
3231
3232MAKEOKFILE=.MakeOk
3233
3234#check if user provides a MUMPS library (that works)
3235AC_LANG_PUSH(C)
3236SAVE_ADDLIBS="$ADDLIBS"
3237ADDLIBS="$ADDLIBS $FLIBS"
3238AC_COIN_HAS_USER_LIBRARY(mumps, MUMPS, dmumps_c.h, dmumps_c)
3239ADDLIBS="$SAVE_ADDLIBS"
3240AC_LANG_POP(C)
3241
3242if test "$coin_has_mumps" = "true"; then  # user provided mumps library
3243  use_mumps=yes
3244  coin_has_mumps=yes
3245
3246  MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $MUMPSINCDIR\`"
3247  ADDLIBS="$MUMPSLIB $ADDLIBS"
3248
3249else # no user provided library, so we try to build our own
3250  use_mumps=BUILD
3251
3252  # Check if the MUMPS' ThirdParty project has been configured
3253  if test "$PACKAGE_NAME" != ThirdPartyMumps; then
3254    if test -r $coin_mumpsobjdir/.MakeOk; then
3255      use_mumps=BUILD
3256      # Mumps needs pthreads
3257      AC_LANG_PUSH(C)
3258      save_LIBS="$LIBS"
3259      LIBS="$LIBS $FLIBS"
3260      AC_CHECK_LIB([pthread],[pthread_create],[LIBS="-lpthread $save_LIBS"; ADDLIBS="-lpthread $ADDLIBS"],[LIBS="save_LIBS"])
3261      AC_LANG_POP(C)
3262 
3263      MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $coin_mumpssrcdir/libseq\` -I\`\$(CYGPATH_W) $coin_mumpssrcdir/include\`"
3264    else
3265      use_mumps=
3266    fi
3267  fi
3268
3269  # if a user provided library is used, then COIN_HAS_USER_LIBRARY takes care of the COIN_HAS_MUMPS conditional and preprocessor symbol
3270  AM_CONDITIONAL([COIN_HAS_MUMPS],[test x"$use_mumps" != x])
3271  if test x"$use_mumps" != x; then
3272    AC_DEFINE([COIN_HAS_MUMPS],[1],[If defined, the MUMPS Library is available.])
3273    coin_has_mumps=yes
3274  else
3275    coin_has_mumps=no
3276  fi
3277  AC_MSG_CHECKING([whether MUMPS is available])
3278  AC_MSG_RESULT([$coin_has_mumps])
3279fi
3280
3281if test x"$use_mumps" != x; then
3282  # we need the Fortran runtime libraries if we want to link with C/C++
3283  coin_need_flibs=yes
3284
3285  AC_SUBST(MUMPS_INCFLAGS)
3286fi
3287
3288AM_CONDITIONAL([COIN_BUILD_MUMPS],[test "$use_mumps" = BUILD])
3289
3290]) # AC_COIN_HAS_MUMPS
3291
3292###########################################################################
3293#                            COIN_HAS_METIS                               #
3294###########################################################################
3295
3296# This macro checks for a library containing the METIS library.  It
3297# checks if the user has provided an argument for the METIS library,
3298# and if not, it checks whether the METIS ThirdParty/Metis directory has
3299# been configured.  It adds to ADDLIBS any flags required to link with
3300# an externally provided METIS.  It defines the makefile conditional
3301# and preprocessor macro COIN_HAS_METIS, if METIS is available, and it
3302# defines the makefile conditional COIN_BUILD_METIS, if METIS is
3303# compiled within COIN.
3304
3305AC_DEFUN([AC_COIN_HAS_METIS],
3306[
3307case "$PACKAGE_NAME" in
3308  ThirdParty*)
3309    coin_metisobjdir=../Metis
3310    ;;
3311  *)
3312    coin_metisobjdir=../ThirdParty/Metis
3313    ;;
3314esac
3315
3316MAKEOKFILE=.MakeOk
3317
3318#check if user provides a METIS library (that works)
3319AC_LANG_PUSH(C)
3320AC_ARG_WITH(metis,
3321   AS_HELP_STRING([--with-metis], [specify flags to link with METIS library]),
3322   [METISLIB="$withval"; coin_has_metis=true], [coin_has_metis=no])
3323
3324if test $coin_has_metis = true; then
3325  coin_save_LIBS="$LIBS"
3326  LIBS="$METISLIB $ADDLIBS"
3327  AC_MSG_CHECKING([whether symbol metis_nodend is available with ])
3328  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[metis_nodend()]])],
3329     [AC_MSG_RESULT(yes)],
3330     [AC_MSG_RESULT(no)
3331      AC_MSG_ERROR([User-supplied METIS library does not work])])
3332  LIBS="$coin_save_LIBS"
3333fi
3334AC_LANG_POP(C)
3335
3336if test "$coin_has_metis" = "true"; then  # user provided metis library
3337  use_metis=yes
3338  coin_has_metis=yes
3339
3340  ADDLIBS="$METISLIB $ADDLIBS"
3341
3342else # no user provided library, so we try to build our own
3343  use_metis=BUILD
3344
3345  # Check if the METIS' ThirdParty project has been configured
3346  if test "$PACKAGE_NAME" != ThirdPartyMetis; then
3347    if test -r $coin_metisobjdir/.MakeOk; then
3348      use_metis=BUILD
3349    else
3350      use_metis=
3351    fi
3352  fi
3353
3354  if test x"$use_metis" != x; then
3355    coin_has_metis=yes
3356  else
3357    coin_has_metis=no
3358  fi
3359  AC_MSG_CHECKING([whether METIS is available])
3360  AC_MSG_RESULT([$coin_has_metis])
3361fi
3362
3363AM_CONDITIONAL([COIN_HAS_METIS],[test $coin_has_metis = yes])
3364if test $coin_has_metis = yes; then
3365  AC_DEFINE([COIN_HAS_METIS],[1],[If defined, the METIS library is available.])
3366fi
3367
3368]) # AC_COIN_HAS_METIS
3369
3370
3371###########################################################################
3372#                             COIN_HAS_GLPK                               #
3373###########################################################################
3374#
3375# This macro checks for the GLPK package. GLPK provides two capabilities,
3376# an LP and MIP solver (GLPK) and the GNU Mathprog modelling language (GMPL).
3377# The macro checks for either Glpk or Gmpl, according to the value specified as
3378# the parameter. Use one of Glpk or Gmpl. Use *exactly* these strings, eh?
3379#
3380#
3381# The macro first uses COIN_HAS_USER_LIBRARY to see if the user has specified
3382# a preexisting library (this allows the use of any glpk version, if the user
3383# is fussy). The macro then checks for ThirdParty/Glpk.
3384#
3385# This macro will define the following variables for Glpk:
3386#   coin_has_glpk       true or false
3387#   GLPKLIB             link flags for GLPK (if user supplied)
3388#   GLPKINCDIR          location of glpk include files
3389#   COIN_HAS_GLPK       Preprocessor symbol, defined to 1
3390#   COIN_HAS_GLPK       Automake conditional
3391#   COIN_BUILD_GLPK     Automake conditional, defined only if Glpk is to be
3392#                       built in ThirdParty/Glpk
3393#
3394# With the exception of COIN_BUILD_GLPK, an identical set of variables is
3395# defined for Gmpl.
3396
3397AC_DEFUN([AC_COIN_HAS_GLPK],
3398[
3399if test "$PACKAGE_NAME" = ThirdPartyGlpk; then
3400  coin_glpkobjdir=../Glpk
3401else
3402  coin_glpkobjdir=../ThirdParty/Glpk
3403fi
3404coin_glpksrcdir=$abs_source_dir/$coin_glpkobjdir
3405
3406use_thirdpartyglpk=no
3407
3408# Check for the requested component. If the user specified an external glpk
3409# library don't force a ThirdParty build, let the error propagate.
3410
3411m4_if([$1],[Glpk],
3412[AC_COIN_HAS_USER_LIBRARY([Glpk],[GLPK],[glpk.h],
3413    [_glp_lpx_simplex glp_lpx_simplex])
3414 if test x"$coin_has_glpk" = xfalse && test x"$GLPKLIB" = x ; then
3415   use_thirdpartyglpk=try
3416 fi])
3417m4_if([$1],[Gmpl],
3418[AC_COIN_HAS_USER_LIBRARY([Gmpl],[GMPL],[glpmpl.h],
3419    [_glp_mpl_initialize glp_mpl_initialize])
3420 if test x"$coin_has_gmpl" = xfalse && test x"$GMPLLIB" = x ; then
3421   use_thirdpartyglpk=try
3422 fi])
3423
3424# If the user has supplied an external library, use it. Otherwise, consider
3425# a build in ThirdParty/Glpk. If we build, assume we get both glpk and gmpl.
3426
3427if test x"$use_thirdpartyglpk" = xtry ; then
3428  MAKEOKFILE=.MakeOk
3429  # Check if the Glpk's ThirdParty project has been configured
3430  if test "$PACKAGE_NAME" != ThirdPartyGlpk; then
3431    if test -r $coin_glpkobjdir/.MakeOk; then
3432      use_thirdpartyglpk=build
3433    else
3434      use_thirdpartyglpk=no
3435    fi
3436  else
3437    use_thirdpartyglpk=build
3438  fi
3439
3440# If we're building, set the library and include directory variables, create a
3441# preprocessor symbol, define a variable that says we're using glpk/gmpl, and
3442# another to indicate a link check is a bad idea (hard to do before the library
3443# exists).
3444
3445  if test x"$use_thirdpartyglpk" = xbuild ; then
3446    m4_toupper($1INCDIR)="$coin_glpksrcdir/glpk/include"
3447    AC_SUBST(m4_toupper($1INCDIR))
3448    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],
3449              [Define to 1 if $1 package is available])
3450    m4_tolower(coin_has_$1)=true
3451    m4_tolower($1_libcheck)=no
3452    m4_toupper($1OBJDIR)=`cd $coin_glpkobjdir; pwd`
3453    AC_SUBST(m4_toupper($1OBJDIR))
3454    AC_MSG_NOTICE([Using $1 in ThirdParty/Glpk])
3455  fi
3456fi
3457
3458# Define the necessary automake conditionals.
3459
3460AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3461               [test x"$m4_tolower(coin_has_$1)" = xtrue])
3462AM_CONDITIONAL([COIN_BUILD_GLPK],[test x"$use_thirdpartyglpk" = xbuild])
3463
3464]) # AC_COIN_HAS_GLPK
3465
3466
3467###########################################################################
3468#                           COIN_DOXYGEN                                  #
3469###########################################################################
3470#
3471# This macro determines the configuration information for doxygen, the tool
3472# used to generate online documentation of COIN code. It takes one parameter,
3473# a list of projects (mixed-case, to match the directory names) that should
3474# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
3475#
3476# This macro will define the following variables:
3477#  coin_have_doxygen    Yes if doxygen is found, no otherwise
3478#  coin_doxy_usedot     Defaults to `no'; --with-dot will check to see if
3479#                       dot is available
3480#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
3481#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
3482#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
3483#                       doxygen documentation
3484#  coin_doxy_excludes   Directories to exclude from doxygen processing
3485
3486AC_DEFUN([AC_COIN_DOXYGEN],
3487[
3488
3489AC_MSG_NOTICE([configuring doxygen documentation options])
3490
3491# Check to see if doxygen is available.
3492
3493AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
3494
3495# Look for the dot tool from the graphviz package, unless the user has
3496# disabled it.
3497
3498AC_ARG_WITH([dot],
3499  AS_HELP_STRING([--with-dot],
3500                 [use dot (from graphviz) when creating documentation with
3501                  doxygen if available; --without-dot to disable]),
3502  [],[withval=yes])
3503if test x"$withval" = xno ; then
3504  coin_doxy_usedot=NO
3505  AC_MSG_CHECKING([for dot ])
3506  AC_MSG_RESULT([disabled])
3507else
3508  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
3509fi
3510
3511# Generate a tag file name and a log file name
3512
3513AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
3514AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
3515
3516# Process the list of project names and massage them into possible doxygen
3517# doc'n directories. Prefer 1) classic external, source processed using
3518# a project-specific doxygen.conf, we use the tag file; 2) classic
3519# external, source processed using package doxygen.conf; 3) installed
3520# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
3521# configured, which we can't know unless this is the package base configure,
3522# since coin_subdirs is only set there. Hence it's sufficient to check for
3523# membership. If we use a tag file from a classic external, exclude the
3524# source from doxygen processing when doxygen runs in the base directory.
3525
3526coin_doxy_tagfiles=
3527coin_doxy_excludes=
3528tmp="$1"
3529for proj in $tmp ; do
3530  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
3531  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
3532  doxytag=${lc_proj}_doxy.tag
3533  doxyfound=no
3534  for chkProj in $coin_subdirs ; do
3535    if test "$chkProj" = "$proj" ; then
3536      # proj will be configured, hence doxydoc present in build tree
3537      doxysrcdir="${srcdir}/${proj}"
3538      # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
3539      if test -d "$doxysrcdir" ; then
3540        # with a doxydoc directory?
3541        doxydir="$doxysrcdir/doxydoc"
3542        # AC_MSG_NOTICE([Considering $doxydir (base)])
3543        # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
3544        if test -d "$doxydir" ; then
3545          # use tag file; don't process source
3546          eval doxydir="`pwd`/${proj}/doxydoc"
3547          coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
3548          AC_MSG_RESULT([$doxydir (tag)])
3549          coin_doxy_excludes="$coin_doxy_excludes */${proj}*"
3550        else
3551          # will process the source -- nothing further to be done here
3552          AC_MSG_RESULT([$doxysrcdir (src)])
3553        fi
3554        doxyfound=yes
3555      fi
3556    fi
3557  done
3558  # Not built, fall back to installed tag file
3559  if test $doxyfound = no ; then
3560    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
3561    # AC_MSG_NOTICE([Considering $doxydir (install)])
3562    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
3563    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
3564    AC_MSG_RESULT([$doxydir (tag)])
3565  fi
3566done
3567AC_SUBST([coin_doxy_tagfiles])
3568AC_SUBST([coin_doxy_excludes])
3569
3570]) # AC_COIN_DOXYGEN
3571
3572
3573###########################################################################
3574#                           COIN_HAS_PKGCONFIG                            #
3575###########################################################################
3576
3577# This macro checks whether a pkg-config tool with a minimal version number is available.
3578# If so, then the variable PKGCONFIG is set to its path.
3579# If not, PKGCONFIG is set to "".
3580# The minimal version number can be given as first parameter, by default it is 0.9.0.
3581# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4
3582#
3583# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is AC_SUBST'ed.
3584# Finally, if this setup belongs to a project directory, then the search path for .pc files
3585# is assembled from the value of $PKG_CONFIG_PATH, the values of --prefix, --coin-instdir,
3586# and the directory named in a file ../coin_subdirs.txt or ../../coin_subdirs.txt in a variable
3587# COIN_PKG_CONFIG_PATH, which is also AC_SUBST'ed.
3588
3589AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
3590[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
3591
3592AC_ARG_ENABLE([pkg-config],
3593  [AC_HELP_STRING([--enable-pkg-config],[use pkg-config if available (default is yes)])],
3594  [use_pkgconfig="$enableval"],
3595  [use_pkgconfig=yes])
3596
3597if test $use_pkgconfig = yes ; then
3598  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
3599    AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
3600  fi
3601  if test -n "$PKG_CONFIG"; then
3602    _pkg_min_version=m4_default([$1], [0.9.0])
3603    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
3604    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
3605      AC_MSG_RESULT([yes])
3606    else
3607      AC_MSG_RESULT([no])
3608      PKG_CONFIG=""
3609    fi
3610  fi
3611
3612  # check if pkg-config supports the short-errors flag
3613  if test -n "$PKG_CONFIG" && \
3614    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
3615    pkg_short_errors=" --short-errors "
3616  else
3617    pkg_short_errors=""
3618  fi
3619fi
3620
3621AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
3622AC_SUBST(PKG_CONFIG)
3623
3624# assemble pkg-config search path for installed projects
3625COIN_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3626
3627# 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
3628# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
3629# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
3630COIN_PKG_CONFIG_PATH="${prefix}/lib/pkgconfig:${COIN_PKG_CONFIG_PATH}"
3631
3632AC_ARG_WITH([coin-instdir],
3633  AC_HELP_STRING([--with-coin-instdir],
3634                 [prefix of installation directory for precompiled COIN packages]),
3635  [if test -d "$withval"; then : ; else
3636     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
3637   fi
3638   COIN_PKG_CONFIG_PATH="$withval/lib/pkgconfig:${COIN_PKG_CONFIG_PATH}"
3639  ],[])
3640
3641AC_SUBST(COIN_PKG_CONFIG_PATH)
3642
3643# assemble additional pkg-config search paths for uninstalled projects
3644if test x$coin_projectdir = xyes ; then
3645  # if we are in a project setup, then in a classic setup, we want to find uninstalled projects
3646  # their (relative) location is written to coin_subdirs.txt by the configure in the project base directory
3647  # unfortunately, if the user set prefix, then we do not know where the project base directory is located
3648  # 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)
3649  COIN_PKG_CONFIG_PATH_UNINSTALLED=
3650  if test -e ../coin_subdirs.txt ; then
3651    for i in `cat ../coin_subdirs.txt` ; do
3652      if test -d ../$i ; then
3653        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3654      fi
3655    done
3656  fi
3657
3658  if test -e ../../coin_subdirs.txt ; then
3659    for i in `cat ../../coin_subdirs.txt` ; do
3660      if test -d ../../$i ; then
3661        COIN_PKG_CONFIG_PATH_UNINSTALLED="`cd ../../$i; pwd`:${COIN_PKG_CONFIG_PATH_UNINSTALLED}"
3662      fi
3663    done
3664  fi
3665
3666  AC_SUBST(COIN_PKG_CONFIG_PATH_UNINSTALLED)
3667fi
3668
3669])
3670
3671###########################################################################
3672#                           COIN_PKG_CHECK_PROJECT_EXISTS                 #
3673###########################################################################
3674
3675# COIN_PKG_CHECK_PROJECT_EXISTS(PROJECT, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3676#
3677# Check to see whether a particular project exists.  Similar
3678# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
3679#
3680AC_DEFUN([AC_COIN_PKG_CHECK_PROJECT_EXISTS],
3681[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3682if test -n "$PKG_CONFIG" ; then
3683  if $PKG_CONFIG --exists "m4_tolower($1)"; then
3684    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
3685    m4_ifval([$2], [$2], [:])
3686  else
3687    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
3688    $3
3689  fi
3690else
3691  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
3692fi
3693])
3694
3695###########################################################################
3696#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
3697###########################################################################
3698
3699# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3700#
3701# Check to see whether a particular set of packages exists.
3702# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
3703#
3704AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
3705[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3706if test -n "$PKG_CONFIG" ; then
3707  if $PKG_CONFIG --exists "$2"; then
3708    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion $2 2>/dev/null`"
3709    $3
3710  else
3711    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors $2`
3712    $4
3713  fi
3714else
3715  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
3716fi
3717])
3718
3719###########################################################################
3720#                           COIN_PKG_HAS_MODULE                           #
3721###########################################################################
3722
3723# COIN_PKG_HAS_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3724#
3725# Checks whether pkg-config files for a given set of packages is available.
3726# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
3727# If not, then ACTION-IF-NOT-FOUND is executed.
3728# A reason for not finding a package is stored in MODULE_PKG_ERRORS
3729#
3730# --------------------------------------------------------------
3731AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
3732[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3733
3734AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
3735  [ cflags=`$PKG_CONFIG --cflags "$2" 2>/dev/null`
3736    # pkg-config cannot handle spaces, so CYGPATH_W cannot be put into .pc files
3737        # thus, we modify the cflags extracted from pkg-config by putting CYGPATH_W behind -I's
3738        # but only do this if is not trivial
3739    if test "$CYGPATH_W" != "echo" ; then
3740      # need to put into brackets since otherwise autoconf replaces the brackets in the sed command
3741          [cflags=`echo $cflags | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
3742        fi
3743    m4_toupper($1)[]_CFLAGS="$cflags"
3744    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "$2" 2>/dev/null`
3745    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "$2" 2>/dev/null`
3746    $3
3747  ],
3748  [ $4 ])
3749
3750])# PKG_CHECK_MODULES
3751
3752###########################################################################
3753#                           COIN_MAIN_PACKAGEDIR                          #
3754###########################################################################
3755
3756# This macro substitutes COIN_MAIN_SUBDIR.
3757# If $2/$1 or $1 is in COIN_SKIP_PROJECTS, do nothing.
3758# If --with-$1-lib, --with-$1-incdir, or --with-$1-datadir is given, then assume that the package is installed.
3759# Otherwise, if pkg-config is available, use it to check whether the package is available.
3760#   If $4 is given, then pkg-config is asked for the existance of $4, otherwise tolower($1) is used.
3761# Otherwise, if the directory $2/$1 and the file $2/$1/$3 exist, check whether $2/$1/configure exists.
3762#   If so, include this directory into the list of directories where configure and make recourse into.
3763# tolower(coin_has_$1) is set to notGiven, skipping, installed, the version of an installed project, or the projects main directory (if uninstalled).
3764
3765AC_DEFUN([AC_COIN_MAIN_PACKAGEDIR],
3766[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3767AC_MSG_CHECKING([whether project $1 is available])
3768
3769m4_tolower(coin_has_$1)=notGiven
3770coin_have_project_dir=no
3771
3772# check if user wants to skip project in any case
3773AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
3774if test x"$COIN_SKIP_PROJECTS" != x; then
3775  for dir in $COIN_SKIP_PROJECTS; do
3776    if test $dir = "$1"; then
3777      m4_tolower(coin_has_$1)=skipping
3778    fi
3779    if test $dir = "$2/$1"; then
3780      m4_tolower(coin_has_$1)=skipping
3781    fi
3782  done
3783fi
3784
3785if test $m4_tolower(coin_has_$1) != skipping; then
3786  if test $PACKAGE_TARNAME = m4_tolower($1); then
3787    m4_tolower(coin_has_$1)=.
3788    coin_have_project_dir=yes
3789  fi
3790
3791  AC_ARG_WITH([m4_tolower($1)-lib],
3792    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3793                   [linker flags for using project $1]),
3794      [m4_tolower(coin_has_$1)=installed],
3795      [])
3796
3797  AC_ARG_WITH([m4_tolower($1)-incdir],
3798    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3799                   [directory with header files for using project $1]),
3800    [m4_tolower(coin_has_$1)=installed],
3801    [])
3802
3803  AC_ARG_WITH([m4_tolower($1)-datadir],
3804    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3805                   [directory with data files for using project $1]),
3806    [m4_tolower(coin_has_$1)=installed],
3807    [])
3808
3809  m4_if(m4_tolower($1), blas, [
3810    #--with-blas can overwrite --with-blas-lib, and can be set to BUILD to enforce building blas
3811    AC_ARG_WITH([blas],
3812      AC_HELP_STRING([--with-blas], [specify BLAS library (or BUILD for compilation)]),
3813        [if test x"$withval" = "xBUILD" ; then
3814           coin_has_blas=notGiven
3815         else
3816           coin_has_blas=installed
3817         fi],
3818        [])])
3819
3820  m4_if(m4_tolower($1), lapack, [
3821    #--with-lapack can overwrite --with-lapack-lib, and can be set to BUILD to enforce building lapack
3822    AC_ARG_WITH([lapack],
3823      AC_HELP_STRING([--with-lapack], [specify LAPACK library (or BUILD for compilation)]),
3824        [if test x"$withval" = "xBUILD" ; then
3825           coin_has_lapack=notGiven
3826         else
3827           coin_has_lapack=installed
3828         fi],
3829        [])])
3830
3831fi
3832
3833if test $m4_tolower(coin_has_$1) = notGiven; then
3834  #check for project by using pkg-config, if pkg-config is available
3835  #we are only interested in installed packages here, so we do not search in $COIN_PKG_CONFIG_PATH_UNINSTALLED
3836  if test -n "$PKG_CONFIG" ; then
3837    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3838    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" ; export PKG_CONFIG_PATH
3839      m4_ifval([$4],
3840        [AC_COIN_PKG_CHECK_PROJECT_EXISTS([$4],
3841                [m4_tolower(coin_has_$1)="$m4_toupper([$4])_VERSION"])],
3842              [AC_COIN_PKG_CHECK_PROJECT_EXISTS([$1],
3843                [m4_tolower(coin_has_$1)="$m4_toupper([$1])_VERSION"])])
3844    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3845    export PKG_CONFIG_PATH
3846  fi
3847fi
3848
3849# if not found yet, check if project is available in present directory
3850if test "$m4_tolower(coin_has_$1)" = notGiven; then
3851  if test -d $srcdir/$2/$1; then
3852    # If a third argument is given, then we have to check if one one the files given in that third argument is present.
3853    # If none of the files in the third argument is available, then we consider the project directory as non-existing.
3854    # However, if no third argument is given, then this means that there should be no check, and existence of the directory is sufficient.
3855    m4_ifvaln([$3],
3856      [for i in $srcdir/m4_ifval($2,[$2/],)$1/$3; do
3857         if test -r $i; then
3858           coin_have_project_dir=yes
3859         fi
3860       done],
3861      [ coin_have_project_dir=yes ])
3862    if test $coin_have_project_dir = yes; then
3863      m4_tolower(coin_has_$1)=m4_ifval($2,[$2/],)$1
3864    fi
3865  fi
3866fi
3867
3868AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3869
3870AC_MSG_CHECKING(whether project $1 need to be configured)
3871if test "$coin_have_project_dir" = yes ; then
3872
3873  if test -r $srcdir/m4_ifval($2,[$2/],)$1/configure; then
3874    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
3875    AC_MSG_RESULT(yes)
3876    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
3877  else
3878    AC_MSG_RESULT(no)
3879  fi
3880else
3881  AC_MSG_RESULT(no)
3882fi
3883])
3884
3885###########################################################################
3886#                            COIN_HAS_MODULE                              #
3887###########################################################################
3888
3889# This macro sets up a COIN-OR module.
3890# A module consists of one or more COIN-OR packages.
3891# It defines the MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA variables, referring to the compiler and linker
3892# flags to use when linking against this module and the directories where the module data resists.
3893# It also defines a COIN_HAS_MODULE preprocessor macro and makefile conditional.
3894# Further, tolower(coin_has_$1) is set to "yes".
3895# If the flag 'required' is set (which is on by default), then the packages of the module are added to
3896# the REQUIREDPACKAGES variable, which can be used to setup a .pc file.
3897# The first argument should be the name (MODULE) of the module (in correct lower
3898# and upper case).
3899# The second argument should be a (space separated) list of projects which this
3900# module consists of. Optionally, required version numbers can be added.
3901# The optional third argument can be used to overwrite default values for flags like 'required'.
3902#
3903# It is also possible to specify a preinstalled version of this module
3904# or to specify only the linker and compiler flags and data directory.
3905# If the flag 'required' (which is on by default) is set, then user-given linker flags are added to
3906# the PCADDLIBS variable, which can be used to setup a .pc file.
3907#
3908# If the user did not specify --with-$1-... flags and pkg-config is not available,
3909# COIN_HAS_MODULE_FALLBACK($1, $2, $3) is called.
3910
3911AC_DEFUN([AC_COIN_HAS_MODULE],
3912[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3913AC_MSG_CHECKING([for COIN-OR module $1])
3914
3915m4_tolower(coin_has_$1)=notGiven
3916
3917# check if user wants to skip module in any case
3918if test x"$COIN_SKIP_PROJECTS" != x; then
3919  for dir in $COIN_SKIP_PROJECTS; do
3920    if test $dir = "$1"; then
3921      m4_tolower(coin_has_$1)=skipping
3922    fi
3923  done
3924fi
3925
3926m4_toupper($1_LIBS)=
3927m4_toupper($1_CFLAGS)=
3928m4_toupper($1_DATA)=
3929AC_SUBST(m4_toupper($1_LIBS))
3930AC_SUBST(m4_toupper($1_CFLAGS))
3931AC_SUBST(m4_toupper($1_DATA))
3932AC_SUBST(REQUIREDPACKAGES)
3933
3934#check if user provided LIBS, CFLAGS, or DATA for module
3935if test $m4_tolower(coin_has_$1) != skipping; then
3936
3937  AC_ARG_WITH([m4_tolower($1)-lib],
3938    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3939                   [linker flags for using module $1]),
3940      [m4_tolower(coin_has_$1)=yes
3941       m4_toupper($1_LIBS)="$withval"
3942       m4_bmatch($3, [required=0], [], [PCADDLIBS="$withval $PCADDLIBS"])
3943      ],
3944      [])
3945
3946  AC_ARG_WITH([m4_tolower($1)-incdir],
3947    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3948                   [directory with header files for using module $1]),
3949    [m4_tolower(coin_has_$1)=yes
3950     m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"],
3951    [])
3952
3953  AC_ARG_WITH([m4_tolower($1)-datadir],
3954    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3955                   [directory with data files for using module $1]),
3956    [m4_tolower(coin_has_$1)=yes
3957     m4_toupper($1_DATA)="$withval"],
3958    [])
3959fi
3960
3961if test $m4_tolower(coin_has_$1) = notGiven; then
3962  if test -n "$PKG_CONFIG" ; then
3963    # set search path for pkg-config
3964    # need to export variable to be sure that the following pkg-config gets these values
3965    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3966    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
3967    export PKG_CONFIG_PATH
3968   
3969    # let pkg-config do it's magic
3970    AC_COIN_PKG_HAS_MODULE([$1],[$2],
3971      [ m4_tolower(coin_has_$1)=yes
3972        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
3973        m4_bmatch($3, [required=0], [], [REQUIREDPACKAGES="$2 $REQUIREDPACKAGES"])
3974      ],
3975      [ m4_tolower(coin_has_$1)=notGiven
3976        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
3977      ])
3978
3979    # reset PKG_CONFIG_PATH variable
3980    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3981    export PKG_CONFIG_PATH
3982  else
3983    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
3984    AC_COIN_HAS_MODULE_FALLBACK([$1], [$2], [$3])
3985  fi
3986
3987else
3988  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3989fi
3990
3991if test $m4_tolower(coin_has_$1) != skipping &&
3992   test $m4_tolower(coin_has_$1) != notGiven ; then
3993  if test 0 = 1 ; then  #change this test to enable a bit of debugging output
3994  if test -n "$m4_toupper($1)_CFLAGS" ; then
3995    AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3996  fi
3997  if test -n "$m4_toupper($1)_LIBS" ; then
3998    AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
3999  fi
4000  if test -n "$m4_toupper($1)_DATA" ; then
4001    AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
4002  fi
4003  fi
4004  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
4005fi
4006
4007# Define the Makefile conditional
4008AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
4009               [test $m4_tolower(coin_has_$1) != notGiven &&
4010                test $m4_tolower(coin_has_$1) != skipping])
4011
4012]) # AC_COIN_HAS_MODULE
4013
4014###########################################################################
4015#                       COIN_HAS_MODULE_FALLBACK                          #
4016###########################################################################
4017
4018# This macro is used if COIN_HAS_MODULE fails to find a module because pkg-config was disabled or is not available.
4019#
4020# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc file in the directories specified in
4021# $COIN_PKG_CONFIG_PATH_UNINSTALLED. The latter variable is setup by COIN_HAS_PKGCONFIG and
4022# consists of the content of the coin_subdirs.txt file which has been created by configure in the base directory.
4023# The content of xxx-uninstalled.pc is parsed in order to defines the variables MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA,
4024# referring to the compiler and linker flags to use when linking against this module
4025# and the directory where the module data resists.
4026# Further, the Required field of each .pc file is parsed and -uninstalled.pc files for these projects are searched for.
4027# The MODULE_CFLAGS and MODULE_LIBS variables are augmented with the information from these .pc files.
4028# Thus, the macros checks also dependencies of $2.
4029# Note that the MODULE_DATA variable is set to the content of datadir of the first .pc file that is parsed.
4030#
4031# If .pc files for all projects in $2 and their dependencies is found, tolower(coin_has_$1) is set to "yes".
4032# Otherwise, if some dependency is not found, tolower(coin_has_$1) is set to no.
4033# Further, a COIN_HAS_MODULE preprocessor macro and a makefile conditional are defined.
4034# If the flag 'required' is set (which is on by default), then the module package is added to
4035# the REQUIREDPACKAGES variable, which can be used to setup a .pc file.
4036#
4037# The first argument should be the name (MODULE) of the module (in correct lower and upper case).
4038# The second argument should be the base names of the projects .pc file which define this module.
4039# The optional third argument can be used to overwrite default values for flags like 'required'.
4040
4041# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into $COIN_PKG_CONFIG_PATH_UNINSTALLED.
4042# When the content of this variable was setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
4043
4044AC_DEFUN([AC_COIN_HAS_MODULE_FALLBACK],
4045[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
4046AC_MSG_CHECKING([for COIN-OR module $1 (fallback)])
4047
4048m4_tolower(coin_has_$1)=notGiven
4049m4_toupper($1_LIBS)=
4050m4_toupper($1_CFLAGS)=
4051m4_toupper($1_DATA)=
4052AC_SUBST(REQUIREDPACKAGES)
4053
4054# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x)
4055projtoprocess="m4_bpatsubsts([$2], [<?>?=[      ]*[^    ]+])"
4056projprocessed=""
4057
4058while test $m4_tolower(coin_has_$1) = notGiven ; do
4059  # setup list of projects that need to be processed in the next round
4060  nextprojtoprocess=""
4061
4062  for proj in $projtoprocess ; do
4063    # if $proj has been processed already, skip this round
4064    if test "x$projprocessed" != x ; then
4065      for projdone in $projprocessed ; do
4066        if test $projdone = $proj ; then
4067          continue 2
4068        fi
4069      done
4070    fi
4071
4072    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
4073    pcfile=""
4074    save_IFS="$IFS"
4075    IFS=":"
4076    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
4077      # 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
4078      if test -r "$dir/$proj-uninstalled.pc" ; then
4079        pcfile="$dir/$proj-uninstalled.pc"
4080        pcfiledir="$dir"
4081        break
4082      fi
4083    done
4084    IFS="$save_IFS"
4085
4086    if test "x$pcfile" != x ; then
4087      # read CFLAGS from $pcfile and add CYGPATH_W cludge into include flags
4088      projcflags=`sed -n -e 's/Cflags://p' "$pcfile"`
4089      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
4090      m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
4091     
4092      # read LIBS from $pcfile and replace -L${libdir} by absolute path to build directory in linker flags
4093      # we assume that the build directory is $pcfiledir/src if this directory exists, otherwise we assume that it is $pcfiledir
4094      projlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' "$pcfile"`
4095      if test "x$projlibs" != x ; then
4096        if test -d "${pcfiledir}/src" ; then
4097          projlibs="-L`cd "${pcfiledir}/src"; pwd` $projlibs"
4098        else
4099          projlibs="-L`cd "$pcfiledir"; pwd` $projlibs"
4100        fi
4101      else
4102        projlibs=`sed -n -e 's/Libs://p' "$pcfile"`
4103      fi
4104      m4_toupper($1_LIBS)="$m4_toupper($1_LIBS) $projlibs"
4105     
4106      # read DATA from $pcfile, if this is the first .pc file we are processing (so assume that its the main one)
4107      if test "x$projprocessed" = x ; then
4108        m4_toupper($1_DATA)=`sed -n -e 's/datadir=//gp' "$pcfile"`
4109      fi
4110     
4111      # read dependencies from $pcfile, filter it, and add to list of projects that need to be processed next
4112      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\?>\?=[         ]*[^    ]\+//g'`]
4113      nextprojtoprocess="$nextprojtoprocess $projrequires"
4114     
4115      # remember that we have processed $proj
4116      projprocessed="$projprocessed $proj"
4117     
4118    else
4119      AC_MSG_RESULT([no, dependency $proj not available])
4120      break 2
4121    fi
4122
4123  done
4124 
4125  projtoprocess="$nextprojtoprocess"
4126 
4127  if test "x$projtoprocess" = x ; then
4128    m4_tolower(coin_has_$1)=yes
4129    AC_MSG_RESULT([yes, dependencies are$projprocessed])
4130   
4131    m4_bmatch($3, [required=0], [], [REQUIREDPACKAGES="$2 $REQUIREDPACKAGES"])
4132    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
4133   
4134    if test 1 = 0 ; then  #change this test to enable a bit of debugging output
4135    if test -n "$m4_toupper($1)_CFLAGS" ; then
4136      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
4137    fi
4138    if test -n "$m4_toupper($1)_LIBS" ; then
4139      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
4140    fi
4141    if test -n "$m4_toupper($1)_DATA" ; then
4142      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
4143    fi
4144    fi
4145  fi
4146done
4147
4148AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
4149               [test $m4_tolower(coin_has_$1) != notGiven &&
4150                test $m4_tolower(coin_has_$1) != skipping])
4151
4152]) # AC_COIN_HAS_MODULE_FALLBACK
4153
4154###########################################################################
4155#                         COIN_HAS_MODULE_BLAS                            #
4156###########################################################################
4157
4158# This macro checks for a library containing the BLAS library.  It
4159# 1. checks the --with-blas argument
4160# 2. if --with-blas=BUILD has been specified goes to point 5
4161# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS to its value
4162# 4. tries standard libraries
4163# 5. calls COIN_HAS_MODULE(Blas, [coinblas]) to check for ThirdParty/Blas
4164# 6. calls COIN_HAS_MODULE_FALLBACK(Blas, [coinblas], [../ThirdParty/Blas or ../Blas])
4165# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
4166# BLAS_LIBS is set to the flags required to link with a Blas library.
4167# In case 3 and 4, the flags to link to Blas are added to PCADDLIBS too.
4168# In case 5, Blas is added to REQUIREDPACKAGES
4169
4170AC_DEFUN([AC_COIN_HAS_MODULE_BLAS],
4171[
4172AC_ARG_WITH([blas],
4173            AC_HELP_STRING([--with-blas],
4174                           [specify BLAS library (or BUILD for compilation)]),
4175            [use_blas="$withval"], [use_blas=])
4176
4177#if user specified --with-blas-lib, then we should give COIN_HAS_MODULE preference
4178AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
4179
4180# Check if user supplied option makes sense
4181if test x"$use_blas" != x; then
4182  if test "$use_blas" = "BUILD"; then
4183    # we come to this later
4184    :
4185  elif test "$use_blas" != "no"; then
4186    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
4187    coin_save_LIBS="$LIBS"
4188    LIBS="$use_blas $LIBS"
4189    AC_COIN_TRY_FLINK([daxpy],
4190                      [AC_MSG_RESULT([yes])],
4191                      [AC_MSG_RESULT([no])
4192                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
4193    LIBS="$coin_save_LIBS"
4194  fi
4195else
4196# Try to autodetect the library for blas based on build system
4197  #AC_MSG_CHECKING([default locations for BLAS])
4198  skip_lblas_check=no
4199  case $build in
4200    *-sgi-*)
4201      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
4202      SAVE_LIBS="$LIBS"
4203      LIBS="-lcomplib.sgimath $LIBS"
4204      AC_COIN_TRY_FLINK([daxpy],
4205                        [AC_MSG_RESULT([yes])
4206                         use_blas="-lcomplib.sgimath"],
4207                        [AC_MSG_RESULT([no])
4208                         SAVE_LIBS="$LIBS"])
4209      ;;
4210
4211# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
4212# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
4213# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
4214# that CC and cc will understand -library in Studio 13. The main extra
4215# function of -xlic_lib and -library is to arrange for the Fortran run-time
4216# libraries to be linked for C++ and C. We can arrange that explicitly.
4217    *-*-solaris*)
4218      SAVE_LIBS="$LIBS"
4219      AC_MSG_CHECKING([for BLAS in libsunperf])
4220      LIBS="-lsunperf $FLIBS $LIBS"
4221      AC_COIN_TRY_FLINK([daxpy],
4222                        [AC_MSG_RESULT([yes])
4223                         use_blas='-lsunperf'
4224                         coin_need_flibs=yes],
4225                        [AC_MSG_RESULT([no])
4226                         LIBS="$SAVE_LIBS"])
4227      ;;
4228    *-cygwin* | *-mingw*)
4229# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
4230# library will want to link with cygwin, hence won't run standalone in DOS.
4231      if test "$enable_doscompile" = mingw; then
4232        skip_lblas_check=yes
4233      fi
4234      case "$CC" in
4235        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
4236          SAVE_LIBS="$LIBS"
4237          AC_MSG_CHECKING([for BLAS in MKL])
4238          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
4239          AC_COIN_TRY_FLINK([daxpy],
4240                            [AC_MSG_RESULT([yes])
4241                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'],
4242                            [AC_MSG_RESULT([no])
4243                             LIBS="$SAVE_LIBS"])
4244          ;;
4245      esac
4246      ;;
4247  esac
4248
4249  if test -z "$use_blas" && test $skip_lblas_check = no; then
4250    SAVE_LIBS="$LIBS"
4251    AC_MSG_CHECKING([whether -lblas has BLAS])
4252    LIBS="-lblas $LIBS"
4253    AC_COIN_TRY_FLINK([daxpy],
4254                      [AC_MSG_RESULT([yes])
4255                       use_blas='-lblas'],
4256                      [AC_MSG_RESULT([no])
4257                       LIBS="$SAVE_LIBS"])
4258  fi
4259  LIBS="$SAVE_LIBS"
4260 
4261  # If we have no other ideas, consider building BLAS.
4262  if test -z "$use_blas" ; then
4263    use_blas=BUILD
4264  fi
4265fi
4266
4267if test "x$use_blas" = xBUILD ; then
4268  AC_COIN_HAS_MODULE(Blas, [coinblas])
4269 
4270elif test "x$use_blas" != x && test "$use_blas" != no; then
4271  coin_has_blas=yes
4272  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
4273  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
4274  BLAS_LIBS="$use_blas"
4275  BLAS_CFLAGS=
4276  BLAS_DATA=
4277  AC_SUBST(BLAS_LIBS)
4278  AC_SUBST(BLAS_CFLAGS)
4279  AC_SUBST(BLAS_DATA)
4280  PCADDLIBS="$use_blas $PCADDLIBS"
4281 
4282else
4283  coin_has_blas=no
4284  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
4285fi
4286
4287]) # AC_COIN_HAS_MODULE_BLAS
4288
4289###########################################################################
4290#                       COIN_HAS_MODULE_LAPACK                            #
4291###########################################################################
4292
4293# This macro checks for a library containing the LAPACK library.  It
4294# 1. checks the --with-lapack argument
4295# 2. if --with-lapack=BUILD has been specified goes to point 5
4296# 3. if --with-lapack has been specified to a working library, sets LAPACK_LIBS to its value
4297# 4. tries standard libraries
4298# 5. calls COIN_HAS_MODULE(Lapack, [lapack]) to check for ThirdParty/Lapack
4299# 6. calls COIN_HAS_MODULE_FALLBACK(Lapack, [coinlapack], [../ThirdParty/Lapack or ../Lapack])
4300# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
4301# LAPACK_LIBS is set to the flags required to link with a Lapack library.
4302# In case 3 and 4, the flags to link to Lapack are added to PCADDLIBS too.
4303# In case 5, Lapack is added to REQUIREDPACKAGES
4304
4305AC_DEFUN([AC_COIN_HAS_MODULE_LAPACK],
4306[
4307AC_ARG_WITH([lapack],
4308            AC_HELP_STRING([--with-lapack],
4309                           [specify LAPACK library (or BUILD for compilation)]),
4310            [use_lapack=$withval], [use_lapack=])
4311           
4312#if user specified --with-lapack-lib, then we should give COIN_HAS_MODULE preference
4313AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
4314
4315# Check if user supplied option makes sense
4316if test x"$use_lapack" != x; then
4317  if test "$use_lapack" = "BUILD"; then
4318    # we come to this later
4319    :
4320  elif test "$use_lapack" != no; then
4321    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
4322    coin_save_LIBS="$LIBS"
4323    LIBS="$use_lapack $LIBS"
4324    AC_COIN_TRY_FLINK([dsyev],
4325                      [AC_MSG_RESULT([yes])],
4326                      [AC_MSG_RESULT([no])
4327                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
4328    LIBS="$coin_save_LIBS"
4329  fi
4330else
4331  if test x$coin_has_blas = xyes; then
4332    # First try to see if LAPACK is already available with BLAS library
4333    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
4334    coin_save_LIBS="$LIBS"
4335    LIBS="$BLAS_LIBS $LIBS"
4336    AC_COIN_TRY_FLINK([dsyev],
4337                      [AC_MSG_RESULT([yes]); use_lapack="$BLAS_LIBS"],
4338                      [AC_MSG_RESULT([no])])
4339    LIBS="$coin_save_LIBS"
4340  fi
4341  skip_llapack_check=no
4342  if test -z "$use_lapack"; then
4343    # Try to autodetect the library for lapack based on build system
4344    case $build in
4345      *-sgi-*)
4346        SAVE_LIBS="$LIBS"
4347        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
4348        LIBS="-lcomplib.sgimath $LIBS"
4349        AC_COIN_TRY_FLINK([dsyev],
4350                          [AC_MSG_RESULT([yes])
4351                           use_lapack="-lcomplib.sgimath;"],
4352                          [AC_MSG_RESULT([no])
4353                           SAVE_LIBS="$LIBS"])
4354        ;;
4355
4356# See comments in COIN_HAS_BLAS.
4357      *-*-solaris*)
4358      SAVE_LIBS="$LIBS"
4359      AC_MSG_CHECKING([for LAPACK in libsunperf])
4360      LIBS="-lsunperf $FLIBS $LIBS"
4361      AC_COIN_TRY_FLINK([dsyev],
4362                        [AC_MSG_RESULT([yes])
4363                         use_lapack='-lsunperf'
4364                         coin_need_flibs=yes],
4365                        [AC_MSG_RESULT([no])
4366                         LIBS="$SAVE_LIBS"])
4367        ;;
4368# On cygwin, do this check only if doscompile is disabled. The prebuilt library
4369# will want to link with cygwin, hence won't run standalone in DOS.
4370      *-cygwin*)
4371        if test "$enable_doscompile" = mingw; then
4372          skip_llapack_check=yes
4373        fi
4374        ;;
4375    esac
4376  fi
4377
4378  if test -z "$use_lapack" && test $skip_llapack_check = no; then
4379    SAVE_LIBS="$LIBS"
4380    AC_MSG_CHECKING([whether -llapack has LAPACK])
4381    LIBS="-llapack $LIBS"
4382    AC_COIN_TRY_FLINK([dsyev],
4383                      [AC_MSG_RESULT([yes])
4384                       use_lapack='-llapack'],
4385                      [AC_MSG_RESULT([no])
4386                       LIBS="$SAVE_LIBS"])
4387  fi
4388 
4389  LIBS="$SAVE_LIBS"
4390
4391  # If we have no other ideas, consider building LAPACK.
4392  if test -z "$use_lapack" ; then
4393    use_lapack=BUILD
4394  fi
4395fi
4396
4397if test "x$use_lapack" = xBUILD ; then
4398  AC_COIN_HAS_MODULE(Lapack, [coinlapack])
4399 
4400elif test "x$use_lapack" != x && test "$use_lapack" != no; then
4401  coin_has_lapack=yes
4402  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
4403  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
4404  LAPACK_LIBS="$use_lapack"
4405  LAPACK_CFLAGS=
4406  LAPACK_DATA=
4407  AC_SUBST(LAPACK_LIBS)
4408  AC_SUBST(LAPACK_CFLAGS)
4409  AC_SUBST(LAPACK_DATA)
4410  if test "x$LAPACK_LIBS" != "x$BLAS_LIBS"; then
4411    PCADDLIBS="$LAPACK_LIBS $PCADDLIBS"
4412  fi
4413 
4414else
4415  coin_has_lapack=no
4416  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
4417fi
4418
4419]) # AC_COIN_HAS_MODULE_LAPACK
4420
4421###########################################################################
4422#                            COIN_HAS_PACKAGE                             #
4423###########################################################################
4424
4425# This macro checks for the existance of a COIN-OR package and provides compiler and linker flags to compile against this package.
4426# A package can consists of one or more COIN-OR or other projects.
4427# It defines the PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA variables, referring to the compiler and linker
4428# flags to use when linking against this module and the directories where the module data resists.
4429# It also defines a COIN_HAS_PACKAGE preprocessor macro and makefile conditional.
4430# Further, tolower(coin_has_$1) is set to "yes".
4431# If a list of build targets using this projects is given in the third argument,
4432# then the compiler and linker variables and .pc file setup variable corresponding to this build target
4433# are extended with the values for this package.
4434# That is, for each build target X, the variables X_CFLAGS, X_LIBS, X_PCLIBS, X_PCREQUIRES are setup,
4435# whereas the last two specify the values to put into the "Libs:" and "Requires:" fields of the .pc file, resp.
4436#
4437# The first argument should be the name (PACKAGE) of the package (in correct lower
4438# and upper case).
4439# The second argument should be a (space separated) list of projects which this
4440# package consists of. Optionally, required version numbers can be added.
4441# The optional third argument should be a (space separated) list of build targets
4442# which use this package, if available.
4443#
4444# It is also possible to specify a preinstalled version of this package
4445# or to specify only the linker and compiler flags and data directory.
4446#
4447# If the user did not specify --with-$1-... flags and pkg-config is not available,
4448# COIN_HAS_PACKAGE_FALLBACK($1, $2, $3) is called.
4449
4450AC_DEFUN([AC_COIN_HAS_PACKAGE],
4451[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
4452AC_MSG_CHECKING([for COIN-OR package $1])
4453
4454m4_tolower(coin_has_$1)=notGiven
4455
4456# check if user wants to skip package in any case
4457if test x"$COIN_SKIP_PROJECTS" != x; then
4458  for dir in $COIN_SKIP_PROJECTS; do
4459    if test $dir = "$1"; then
4460      m4_tolower(coin_has_$1)=skipping
4461    fi
4462  done
4463fi
4464
4465m4_toupper($1_LIBS)=
4466m4_toupper($1_CFLAGS)=
4467m4_toupper($1_DATA)=
4468AC_SUBST(m4_toupper($1_LIBS))
4469AC_SUBST(m4_toupper($1_CFLAGS))
4470AC_SUBST(m4_toupper($1_DATA))
4471coin_foreach_w([myvar], [$3], [
4472  AC_SUBST(m4_toupper(myvar)_CFLAGS)
4473  AC_SUBST(m4_toupper(myvar)_LIBS)
4474  AC_SUBST(m4_toupper(myvar)_PCLIBS)
4475  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
4476])
4477
4478#check if user provided LIBS, CFLAGS, or DATA for module
4479if test $m4_tolower(coin_has_$1) != skipping; then
4480
4481  AC_ARG_WITH([m4_tolower($1)-lib],
4482    AC_HELP_STRING([--with-m4_tolower($1)-lib],
4483                   [linker flags for using package $1]),
4484      [m4_tolower(coin_has_$1)=yes
4485       m4_toupper($1_LIBS)="$withval"
4486       coin_foreach_w([myvar], [$3], [
4487         m4_toupper(myvar)_PCLIBS="$withval $m4_toupper(myvar)_PCLIBS"
4488         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
4489       ])
4490      ],
4491      [])
4492
4493  AC_ARG_WITH([m4_tolower($1)-incdir],
4494    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
4495                   [directory with header files for using package $1]),
4496    [m4_tolower(coin_has_$1)=yes
4497     m4_toupper($1_CFLAGS)="-I`${CYGPATH_W} $withval`"
4498     coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="$withval $m4_toupper(myvar)_CFLAGS"
4499     ])
4500    ],
4501    [])
4502
4503  AC_ARG_WITH([m4_tolower($1)-datadir],
4504    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
4505                   [directory with data files for using package $1]),
4506    [m4_tolower(coin_has_$1)=yes
4507     m4_toupper($1_DATA)="$withval"],
4508    [])
4509fi
4510
4511if test $m4_tolower(coin_has_$1) = notGiven; then
4512  if test -n "$PKG_CONFIG" ; then
4513    # set search path for pkg-config
4514    # need to export variable to be sure that the following pkg-config gets these values
4515    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
4516    PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH:$COIN_PKG_CONFIG_PATH_UNINSTALLED"
4517    export PKG_CONFIG_PATH
4518   
4519    # let pkg-config do it's magic
4520    AC_COIN_PKG_HAS_MODULE([$1],[$2],
4521      [ m4_tolower(coin_has_$1)=yes
4522        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
4523        coin_foreach_w([myvar], [$3], [m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
4524        ])
4525      ],
4526      [ m4_tolower(coin_has_$1)=notGiven
4527        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
4528      ])
4529
4530    # reset PKG_CONFIG_PATH variable
4531    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
4532    export PKG_CONFIG_PATH
4533   
4534    # augment X_CFLAGS and X_LIBS for each build target X in $3
4535    coin_foreach_w([myvar], [$3], [
4536      m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
4537      m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
4538    ])
4539  else
4540    AC_MSG_RESULT([skipped check via pkg-config, redirect to fallback])
4541    AC_COIN_HAS_PACKAGE_FALLBACK([$1], [$2], [$3])
4542  fi
4543
4544else
4545  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
4546fi
4547
4548if test $m4_tolower(coin_has_$1) != skipping &&
4549   test $m4_tolower(coin_has_$1) != notGiven ; then
4550  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
4551   
4552  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
4553    if test -n "$m4_toupper($1)_CFLAGS" ; then
4554      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
4555    fi
4556    if test -n "$m4_toupper($1)_LIBS" ; then
4557      AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
4558    fi
4559    if test -n "$m4_toupper($1)_DATA" ; then
4560      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
4561    fi
4562    if test -n "$m4_toupper($1)_CFLAGS" ; then
4563      AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
4564    fi
4565    coin_foreach_w([myvar], [$3], [
4566      AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
4567      AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
4568    ])
4569  fi
4570fi
4571
4572# Define the Makefile conditional
4573AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
4574               [test $m4_tolower(coin_has_$1) != notGiven &&
4575                test $m4_tolower(coin_has_$1) != skipping])
4576
4577]) # AC_COIN_HAS_MODULE
4578
4579###########################################################################
4580#                       COIN_HAS_PACKAGE_FALLBACK                         #
4581###########################################################################
4582
4583# This macro is used if COIN_HAS_PACKAGE fails to find a module because pkg-config was disabled or is not available.
4584#
4585# For each project xxx specified in $2, it searches for a xxx-uninstalled.pc file in the directories specified in
4586# $COIN_PKG_CONFIG_PATH_UNINSTALLED. The latter variable is setup by COIN_HAS_PKGCONFIG and
4587# consists of the content of the coin_subdirs.txt file which has been created by configure in the base directory.
4588# The content of xxx-uninstalled.pc is parsed in order to defines the variables PACKAGE_CFLAGS, PACKAGE_LIBS, and PACKAGE_DATA,
4589# referring to the compiler and linker flags to use when linking against this package
4590# and the directory where the package data resists.
4591# Further, for each build target X specified in the third argument, the variables X_CFLAGS and X_LIBS are
4592# extended with the compiler and linker flags of this package and the variables X_PCLIBS and X_PCREQUIRES are extended by the list
4593# of linker flags and dependent projects as needed to setup a .pc file.
4594# The macros checks also dependencies of $2.
4595# Note that the PACKAGE_DATA variable is set to the content of datadir of the first .pc file that is parsed.
4596#
4597# If .pc files for all projects in $2 and their dependencies is found, tolower(coin_has_$1) is set to "yes".
4598# Otherwise, if some dependency is not found, tolower(coin_has_$1) is set to "notGiven".
4599# Further, a COIN_HAS_PACKAGE preprocessor macro and a makefile conditional are defined.
4600#
4601# The first argument should be the name (PACKAGE) of the package (in correct lower and upper case).
4602# The second argument should be the base names of the projects .pc file which define this package.
4603# The optional third argument should be a (space separated) list of build targets
4604# which use this package, if available.
4605
4606# $1 is not checked for $COIN_SKIP_PROJECTS, since we only look into $COIN_PKG_CONFIG_PATH_UNINSTALLED.
4607# When the content of this variable was setup in the base directory, $COIN_SKIP_PROJECTS has already been considered.
4608
4609AC_DEFUN([AC_COIN_HAS_PACKAGE_FALLBACK],
4610[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
4611AC_MSG_CHECKING([for COIN-OR package $1 (fallback)])
4612
4613m4_tolower(coin_has_$1)=notGiven
4614m4_toupper($1_LIBS)=
4615m4_toupper($1_CFLAGS)=
4616m4_toupper($1_DATA)=
4617
4618# initial list of dependencies is "$2", but we need to filter out version number specifications (= x, <= x, >= x)
4619projtoprocess="m4_bpatsubsts([$2], [<?>?=[      ]*[^    ]+])"
4620projprocessed=""
4621
4622while test $m4_tolower(coin_has_$1) = notGiven ; do
4623  # setup list of projects that need to be processed in the next round
4624  nextprojtoprocess=""
4625
4626  for proj in $projtoprocess ; do
4627    # if $proj has been processed already, skip this round
4628    if test "x$projprocessed" != x ; then
4629      for projdone in $projprocessed ; do
4630        if test $projdone = $proj ; then
4631          continue 2
4632        fi
4633      done
4634    fi
4635
4636    # if $proj is available and configured, then a project-uninstalled.pc file should have been created, so search for it
4637    pcfile=""
4638    save_IFS="$IFS"
4639    IFS=":"
4640    for dir in $COIN_PKG_CONFIG_PATH_UNINSTALLED ; do
4641      # 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
4642      if test -r "$dir/$proj-uninstalled.pc" ; then
4643        pcfile="$dir/$proj-uninstalled.pc"
4644        pcfiledir="$dir"
4645        break
4646      fi
4647    done
4648    IFS="$save_IFS"
4649
4650    if test "x$pcfile" != x ; then
4651      # read CFLAGS from $pcfile and add CYGPATH_W cludge into include flags
4652      projcflags=`sed -n -e 's/Cflags://p' "$pcfile"`
4653      projcflags=[`echo "$projcflags" | sed -e 's/-I\([^ ]*\)/-I\`${CYGPATH_W} \1\`/g'`]
4654      m4_toupper($1_CFLAGS)="$projcflags $m4_toupper($1_CFLAGS)"
4655     
4656      # read LIBS from $pcfile and replace -L${libdir} by absolute path to build directory in linker flags
4657      # we assume that the build directory is $pcfiledir/src if this directory exists, otherwise we assume that it is $pcfiledir
4658      projlibs=`sed -n -e 's/Libs://' -e 's/-L\${libdir}//p' "$pcfile"`
4659      if test "x$projlibs" != x ; then
4660        if test -d "${pcfiledir}/src" ; then
4661          projlibs="-L`cd "${pcfiledir}/src"; pwd` $projlibs"
4662        else
4663          projlibs="-L`cd "$pcfiledir"; pwd` $projlibs"
4664        fi
4665      else
4666        projlibs=`sed -n -e 's/Libs://p' "$pcfile"`
4667      fi
4668      m4_toupper($1_LIBS)="$m4_toupper($1_LIBS) $projlibs"
4669     
4670      # read DATA from $pcfile, if this is the first .pc file we are processing (so assume that its the main one)
4671      if test "x$projprocessed" = x ; then
4672        m4_toupper($1_DATA)=`sed -n -e 's/datadir=//gp' "$pcfile"`
4673      fi
4674     
4675      # read dependencies from $pcfile, filter it, and add to list of projects that need to be processed next
4676      projrequires=[`sed -n -e 's/Requires://gp' "$pcfile" | sed -e 's/<\?>\?=[         ]*[^    ]\+//g'`]
4677      nextprojtoprocess="$nextprojtoprocess $projrequires"
4678     
4679      # remember that we have processed $proj
4680      projprocessed="$projprocessed $proj"
4681     
4682    else
4683      AC_MSG_RESULT([no, dependency $proj not available])
4684      break 2
4685    fi
4686
4687  done
4688 
4689  projtoprocess="$nextprojtoprocess"
4690 
4691  # if there are no more projects to search for, finish up
4692  if test "x$projtoprocess" = x ; then
4693    m4_tolower(coin_has_$1)=yes
4694    AC_MSG_RESULT([yes, dependencies are$projprocessed])
4695    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
4696   
4697    coin_foreach_w([myvar], [$3], [
4698      m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
4699      m4_toupper(myvar)_CFLAGS="$m4_toupper($1)_CFLAGS $m4_toupper(myvar)_CFLAGS"
4700      m4_toupper(myvar)_LIBS="$m4_toupper($1)_LIBS $m4_toupper(myvar)_LIBS"
4701    ])
4702   
4703    if test 1 = 0 ; then  #change this test to enable a bit of debugging output
4704      if test -n "$m4_toupper($1)_CFLAGS" ; then
4705        AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
4706      fi
4707      if test -n "$m4_toupper($1)_LIBS" ; then
4708        AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
4709      fi
4710      if test -n "$m4_toupper($1)_DATA" ; then
4711        AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
4712      fi
4713      coin_foreach_w([myvar], [$3], [
4714        AC_MSG_NOTICE([myvar CFLAGS are $m4_toupper(myvar)_CFLAGS])
4715        AC_MSG_NOTICE([myvar LIBS   are $m4_toupper(myvar)_LIBS])
4716      ])
4717    fi
4718  fi
4719done
4720
4721AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
4722               [test $m4_tolower(coin_has_$1) != notGiven &&
4723                test $m4_tolower(coin_has_$1) != skipping])
4724
4725]) # AC_COIN_HAS_PACKAGE_FALLBACK
4726
4727###########################################################################
4728#                         COIN_HAS_PACKAGE_BLAS                           #
4729###########################################################################
4730
4731# This macro checks for a library containing the BLAS library.  It
4732# 1. checks the --with-blas argument
4733# 2. if --with-blas=BUILD has been specified goes to point 5
4734# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS to its value
4735# 4. tries standard libraries
4736# 5. calls COIN_HAS_PACKAGE(Blas, [coinblas], [$1]) to check for ThirdParty/Blas
4737# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
4738# BLAS_LIBS is set to the flags required to link with a Blas library.
4739# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
4740# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
4741# In case 5, Blas is added to X_PCREQUIRES.
4742
4743AC_DEFUN([AC_COIN_HAS_PACKAGE_BLAS],
4744[
4745AC_ARG_WITH([blas],
4746            AC_HELP_STRING([--with-blas],
4747                           [specify BLAS library (or BUILD for compilation)]),
4748            [use_blas="$withval"], [use_blas=])
4749
4750#if user specified --with-blas-lib, then we should give COIN_HAS_PACKAGE preference
4751AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
4752
4753# Check if user supplied option makes sense
4754if test x"$use_blas" != x; then
4755  if test "$use_blas" = "BUILD"; then
4756    # we come to this later
4757    :
4758  elif test "$use_blas" != "no"; then
4759    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
4760    coin_save_LIBS="$LIBS"
4761    LIBS="$use_blas $LIBS"
4762    AC_COIN_TRY_FLINK([daxpy],
4763                      [AC_MSG_RESULT([yes])],
4764                      [AC_MSG_RESULT([no])
4765                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
4766    LIBS="$coin_save_LIBS"
4767  fi
4768else
4769# Try to autodetect the library for blas based on build system
4770  #AC_MSG_CHECKING([default locations for BLAS])
4771  skip_lblas_check=no
4772  case $build in
4773    *-sgi-*)
4774      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
4775      coin_save_LIBS="$LIBS"
4776      LIBS="-lcomplib.sgimath $LIBS"
4777      AC_COIN_TRY_FLINK([daxpy],
4778                        [AC_MSG_RESULT([yes])
4779                         use_blas="-lcomplib.sgimath"],
4780                        [AC_MSG_RESULT([no])])
4781      LIBS="$coin_save_LIBS"
4782      ;;
4783
4784# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
4785# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
4786# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
4787# that CC and cc will understand -library in Studio 13. The main extra
4788# function of -xlic_lib and -library is to arrange for the Fortran run-time
4789# libraries to be linked for C++ and C. We can arrange that explicitly.
4790    *-*-solaris*)
4791      AC_MSG_CHECKING([for BLAS in libsunperf])
4792      coin_save_LIBS="$LIBS"
4793      LIBS="-lsunperf $FLIBS $LIBS"
4794      AC_COIN_TRY_FLINK([daxpy],
4795                        [AC_MSG_RESULT([yes])
4796                         use_blas='-lsunperf'
4797                         coin_need_flibs=yes],
4798                        [AC_MSG_RESULT([no])])
4799      LIBS="$coin_save_LIBS"
4800      ;;
4801    *-cygwin* | *-mingw*)
4802# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
4803# library will want to link with cygwin, hence won't run standalone in DOS.
4804      if test "$enable_doscompile" = mingw; then
4805        skip_lblas_check=yes
4806      fi
4807      case "$CC" in
4808        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
4809          AC_MSG_CHECKING([for BLAS in MKL])
4810          coin_save_LIBS="$LIBS"
4811          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
4812          AC_COIN_TRY_FLINK([daxpy],
4813                            [AC_MSG_RESULT([yes])
4814                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'],
4815                            [AC_MSG_RESULT([no])])
4816          LIBS="$coin_save_LIBS"
4817          ;;
4818      esac
4819      ;;
4820  esac
4821
4822  if test -z "$use_blas" && test $skip_lblas_check = no; then
4823    AC_MSG_CHECKING([whether -lblas has BLAS])
4824    coin_save_LIBS="$LIBS"
4825    LIBS="-lblas $LIBS"
4826    AC_COIN_TRY_FLINK([daxpy],
4827                      [AC_MSG_RESULT([yes])
4828                       use_blas='-lblas'],
4829                      [AC_MSG_RESULT([no])])
4830    LIBS="$coin_save_LIBS"
4831  fi
4832 
4833  # If we have no other ideas, consider building BLAS.
4834  if test -z "$use_blas" ; then
4835    use_blas=BUILD
4836  fi
4837fi
4838
4839if test "x$use_blas" = xBUILD ; then
4840  AC_COIN_HAS_PACKAGE(Blas, [coinblas], [$1])
4841 
4842elif test "x$use_blas" != x && test "$use_blas" != no; then
4843  coin_has_blas=yes
4844  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
4845  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
4846  BLAS_LIBS="$use_blas"
4847  BLAS_CFLAGS=
4848  BLAS_DATA=
4849  AC_SUBST(BLAS_LIBS)
4850  AC_SUBST(BLAS_CFLAGS)
4851  AC_SUBST(BLAS_DATA)
4852  coin_foreach_w([myvar], [$1], [
4853    m4_toupper(myvar)_PCLIBS="$BLAS_LIBS $m4_toupper(myvar)_PCLIBS"
4854    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
4855  ])
4856 
4857else
4858  coin_has_blas=no
4859  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
4860fi
4861
4862coin_foreach_w([myvar], [$1], [
4863  AC_SUBST(m4_toupper(myvar)_PCLIBS)
4864  AC_SUBST(m4_toupper(myvar)_LIBS)
4865])
4866
4867]) # AC_COIN_HAS_PACKAGE_BLAS
4868
4869###########################################################################
4870#                       COIN_HAS_PACKAGE_LAPACK                           #
4871###########################################################################
4872
4873# This macro checks for a library containing the LAPACK library.  It
4874# 1. checks the --with-lapack argument
4875# 2. if --with-lapack=BUILD has been specified goes to point 5
4876# 3. if --with-lapack has been specified to a working library, sets LAPACK_LIBS to its value
4877# 4. tries standard libraries
4878# 5. calls COIN_HAS_PACKAGE(Lapack, [lapack], [$1]) to check for ThirdParty/Lapack
4879# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
4880# LAPACK_LIBS is set to the flags required to link with a Lapack library.
4881# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
4882# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
4883# In case 5, Lapack is added to X_PCREQUIRES.
4884
4885AC_DEFUN([AC_COIN_HAS_PACKAGE_LAPACK],
4886[
4887AC_ARG_WITH([lapack],
4888            AC_HELP_STRING([--with-lapack],
4889                           [specify LAPACK library (or BUILD for compilation)]),
4890            [use_lapack=$withval], [use_lapack=])
4891           
4892#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
4893AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
4894
4895# Check if user supplied option makes sense
4896if test x"$use_lapack" != x; then
4897  if test "$use_lapack" = "BUILD"; then
4898    # we come to this later
4899    :
4900  elif test "$use_lapack" != no; then
4901    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
4902    coin_save_LIBS="$LIBS"
4903    LIBS="$use_lapack $LIBS"
4904    AC_COIN_TRY_FLINK([dsyev],
4905                      [AC_MSG_RESULT([yes])],
4906                      [AC_MSG_RESULT([no])
4907                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
4908    LIBS="$coin_save_LIBS"
4909  fi
4910else
4911  if test x$coin_has_blas = xyes; then
4912    # First try to see if LAPACK is already available with BLAS library
4913    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
4914    coin_save_LIBS="$LIBS"
4915    LIBS="$BLAS_LIBS $LIBS"
4916    AC_COIN_TRY_FLINK([dsyev],
4917                      [AC_MSG_RESULT([yes]); use_lapack="$BLAS_LIBS"],
4918                      [AC_MSG_RESULT([no])])
4919    LIBS="$coin_save_LIBS"
4920  fi
4921  skip_llapack_check=no
4922  if test -z "$use_lapack"; then
4923    # Try to autodetect the library for lapack based on build system
4924    case $build in
4925      *-sgi-*)
4926        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
4927        coin_save_LIBS="$LIBS"
4928        LIBS="-lcomplib.sgimath $LIBS"
4929        AC_COIN_TRY_FLINK([dsyev],
4930                          [AC_MSG_RESULT([yes])
4931                           use_lapack="-lcomplib.sgimath;"],
4932                          [AC_MSG_RESULT([no])])
4933        LIBS="$coin_save_LIBS"
4934        ;;
4935
4936      # See comments in COIN_HAS_BLAS.
4937      *-*-solaris*)
4938        AC_MSG_CHECKING([for LAPACK in libsunperf])
4939        coin_save_LIBS="$LIBS"
4940        LIBS="-lsunperf $FLIBS $LIBS"
4941        AC_COIN_TRY_FLINK([dsyev],
4942                          [AC_MSG_RESULT([yes])
4943                           use_lapack='-lsunperf'
4944                           coin_need_flibs=yes],
4945                          [AC_MSG_RESULT([no])])
4946        LIBS="$coin_save_LIBS"
4947        ;;
4948        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
4949        # will want to link with cygwin, hence won't run standalone in DOS.
4950      *-cygwin*)
4951        if test "$enable_doscompile" = mingw; then
4952          skip_llapack_check=yes
4953        fi
4954        ;;
4955    esac
4956  fi
4957
4958  if test -z "$use_lapack" && test $skip_llapack_check = no; then
4959    AC_MSG_CHECKING([whether -llapack has LAPACK])
4960    coin_save_LIBS="$LIBS"
4961    LIBS="-llapack $LIBS"
4962    AC_COIN_TRY_FLINK([dsyev],
4963                      [AC_MSG_RESULT([yes])
4964                       use_lapack='-llapack'],
4965                      [AC_MSG_RESULT([no])])
4966    LIBS="$coin_save_LIBS"
4967  fi
4968
4969  # If we have no other ideas, consider building LAPACK.
4970  if test -z "$use_lapack" ; then
4971    use_lapack=BUILD
4972  fi
4973fi
4974
4975if test "x$use_lapack" = xBUILD ; then
4976  AC_COIN_HAS_PACKAGE(Lapack, [coinlapack], [$1])
4977 
4978elif test "x$use_lapack" != x && test "$use_lapack" != no; then
4979  coin_has_lapack=yes
4980  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
4981  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
4982  LAPACK_LIBS="$use_lapack"
4983  LAPACK_CFLAGS=
4984  LAPACK_DATA=
4985  AC_SUBST(LAPACK_LIBS)
4986  AC_SUBST(LAPACK_CFLAGS)
4987  AC_SUBST(LAPACK_DATA)
4988  coin_foreach_w([myvar], [$1], [
4989    m4_toupper(myvar)_PCLIBS="$LAPACK_LIBS $m4_toupper(myvar)_PCLIBS"
4990    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
4991  ])
4992 
4993else
4994  coin_has_lapack=no
4995  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
4996fi
4997
4998coin_foreach_w([myvar], [$1], [
4999  AC_SUBST(m4_toupper(myvar)_PCLIBS)
5000  AC_SUBST(m4_toupper(myvar)_LIBS)
5001])
5002
5003]) # AC_COIN_HAS_PACKAGE_LAPACK
Note: See TracBrowser for help on using the repository browser.