source: trunk/coin.m4 @ 1555

Last change on this file since 1555 was 1555, checked in by lou, 11 years ago

Precursor; adding macro for doxygen in preparation for later changes.

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