source: branches/split/coin.m4 @ 1509

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

add cludge to handle different usual locations for project libraries

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