source: trunk/coin.m4 @ 1614

Last change on this file since 1614 was 1614, checked in by stefan, 10 years ago

do not touch ADDLIBS variable in COIN_HAS_MODULE*; instead, assemble variable PCADDLIBS with linker flags that are not found via pkg-config

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