source: stable/0.6/coin.m4 @ 1694

Last change on this file since 1694 was 1694, checked in by tkr, 11 years ago

Backing out r1579

  • Property svn:keywords set to Author Date Id Revision
File size: 113.5 KB
Line 
1# Copyright (C) 2006, 2009 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Common Public License.
4#
5## $Id: coin.m4 1694 2010-10-30 22:19:15Z tkr $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_PREREQ(2.59)
14
15###########################################################################
16#                           COIN_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  AC_OUTPUT
2162
2163  if test x"$coin_vpath_link_files" = x; then : ; else
2164    lnkcmd="$coin_link_input_cmd"
2165    if test "$lnkcmd" = cp; then
2166      AC_MSG_NOTICE(Copying data files for VPATH configuration)
2167    else
2168      AC_MSG_NOTICE(Creating VPATH links for data files)
2169    fi
2170    for file in $coin_vpath_link_files; do
2171      dir=`AS_DIRNAME(["./$file"])`
2172      if test -d $dir; then : ; else
2173        AS_MKDIR_P($dir)
2174      fi
2175      rm -f $file
2176      $lnkcmd $abs_source_dir/$file $file
2177    done
2178  fi
2179
2180  if test x$coin_projectdir = xyes; then
2181    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
2182  else
2183    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
2184  fi
2185else
2186  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
2187fi
2188
2189]) #AC_COIN_FINALIZE
2190
2191###########################################################################
2192#                             COIN_VPATH_LINK                             #
2193###########################################################################
2194
2195# This macro makes sure that a symbolic link is created to a file in
2196# the source code directory tree if we are in a VPATH compilation, and
2197# if this package is the main package to be installed
2198
2199AC_DEFUN([AC_COIN_VPATH_LINK],
2200[AC_REQUIRE([AC_COIN_CHECK_VPATH])
2201if test $coin_vpath_config = yes; then
2202  coin_vpath_link_files="$coin_vpath_link_files $1"
2203fi
2204]) #AC_COIN_VPATH_LINK
2205
2206###########################################################################
2207#                       COIN_ENABLE_GNU_PACKAGES                          #
2208###########################################################################
2209
2210# This macro defined the --enable-gnu-packages flag.  This can be used
2211# to check if a user wants to compile GNU packges (such as readline or
2212# zlib) into the executable.  By default, GNU packages are disabled.
2213# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
2214
2215AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
2216[AC_ARG_ENABLE([gnu-packages],
2217               [AC_HELP_STRING([--enable-gnu-packages],
2218                               [compile with GNU packages (disabled by default)])],
2219               [coin_enable_gnu=$enableval],
2220               [coin_enable_gnu=no])
2221]) # AC_COIN_ENABLE_GNU_PACKAGES
2222
2223###########################################################################
2224#                           COIN_CHECK_GNU_ZLIB                           #
2225###########################################################################
2226
2227# This macro checks for the libz library.
2228
2229AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2230[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2231AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2232AC_BEFORE([AC_COIN_PROG_CC],[$0])
2233AC_BEFORE([AC_COIN_PROG_F77],[$0])
2234AC_BEFORE([$0],[AC_COIN_FINALIZE])
2235
2236coin_has_zlib=no
2237if test $coin_enable_gnu = yes; then
2238  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2239
2240  if test $coin_has_zlib = yes; then
2241    AC_CHECK_LIB([z],[gzopen],
2242                 [ADDLIBS="-lz $ADDLIBS"],
2243                 [coin_has_zlib=no])
2244  fi
2245
2246  if test $coin_has_zlib = yes; then
2247    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2248  fi
2249fi
2250
2251AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2252]) # AC_COIN_CHECK_GNU_ZLIB
2253
2254
2255###########################################################################
2256#                          COIN_CHECK_GNU_BZLIB                           #
2257###########################################################################
2258
2259# This macro checks for the libbz2 library.
2260
2261AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2262[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2263AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2264AC_BEFORE([AC_COIN_PROG_CC],[$0])
2265AC_BEFORE([AC_COIN_PROG_F77],[$0])
2266AC_BEFORE([$0],[AC_COIN_FINALIZE])
2267
2268coin_has_bzlib=no
2269if test $coin_enable_gnu = yes; then
2270  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2271
2272  if test $coin_has_bzlib = yes; then
2273    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2274                 [ADDLIBS="-lbz2 $ADDLIBS"],
2275                 [coin_has_bzlib=no])
2276  fi
2277
2278  if test $coin_has_bzlib = yes; then
2279    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2280  fi
2281fi
2282]) # AC_COIN_CHECK_GNU_BZLIB
2283
2284
2285###########################################################################
2286#                         COIN_CHECK_GNU_READLINE                         #
2287###########################################################################
2288
2289# This macro checks for GNU's readline.  It verifies that the header
2290# readline/readline.h is available, and that the -lreadline library
2291# contains "readline".  It is assumed that #include <stdio.h> is included
2292# in the source file before the #include<readline/readline.h>
2293
2294AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2295[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2296AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2297AC_BEFORE([AC_COIN_PROG_CC],[$0])
2298AC_BEFORE([AC_COIN_PROG_F77],[$0])
2299AC_BEFORE([$0],[AC_COIN_FINALIZE])
2300
2301coin_has_readline=no
2302if test $coin_enable_gnu = yes; then
2303  AC_COIN_CHECK_HEADER([readline/readline.h],
2304                       [coin_has_readline=yes],[],
2305                       [#include <stdio.h>])
2306
2307  coin_save_LIBS="$LIBS"
2308  LIBS=
2309  # First we check if tputs and friends are available
2310  if test $coin_has_readline = yes; then
2311    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2312                   [coin_has_readline=no])
2313  fi
2314
2315  # Now we check for readline
2316  if test $coin_has_readline = yes; then
2317    AC_CHECK_LIB([readline],[readline],
2318                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
2319                 [coin_has_readline=no])
2320  fi
2321
2322  if test $coin_has_readline = yes; then
2323    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2324  fi
2325
2326  LIBS="$coin_save_LIBS"
2327fi
2328]) # AC_COIN_CHECK_GNU_READLINE
2329
2330###########################################################################
2331#                             COIN_DATA_PATH                              #
2332###########################################################################
2333
2334# This macro defines a preprocessor macro with the absolute path to a
2335# subdirectory of Data.  The argument of this macro is the name of the
2336# subdirectory (in correct case), and the name of the macro is
2337# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2338# the directory.  The path ends with a separator ("/" for linux and
2339# '\\' for Windows).  The default value for this path can be
2340# overwritten with the input variable with the same name
2341# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2342# $srcdir/../Data subdirectory.
2343
2344AC_DEFUN([AC_COIN_DATA_PATH],
2345[AC_MSG_CHECKING([absolute path to data directory $1])
2346
2347AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2348
2349if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2350  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2351fi
2352
2353# Under Cygwin, use Windows path.  Add separator
2354case $build in
2355  *-cygwin*)
2356    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2357    ;;
2358  *)
2359    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2360    ;;
2361esac
2362
2363if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2364  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2365            [Define to absolute path for Data subdirectory $1])
2366  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2367else
2368  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2369fi
2370]) # AC_COIN_HAS_DATA
2371
2372###########################################################################
2373#                       COIN_LINK_FROM_FILELIST                           #
2374###########################################################################
2375
2376# This macro creates links (or copies, if necessary) to files listed
2377# as content in a text file (second argument) into a target directory
2378# (first argument), which is created if it doesn't exist yet.  If s link
2379# already exists, nothing happens.
2380
2381AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
2382[cmd="$3"
2383if test -e $srcdir/$2 ; then
2384  my_target_dir="$1"
2385  my_link_files=`cat $srcdir/$2`
2386  my_dirname=`AS_DIRNAME($2)`
2387#  if test -e $my_target_dir; then : ; else
2388#    AS_MKDIR_P($my_target_dir)
2389#  fi
2390  for i in $my_link_files; do
2391    #rm -rf $my_target_dir/$i
2392    if test -e $my_target_dir/$i; then : ; else
2393      dirn2=`AS_DIRNAME($my_target_dir/$i)`
2394      if test -e $dirn2; then : ; else
2395        AS_MKDIR_P($dirn2)
2396      fi
2397      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
2398    fi
2399  done
2400else
2401  AC_MSG_WARN([File list file $2 missing!])
2402fi
2403])
2404
2405AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
2406[
2407AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2408echo Creating links in $1 ...
2409AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
2410])
2411
2412###########################################################################
2413#                       COIN_COPY_FROM_FILELIST                           #
2414###########################################################################
2415
2416# Like COIN_LINK_FROM_FILELIST, but copies the files.
2417
2418AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
2419[
2420echo Creating copies in $1 ...
2421AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
2422])
2423
2424###########################################################################
2425#                          COIN_EXAMPLE_FILES                             #
2426###########################################################################
2427
2428# This macro determines the names of the example files (using the
2429# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2430# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2431# creates soft links to the example files.
2432
2433AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2434[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
2435AC_REQUIRE([AC_COIN_CHECK_VPATH])
2436files=`cd $srcdir; ls $1`
2437# We need to do the following loop to make sure that are no newlines
2438# in the variable
2439for file in $files; do
2440  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2441done
2442if test $coin_vpath_config = yes; then
2443  lnkcmd=
2444  if test "$enable_doscompile" != no; then
2445    lnkcmd=cp
2446  fi
2447  case "$CC" in
2448    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2449      lnkcmd=cp ;;
2450  esac
2451  if test "$lnkcmd" = cp; then
2452    AC_MSG_NOTICE([Copying example files ($1)])
2453  else
2454    AC_PROG_LN_S
2455    AC_MSG_NOTICE([Creating links to the example files ($1)])
2456    lnkcmd="$LN_S"
2457  fi
2458  for file in $EXAMPLE_FILES; do
2459    rm -f $file
2460    $lnkcmd $srcdir/$file $file
2461  done
2462  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2463else
2464  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2465fi
2466
2467# In case there are compressed files, we create a variable with the
2468# uncompressed names
2469EXAMPLE_UNCOMPRESSED_FILES=
2470for file in $EXAMPLE_FILES; do
2471  case $file in
2472    *.gz)
2473      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2474      ;;
2475  esac
2476done
2477
2478AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2479AC_SUBST(EXAMPLE_FILES)
2480AC_SUBST(EXAMPLE_CLEAN_FILES)
2481]) #AC_COIN_EXAMPLE_FILES
2482
2483###########################################################################
2484#                            COIN_HAS_PROJECT                             #
2485###########################################################################
2486
2487# This macro sets up usage of a Coin package.  It defines the
2488# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
2489# object directory of the package, respectively.  It also defines
2490# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
2491# argument should be the name (Pkg) of the project (in correct lower
2492# and upper case)
2493
2494AC_DEFUN([AC_COIN_HAS_PROJECT],
2495[AC_MSG_CHECKING([for COIN project $1])
2496
2497# First check, if the sub-project is actually available (ToDo: allow
2498# other locations)
2499
2500m4_tolower(coin_has_$1)=unavailable
2501if test x"$COIN_SKIP_PROJECTS" != x; then
2502  for dir in $COIN_SKIP_PROJECTS; do
2503    if test $dir = $1; then
2504      m4_tolower(coin_has_$1)=skipping
2505    fi
2506  done
2507fi
2508
2509if test $m4_tolower(coin_has_$1) != skipping; then
2510  if test $PACKAGE_TARNAME = m4_tolower($1); then
2511    m4_tolower(coin_has_$1)=.
2512  else
2513    if test -d $srcdir/../$1; then
2514      m4_tolower(coin_has_$1)=../$1
2515    fi
2516  fi
2517fi
2518
2519if test $m4_tolower(coin_has_$1) != unavailable &&
2520   test $m4_tolower(coin_has_$1) != skipping; then
2521  # Set the #define if the component is available
2522  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
2523
2524  # Set the variables for source and object code location
2525  AC_SUBST(m4_toupper($1SRCDIR))
2526  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
2527  AC_SUBST(m4_toupper($1OBJDIR))
2528  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
2529  AC_SUBST(m4_toupper($1DOCDIR))
2530  m4_toupper($1DOCDIR)=$abs_lib_dir/../share/doc/coin/$1
2531fi
2532
2533  # Define the Makefile conditional
2534AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2535               [test $m4_tolower(coin_has_$1) != unavailable &&
2536                test $m4_tolower(coin_has_$1) != skipping])
2537AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2538]) # AC_COIN_HAS_PROJECT
2539
2540###########################################################################
2541#                        COIN_HAS_USER_LIBRARY                            #
2542###########################################################################
2543# This macro sets up usage of a user library with header files. The assumption
2544# is that the header file(s) and library do not reside in standard system
2545# directories, hence both the include directory and link flags must be
2546# specified. There are two mandatory arguments and two optional arguments.
2547#
2548# The first argument (mandatory) should be a name (LibraryName) for the
2549# library.  The second argument (mandatory) should be an abbreviation in
2550# upper case letters (LBRY) for the library. Ultimately, the macro will
2551# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2552# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2553# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2554# directory containing include files for the library. LBRYLIB should specify
2555# the flags necessary to link to the library. A variable coin_has_lbry will
2556# be set to true or false, as appropriate. A variable lbry_libcheck will be
2557# be set to yes or no; no indicates link checks should not be attempted.
2558#
2559# The macro defines three configure arguments, --with-libraryname-incdir,
2560# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2561# LibraryName to lower case.
2562#
2563# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2564# part of the configure command using --with-libraryname-incdir and
2565# --with-libraryname-lib, respectively. Command line arguments override
2566# environment variables.
2567#
2568# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2569# macro will check for the presence of the file. If a fourth argument is given,
2570# it should specify a function name, `fname'.  The macro will attempt to link a
2571# trivial program containing a parameterless call to the function, `fname()',
2572# using the LBRYLIB flags. The link check uses C as the language; this has been
2573# adequate to date but has limitations. It is possible to disable the link
2574# check by specifying --disable-libraryname-libcheck. This is a workaround for
2575# instances where the link check does not work properly, for whatever reason.
2576# If you're trying to link to a Fortran library, consider using F77_FUNC or
2577# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2578# library, you're on your own unless the library declares some function with
2579# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2580# name.
2581
2582AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
2583[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2584  AC_MSG_CHECKING(if user provides library for $1)
2585
2586# Check for header file directory
2587
2588  AC_ARG_WITH(m4_tolower($1)-incdir,
2589      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2590                     [specify the header file directory for library $1]),
2591      [$2INCDIR=`cd $withval; pwd`])
2592
2593# Check for library directory
2594
2595  AC_ARG_WITH(m4_tolower($1)-lib,
2596      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2597                     [specify the flags used to link with the library $1]),
2598      [$2LIB=$withval])
2599
2600# Switch to disable library check if requested
2601
2602  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2603      AS_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2604                     [use disable-m4_tolower($1)-libcheck to skip the link
2605                      check at configuration time]),
2606      [m4_tolower($1)_libcheck=$enableval],
2607      [m4_tolower($1)_libcheck=yes])
2608
2609# At this point, if we're going to use the library, both LBRYINCDIR and
2610# LBRYLIB must be defined and not empty.
2611
2612  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2613    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2614      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.])
2615    fi
2616    m4_tolower(coin_has_$2)=true
2617    AC_MSG_RESULT(yes)
2618  else
2619    m4_tolower(coin_has_$2)=false
2620    AC_MSG_RESULT(no)
2621  fi
2622
2623# If we have instructions for use, consider header and link checks.
2624
2625  if test $m4_tolower(coin_has_$2) = true; then
2626
2627# If argument 3 (file) is given, check for the file. Typically this will be a
2628# header file, but that's not assumed.
2629
2630    m4_ifval([$3],
2631        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2632             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2633
2634# Now see if we can link the function. There are arguments for and against
2635# assuming argument 3 is a header file declaring the function. A correct
2636# function declaration is the main argument in favour. Having to cope with
2637# possible dependencies or other oddities are the main arguments against.
2638# Force the use of C as the best single choice amongst C++, C, and Fortran.
2639# Obviously, this has limits.
2640
2641    m4_ifvaln([$4],
2642        [if test x"$m4_tolower($1)_libcheck" != xno; then
2643           coin_save_LIBS="$LIBS"
2644           LIBS="$$2LIB $ADDLIBS"
2645           coin_$2_link=no
2646           AC_LANG_PUSH(C)
2647           for fnm in $4 ; do
2648             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2649             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2650                 [AC_MSG_RESULT(yes)
2651                  coin_$2_link=yes
2652                  break],
2653                 [AC_MSG_RESULT(no)])
2654           done
2655           AC_LANG_POP(C)
2656           if test x"$coin_$2_link" = xyes ; then
2657             LIBS="$coin_save_LIBS"
2658           else
2659             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2660           fi
2661         fi])
2662
2663# If we make it this far, we've verified the file and linked the function. Add
2664# the necessary link flags to ADDLIBS and define the preprocessor symbol
2665# COIN_HAS_LBRY.
2666
2667    ADDLIBS="$$2LIB $ADDLIBS"
2668    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2669  fi
2670
2671# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2672# automake conditional. These actions must occur unconditionally.
2673
2674  AC_SUBST($2INCDIR)
2675  AC_SUBST($2LIB)
2676  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2677]) #AC_COIN_HAS_USER_LIBRARY
2678
2679###########################################################################
2680#                               COIN_HAS_ASL                              #
2681###########################################################################
2682
2683# This macro checks if the user has provide arguments that say where
2684# the precompiled ASL files should be found (with the --with-asldir
2685# flag).  If this is not the case, we check if the ThirdParty/ASL
2686# directory has been configured, which indicates that the files will
2687# be in that directory and can be used.
2688
2689AC_DEFUN([AC_COIN_HAS_ASL],
2690[coin_aslobjdir=../ThirdParty/ASL
2691coin_aslsrcdir=$srcdir/$coin_aslobjdir
2692
2693# Determine the name of the ASL library
2694case "$CC" in
2695  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2696    ampllib=amplsolv.lib ;;
2697  *)
2698    ampllib=amplsolver.a ;;
2699esac
2700
2701AC_ARG_WITH([asldir],
2702            AC_HELP_STRING([--with-asldir],
2703                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
2704            [use_asldir=$withval], [use_asldir=])
2705
2706if test "$use_asldir" = BUILD; then
2707  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2708    # If we are configuring ThirdParty/ASL, don't check
2709    if test -r $coin_aslobjdir/.MakeOk; then :; else
2710      AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])
2711    fi
2712  fi
2713elif test -z "$use_asldir"; then
2714 # try to find sources - if not given don't compile
2715  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2716    if test -r $coin_aslobjdir/.MakeOk; then
2717      use_asldir=BUILD
2718    else
2719      use_asldir=no
2720    fi
2721  else
2722    use_asldir=no
2723  fi
2724elif test "$use_asldir" != "no"; then
2725  AC_COIN_CHECK_FILE([$use_asldir/$ampllib],[],
2726                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
2727  AC_COIN_CHECK_FILE([$use_asldir/asl.h],[],
2728                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
2729  use_asldir=`cd $use_asldir; pwd`
2730  case $build in
2731    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
2732  esac
2733fi
2734
2735# Variable containing ASL library (including full path)
2736AC_SUBST(ASLLIB)
2737# Variable containing flags for including ASL header files
2738AC_SUBST(ASL_CPPFLAGS)
2739
2740if test "$use_asldir" = BUILD; then
2741  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
2742  ASLLIB=`$CYGPATH_W $coin_aslobjdir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2743  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
2744  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir | sed -e sX\\\\\\\\X/Xg`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers | sed -e sX\\\\\\\\X/Xg`
2745elif test "$use_asldir" != no; then
2746  ASLLIB=`$CYGPATH_W $use_asldir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2747  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir | sed -e sX\\\\\\\\X/Xg`
2748fi
2749
2750if test "$use_asldir" != no; then
2751  AC_LANG_PUSH(C)
2752  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
2753  coin_has_asl=yes
2754  AC_DEFINE([COIN_HAS_ASL],[1],
2755            [If defined, the Ampl Solver Library is available.])
2756  AC_LANG_POP(C)
2757else
2758  coin_has_asl=no
2759fi
2760AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
2761]) # AC_COIN_HAS_ASL
2762
2763###########################################################################
2764#                            COIN_TRY_FLINK                               #
2765###########################################################################
2766
2767# Auxilliary macro to test if a Fortran function name can be linked,
2768# given the current settings of LIBS.  We determine from the context, what
2769# the currently active programming language is, and cast the name accordingly.
2770# The first argument is the name of the function/subroutine, in small letters,
2771# the second argument are the actions taken when the test works, and the
2772# third argument are the actions taken if the test fails.
2773
2774AC_DEFUN([AC_COIN_TRY_FLINK],
2775[case $ac_ext in
2776  f)
2777    AC_TRY_LINK(,[      call $1],[$2],[$3])
2778    ;;
2779  c)
2780    AC_F77_FUNC($1,cfunc$1)
2781    if test x"$coin_need_flibs" = xyes; then
2782      flink_try=no;
2783    else
2784      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2785                  [flink_try=yes],[flink_try=no])
2786    fi
2787    if test $flink_try = yes; then
2788      $2
2789    else
2790      if test x"$FLIBS" != x; then
2791        flink_save_libs="$LIBS"
2792        LIBS="$LIBS $FLIBS"
2793        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2794                    [LIBS="$flink_save_libs"
2795                     $2
2796                     coin_need_flibs=yes],
2797                    [LIBS="$flink_save_libs"
2798                     $3])
2799      else
2800        $3
2801      fi
2802    fi
2803    ;;
2804  cc|cpp)
2805    AC_F77_FUNC($1,cfunc$1)
2806    if test x"$coin_need_flibs" = xyes; then
2807      flink_try=no;
2808    else
2809      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2810                  [flink_try=yes],[flink_try=no])
2811    fi
2812    if test $flink_try = yes; then
2813      $2
2814    else
2815      if test x"$FLIBS" != x; then
2816        flink_save_libs="$LIBS"
2817        LIBS="$LIBS $FLIBS"
2818        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2819                    [LIBS="$flink_save_libs"
2820                     $2
2821                     coin_need_flibs=yes],
2822                    [LIBS="$flink_save_libs"
2823                     $3])
2824      else
2825        $3
2826      fi
2827    fi
2828    ;;
2829esac
2830]) # AC_COIN_TRY_FLINK
2831
2832###########################################################################
2833#                             COIN_HAS_BLAS                               #
2834###########################################################################
2835
2836# This macro checks for a library containing the BLAS library.  It
2837# tries standard libraries, and if none is found to be working, it
2838# checks whether the BLAS ThirdParty/Blas directory has been configured.
2839# It adds to ADDLIBS any flags required to link with an externally provided
2840# BLAS.  It defines the makefile conditional and preprocessor macro
2841# COIN_HAS_BLAS, if blas is available, and it defines the makefile conditional
2842# COIN_BUILD_BLAS, if blas is compiled within COIN.
2843
2844AC_DEFUN([AC_COIN_HAS_BLAS],
2845[if test "$PACKAGE_NAME" = ThirdPartyBlas || test "$PACKAGE_NAME" = ThirdPartyLapack || test "$PACKAGE_NAME" = ThirdPartyMumps; then
2846  coin_blasobjdir=../Blas
2847else
2848  coin_blasobjdir=../ThirdParty/Blas
2849fi
2850coin_blassrcdir=$srcdir/$coin_blasobjdir
2851
2852AC_ARG_WITH([blas],
2853            AC_HELP_STRING([--with-blas],
2854                           [specify BLAS library (or BUILD for compilation)]),
2855            [use_blas=$withval], [use_blas=])
2856
2857MAKEOKFILE=.MakeOk
2858# Check if user supplied option makes sense
2859if test x"$use_blas" != x; then
2860  if test "$use_blas" = "BUILD"; then
2861    # Don't check for course code if this is executed in ThirdParty/Blas
2862    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2863      if test -r $coin_blasobjdir/.MakeOk; then :; else
2864        AC_MSG_ERROR([option \"BUILD\" specified for Blas, but $coin_blasobjdir directory is not properly configured])
2865      fi
2866    fi
2867  elif test "$use_blas" != no ; then
2868    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2869    LIBS="$use_blas $LIBS"
2870    ADDLIBS="$use_blas $ADDLIBS"
2871    AC_COIN_TRY_FLINK([daxpy],
2872                      [AC_MSG_RESULT([yes])],
2873                      [AC_MSG_RESULT([no])
2874                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2875  fi
2876else
2877# Try to autodetect the library for blas based on build system
2878  #AC_MSG_CHECKING([default locations for BLAS])
2879  skip_lblas_check=no
2880  case $build in
2881    *-sgi-*)
2882      SAVE_LIBS="$LIBS"
2883      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2884      LIBS="-lcomplib.sgimath $LIBS"
2885      AC_COIN_TRY_FLINK([daxpy],
2886                        [AC_MSG_RESULT([yes])
2887                         use_blas=-lcomplib.sgimath;
2888                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2889                        [AC_MSG_RESULT([no])
2890                         SAVE_LIBS="$LIBS"])
2891      ;;
2892
2893# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
2894# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
2895# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
2896# that CC and cc will understand -library in Studio 13. The main extra
2897# function of -xlic_lib and -library is to arrange for the Fortran run-time
2898# libraries to be linked for C++ and C. We can arrange that explicitly.
2899    *-*-solaris*)
2900      SAVE_LIBS="$LIBS"
2901      AC_MSG_CHECKING([for BLAS in libsunperf])
2902      LIBS="-lsunperf $FLIBS $LIBS"
2903      AC_COIN_TRY_FLINK([daxpy],
2904                        [AC_MSG_RESULT([yes])
2905                         use_blas='-lsunperf'
2906                         ADDLIBS="-lsunperf $ADDLIBS"
2907                         coin_need_flibs=yes],
2908                        [AC_MSG_RESULT([no])
2909                         LIBS="$SAVE_LIBS"])
2910      ;;
2911    *-cygwin* | *-mingw*)
2912# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
2913# library will want to link with cygwin, hence won't run standalone in DOS.
2914      if test "$enable_doscompile" = mingw; then
2915        skip_lblas_check=yes
2916      fi
2917      case "$CC" in
2918        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2919          SAVE_LIBS="$LIBS"
2920          AC_MSG_CHECKING([for BLAS in MKL])
2921          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
2922          AC_COIN_TRY_FLINK([daxpy],
2923                            [AC_MSG_RESULT([yes])
2924                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
2925                             ADDLIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $ADDLIBS"],
2926                            [AC_MSG_RESULT([no])
2927                             LIBS="$SAVE_LIBS"])
2928          ;;
2929      esac
2930      ;;
2931  esac
2932
2933  if test -z "$use_blas" && test $skip_lblas_check = no; then
2934    SAVE_LIBS="$LIBS"
2935    AC_MSG_CHECKING([whether -lblas has BLAS])
2936    LIBS="-lblas $LIBS"
2937    AC_COIN_TRY_FLINK([daxpy],
2938                      [AC_MSG_RESULT([yes])
2939                       ADDLIBS="-lblas $ADDLIBS"
2940                       use_blas='-lblas'],
2941                      [AC_MSG_RESULT([no])
2942                       LIBS="$SAVE_LIBS"])
2943  fi
2944
2945# If we have no other ideas, consider building BLAS.
2946  if test -z "$use_blas"; then
2947    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2948      if test -r $coin_blasobjdir/.MakeOk; then
2949        use_blas=BUILD
2950      fi
2951    fi
2952  fi
2953fi
2954
2955if test "$use_blas" = BUILD; then
2956  coin_need_flibs=yes
2957fi
2958
2959AM_CONDITIONAL([COIN_HAS_BLAS],[test x"$use_blas" != x])
2960AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
2961
2962if test x"$use_blas" = x || test "$use_blas" = no; then
2963  coin_has_blas=no
2964else
2965  coin_has_blas=yes
2966  AC_DEFINE([COIN_HAS_BLAS],[1],
2967            [If defined, the BLAS Library is available.])
2968fi
2969]) # AC_COIN_HAS_BLAS
2970
2971###########################################################################
2972#                            COIN_HAS_LAPACK                              #
2973###########################################################################
2974
2975# This macro checks for a library containing the LAPACK library.  It
2976# tries standard libraries, and if none is found to be working, it
2977# checks whether the LAPACK ThirdParty/Lapack directory has been
2978# configured.  It adds to ADDLIBS any flags required to link with an
2979# externally provided LAPACK.  It defines the makefile conditional and
2980# preprocessor macro COIN_HAS_LAPACK, if lapack is available, and it
2981# defines the makefile conditional COIN_BUILD_LAPACK, if lapack is
2982# compiled within COIN.
2983
2984AC_DEFUN([AC_COIN_HAS_LAPACK],
2985[coin_lapackobjdir=../ThirdParty/Lapack
2986coin_lapacksrcdir=$srcdir/$coin_lapackobjdir
2987
2988AC_ARG_WITH([lapack],
2989            AC_HELP_STRING([--with-lapack],
2990                           [specify LAPACK library (or BUILD for compilation)]),
2991            [use_lapack=$withval], [use_lapack=])
2992
2993# Check if user supplied option makes sense
2994if test x"$use_lapack" != x; then
2995  if test "$use_lapack" = "BUILD"; then
2996    # Don't check for course code if this is executed in ThirdParty/Lapack
2997    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
2998      if test -r $coin_lapackobjdir/.MakeOk; then :; else
2999        AC_MSG_ERROR([option \"BUILD\" specified for LAPACK, but $coin_lapackobjdir directory is not configured])
3000      fi
3001    fi
3002  elif test "$use_lapack" != no; then
3003    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
3004    LIBS="$use_lapack $LIBS"
3005    ADDLIBS="$use_lapack $ADDLIBS"
3006    AC_COIN_TRY_FLINK([dsyev],
3007                      [AC_MSG_RESULT([yes])],
3008                      [AC_MSG_RESULT([no])
3009                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
3010  fi
3011else
3012  if test x$coin_has_blas = xyes; then
3013    # First try to see if LAPACK is already available with BLAS library
3014    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
3015    AC_COIN_TRY_FLINK([dsyev],
3016                      [AC_MSG_RESULT([yes]); use_lapack=ok],
3017                      [AC_MSG_RESULT([no])])
3018  fi
3019  skip_llapack_check=no
3020  if test -z "$use_lapack"; then
3021    # Try to autodetect the library for lapack based on build system
3022    case $build in
3023      *-sgi-*)
3024        SAVE_LIBS="$LIBS"
3025        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
3026        LIBS="-lcomplib.sgimath $LIBS"
3027        AC_COIN_TRY_FLINK([dsyev],
3028                          [AC_MSG_RESULT([yes])
3029                           use_lapack=-lcomplib.sgimath;
3030                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
3031                          [AC_MSG_RESULT([no])
3032                           SAVE_LIBS="$LIBS"])
3033        ;;
3034
3035# See comments in COIN_HAS_BLAS.
3036      *-*-solaris*)
3037      SAVE_LIBS="$LIBS"
3038      AC_MSG_CHECKING([for LAPACK in libsunperf])
3039      LIBS="-lsunperf $FLIBS $LIBS"
3040      AC_COIN_TRY_FLINK([dsyev],
3041                        [AC_MSG_RESULT([yes])
3042                         use_blas='-lsunperf'
3043                         ADDLIBS="-lsunperf $ADDLIBS"
3044                         coin_need_flibs=yes],
3045                        [AC_MSG_RESULT([no])
3046                         LIBS="$SAVE_LIBS"])
3047        ;;
3048# On cygwin, do this check only if doscompile is disabled. The prebuilt library
3049# will want to link with cygwin, hence won't run standalone in DOS.
3050      *-cygwin*)
3051        if test "$enable_doscompile" = mingw; then
3052          skip_llapack_check=yes
3053        fi
3054        ;;
3055    esac
3056  fi
3057
3058  if test -z "$use_lapack" && test $skip_llapack_check = no; then
3059    SAVE_LIBS="$LIBS"
3060    AC_MSG_CHECKING([whether -llapack has LAPACK])
3061    LIBS="-llapack $LIBS"
3062    AC_COIN_TRY_FLINK([dsyev],
3063                      [AC_MSG_RESULT([yes])
3064                       ADDLIBS="-llapack $ADDLIBS"
3065                       use_lapack='-llapack'],
3066                      [AC_MSG_RESULT([no])
3067                       LIBS="$SAVE_LIBS"])
3068  fi
3069
3070# If we have no other ideas, consider building LAPACK.
3071  if test -z "$use_lapack"; then
3072    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
3073      if test -r $coin_lapackobjdir/.MakeOk; then
3074        use_lapack=BUILD
3075      fi
3076    fi
3077  fi
3078fi
3079
3080if test "$use_lapack" = BUILD; then
3081  coin_need_flibs=yes
3082fi
3083
3084AM_CONDITIONAL([COIN_HAS_LAPACK],[test x"$use_lapack" != x])
3085AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
3086
3087if test x"$use_lapack" = x || test "$use_lapack" = no; then
3088  coin_has_lapack=no
3089else
3090  coin_has_lapack=yes
3091  AC_DEFINE([COIN_HAS_LAPACK],[1],
3092            [If defined, the LAPACK Library is available.])
3093fi
3094]) # AC_COIN_HAS_LAPACK
3095
3096###########################################################################
3097#                            COIN_HAS_MUMPS                               #
3098###########################################################################
3099
3100# This macro checks for a library containing the MUMPS library.  It
3101# checks if the user has provided an argument for the MUMPS library,
3102# and if not, it checks whether the MUMPS ThirdParty/Mumps directory has
3103# been configured.  It adds to ADDLIBS any flags required to link with
3104# an externally provided MUMPS.  It defines the makefile conditional
3105# and preprocessor macro COIN_HAS_MUMPS, if MUMPS is available, and it
3106# defines the makefile conditional COIN_BUILD_MUMPS, if MUMPS is
3107# compiled within COIN.
3108
3109AC_DEFUN([AC_COIN_HAS_MUMPS],
3110[
3111if test "$PACKAGE_NAME" = ThirdPartyMumps; then
3112  coin_mumpsobjdir=../Mumps
3113else
3114  coin_mumpsobjdir=../ThirdParty/Mumps
3115fi
3116coin_mumpssrcdir=$abs_source_dir/$coin_mumpsobjdir/MUMPS
3117
3118MAKEOKFILE=.MakeOk
3119
3120#check if user provides a MUMPS library (that works)
3121AC_LANG_PUSH(C)
3122SAVE_ADDLIBS="$ADDLIBS"
3123ADDLIBS="$ADDLIBS $FLIBS"
3124AC_COIN_HAS_USER_LIBRARY(mumps, MUMPS, dmumps_c.h, dmumps_c)
3125ADDLIBS="$SAVE_ADDLIBS"
3126AC_LANG_POP(C)
3127
3128if test "$coin_has_mumps" = "true"; then  # user provided mumps library
3129  use_mumps=yes
3130  coin_has_mumps=yes
3131
3132  MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $MUMPSINCDIR\`"
3133  ADDLIBS="$MUMPSLIB $ADDLIBS"
3134
3135else # no user provided library, so we try to build our own
3136  use_mumps=BUILD
3137
3138  # Check if the MUMPS' ThirdParty project has been configured
3139  if test "$PACKAGE_NAME" != ThirdPartyMumps; then
3140    if test -r $coin_mumpsobjdir/.MakeOk; then
3141      use_mumps=BUILD
3142      # Mumps needs pthreads
3143      AC_LANG_PUSH(C)
3144      save_LIBS="$LIBS"
3145      LIBS="$LIBS $FLIBS"
3146      AC_CHECK_LIB([pthread],[pthread_create],[LIBS="-lpthread $save_LIBS"; ADDLIBS="-lpthread $ADDLIBS"],[LIBS="save_LIBS"])
3147      AC_LANG_POP(C)
3148 
3149      MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $coin_mumpssrcdir/libseq\` -I\`\$(CYGPATH_W) $coin_mumpssrcdir/include\`"
3150    else
3151      use_mumps=
3152    fi
3153  fi
3154
3155  # if a user provided library is used, then COIN_HAS_USER_LIBRARY takes care of the COIN_HAS_MUMPS conditional and preprocessor symbol
3156  AM_CONDITIONAL([COIN_HAS_MUMPS],[test x"$use_mumps" != x])
3157  if test x"$use_mumps" != x; then
3158    AC_DEFINE([COIN_HAS_MUMPS],[1],[If defined, the MUMPS Library is available.])
3159    coin_has_mumps=yes
3160  else
3161    coin_has_mumps=no
3162  fi
3163  AC_MSG_CHECKING([whether MUMPS is available])
3164  AC_MSG_RESULT([$coin_has_mumps])
3165fi
3166
3167if test x"$use_mumps" != x; then
3168  # we need the Fortran runtime libraries if we want to link with C/C++
3169  coin_need_flibs=yes
3170
3171  AC_SUBST(MUMPS_INCFLAGS)
3172fi
3173
3174AM_CONDITIONAL([COIN_BUILD_MUMPS],[test "$use_mumps" = BUILD])
3175
3176]) # AC_COIN_HAS_MUMPS
3177
3178###########################################################################
3179#                            COIN_HAS_METIS                               #
3180###########################################################################
3181
3182# This macro checks for a library containing the METIS library.  It
3183# checks if the user has provided an argument for the METIS library,
3184# and if not, it checks whether the METIS ThirdParty/Metis directory has
3185# been configured.  It adds to ADDLIBS any flags required to link with
3186# an externally provided METIS.  It defines the makefile conditional
3187# and preprocessor macro COIN_HAS_METIS, if METIS is available, and it
3188# defines the makefile conditional COIN_BUILD_METIS, if METIS is
3189# compiled within COIN.
3190
3191AC_DEFUN([AC_COIN_HAS_METIS],
3192[
3193case "$PACKAGE_NAME" in
3194  ThirdParty*)
3195    coin_metisobjdir=../Metis
3196    ;;
3197  *)
3198    coin_metisobjdir=../ThirdParty/Metis
3199    ;;
3200esac
3201
3202MAKEOKFILE=.MakeOk
3203
3204#check if user provides a METIS library (that works)
3205AC_LANG_PUSH(C)
3206AC_ARG_WITH(metis,
3207   AS_HELP_STRING([--with-metis], [specify flags to link with METIS library]),
3208   [METISLIB="$withval"; coin_has_metis=true], [coin_has_metis=no])
3209
3210if test $coin_has_metis = true; then
3211  coin_save_LIBS="$LIBS"
3212  LIBS="$METISLIB $ADDLIBS"
3213  AC_MSG_CHECKING([whether symbol metis_nodend is available with ])
3214  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[metis_nodend()]])],
3215     [AC_MSG_RESULT(yes)],
3216     [AC_MSG_RESULT(no)
3217      AC_MSG_ERROR([User-supplied METIS library does not work])])
3218  LIBS="$coin_save_LIBS"
3219fi
3220AC_LANG_POP(C)
3221
3222if test "$coin_has_metis" = "true"; then  # user provided metis library
3223  use_metis=yes
3224  coin_has_metis=yes
3225
3226  ADDLIBS="$METISLIB $ADDLIBS"
3227
3228else # no user provided library, so we try to build our own
3229  use_metis=BUILD
3230
3231  # Check if the METIS' ThirdParty project has been configured
3232  if test "$PACKAGE_NAME" != ThirdPartyMetis; then
3233    if test -r $coin_metisobjdir/.MakeOk; then
3234      use_metis=BUILD
3235    else
3236      use_metis=
3237    fi
3238  fi
3239
3240  if test x"$use_metis" != x; then
3241    coin_has_metis=yes
3242  else
3243    coin_has_metis=no
3244  fi
3245  AC_MSG_CHECKING([whether METIS is available])
3246  AC_MSG_RESULT([$coin_has_metis])
3247fi
3248
3249AM_CONDITIONAL([COIN_HAS_METIS],[test $coin_has_metis = yes])
3250if test $coin_has_metis = yes; then
3251  AC_DEFINE([COIN_HAS_METIS],[1],[If defined, the METIS library is available.])
3252fi
3253
3254]) # AC_COIN_HAS_METIS
3255
3256
3257###########################################################################
3258#                             COIN_HAS_GLPK                               #
3259###########################################################################
3260#
3261# This macro checks for the GLPK package. GLPK provides two capabilities,
3262# an LP and MIP solver (GLPK) and the GNU Mathprog modelling language (GMPL).
3263# The macro checks for either Glpk or Gmpl, according to the value specified as
3264# the parameter. Use one of Glpk or Gmpl. Use *exactly* these strings, eh?
3265#
3266#
3267# The macro first uses COIN_HAS_USER_LIBRARY to see if the user has specified
3268# a preexisting library (this allows the use of any glpk version, if the user
3269# is fussy). The macro then checks for ThirdParty/Glpk.
3270#
3271# This macro will define the following variables for Glpk:
3272#   coin_has_glpk       true or false
3273#   GLPKLIB             link flags for GLPK (if user supplied)
3274#   GLPKINCDIR          location of glpk include files
3275#   COIN_HAS_GLPK       Preprocessor symbol, defined to 1
3276#   COIN_HAS_GLPK       Automake conditional
3277#   COIN_BUILD_GLPK     Automake conditional, defined only if Glpk is to be
3278#                       built in ThirdParty/Glpk
3279#
3280# With the exception of COIN_BUILD_GLPK, an identical set of variables is
3281# defined for Gmpl.
3282
3283AC_DEFUN([AC_COIN_HAS_GLPK],
3284[
3285if test "$PACKAGE_NAME" = ThirdPartyGlpk; then
3286  coin_glpkobjdir=../Glpk
3287else
3288  coin_glpkobjdir=../ThirdParty/Glpk
3289fi
3290coin_glpksrcdir=$abs_source_dir/$coin_glpkobjdir
3291
3292use_thirdpartyglpk=no
3293
3294# Check for the requested component. If the user specified an external glpk
3295# library don't force a ThirdParty build, let the error propagate.
3296
3297m4_if([$1],[Glpk],
3298[AC_COIN_HAS_USER_LIBRARY([Glpk],[GLPK],[glpk.h],
3299    [_glp_lpx_simplex glp_lpx_simplex])
3300 if test x"$coin_has_glpk" = xfalse && test x"$GLPKLIB" = x ; then
3301   use_thirdpartyglpk=try
3302 fi])
3303m4_if([$1],[Gmpl],
3304[AC_COIN_HAS_USER_LIBRARY([Gmpl],[GMPL],[glpmpl.h],
3305    [_glp_mpl_initialize glp_mpl_initialize])
3306 if test x"$coin_has_gmpl" = xfalse && test x"$GMPLLIB" = x ; then
3307   use_thirdpartyglpk=try
3308 fi])
3309
3310# If the user has supplied an external library, use it. Otherwise, consider
3311# a build in ThirdParty/Glpk. If we build, assume we get both glpk and gmpl.
3312
3313if test x"$use_thirdpartyglpk" = xtry ; then
3314  MAKEOKFILE=.MakeOk
3315  # Check if the Glpk's ThirdParty project has been configured
3316  if test "$PACKAGE_NAME" != ThirdPartyGlpk; then
3317    if test -r $coin_glpkobjdir/.MakeOk; then
3318      use_thirdpartyglpk=build
3319    else
3320      use_thirdpartyglpk=no
3321    fi
3322  else
3323    use_thirdpartyglpk=build
3324  fi
3325
3326# If we're building, set the library and include directory variables, create a
3327# preprocessor symbol, define a variable that says we're using glpk/gmpl, and
3328# another to indicate a link check is a bad idea (hard to do before the library
3329# exists).
3330
3331  if test x"$use_thirdpartyglpk" = xbuild ; then
3332    m4_toupper($1INCDIR)="$coin_glpksrcdir/glpk/include"
3333    AC_SUBST(m4_toupper($1INCDIR))
3334    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],
3335              [Define to 1 if $1 package is available])
3336    m4_tolower(coin_has_$1)=true
3337    m4_tolower($1_libcheck)=no
3338    m4_toupper($1OBJDIR)=`cd $coin_glpkobjdir; pwd`
3339    AC_SUBST(m4_toupper($1OBJDIR))
3340    AC_MSG_NOTICE([Using $1 in ThirdParty/Glpk])
3341  fi
3342fi
3343
3344# Define the necessary automake conditionals.
3345
3346AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3347               [test x"$m4_tolower(coin_has_$1)" = xtrue])
3348AM_CONDITIONAL([COIN_BUILD_GLPK],[test x"$use_thirdpartyglpk" = xbuild])
3349
3350]) # AC_COIN_HAS_GLPK
Note: See TracBrowser for help on using the repository browser.