source: trunk/coin.m4 @ 1372

Last change on this file since 1372 was 1372, checked in by stefan, 13 years ago

AC_COIN_EXAMPLE_FILES: add and evaluate enable-doscompile option before using it; require AC_PROG_LN_S instead of running it at each call

  • 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 1372 2009-07-25 13:55:30Z stefan $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_PREREQ(2.59)
14
15###########################################################################
16#                           COIN_MAIN_SUBDIRS                             #
17###########################################################################
18
19# This macro sets up the recursion into configure scripts into
20# subdirectories.  Each possible subdirectory should be provided as a
21# new argument to this macro.  The current limit is 10 subdirectories.
22# This automatically also checks for the Data subdirectory.
23
24AC_DEFUN([AC_COIN_MAIN_SUBDIRS],
25[AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
26
27m4_ifvaln([$1],[AC_MSG_CHECKING(whether directory $1 is available)
28                coin_skip=no
29                if test x"$COIN_SKIP_PROJECTS" != x; then
30                  for dir in $COIN_SKIP_PROJECTS; do
31                    if test $dir = $1; then
32                      coin_skip=yes
33                    fi
34                  done
35                fi
36                if test $coin_skip = yes; then
37                  AC_MSG_RESULT(skipping)
38                elif test -r $srcdir/$1/configure; then
39                  coin_subdirs="$coin_subdirs $1"
40                  AC_MSG_RESULT(yes)
41                  AC_CONFIG_SUBDIRS($1)
42                else
43                  AC_MSG_RESULT(no)
44                fi])
45m4_ifvaln([$2],[AC_MSG_CHECKING(whether directory $2 is available)
46                coin_skip=no
47                if test x"$COIN_SKIP_PROJECTS" != x; then
48                  for dir in $COIN_SKIP_PROJECTS; do
49                    if test $dir = $2; then
50                      coin_skip=yes
51                    fi
52                  done
53                fi
54                if test $coin_skip = yes; then
55                  AC_MSG_RESULT(skipping)
56                elif test -r $srcdir/$2/configure; then
57                  coin_subdirs="$coin_subdirs $2"
58                  AC_MSG_RESULT(yes)
59                  AC_CONFIG_SUBDIRS($2)
60                else
61                  AC_MSG_RESULT(no)
62                fi])
63m4_ifvaln([$3],[AC_MSG_CHECKING(whether directory $3 is available)
64                coin_skip=no
65                if test x"$COIN_SKIP_PROJECTS" != x; then
66                  for dir in $COIN_SKIP_PROJECTS; do
67                    if test $dir = $3; then
68                      coin_skip=yes
69                    fi
70                  done
71                fi
72                if test $coin_skip = yes; then
73                  AC_MSG_RESULT(skipping)
74                elif test -r $srcdir/$3/configure; then
75                  coin_subdirs="$coin_subdirs $3"
76                  AC_MSG_RESULT(yes)
77                  AC_CONFIG_SUBDIRS($3)
78                else
79                  AC_MSG_RESULT(no)
80                fi])
81m4_ifvaln([$4],[AC_MSG_CHECKING(whether directory $4 is available)
82                coin_skip=no
83                if test x"$COIN_SKIP_PROJECTS" != x; then
84                  for dir in $COIN_SKIP_PROJECTS; do
85                    if test $dir = $4; then
86                      coin_skip=yes
87                    fi
88                  done
89                fi
90                if test $coin_skip = yes; then
91                  AC_MSG_RESULT(skipping)
92                elif test -r $srcdir/$4/configure; then
93                  coin_subdirs="$coin_subdirs $4"
94                  AC_MSG_RESULT(yes)
95                  AC_CONFIG_SUBDIRS($4)
96                else
97                  AC_MSG_RESULT(no)
98                fi])
99m4_ifvaln([$5],[AC_MSG_CHECKING(whether directory $5 is available)
100                coin_skip=no
101                if test x"$COIN_SKIP_PROJECTS" != x; then
102                  for dir in $COIN_SKIP_PROJECTS; do
103                    if test $dir = $5; then
104                      coin_skip=yes
105                    fi
106                  done
107                fi
108                if test $coin_skip = yes; then
109                  AC_MSG_RESULT(skipping)
110                elif test -r $srcdir/$5/configure; then
111                  coin_subdirs="$coin_subdirs $5"
112                  AC_MSG_RESULT(yes)
113                  AC_CONFIG_SUBDIRS($5)
114                else
115                  AC_MSG_RESULT(no)
116                fi])
117m4_ifvaln([$6],[AC_MSG_CHECKING(whether directory $6 is available)
118                coin_skip=no
119                if test x"$COIN_SKIP_PROJECTS" != x; then
120                  for dir in $COIN_SKIP_PROJECTS; do
121                    if test $dir = $6; then
122                      coin_skip=yes
123                    fi
124                  done
125                fi
126                if test $coin_skip = yes; then
127                  AC_MSG_RESULT(skipping)
128                elif test -r $srcdir/$6/configure; then
129                  coin_subdirs="$coin_subdirs $6"
130                  AC_MSG_RESULT(yes)
131                  AC_CONFIG_SUBDIRS($6)
132                else
133                  AC_MSG_RESULT(no)
134                fi])
135m4_ifvaln([$7],[AC_MSG_CHECKING(whether directory $7 is available)
136                coin_skip=no
137                if test x"$COIN_SKIP_PROJECTS" != x; then
138                  for dir in $COIN_SKIP_PROJECTS; do
139                    if test $dir = $7; then
140                      coin_skip=yes
141                    fi
142                  done
143                fi
144                if test $coin_skip = yes; then
145                  AC_MSG_RESULT(skipping)
146                elif test -r $srcdir/$7/configure; then
147                  coin_subdirs="$coin_subdirs $7"
148                  AC_MSG_RESULT(yes)
149                  AC_CONFIG_SUBDIRS($7)
150                else
151                  AC_MSG_RESULT(no)
152                fi])
153m4_ifvaln([$8],[AC_MSG_CHECKING(whether directory $8 is available)
154                coin_skip=no
155                if test x"$COIN_SKIP_PROJECTS" != x; then
156                  for dir in $COIN_SKIP_PROJECTS; do
157                    if test $dir = $8; then
158                      coin_skip=yes
159                    fi
160                  done
161                fi
162                if test $coin_skip = yes; then
163                  AC_MSG_RESULT(skipping)
164                elif test -r $srcdir/$8/configure; then
165                  coin_subdirs="$coin_subdirs $8"
166                  AC_MSG_RESULT(yes)
167                  AC_CONFIG_SUBDIRS($8)
168                else
169                  AC_MSG_RESULT(no)
170                fi])
171m4_ifvaln([$9],[AC_MSG_CHECKING(whether directory $9 is available)
172                coin_skip=no
173                if test x"$COIN_SKIP_PROJECTS" != x; then
174                  for dir in $COIN_SKIP_PROJECTS; do
175                    if test $dir = $9; then
176                      coin_skip=yes
177                    fi
178                  done
179                fi
180                if test $coin_skip = yes; then
181                  AC_MSG_RESULT(skipping)
182                elif test -r $srcdir/$9/configure; then
183                  coin_subdirs="$coin_subdirs $9"
184                  AC_MSG_RESULT(yes)
185                  AC_CONFIG_SUBDIRS($9)
186                else
187                  AC_MSG_RESULT(no)
188                fi])
189m4_ifvaln([$10],[AC_MSG_CHECKING(whether directory $10 is available)
190                coin_skip=no
191                if test x"$COIN_SKIP_PROJECTS" != x; then
192                  for dir in $COIN_SKIP_PROJECTS; do
193                    if test $dir = $10; then
194                      coin_skip=yes
195                    fi
196                  done
197                fi
198                if test $coin_skip = yes; then
199                  AC_MSG_RESULT(skipping)
200                elif test -r $srcdir/$10/configure; then
201                  coin_subdirs="$coin_subdirs $10"
202                  AC_MSG_RESULT(yes)
203                  AC_CONFIG_SUBDIRS($10)
204                else
205                  AC_MSG_RESULT(no)
206                fi])
207]) # AC_COIN_MAIN_SUBDIRS
208
209###########################################################################
210#                            COIN_CHECK_FILE                              #
211###########################################################################
212
213# A simple replacement for AC_CHECK_FILE that works for cross compilation
214
215AC_DEFUN([AC_COIN_CHECK_FILE],
216[if test -r $1; then
217  $2
218  :
219else
220  $3
221  :
222fi
223])
224
225###########################################################################
226#                        COIN_THIRDPARTY_SUBDIRS                          #
227###########################################################################
228
229# This macro sets up the recursion into the configure script in a
230# subdirectory for compilation of third party code.  The first
231# argument is just the string that appears in the configure output.
232# The second argument is the directory with the configure script, and
233# the third one is a file that should exists in that directory.  If
234# this file does not exist, we assume that the user has not downloaded
235# the code, and we are not going to compile it
236
237AC_DEFUN([AC_COIN_THIRDPARTY_SUBDIRS],
238[AC_MSG_CHECKING(whether code for third party package $1 is available)
239coin_skip=no
240if test x"$COIN_SKIP_PROJECTS" != x; then
241  for dir in $COIN_SKIP_PROJECTS; do
242    if test $dir = $2; then
243      coin_skip=yes
244    fi
245  done
246fi
247if test $coin_skip = yes; then
248  AC_MSG_RESULT(skipping)
249else
250  coin_tmp=`echo $srcdir/$2/$3`
251  # There is probably a more elegant way to get the first thing out here...
252  for i in $coin_tmp; do
253    coin_tmp2=$i
254    #break 1
255  done
256  if test -r $coin_tmp2; then
257    coin_subdirs="$coin_subdirs $2"
258    AC_MSG_RESULT(yes)
259    AC_CONFIG_SUBDIRS($2)
260  else
261    AC_MSG_RESULT(no)
262  fi
263fi
264]) # AC_COIN_THIRDPARTY_SUBDIRS
265
266###########################################################################
267#                           COIN_CHECK_VPATH                              #
268###########################################################################
269
270# This macro sets the variable coin_vpath_config to true if this is a
271# VPATH configuration, otherwise it sets it to false.
272AC_DEFUN([AC_COIN_CHECK_VPATH],
273[AC_MSG_CHECKING(whether this is a VPATH configuration)
274if test `cd $srcdir; pwd` != `pwd`; then
275  coin_vpath_config=yes;
276else
277  coin_vpath_config=no;
278fi
279AC_MSG_RESULT($coin_vpath_config)
280]) # AC_COIN_CHECK_VPATH
281
282###########################################################################
283#                         COIN_PROJECTDIR_INIT                            #
284###########################################################################
285
286# This macro does everything that is required in the early part in the
287# configure script, such as defining a few variables.  This should only
288# be used in the main directory of a project directory (the one under
289# which src is)
290
291AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
292[# Initialize the ADDLIBS variable
293ADDLIBS="-lm $LIBS"
294AC_SUBST(ADDLIBS)
295
296# As backup, we make sure we don't loose an FLIBS if it has been set
297# by the user
298save_FLIBS="$FLIBS"
299
300# Initialize the FADDLIBS variable (which is to be used with a fortran
301# compiler and will not include FLIBS)
302FADDLIBS="$LIBS"
303AC_SUBST(FADDLIBS)
304
305# A useful makefile conditional that is always false
306AM_CONDITIONAL(ALWAYS_FALSE, false)
307
308# We set the following variable so that we know later in AC_COIN_FINALIZE
309# that we are in a project main directory
310coin_projectdir=yes
311
312# Check if a library version is set for libtool
313m4_ifvaln([$1],[coin_libversion=$1],[])
314]) # AC_COIN_PROJECTDIR_INIT
315
316###########################################################################
317#                          COIN_DEBUG_COMPILE                             #
318###########################################################################
319
320# enable the configure flags --enable-debug and --enable-debug-prjct
321# (where prcjt is the name of the project in lower case) and set the
322# variable coin_debug_compile to true or false This is used by
323# COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77 to determine the
324# compilation flags.  This macro also makes the switches
325# --with-prjct-verbosity and --with-prjct-checklevel available, which
326# define the preprocessor macros COIN_PRJCT_VERBOSITY and
327# COIN_PRJCT_CHECKLEVEL to the specified value (default is 0).
328#
329# The project specific flags are only made available, if one gives the
330# name of the project as first argument to this macro.
331
332AC_DEFUN([AC_COIN_DEBUG_COMPILE],
333[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
334AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
335AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
336
337AC_MSG_CHECKING([whether we want to compile in debug mode])
338
339AC_ARG_ENABLE([debug],
340[AC_HELP_STRING([--enable-debug],
341                [compile all projects with debug options tests])],
342[case "${enableval}" in
343   yes) coin_debug_compile=true
344        if test "${enable_shared+set}" = set; then :; else
345          enable_shared=no
346        fi
347        ;;
348   no)  coin_debug_compile=false
349        ;;
350   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
351        ;;
352esac],
353[coin_debug_compile=false])
354
355m4_ifvaln([$1],
356[AC_ARG_ENABLE(debug-m4_tolower($1),
357 [AC_HELP_STRING([--enable-debug-m4_tolower($1)],
358                 [compile this project ($1) with debug options])],
359 [case "${enableval}" in
360    yes) coin_debug_compile=true
361         enable_shared=no
362         ;;
363    no)  coin_debug_compile=false
364         ;;
365    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
366         ;;
367 esac],[:])
368]) # m4_ifvaln([$1],
369
370if test $coin_debug_compile = true; then
371  AC_MSG_RESULT([yes])
372else
373  AC_MSG_RESULT([no])
374fi
375
376m4_ifvaln([$1],
377[AC_ARG_WITH(m4_tolower($1)-verbosity,
378             AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
379                            [specify the debug verbosity level for project $1]),
380             [if test "$withval" = yes; then
381                withval=1
382              fi
383              m4_tolower(coin_$1_verbosity)=$withval],
384             [m4_tolower(coin_$1_verbosity)=0])
385 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
386                    m4_tolower($coin_$1_verbosity),
387                    [Define to the debug verbosity level (0 is no output)])
388
389 AC_ARG_WITH(m4_tolower($1)-checklevel,
390             AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
391                            [specify the sanity check level for project $1]),
392             [if test "$withval" = yes; then
393                withval=1
394              fi
395              m4_tolower(coin_$1_checklevel)=$withval],
396             [m4_tolower(coin_$1_checklevel)=0])
397 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
398                    m4_tolower($coin_$1_checklevel),
399                    [Define to the debug sanity check level (0 is no test)])
400
401# We use the following variable to have a string with the upper case
402# version of the project name
403COIN_PRJCT=m4_toupper($1)
404
405]) # m4_ifvaln([$1],
406 
407]) # AC_COIN_DEBUG_COMPILE
408
409###########################################################################
410#                          COIN_MINGW_LD_FIX                              #
411###########################################################################
412
413# This macro is included by any PROG_compiler macro, to set the LD
414# environment variable on MinGW to the correct value (link). But note that
415# if we're building in cygwin with -mno-cygwin, we still want ld! If we're
416# building from cygwin with MSVC tools (cl/link), then we do want link and
417# you'd better have your PATH variable straight, else you'll be doing file
418# links instead of code links! Arguably, LDFLAGS should include -mno-cygwin
419# but in practice all linking seems to be handled through the compilers, so
420# CFLAGS and CXXFLAGS suffice.
421
422AC_DEFUN([AC_COIN_MINGW_LD_FIX],
423[case $build in
424  *-mingw*)
425    if test "${LD+set}" = set; then :; else
426      LD=link
427    fi
428    ;;
429 esac
430 case $enable_doscompile in
431   msvc)
432     if test "x${LD+set}" = xset; then :; else
433       LD=link
434     fi
435     ;;
436 esac
437])
438
439###########################################################################
440#                        COIN_ENABLE_DOSCOMPILE                           #
441###########################################################################
442
443# This macro is invoked by any PROG_compiler macro to establish the
444# --enable-doscompile option, used when one wants to compile an executable
445# under Cygwin which also runs directly under DOS (without requiring
446# Cygwin1.dll). The job of this macro is to make sure the option is correct and
447# to set enable_doscompile. Legal values are mingw, msvc, and no (disabled).
448# mingw: Fake mingw under cygwin, using GCC tools and -mno-cygwin. The most
449#        important thing here is that preprocess, compile, and link steps
450#        *all* see -mno-cygwin.
451# msvc:  Assume the presence of cl/link. It's the user's responsibility to
452#        make sure their PATH is correct. In particular, that MSVC link is
453#        found and not cygwin link (we want to do code linking, not file
454#        linking).
455# It's the responsibility of individual PROG_compiler macros to ensure that
456# they correctly set the compiler search list and preprocess, compile, and
457# link flags. This is tied to compiler setup because in practice invocations
458# of the preprocessor and linker are made through the compiler.
459
460AC_DEFUN([AC_COIN_ENABLE_DOSCOMPILE],
461[AC_REQUIRE([AC_CANONICAL_BUILD])
462 AC_ARG_ENABLE([doscompile],
463  [AC_HELP_STRING([--enable-doscompile],
464                  [Under Cygwin, compile so that executables run under DOS.
465                   Set to mingw to use gcc/g++/ld with -mno-cygwin.
466                   Set to msvc to use cl/link (or icl/link).
467                   Default when mentioned: mingw.
468                   Default when not mentioned: disabled.])],
469  [if test "$enable_doscompile" != no; then
470     case $build in
471       *-cygwin* | *-mingw*) ;;
472       *) AC_MSG_ERROR([--enable-doscompile option makes sense only under Cygwin or MinGW]) ;;
473     esac
474   fi],
475  [enable_doscompile=no])
476 case "$enable_doscompile" in
477   mingw)
478     case $build in
479       *-mingw*) enable_doscompile=no ;;
480     esac
481     ;;
482   msvc|no) ;;
483   yes) enable_doscompile=mingw ;;
484   *) AC_MSG_ERROR([Invalid value $enable_doscompile for --enable-doscompile.
485                    Try configure --help=recursive.])
486      ;;
487  esac
488  if test "$enable_doscompile" != no ; then
489    AC_MSG_NOTICE([DOS compile style is: $enable_doscompile])
490  fi
491])
492
493###########################################################################
494#                             COIN_PROG_CXX                               #
495###########################################################################
496
497# Find the compile command by running AC_PROG_CXX (with compiler names for
498# different operating systems) and put it into CXX (unless it was given by the
499# user). Then find an appropriate value for CXXFLAGS. If either of CXXFLAGS or
500# PRJCT_CXXFLAGS is defined, that value is used (replace PRJCT with the upper
501# case name of this project).  It is possible to provide additional -D flags
502# in the variable CXXDEFS, and additional compilation flags with ADD_CXXFLAGS.
503
504AC_DEFUN([AC_COIN_PROG_CXX],
505[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
506AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
507AC_LANG_PUSH(C++)
508
509AC_ARG_VAR(CXXDEFS,[Additional -D flags to be used when compiling C++ code.])
510AC_ARG_VAR(ADD_CXXFLAGS,[Additional C++ compiler options])
511AC_ARG_VAR(DBG_CXXFLAGS,[Debug C++ compiler options])
512AC_ARG_VAR(OPT_CXXFLAGS,[Optimize C++ compiler options])
513
514coin_has_cxx=yes
515
516save_cxxflags="$CXXFLAGS"
517# For *-*-solaris*, promote Studio/Workshop compiler to front of list.
518case $build in
519  *-cygwin* | *-mingw*)
520             if test "$enable_doscompile" = msvc ; then
521               comps="icl cl"
522             else
523               comps="g++ cl"
524             fi ;;
525  *-*-solaris*)
526             comps="CC xlC_r aCC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
527  *-darwin*) comps="g++ c++ CC" ;;
528          *) comps="xlC_r aCC CC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
529esac
530
531# We delete the cached value, since the test might not have been
532# performed with our choice of compilers earlier
533$as_unset ac_cv_prog_CXX || test "${ac_cv_prog_CXX+set}" != set || { ac_cv_prog_CXX=; export ac_cv_prog_CXX; }
534# AC_MSG_NOTICE([C++ compiler candidates: $comps])
535AC_PROG_CXX([$comps])
536
537#AC_PROG_CXX sets CXX to g++ if it cannot find a working C++ compiler
538#thus, we test here whether $CXX is actually working
539AC_LANG_PUSH(C++)
540AC_MSG_CHECKING([whether C++ compiler $CXX works]);
541AC_COMPILE_IFELSE(
542  [AC_LANG_PROGRAM(, [int i=0;])],
543  [AC_MSG_RESULT(yes)],
544  [AC_MSG_RESULT(no)
545   AC_MSG_ERROR(failed to find a C++ compiler or C++ compiler $CXX does not work)]
546)
547AC_LANG_POP(C++)
548
549# It seems that we need to cleanup something here for the Windows
550case "$CXX" in
551  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
552    sed -e 's/^void exit (int);//' confdefs.h >> confdefs.hh
553    mv confdefs.hh confdefs.h
554    ;;
555esac
556
557# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
558case "$CXX" in
559  cl* | */cl* | CL* | */CL* )
560    if test "$ac_cv_prog_cxx_g" = yes ; then
561      ac_cv_prog_cxx_g=no
562      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
563    fi ;;
564esac
565CXXFLAGS="$save_cxxflags"
566
567# Check if a project specific CXXFLAGS variable has been set
568if test x$COIN_PRJCT != x; then
569  eval coin_tmp=\${${COIN_PRJCT}_CXXFLAGS+set}
570  if test x$coin_tmp = xset; then
571    eval CXXFLAGS=\${${COIN_PRJCT}_CXXFLAGS}
572  fi
573fi
574
575if test x"$CXXFLAGS" = x; then
576
577# ToDo decide whether we want -DNDEBUG for optimization
578  coin_add_cxxflags=
579  coin_opt_cxxflags=
580  coin_dbg_cxxflags=
581  coin_warn_cxxflags=
582
583  if test "$GXX" = "yes"; then
584    case "$CXX" in
585      icpc* | */icpc*)
586        ;;
587      *)
588# ToDo decide about unroll-loops
589        coin_opt_cxxflags="-O3 -fomit-frame-pointer"
590        coin_add_cxxflags="-pipe"
591        coin_dbg_cxxflags="-g"
592        coin_warn_cxxflags="-Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas"
593        case $build in
594          *-darwin*)
595            ;;
596          *)
597            coin_warn_cxxflags="-pedantic-errors $coin_warn_cxxflags"
598            ;;
599        esac
600
601        case $enable_doscompile in
602          mingw)
603            CXXFLAGS="-mno-cygwin"
604            AC_TRY_LINK(,[int i=0; i++;],[coin_add_cxxflags="-mno-cygwin $coin_add_cxxflags"])
605            CXXFLAGS=
606          ;;
607        esac
608    esac
609  fi
610
611# Note that we do not need to cover GCC in the following tests.
612
613  if test -z "$coin_opt_cxxflags"; then
614    case $build in
615      *-cygwin* | *-mingw*)
616        case "$CXX" in
617          cl* | */cl* | CL* | */CL*)
618            # The MT and MTd options are mutually exclusive
619            coin_opt_cxxflags='-MT -O2'
620            coin_add_cxxflags='-nologo -EHsc -GR -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
621            coin_dbg_cxxflags='-MTd'
622            ;;
623          icl* | */icl* | ICL* | */ICL*)
624            # The MT and MTd options are mutually exclusive
625            coin_opt_cxxflags='-MT -Ox'
626            coin_add_cxxflags='-nologo -EHsc -GR -D_CRT_SECURE_NO_DEPRECATE'
627            coin_dbg_cxxflags='-MTd -debug'
628            ;;
629        esac
630        ;;
631      *-linux-*)
632        case "$CXX" in
633          icpc* | */icpc*)
634            coin_opt_cxxflags="-O3 -ip -mp1"
635            coin_add_cxxflags=""
636            coin_dbg_cxxflags="-g"
637            # Check if -i_dynamic is necessary (for new glibc library)
638            CXXFLAGS=
639            AC_TRY_LINK(,[int i=0; i++;],[],
640                        [coin_add_cxxflags="-i_dynamic $coin_add_cxxflags"])
641            ;;
642          pgCC* | */pgCC*)
643            coin_opt_cxxflags="-fast"
644            coin_add_cxxflags="-Kieee -pc 64"
645            coin_dbg_cxxflags="-g"
646            ;;
647        esac
648        ;;
649      *-ibm-*)
650        case "$CXX" in
651          xlC* | */xlC* | mpxlC* | */mpxlC*)
652            coin_opt_cxxflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
653            coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna -qsuppress=1500-036 -qsuppress=1500-029 -qsourcetype=c++"
654            coin_dbg_cxxflags="-g"
655            ;;
656        esac
657        ;;
658      *-hp-*)
659        case "$CXX" in
660          aCC* | */aCC* )
661            coin_opt_cxxflags="-O"
662            coin_add_cxxflags="-AA"
663            coin_dbg_cxxflags="-g"
664            ;;
665        esac
666        ;;
667      *-*-solaris*)
668          coin_opt_cxxflags="-O4"
669          coin_dbg_cxxflags="-g"
670        ;;
671    esac
672  fi
673
674# Generic flag settings. If these don't work, add a case above.
675
676  if test "$ac_cv_prog_cxx_g" = yes && test -z "$coin_dbg_cxxflags" ; then
677    coin_dbg_cxxflags="-g"
678  fi
679
680  if test -z "$coin_opt_cxxflags"; then
681    # Try if -O option works if nothing else is set
682    CXXFLAGS=-O
683    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cxxflags="-O"])
684  fi
685
686  # if PM doesn't want the warning messages, take them out
687  if test x"$coin_skip_warn_cxxflags" = xyes; then
688    coin_warn_cxxflags=
689  fi
690
691# Do final setup of flags based on values determined above.
692
693  if test x${DBG_CXXFLAGS+set} != xset; then
694    DBG_CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
695  fi
696  if test x${OPT_CXXFLAGS+set} != xset; then
697    OPT_CXXFLAGS="$coin_opt_cxxflags $coin_add_cxxflags -DNDEBUG $coin_warn_cxxflags"
698  fi
699
700  DBG_CXXFLAGS="$DBG_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
701  OPT_CXXFLAGS="$OPT_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
702
703  if test "$coin_debug_compile" = "true"; then
704    CXXFLAGS="$DBG_CXXFLAGS"
705  else
706    CXXFLAGS="$OPT_CXXFLAGS"
707  fi
708
709# Handle the case where CXXFLAGS was set externally.
710else
711  CXXFLAGS="$CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
712  if test x${DBG_CXXFLAGS+set} != xset; then
713    DBG_CXXFLAGS="$CXXFLAGS"
714  fi
715  if test x${OPT_CXXFLAGS+set} != xset; then
716    OPT_CXXFLAGS="$CXXFLAGS"
717  fi
718fi
719
720# If CXXFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
721
722case "$CXXFLAGS" in
723  *-mno-cygwin*)
724    if test x${CPPFLAGS+set} != xset ; then
725      CPPFLAGS="-mno-cygwin"
726    else
727      case "$CPPFLAGS" in
728        *-mno-cygwin*)
729          ;;
730        *)
731          CPPFLAGS="$CPPFLAGS -mno-cygwin"
732          ;;
733      esac
734    fi ;;
735esac
736
737# Try if CXXFLAGS works
738save_CXXFLAGS="$CXXFLAGS"
739AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
740if test -z "$CXXFLAGS"; then
741  AC_MSG_WARN([The flags CXXFLAGS="$save_CXXFLAGS" do not work.  I will now just try '-O', but you might want to set CXXFLAGS manually.])
742  CXXFLAGS='-O'
743  AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
744  if test -z "$CXXFLAGS"; then
745    AC_MSG_WARN([This value for CXXFLAGS does not work.  I will continue with empty CXXFLAGS, but you might want to set CXXFLAGS manually.])
746  fi
747fi
748
749AC_MSG_NOTICE([C++ compiler options are: $CXXFLAGS])
750
751AC_ARG_VAR(MPICXX,[C++ MPI Compiler])
752if test x"$MPICXX" = x; then :; else
753  AC_MSG_NOTICE([Will use MPI C++ compiler $MPICXX])
754  CXX="$MPICXX"
755fi
756
757case "$CXX" in
758  cl* | */cl* | CL* | */CL* )
759    AC_COIN_MINGW_LD_FIX
760    ;;
761esac
762
763AC_LANG_POP(C++)
764]) # AC_COIN_PROG_CXX
765
766
767###########################################################################
768#                             COIN_CXXLIBS                                #
769###########################################################################
770
771# Determine the C++ runtime libraries required for linking a C++ library
772# with a Fortran or C compiler.  The result is available in CXXLIBS.
773
774AC_DEFUN([AC_COIN_CXXLIBS],
775[AC_REQUIRE([AC_PROG_CXX])dnl
776AC_LANG_PUSH(C++)
777AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with Fortran compiler])
778if test -z "$CXXLIBS"; then
779  if test "$GXX" = "yes"; then
780    case "$CXX" in
781      icpc* | */icpc*)
782        CXXLIBS="-lstdc++"
783        ;;
784      *)
785        CXXLIBS="-lstdc++ -lm" # -lgcc"
786        ;;
787    esac
788  else
789    case $build in
790     *-mingw32 | *-cygwin* )
791      case "$CXX" in
792      cl* | */cl* | CL* | */CL*)
793        CXXLIBS=nothing;;
794      esac;;
795     *-linux-*)
796      case "$CXX" in
797      icpc* | */icpc*)
798        CXXLIBS="-lstdc++"
799             ;;
800      pgCC* | */pgCC*)
801        CXXLIBS="-lstd -lC -lc"
802             ;;
803      esac;;
804    *-ibm-*)
805      CXXLIBS="-lC -lc"
806      ;;
807    *-hp-*)
808      CXXLIBS="-L/opt/aCC/lib -l++ -lstd_v2 -lCsup_v2 -lm -lcl -lc"
809      ;;
810    *-*-solaris*)
811      CXXLIBS="-lCstd -lCrun"
812    esac
813  fi
814fi
815if test -z "$CXXLIBS"; then
816  AC_MSG_WARN([Could not automatically determine CXXLIBS (C++ link libraries; necessary if main program is in Fortran or C).])
817else
818  AC_MSG_NOTICE([Assuming that CXXLIBS is \"$CXXLIBS\".])
819fi
820if test x"$CXXLIBS" = xnothing; then
821  CXXLIBS=
822fi
823AC_LANG_POP(C++)
824]) # AC_COIN_CXXLIBS
825
826###########################################################################
827#                           COIN_CHECK_HEADER                             #
828###########################################################################
829
830# This macro checks for a header file, but it does so without the
831# standard header.  This avoids warning messages like:
832#
833# configure: WARNING: dlfcn.h: present but cannot be compiled
834# configure: WARNING: dlfcn.h:     check for missing prerequisite headers?
835# configure: WARNING: dlfcn.h: see the Autoconf documentation
836# configure: WARNING: dlfcn.h:     section "Present But Cannot Be Compiled"
837# configure: WARNING: dlfcn.h: proceeding with the preprocessor's result
838# configure: WARNING: dlfcn.h: in the future, the compiler will take precedence
839
840# My guess that the problem lay with CPPFLAGS seems to be correct. With this
841# macro reduced to a direct call to AC_CHECK_HEADERS, there are no warnings
842# now that CPPFLAGS contains -mno-cygwin when it needs it. -- lh, 061214 --
843
844# AW 070609: I restored the previous version, since otherwise the warnings
845# still pop up for the cl compiler
846
847AC_DEFUN([AC_COIN_CHECK_HEADER],
848[#if test x"$4" = x; then
849#  hdr="#include <$1>"
850#else
851#  hdr="$4"
852#fi
853#AC_CHECK_HEADERS([$1],[$2],[$3],[$hdr])
854AC_CHECK_HEADERS([$1],[$2],[$3],[$4])
855]) # AC_COIN_CHECK_HEADER
856
857###########################################################################
858#                       COIN_CHECK_CXX_CHEADER                             #
859###########################################################################
860
861# This macro checks for C header files that are used from C++.  For a give
862# stub (e.g., math), it first checks if the C++ library (cmath) is available.
863# If it is, it defines HAVE_CMATH (or whatever the stub is).  If it is not
864# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
865# if that one exists.
866
867AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
868[AC_LANG_PUSH(C++)
869AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
870if test "$ac_cv_header_c$1" != "yes"; then
871  AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
872fi
873AC_LANG_POP(C++)
874]) # AC_COIN_CHECK_CXX_CHEADER
875
876###########################################################################
877#                             COIN_PROG_CC                                #
878###########################################################################
879
880# Find the compile command by running AC_PROG_CC (with compiler names
881# for different operating systems) and put it into CC (unless it was
882# given my the user), and find an appropriate value for CFLAGS.  It is
883# possible to provide additional -D flags in the variable CDEFS.
884
885AC_DEFUN([AC_COIN_PROG_CC],
886[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
887AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
888AC_LANG_PUSH(C)
889
890# For consistency, we set the C compiler to the same value of the C++
891# compiler, if the C++ is set, but the C compiler isn't (only for CXX=cl)
892if test x"$CXX" != x; then
893  case "$CXX" in
894    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
895      if test x"$CC" = x; then
896        CC="$CXX"
897        AC_MSG_WARN([C++ compiler name provided as $CXX, but CC is unset. Setting CC to $CXX])
898      fi
899      ;;
900  esac
901fi
902
903AC_ARG_VAR(CDEFS,[Additional -D flags to be used when compiling C code.])
904AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options])
905AC_ARG_VAR(DBG_CFLAGS,[Debug C compiler options])
906AC_ARG_VAR(OPT_CFLAGS,[Optimize C compiler options])
907
908coin_has_cc=yes
909
910save_cflags="$CFLAGS"
911
912# For *-*-solaris*, promote Studio/Workshop cc compiler to front of list.
913# Depending on the user's PATH, when Studio/Workshop cc is not present we may
914# find /usr/ucb/cc, which is almost certainly not a good choice for the C
915# compiler. In this case, put cc after gcc.
916
917case $build in
918  *-cygwin* | *-mingw*)
919             if test "$enable_doscompile" = msvc ; then
920               comps="icl cl"
921             else
922               comps="gcc cl"
923             fi ;;
924  *-*-solaris*)
925             AC_CHECK_PROG(sol_cc_compiler,cc,cc,[],[],/usr/ucb/cc)
926             if test "$sol_cc_compiler" = "cc" ; then
927               comps="cc xlc gcc pgcc icc"
928             else
929               comps="xlc gcc pgcc icc cc"
930             fi
931             ;;
932  *-linux-*) comps="xlc gcc cc pgcc icc" ;;
933  *)         comps="xlc_r xlc cc gcc pgcc icc" ;;
934esac
935
936# We delete the cached value, since the test might not have been
937# performed with our choice of compilers earlier
938$as_unset ac_cv_prog_CC || test "${ac_cv_prog_CC+set}" != set || { ac_cv_prog_CC=; export ac_cv_prog_CC; }
939# AC_MSG_NOTICE([C compiler candidates: $comps])
940AC_PROG_CC([$comps])
941if test -z "$CC" ; then
942  AC_MSG_ERROR([Failed to find a C compiler!])
943fi
944# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
945case "$CC" in
946  cl* | */cl* | CL* | */CL* )
947    if test "$ac_cv_prog_cc_g" = yes ; then
948      ac_cv_prog_cc_g=no
949      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
950    fi ;;
951esac
952CFLAGS="$save_cflags"
953
954# Check if a project specific CFLAGS variable has been set
955if test x$COIN_PRJCT != x; then
956  eval coin_tmp=\${${COIN_PRJCT}_CFLAGS+set}
957  if test x$coin_tmp = xset; then
958    eval CFLAGS=\${${COIN_PRJCT}_CFLAGS}
959  fi
960fi
961
962if test x"$CFLAGS" = x; then
963
964  coin_add_cflags=
965  coin_opt_cflags=
966  coin_dbg_cflags=
967  coin_warn_cflags=
968
969  if test "$GCC" = "yes"; then
970    case "$CC" in
971      icc* | */icc*)
972        ;;
973      *)
974        coin_opt_cflags="-O3 -fomit-frame-pointer"
975        coin_add_cflags="-pipe"
976        coin_dbg_cflags="-g"
977        coin_warn_cflags="-Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall -Wno-unknown-pragmas"
978        case $build in
979          *-darwin*)
980            ;;
981          *)
982            coin_warn_cflags="-pedantic-errors $coin_warn_cflags"
983            ;;
984        esac
985        case $enable_doscompile in
986          mingw)
987            CFLAGS="-mno-cygwin"
988            AC_TRY_LINK([],[int i=0; i++;],
989                        [coin_add_cflags="-mno-cygwin $coin_add_cflags"])
990            CFLAGS=
991          ;;
992        esac
993    esac
994  fi
995  if test -z "$coin_opt_cflags"; then
996    case $build in
997      *-cygwin* | *-mingw*)
998        case "$CC" in
999          cl* | */cl* | CL* | */CL*)
1000            coin_opt_cflags='-MT -O2'
1001            coin_add_cflags='-nologo -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
1002            coin_dbg_cflags='-MTd'
1003            ;;
1004          icl* | */icl* | ICL* | */ICL*)
1005            coin_opt_cflags='-MT -Ox'
1006            coin_add_cflags='-nologo -D_CRT_SECURE_NO_DEPRECATE'
1007            coin_dbg_cflags='-MTd -debug'
1008            ;;
1009        esac
1010        ;;
1011      *-linux-*)
1012        case "$CC" in
1013          icc* | */icc*)
1014            coin_opt_cflags="-O3 -ip -mp1"
1015            coin_add_cflags=""
1016            coin_dbg_cflags="-g"
1017            # Check if -i_dynamic is necessary (for new glibc library)
1018            CFLAGS=
1019            AC_TRY_LINK([],[int i=0; i++;],[],
1020                        [coin_add_cflags="-i_dynamic $coin_add_cflags"])
1021            ;;
1022          pgcc* | */pgcc*)
1023            coin_opt_cflags="-fast"
1024            coin_add_cflags="-Kieee -pc 64"
1025            coin_dbg_cflags="-g"
1026            ;;
1027        esac
1028        ;;
1029      *-ibm-*)
1030        case "$CC" in
1031          xlc* | */xlc* | mpxlc* | */mpxlc*)
1032            coin_opt_cflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
1033            coin_add_cflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
1034            coin_dbg_cflags="-g"
1035          ;;
1036        esac
1037        ;;
1038      *-hp-*)
1039        coin_opt_cflags="-O"
1040        coin_add_cflags="-Ae"
1041        coin_dbg_cflags="-g"
1042        ;;
1043      *-*-solaris*)
1044        coin_opt_cflags="-xO4"
1045        coin_dbg_cflags="-g"
1046        ;;
1047      *-sgi-*)
1048        coin_opt_cflags="-O -OPT:Olimit=0"
1049        coin_dbg_cflags="-g"
1050        ;;
1051    esac
1052  fi
1053
1054  if test "$ac_cv_prog_cc_g" = yes && test -z "$coin_dbg_cflags" ; then
1055    coin_dbg_cflags="-g"
1056  fi
1057
1058  if test -z "$coin_opt_cflags"; then
1059    # Try if -O option works if nothing else is set
1060    CFLAGS="-O"
1061    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cflags="-O"])
1062  fi
1063
1064  # if PM doesn't want the warning messages, take them out
1065  if test x"$coin_skip_warn_cflags" = xyes; then
1066    coin_warn_cflags=
1067  fi
1068
1069  if test x${DBG_CFLAGS+set} != xset; then
1070    DBG_CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
1071  fi
1072  if test x${OPT_CFLAGS+set} != xset; then
1073    OPT_CFLAGS="$coin_opt_cflags $coin_add_cflags -DNDEBUG $coin_warn_cflags"
1074  fi
1075
1076  DBG_CFLAGS="$DBG_CFLAGS $ADD_CFLAGS $CDEFS"
1077  OPT_CFLAGS="$OPT_CFLAGS $ADD_CFLAGS $CDEFS"
1078
1079  if test "$coin_debug_compile" = "true"; then
1080    CFLAGS="$DBG_CFLAGS"
1081  else
1082    CFLAGS="$OPT_CFLAGS"
1083  fi
1084else
1085  CFLAGS="$CFLAGS $ADD_CFLAGS $CDEFS"
1086  if test x${DBG_CFLAGS+set} != xset; then
1087    DBG_CFLAGS="$CFLAGS"
1088  fi
1089  if test x${OPT_CFLAGS+set} != xset; then
1090    OPT_CFLAGS="$CFLAGS"
1091  fi
1092fi
1093
1094# If CFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
1095
1096case "$CFLAGS" in
1097  *-mno-cygwin*)
1098    if test x${CPPFLAGS+set} != xset ; then
1099      CPPFLAGS="-mno-cygwin"
1100    else
1101      case "$CPPFLAGS" in
1102        *-mno-cygwin*)
1103          ;;
1104        *)
1105          CPPFLAGS="$CPPFLAGS -mno-cygwin"
1106          ;;
1107      esac
1108    fi ;;
1109esac
1110
1111# Try if CFLAGS works
1112save_CFLAGS="$CFLAGS"
1113AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
1114if test -z "$CFLAGS"; then
1115  AC_MSG_WARN([The value CFLAGS="$save_CFLAGS" do not work.  I will now just try '-O', but you might want to set CFLAGS manually.])
1116  CFLAGS='-O'
1117  AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
1118  if test -z "$CFLAGS"; then
1119    AC_MSG_WARN([This value for CFLAGS does not work.  I will continue with empty CFLAGS, but you might want to set CFLAGS manually.])
1120  fi
1121fi
1122
1123AC_MSG_NOTICE([C compiler options are: $CFLAGS])
1124
1125AC_ARG_VAR(MPICC,[C MPI Compiler])
1126if test x"$MPICC" = x; then :; else
1127  AC_MSG_NOTICE([Will use MPI C compiler $MPICC])
1128  CC="$MPICC"
1129fi
1130
1131# Correct ADDLIBS initialization if we are using the MS compiler
1132case "$CC" in
1133  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1134    ADDLIBS=
1135    AC_COIN_MINGW_LD_FIX
1136    ;;
1137esac
1138
1139AC_LANG_POP(C)
1140]) # AC_COIN_PROG_CC
1141
1142###########################################################################
1143#                             COIN_PROG_F77                               #
1144###########################################################################
1145
1146# Find the compile command by running AC_PROG_F77 (with compiler names
1147# for different operating systems) and put it into F77 (unless it was
1148# given by the user), and find an appropriate value for FFLAGS
1149
1150AC_DEFUN([AC_COIN_PROG_F77],
1151[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
1152AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1153AC_REQUIRE([AC_COIN_PROG_CC])
1154AC_REQUIRE([AC_COIN_F77_COMPS])
1155AC_LANG_PUSH([Fortran 77])
1156
1157AC_ARG_VAR(ADD_FFLAGS,[Additional Fortran compiler options])
1158AC_ARG_VAR(DBG_FFLAGS,[Debug Fortran compiler options])
1159AC_ARG_VAR(OPT_FFLAGS,[Optimize Fortran compiler options])
1160
1161coin_has_f77=yes
1162
1163save_fflags="$FFLAGS"
1164
1165# We delete the cached value, since the test might not have been
1166# performed with our choice of compilers earlier
1167$as_unset ac_cv_prog_F77 || test "${ac_cv_prog_F77+set}" != set || { ac_cv_prog_F77=; export ac_cv_prog_F77; }
1168
1169# This is a real belt-and-suspenders approach. AC_COIN_FIND_F77 will use
1170# coin_f77_comps to see if there's a program that matches one of the names.
1171# If there's no such program, F77 = unavailable. If we match the name,
1172# feed AC_PROG_F77 the same search list, just to be sure it's a functioning
1173# compiler.
1174# AC_MSG_NOTICE([Fortran compiler candidates: $coin_f77_comps])
1175AC_COIN_FIND_F77
1176if test "$F77" != "unavailable" ; then
1177  AC_PROG_F77($coin_f77_comps)
1178else
1179  AC_MSG_WARN([Failed to find a Fortran compiler!])
1180fi
1181
1182FFLAGS="$save_fflags"
1183
1184# Check if a project specific FFLAGS variable has been set
1185if test x$COIN_PRJCT != x; then
1186  eval coin_tmp=\${${COIN_PRJCT}_FFLAGS+set}
1187  if test x$coin_tmp = xset; then
1188    eval FFLAGS=\${${COIN_PRJCT}_FFLAGS}
1189  fi
1190fi
1191
1192if test "$F77" != "unavailable" && test x"$FFLAGS" = x ; then
1193
1194  coin_add_fflags=
1195  coin_opt_fflags=
1196  coin_dbg_fflags=
1197  coin_warn_fflags=
1198
1199  if test "$G77" = "yes"; then
1200    coin_opt_fflags="-O3 -fomit-frame-pointer"
1201    coin_add_fflags="-pipe"
1202    coin_dbg_fflags="-g"
1203    case $enable_doscompile in
1204      mingw)
1205        FFLAGS="-mno-cygwin"
1206        AC_TRY_LINK(,[      write(*,*) 'Hello world'],
1207                    [coin_add_fflags="-mno-cygwin $coin_add_fflags"])
1208        FFLAGS=
1209      ;;
1210    esac
1211  else
1212    case $build in
1213      *-cygwin* | *-mingw*)
1214        case $F77 in
1215          ifort* | */ifort* | IFORT* | */IFORT* )
1216            coin_opt_fflags='-MT -O3'
1217            coin_add_fflags='-fpp -nologo'
1218            coin_dbg_fflags='-MTd -debug'
1219          ;;
1220          compile_f2c*)
1221            coin_opt_fflags='-MT -O2'
1222            coin_add_fflags='-nologo -wd4996'
1223            coin_dbg_fflags='-MTd'
1224          ;;
1225        esac
1226        ;;
1227      *-linux-*)
1228        case $F77 in
1229          ifc* | */ifc* | ifort* | */ifort*)
1230            coin_opt_fflags="-O3 -ip"
1231            coin_add_fflags="-cm -w90 -w95"
1232            coin_dbg_fflags="-g -CA -CB -CS"
1233            # Check if -i_dynamic is necessary (for new glibc library)
1234            FFLAGS=
1235            AC_TRY_LINK(,[      write(*,*) 'Hello world'],[],
1236                        [coin_add_fflags="-i_dynamic $coin_add_fflags"])
1237            ;;
1238          pgf77* | */pgf77* | pgf90* | */pgf90*)
1239            coin_opt_fflags="-fast"
1240            coin_add_fflags="-Kieee -pc 64"
1241            coin_dbg_fflags="-g"
1242          ;;
1243        esac
1244        ;;
1245      *-ibm-*)
1246        case "$F77" in
1247          xlf* | */xlf* | mpxlf* | */mpxlf* )
1248            coin_opt_fflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
1249            coin_add_fflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
1250            coin_dbg_fflags="-g -C"
1251            ;;
1252        esac
1253        ;;
1254      *-hp-*)
1255        coin_opt_fflags="+O3"
1256        coin_add_fflags="+U77"
1257        coin_dbg_fflags="-C -g"
1258        ;;
1259      *-*-solaris*)
1260        coin_opt_fflags="-O4"
1261        coin_dbg_fflags="-g"
1262        ;;
1263      *-sgi-*)
1264        coin_opt_fflags="-O5 -OPT:Olimit=0"
1265        coin_dbg_fflags="-g"
1266        ;;
1267    esac
1268  fi
1269
1270  if test "$ac_cv_prog_f77_g" = yes && test -z "$coin_dbg_fflags" ; then
1271    coin_dbg_fflags="-g"
1272  fi
1273
1274  if test -z "$coin_opt_fflags"; then
1275    # Try if -O option works if nothing else is set
1276    FFLAGS=-O
1277    AC_TRY_LINK(,[      integer i], [coin_opt_fflags="-O"])
1278  fi
1279
1280  # if PM doesn't want the warning messages, take them out
1281  if test x"$coin_skip_warn_fflags" = xyes; then
1282    coin_warn_fflags=
1283  fi
1284
1285  if test x${DBG_FFLAGS+set} != xset; then
1286    DBG_FFLAGS="$coin_dbg_fflags $coin_add_fflags $coin_warn_fflags"
1287  fi
1288  if test x${OPT_FFLAGS+set} != xset; then
1289    OPT_FFLAGS="$coin_opt_fflags $coin_add_fflags $coin_warn_fflags"
1290  fi
1291
1292  DBG_FFLAGS="$DBG_FFLAGS $ADD_FFLAGS"
1293  OPT_FFLAGS="$OPT_FFLAGS $ADD_FFLAGS"
1294
1295  if test "$coin_debug_compile" = "true"; then
1296    FFLAGS="$DBG_FFLAGS"
1297  else
1298    FFLAGS="$OPT_FFLAGS"
1299  fi
1300else
1301  FFLAGS="$FFLAGS $ADD_FFLAGS"
1302  if test x${DBG_FFLAGS+set} != xset; then
1303    DBG_FFLAGS="$FFLAGS"
1304  fi
1305  if test x${OPT_FFLAGS+set} != xset; then
1306    OPT_FFLAGS="$FFLAGS"
1307  fi
1308fi
1309
1310# If FFLAGS contains -mno-cygwin, CPPFLAGS must have it.
1311case "$FFLAGS" in
1312  *-mno-cygwin*)
1313    if test x${CPPFLAGS+set} != xset ; then
1314      CPPFLAGS="-mno-cygwin"
1315    else
1316      case "$CPPFLAGS" in
1317        *-mno-cygwin*)
1318          ;;
1319        *)
1320          CPPFLAGS="$CPPFLAGS -mno-cygwin"
1321          ;;
1322      esac
1323    fi ;;
1324esac
1325
1326# Try if FFLAGS works
1327if test "$F77" != "unavailable" ; then
1328  AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1329  if test -z "$FFLAGS"; then
1330    AC_MSG_WARN([The flags FFLAGS="$FFLAGS" do not work.  I will now just try '-O', but you might want to set FFLAGS manually.])
1331    FFLAGS='-O'
1332    AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1333    if test -z "$FFLAGS"; then
1334      AC_MSG_WARN([This value for FFLAGS does not work.  I will continue with empty FFLAGS, but you might want to set FFLAGS manually.])
1335    fi
1336  fi
1337fi
1338
1339AC_MSG_NOTICE([Fortran compiler options are: $FFLAGS])
1340
1341AC_ARG_VAR(MPIF77,[Fortran MPI Compiler])
1342if test x"$MPIF77" = x; then :; else
1343  AC_MSG_NOTICE([Will use MPI Fortran compiler $MPIF77])
1344  F77="$MPIF77"
1345fi
1346
1347case "$F77" in
1348  ifort* | */ifort* | IFORT* | */IFORT*)
1349    AC_COIN_MINGW_LD_FIX
1350    ;;
1351esac
1352
1353AC_LANG_POP([Fortran 77])
1354]) # AC_COIN_PROG_F77
1355
1356###########################################################################
1357#                           COIN_F77_WRAPPERS                             #
1358###########################################################################
1359
1360# Calls autoconfs AC_F77_WRAPPERS and does additional corrections to FLIBS
1361
1362AC_DEFUN([AC_COIN_F77_WRAPPERS],
1363[AC_BEFORE([AC_COIN_PROG_F77],[$0])dnl
1364AC_BEFORE([AC_PROG_F77],[$0])dnl
1365
1366AC_LANG_PUSH([Fortran 77])
1367
1368AC_F77_WRAPPERS
1369
1370# If FLIBS has been set by the user, we just restore its value here
1371if test x"$save_FLIBS" != x; then
1372  FLIBS="$save_FLIBS"
1373else
1374  # This is to correct a missing exclusion in autoconf 2.59
1375  if test x"$FLIBS" != x; then
1376    my_flibs=
1377    for flag in $FLIBS; do
1378      case $flag in
1379        -lcrt*.o) ;;
1380        -lcygwin) ;;
1381               *) my_flibs="$my_flibs $flag" ;;
1382      esac
1383    done
1384    FLIBS="$my_flibs"
1385  fi
1386
1387  case $build in
1388  # The following is a fix to define FLIBS for ifort on Windows
1389  # In its original version, it linked in libifcorert.lib or libifcorertd.lib on Windows/ifort explicitly.
1390  # However, this seem to create a dependency on libifcorert.dll (or libifcorertd.dll) in the executables.
1391  # This is seem to be unnecessary, libifcorert(d).lib has been removed from the link line.
1392     *-cygwin* | *-mingw*)
1393       case "$F77" in
1394         ifort* | */ifort* | IFORT* | */IFORT*)
1395           FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib"
1396#           if "$coin_debug_compile" = true ; then
1397#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib"
1398#           else
1399#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib"
1400#           fi
1401           ;;
1402         compile_f2c*)
1403           FLIBS=`$F77 -FLIBS` ;;
1404       esac;;
1405     *-hp-*)
1406         FLIBS="$FLIBS -lm";;
1407     *-ibm-*)
1408         FLIBS=`echo $FLIBS | sed 's/-lc)/-lc/g'` ;;
1409     *-linux-*)
1410       case "$F77" in
1411         pgf77* | */pgf77* | pgf90* | */pgf90*)
1412# ask linker to go through the archives multiple times
1413# (the Fortran compiler seems to do that automatically...
1414           FLIBS="-Wl,--start-group $FLIBS -Wl,--end-group" ;;
1415       esac
1416  esac
1417  ac_cv_f77_libs="$FLIBS"
1418fi
1419
1420AC_LANG_POP([Fortran 77])
1421
1422]) # AC_COIN_F77_WRAPPERS
1423
1424###########################################################################
1425#                             COIN_FIND_F77                               #
1426###########################################################################
1427
1428# Attempt to preempt autoconf by locating an appropriate F77 program. This
1429# macro will not trigger a fatal error if a suitable compiler cannot be
1430# found. It should be called before COIN_PROG_F77 or COIN_TRY_FLINK.
1431
1432AC_DEFUN([AC_COIN_FIND_F77],
1433[AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1434AC_REQUIRE([AC_COIN_F77_COMPS])
1435AC_MSG_NOTICE([Trying to determine Fortran compiler name])
1436AC_CHECK_PROGS([F77],[$coin_f77_comps],[unavailable])
1437])
1438
1439# Auxilliary macro to make sure both COIN_PROG_F77 and COIN_FIND_F77 use
1440# the same search lists for compiler names.
1441# For *-*-solaris*, promote Studio/Workshop compilers to front of list.
1442AC_DEFUN([AC_COIN_F77_COMPS],
1443[case $build in
1444  *-cygwin* | *-mingw*)
1445     if test "$enable_doscompile" = msvc ; then
1446       coin_f77_comps="ifort fl32 compile_f2c"
1447     else
1448       coin_f77_comps="gfortran g77 ifort fl32 compile_f2c"
1449     fi ;;
1450  *-*-solaris*)
1451     coin_f77_comps="f95 f90 f77 xlf_r fort77 gfortran g77 pgf90 pgf77 ifort ifc frt af77" ;;
1452  *) coin_f77_comps="xlf_r fort77 gfortran f77 g77 pgf90 pgf77 ifort ifc frt af77" ;;
1453 esac
1454])
1455
1456###########################################################################
1457#                          COIN_INIT_AUTOMAKE                             #
1458###########################################################################
1459
1460# This macro calls the regular INIT_AUTOMAKE and MAINTAINER_MODE
1461# macros, and defines additional variables and makefile conditionals,
1462# that are used in the maintainer parts of the makfile.  It also
1463# checks if the correct versions of the autotools are used.
1464#
1465# This also defines the AC_SUBST variables:
1466# abs_source_dir     absolute path to source code for this package
1467# abs_bin_dir        absolute path to the directory where binaries are
1468#                    going to be installed (prefix/bin)
1469# abs_lib_dir        absolute path to the directory where libraries are
1470#                    going to be installed (prefix/lib)
1471# abs_include_dir    absolute path to the directory where the header files
1472#                    are installed (prefix/include)
1473
1474AC_DEFUN([AC_COIN_INIT_AUTOMAKE],
1475[AC_REQUIRE([AC_PROG_EGREP])
1476
1477# AC_MSG_NOTICE([Beginning automake initialisation.])
1478# Stuff for automake
1479AM_INIT_AUTOMAKE
1480AM_MAINTAINER_MODE
1481
1482coin_have_externals=no
1483if test "$enable_maintainer_mode" = yes; then
1484
1485  # If maintainer mode is chosen, we make sure that the correct versions
1486  # of the tools are used, and that we know where libtool.m4 is (to
1487  # recreate acinclude.m4)
1488
1489  AC_SUBST(LIBTOOLM4)
1490  LIBTOOLM4=
1491  # Normally, $HOME
1492  AUTOTOOLS_DFLT=$HOME
1493
1494  AC_CACHE_CHECK([whether we are using the correct autotools],
1495                 [ac_cv_use_correct_autotools],
1496                 [ac_cv_use_correct_autotools=check])
1497
1498  if test $ac_cv_use_correct_autotools = check; then
1499    ac_cv_use_correct_autotools=yes
1500    # Check if we have autoconf
1501    AC_CHECK_PROG([have_autoconf],[autoconf],[yes],[no])
1502    if test $have_autoconf = no; then
1503      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find autoconf in your path.])
1504    fi
1505
1506    # Check whether autoconf is the correct version
1507    correct_version='2.59'
1508    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1509    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of autoconf])
1510    autoconf --version > confauto.out 2>&1
1511    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1512      AC_MSG_RESULT([yes])
1513    else
1514      rm -f confauto.out
1515      AC_MSG_RESULT([no])
1516      AC_MSG_ERROR([You don't have the correct version of autoconf as the first one in your path.])
1517    fi
1518    rm -f confauto.out
1519
1520    # Check if the executable autoconf is picked up from the correct location
1521    AC_MSG_CHECKING([whether autoconf is coming from the correct location])
1522    autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
1523    autoconf_dir=`cd $autoconf_dir; pwd`
1524    if test x$AUTOTOOLS_DIR = x; then
1525      want_dir=$AUTOTOOLS_DFLT/bin
1526    else
1527      want_dir=$AUTOTOOLS_DIR/bin
1528    fi
1529    if test $autoconf_dir = `cd $want_dir; pwd`; then
1530      AC_MSG_RESULT([yes])
1531    else
1532      rm -f confauto.out
1533      AC_MSG_RESULT([no])
1534      AC_MSG_ERROR([The autoconf executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1535    fi
1536
1537    # Check if we have automake
1538    AC_CHECK_PROG([have_automake],[automake],[yes],[no])
1539    if test $have_automake = no; then
1540      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find automake in your path.])
1541    fi
1542 
1543    # Check whether automake is the correct version
1544    correct_version='1.9.6'
1545    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1546    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of automake])
1547    automake --version > confauto.out 2>&1
1548    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1549      AC_MSG_RESULT([yes])
1550    else
1551      rm -f confauto.out
1552      AC_MSG_RESULT([no])
1553      AC_MSG_ERROR([You don't have the correct version of automake as the first one in your path.])
1554    fi
1555    rm -f confauto.out
1556
1557    # Check if the executable automake is picked up from the correct location
1558    AC_MSG_CHECKING([whether automake is coming from the correct location])
1559    automake_dir=`which automake | sed -e 's=/automake=='`
1560    automake_dir=`cd $automake_dir; pwd`
1561    if test x$AUTOTOOLS_DIR = x; then
1562      want_dir=$AUTOTOOLS_DFLT/bin
1563    else
1564      want_dir=$AUTOTOOLS_DIR/bin
1565    fi
1566    if test $automake_dir = `cd $want_dir; pwd`; then
1567      AC_MSG_RESULT([yes])
1568    else
1569      rm -f confauto.out
1570      AC_MSG_RESULT([no])
1571      AC_MSG_ERROR([The automake executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1572    fi
1573
1574    # Check if this is the correct version of libtool (with escaped dots)
1575    if test x$AUTOTOOLS_DIR = x; then
1576      want_dir=$AUTOTOOLS_DFLT/share
1577    else
1578      want_dir=$AUTOTOOLS_DIR/share
1579    fi
1580    correct_version='1.5.22'
1581    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1582    AC_COIN_CHECK_FILE([$want_dir/libtool/ltmain.sh],
1583                       [have_ltmain=yes],
1584                       [have_ltmain=no])
1585    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of libtool.])
1586    if test $have_ltmain = yes; then
1587    if $EGREP $grep_version $want_dir/libtool/ltmain.sh >/dev/null 2>&1; then
1588        AC_MSG_RESULT([yes])
1589      else
1590        AC_MSG_RESULT([no])
1591        AC_MSG_ERROR([You don't have the correct version of libtool.])
1592      fi
1593    else
1594      AC_MSG_RESULT([no])
1595      AC_MSG_ERROR([I cannot find the ltmain.sh file.])
1596    fi
1597  fi
1598
1599  # Check if we can find the libtool file
1600  if test x$AUTOTOOLS_DIR = x; then
1601    want_dir=$AUTOTOOLS_DFLT/share
1602  else
1603    want_dir=$AUTOTOOLS_DIR/share
1604  fi
1605  AC_COIN_CHECK_FILE([$want_dir/aclocal/libtool.m4],
1606                     [LIBTOOLM4="$want_dir/aclocal/libtool.m4"],
1607                     [AC_MSG_ERROR([I cannot find the libtool.m4 file.])])
1608
1609  # Check if we have an Externals file
1610  if test -r $srcdir/Externals; then
1611    coin_have_externals=yes
1612  fi
1613  # Check if subversion is installed and understands https
1614  AC_CHECK_PROG([have_svn],[svn],[yes],[no])
1615  if test x$have_svn = xyes; then
1616    AC_CACHE_CHECK([whether svn understands https],
1617                   [ac_cv_svn_understands_https],
1618                   [svn --version > confauto.out 2>&1
1619                    if $EGREP https confauto.out >/dev/null 2>&1; then
1620                      ac_cv_svn_understands_https=yes
1621                    else
1622                      ac_cv_svn_understands_https=no
1623                      have_svn=no
1624                      ac_cv_prog_have_svn=no
1625                    fi
1626                    rm -f confauto.out])
1627  fi
1628
1629  # Find the location of the BuildTools directory
1630  BUILDTOOLSDIR=
1631  if test -r $srcdir/BuildTools/coin.m4; then
1632    BUILDTOOLSDIR=$srcdir/BuildTools
1633  else
1634    if test -r $srcdir/../BuildTools/coin.m4; then
1635      BUILDTOOLSDIR=$srcdir/../BuildTools
1636    else
1637      if test -r $srcdir/../../BuildTools/coin.m4; then
1638        BUILDTOOLSDIR=$srcdir/../../BuildTools
1639      else
1640        AC_MSG_ERROR(Cannot find the BuildTools directory)
1641      fi
1642    fi
1643  fi
1644  AC_SUBST(BUILDTOOLSDIR)
1645
1646  # The following variable is set to the name of the directory where
1647  # the autotool scripts are located
1648  AC_SUBST(AUX_DIR)
1649  AUX_DIR=$ac_aux_dir
1650fi
1651
1652# helpful variable for the base directory of this package
1653abs_source_dir=`cd $srcdir; pwd`
1654AC_SUBST(abs_source_dir)
1655
1656# Stuff for example Makefiles
1657if test x$prefix = xNONE; then
1658  full_prefix=$ac_default_prefix
1659else
1660  full_prefix=$prefix
1661fi
1662full_prefix=`cd $full_prefix ; pwd`
1663AC_SUBST(abs_lib_dir)
1664abs_lib_dir=$full_prefix/lib
1665AC_SUBST(abs_include_dir)
1666abs_include_dir=$full_prefix/include
1667AC_SUBST(abs_bin_dir)
1668abs_bin_dir=$full_prefix/bin
1669
1670AM_CONDITIONAL(HAVE_EXTERNALS,
1671               test $coin_have_externals = yes && test x$have_svn = xyes)
1672
1673# AC_MSG_NOTICE([End automake initialisation.])
1674
1675]) # AC_COIN_INIT_AUTOMAKE
1676
1677###########################################################################
1678#                          COIN_CREATE_LIBTOOL                            #
1679###########################################################################
1680
1681# This does all the tests necessary to create the libtool script in the
1682# package base directory.  If this is used, then the COIN_INIT_AUTO_TOOLS
1683# test in the subdirectories will be able to skip the libtool tests and
1684# just use the one in the package base directory.
1685
1686m4_define([AC_COIN_CREATE_LIBTOOL],
1687[AC_CANONICAL_BUILD
1688
1689# Check if user wants to produce debugging code
1690AC_COIN_DEBUG_COMPILE
1691
1692# Get the name of the C compiler and appropriate compiler options
1693AC_COIN_PROG_CC
1694
1695# Get the name of the C++ compiler and appropriate compiler options
1696AC_COIN_PROG_CXX
1697
1698# Get the name of the Fortran compiler and appropriate compiler options
1699AC_COIN_PROG_F77
1700
1701# Initialize automake and libtool
1702# AC_MSG_NOTICE([Calling INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1703AC_COIN_INIT_AUTO_TOOLS
1704# AC_MSG_NOTICE([Finished INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1705])
1706
1707###########################################################################
1708#                         COIN_INIT_AUTO_TOOLS                            #
1709###########################################################################
1710
1711# Initialize the auto tools automake and libtool, with all
1712# modifications we want for COIN packages.
1713#
1714# RPATH_FLAGS        link flags for hardcoding path to shared objects
1715
1716# This is a trick to have this code before AC_COIN_PROG_LIBTOOL
1717AC_DEFUN([AC_COIN_DISABLE_STATIC],
1718[
1719# Test if force_shared has been set
1720if test "x$1" = xforce_shared; then
1721  if test x$enable_shared = xno; then
1722    AC_MSG_ERROR([Shared libraries are disabled by user, but this is not feasible with the given options])
1723  fi
1724  enable_shared=yes;
1725else
1726  # On Cygwin and AIX, building DLLs doesn't work
1727  case $build in
1728    *-cygwin*)
1729      coin_disable_shared=yes
1730      platform=Cygwin
1731    ;;
1732    *-aix*)
1733      coin_disable_shared=yes
1734      platform=AIX
1735    ;;
1736    *-mingw*)
1737      coin_disable_shared=yes
1738      platform="Msys"
1739#      case "$CXX" in
1740#        cl*)
1741#          coin_disable_shared=yes
1742#          platform="Msys with cl"
1743#      ;;
1744#      esac
1745    ;;
1746  esac
1747fi
1748if test x"$coin_disable_shared" = xyes; then
1749  if test x"$enable_shared" = xyes; then
1750    AC_MSG_WARN([On $platform, shared objects are not supported. I'm disabling your choice.])
1751  fi
1752  enable_shared=no
1753fi
1754# By default, we only want the shared objects to be compiled
1755AC_DISABLE_STATIC
1756])
1757
1758m4_define([AC_COIN_INIT_AUTO_TOOLS],
1759[{AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1760AC_BEFORE([AC_COIN_PROG_CC],[$0])
1761AC_BEFORE([AC_COIN_PROG_F77],[$0])
1762
1763# START
1764AC_COIN_DISABLE_STATIC([$1])
1765
1766# Initialize automake
1767AC_COIN_INIT_AUTOMAKE
1768
1769LIBTOOL=
1770if test -r ../libtool; then
1771  coin_config_dir=..
1772  LIBTOOL='$(SHELL) $(top_builddir)/../libtool'
1773fi
1774if test "x$LIBTOOL" = x; then
1775  if test -r ../../libtool; then
1776    coin_config_dir=../..
1777    LIBTOOL='$(SHELL) $(top_builddir)/../../libtool'
1778  fi
1779fi
1780
1781if test "x$LIBTOOL" = x; then
1782# AC_MSG_NOTICE([Creating libtool script (calling COIN_PROG_LIBTOOL).])
1783  # Stuff for libtool
1784  AC_COIN_PROG_LIBTOOL
1785# AC_MSG_NOTICE([Finished COIN_PROG_LIBTOOL.])
1786  # set RPATH_FLAGS to the compiler link flags required to hardcode location
1787  # of the shared objects
1788  AC_COIN_RPATH_FLAGS($abs_lib_dir)
1789
1790else
1791
1792  AC_MSG_NOTICE([Using libtool script in directory $coin_config_dir])
1793  # get all missing information from the config.log file
1794
1795  # output variables and defines
1796  as_save_IFS=$IFS
1797  IFS='
1798'
1799  for oneline in `cat $coin_config_dir/config.status`; do
1800    case "$oneline" in
1801         # First some automake conditionals
1802      s,@am__fastdep* | s,@AR@* | s,@CPP@*  | s,@CPPFLAGS@* | s,@CXXCPP@*  | \
1803      s,@RANLIB@* | s,@STRIP@* | s,@ac_ct_AR@* | s,@ac_ct_RANLIB@* | \
1804      s,@ac_ct_STRIP@* | s,@host* | s,@LN_S@* | s,@RPATH_FLAGS@* | \
1805      s,@ac_c_preproc_warn_flag@* |  s,@ac_cxx_preproc_warn_flag@* )
1806        command=`echo $oneline | sed -e 's/^s,@//' -e 's/@,/="/' -e 's/,;t t/"/'`
1807#        echo "$command"
1808        eval "$command"
1809        ;;
1810      s,@DEFS@* )
1811        command=`echo $oneline | sed -e 's/^s,@DEFS@,/defsline="/' -e 's/,;t t/"/'`
1812#        echo "$command"
1813        eval "$command"
1814        ;;
1815    esac
1816  done
1817  IFS=$as_save_IFS
1818
1819  # And some defines (assuming here that the packages base dir
1820  # doesn't have a config.h file
1821  for word in $defsline; do
1822#    echo word $word
1823    case $word in
1824      -DHAVE_@<:@A-Z_@:>@*_H=1 | -DSTDC_HEADERS=1 )
1825        i=`echo $word | sed -e 's/-D/#define /' -e 's/=/ /'`
1826#        echo dd $i
1827        echo $i >>confdefs.h
1828        ;;
1829    esac
1830  done
1831fi
1832
1833# AC_MSG_NOTICE([End of INIT_AUTO_TOOLS.])
1834
1835# ToDo
1836# For now, don't use the -no-undefined flag, since the Makefiles are
1837# not yet set up that way.  But we need to fix this, when we want
1838# to comile DLLs under Windows.
1839LT_LDFLAGS=
1840
1841# Check if we want to set the library version
1842AC_MSG_CHECKING([if library version is set])
1843if test x"$coin_libversion" != x; then
1844  LT_LDFLAGS="$LT_LDFLAGS -version-info $coin_libversion"
1845  AC_MSG_RESULT([$coin_libversion])
1846else
1847  AC_MSG_RESULT([no])
1848fi
1849
1850AC_SUBST(LT_LDFLAGS)
1851
1852#END
1853}])
1854
1855
1856###########################################################################
1857#                      COIN_PATCH_LIBTOOL_CYGWIN                          #
1858###########################################################################
1859
1860# Patches to libtool for cygwin. Lots for cl, a few for GCC.
1861# For cl:
1862# - cygpath is not correctly quoted in fix_srcfile_path
1863# - paths generated for .lib files is not run through cygpath -w
1864
1865
1866AC_DEFUN([AC_COIN_PATCH_LIBTOOL_CYGWIN],
1867[ case "$CXX" in
1868    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1869      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1870      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1871          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1872          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1873          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1874          -e 's%lib /OUT:%lib -OUT:%' \
1875          -e "s%cygpath -w%$CYGPATH_W%" \
1876          -e 's%$AR x \\$f_ex_an_ar_oldlib%bla=\\`lib -nologo -list \\$f_ex_an_ar_oldlib | xargs echo '"$mydos2unix"'\\`; echo \\$bla; for i in \\$bla; do lib -nologo -extract:\\$i \\$f_ex_an_ar_oldlib; done%' \
1877          -e 's/$AR t/lib -nologo -list/' \
1878          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1879          -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1880          -e 's%old_archive_cmds="lib -OUT:\\$oldlib\\$oldobjs\\$old_deplibs"%old_archive_cmds="if test -r \\$oldlib; then bla=\\"\\$oldlib\\"; else bla=; fi; lib -OUT:\\$oldlib \\\\\\$bla\\$oldobjs\\$old_deplibs"%' \
1881      libtool > conftest.bla
1882
1883      mv conftest.bla libtool
1884      chmod 755 libtool
1885      ;;
1886    *)
1887      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
1888      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1889          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1890          -e 's|libext="lib"|libext="a"|' \
1891      libtool > conftest.bla
1892
1893      mv conftest.bla libtool
1894      chmod 755 libtool
1895      ;;
1896  esac ]) # COIN_PATCH_LIBTOOL_CYGWIN
1897
1898###########################################################################
1899#                    COIN_PATCH_LIBTOOL_SOLARIS                           #
1900###########################################################################
1901# If we want to do a 64-bit build with GCC on Solaris, the system search
1902# libraries need to point to 64-bit subdirectories. If they do not already do
1903# that, fix them. This patch is evolving, as are GCC compilers.  GCC 4.2.1
1904# reports the correct search list, given the correct call. GCC 4.1.1 does not.
1905# `Correct call' means -m64 is specified. `Correct search list' seems to amount
1906# to prepending the list of 64-bit subdirectories to the 32-bit directories.
1907# Both SPARC and x86 have this issue, but a different hardware id string is
1908# required depending on the underlying CPU. The macro executes isainfo to get
1909# the string. This will fail, of course, if we're cross-compiling. The
1910# alternative is to fail on a regular basis each time a new CPU identifier is
1911# needed. This macro will also fail if the search list reported with
1912# -print-search-dirs differs between the C, C++, and Fortran compilers; each
1913# have their own setting in libtool.  If GCC reports the correct search list
1914# given the -m64 flag, the best solution is to define CC='gcc -m64', and
1915# similarly for CXX, F77, so that libtool will make the correct call.
1916###########################################################################
1917AC_DEFUN([AC_COIN_PATCH_LIBTOOL_SOLARIS],
1918[ if test "$GCC" = yes && \
1919     (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm64' >/dev/null 2>&1) ; then
1920    hdwisa=`isainfo | sed -e 's/\(@<:@^ @:>@*\) .*$/\1/'`
1921    if `$EGREP 'sys_lib_search_path_spec=' libtool | $EGREP -v $hdwisa >/dev/null 2>&1` ; then
1922      AC_MSG_NOTICE([Applying patches to libtool for 64-bit GCC compilation])
1923      fixlibtmp=`$CC -m64 -print-search-dirs | $EGREP '^libraries:'`
1924      fixlibtmp=`echo $fixlibtmp | sed -e 's/libraries: =//' -e 's/:/ /g'`
1925      if `echo "$fixlibtmp" | $EGREP -v $hdwisa  >/dev/null 2>&1` ; then
1926        # AC_MSG_NOTICE(Compensating for broken gcc)
1927        for lib in $fixlibtmp ; do
1928          if test -d "${lib}${hdwisa}" ; then
1929            syslibpath64="$syslibpath64 ${lib}${hdwisa}/"
1930          fi
1931        done
1932        syslibpath64="${syslibpath64} ${fixlibtmp}"
1933      else
1934        syslibpath64="$fixlibtmp"
1935      fi
1936      sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="'"$syslibpath64"'"|' libtool > conftest.bla
1937      mv conftest.bla libtool
1938      chmod 755 libtool 
1939    fi
1940    # AC_MSG_NOTICE(Result is )
1941    # $EGREP 'sys_lib_search_path_spec=' libtool
1942  fi ]) # COIN_PATCH_LIBTOOL_SOLARIS
1943
1944###########################################################################
1945#                           COIN_PROG_LIBTOOL                             #
1946###########################################################################
1947
1948# Setup the libtool stuff together with any modifications to make it
1949# work on additional platforms
1950
1951AC_DEFUN([AC_COIN_LIBTOOL_WRAPPER],
1952[AC_BEFORE([AC_COIN_BLA],[$0])
1953AC_PROG_LIBTOOL])
1954
1955AC_DEFUN([AC_COIN_BLA],[echo bla])
1956
1957AC_DEFUN([AC_COIN_PROG_LIBTOOL],
1958[# No longer needed now that CPPFLAGS is correctly set -- lh, 061214 --
1959 # AC_REQUIRE([AC_COIN_DLFCN_H])
1960
1961# NEW: If libtool exists in the directory higher up, we use that one
1962#      instead of creating a new one
1963
1964# It turns out that the code for AC_PROG_LIBTOOL is somehow AC_REQUIRED
1965# out in front of this macro body. You'll notice that LIBTOOL is already
1966# defined here.  We'll have to count on this macro not being called if libtool
1967# already exists, or at least move the libtool fixes outside the conditional.
1968# AC_MSG_NOTICE([Entering coin_prog_libtool, LIBTOOL = "$LIBTOOL".])
1969# This test is therefore removed.  -- lh, 061214 --
1970# if test "x$LIBTOOL" = x; then
1971
1972# AC_MSG_NOTICE([Calling PROG_LIBTOOL.])
1973  AC_PROG_LIBTOOL
1974# AC_MSG_NOTICE([Finished PROG_LIBTOOL.])
1975  AC_SUBST(ac_c_preproc_warn_flag)
1976  AC_SUBST(ac_cxx_preproc_warn_flag)
1977
1978  AC_MSG_NOTICE([Build is "$build".])
1979  mydos2unix='| dos2unix'
1980  case $build in
1981    *-mingw*)
1982      CYGPATH_W=echo
1983      mydos2unix=
1984      ;;
1985  esac
1986
1987  case $build in
1988    # Here we need to check if -m32 is specified.  If so, we need to correct
1989    # sys_lib_search_path_spec
1990    *x86_64-*)
1991      if test "$GCC" = yes && (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm32' >& /dev/null); then
1992        AC_MSG_NOTICE(Applying patches to libtool for 32bit compilation)
1993        sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="/lib /usr/lib"|' libtool > conftest.bla
1994        mv conftest.bla libtool
1995        chmod 755 libtool 
1996      fi
1997      ;;
1998
1999    *-solaris*)
2000      AC_COIN_PATCH_LIBTOOL_SOLARIS
2001      ;;
2002    # Cygwin. Ah, cygwin. Too big and ugly to inline; see the macro.
2003    *-cygwin* | *-mingw*)
2004      AC_COIN_PATCH_LIBTOOL_CYGWIN
2005      ;;
2006    *-darwin*)
2007      AC_MSG_NOTICE(Applying patches to libtool for Darwin)
2008      sed -e 's/verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"/verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"/' \
2009        -e 's/ -dynamiclib / -dynamiclib -single_module /g' \
2010      libtool > conftest.bla
2011
2012      mv conftest.bla libtool
2013      chmod 755 libtool
2014      ;;
2015  esac
2016# This fi matches the commented `if test "x$LIBTOOL" = x;' up at the head of
2017# the macro. -- lh, 061214 --
2018# fi
2019
2020# AC_MSG_NOTICE([End libtool initialisation.])
2021]) # AC_COIN_PROG_LIBTOOL
2022
2023# This is a trick to force the check for the dlfcn header to be done before
2024# the checks for libtool
2025# No longer needed now that CPPFLAGS is correctly set.  -- lh, 061214 --
2026# ACDEFUN([AC_COIN_DLFCN_H],
2027# [AC_LANG_PUSH(C)
2028# AC_COIN_CHECK_HEADER([dlfcn.h])
2029# AC_LANG_POP(C)
2030# ]) # AC_COIN_DLFCN_H
2031
2032###########################################################################
2033#                            COIN_RPATH_FLAGS                             #
2034###########################################################################
2035
2036# This macro, in case shared objects are used, defines a variable
2037# RPATH_FLAGS that can be used by the linker to hardwire the library
2038# search path for the given directories.  This is useful for example
2039# Makefiles
2040
2041AC_DEFUN([AC_COIN_RPATH_FLAGS],
2042[RPATH_FLAGS=
2043
2044if test $enable_shared = yes; then
2045  case $build in
2046    *-linux-*)
2047      if test "$GXX" = "yes"; then
2048        RPATH_FLAGS=
2049        for dir in $1; do
2050          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
2051        done
2052      fi ;;
2053    *-darwin*)
2054        RPATH_FLAGS=nothing ;;
2055    *-ibm-*)
2056      case "$CXX" in
2057      xlC* | */xlC* | mpxlC* | */mpxlC*)
2058        RPATH_FLAGS=nothing ;;
2059      esac ;;
2060    *-hp-*)
2061        RPATH_FLAGS=nothing ;;
2062    *-mingw32)
2063        RPATH_FLAGS=nothing ;;
2064    *-*-solaris*)
2065        RPATH_FLAGS=
2066        for dir in $1; do
2067          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
2068        done
2069  esac
2070
2071  if test "$RPATH_FLAGS" = ""; then
2072    AC_MSG_WARN([Could not automatically determine how to tell the linker about automatic inclusion of the path for shared libraries.  The test examples might not work if you link against shared objects.  You will need to set the LD_LIBRARY_PATH, DYLP_LIBRARY_PATH, or LIBDIR variable manually.])
2073  fi
2074  if test "$RPATH_FLAGS" = "nothing"; then
2075    RPATH_FLAGS=
2076  fi
2077fi
2078
2079AC_SUBST(RPATH_FLAGS)
2080]) # AC_COIN_RPATH_FLAGS
2081
2082###########################################################################
2083#                        COIN_LINK_INPUT_CMD                              #
2084###########################################################################
2085
2086# This macro determines which command should be used to "link" files
2087# that are input to the generated executables.  On Windows, the codes
2088# using the native Windows system libraries, cannot understand symbolic
2089# links, and a copy should be used instead of 'ln -s'.
2090# The result is stored in coin_link_input_cmd
2091
2092AC_DEFUN([AC_COIN_LINK_INPUT_CMD],
2093[AC_REQUIRE([AC_PROG_LN_S])
2094AC_BEFORE([AC_COIN_PROG_CC], [$0])
2095AC_BEFORE([AC_COIN_ENABLE_DOSCOMPILE], [$0])
2096
2097AC_MSG_CHECKING([which command should be used to link input files])
2098coin_link_input_cmd="$LN_S"
2099if test "$enable_doscompile" = mingw; then
2100  coin_link_input_cmd=cp
2101fi
2102case "$CC" in
2103  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2104    coin_link_input_cmd=cp ;;
2105esac
2106AC_MSG_RESULT($coin_link_input_cmd)
2107])
2108
2109###########################################################################
2110#                              COIN_FINALIZE                              #
2111###########################################################################
2112
2113# This macro should be called at the very end of the configure.ac file.
2114# It creates the output files (by using AC_OUTPUT), and might do some other
2115# things (such as generating links to data files in a VPATH configuration).
2116# It also prints the "success" message.
2117# Note: If the variable coin_skip_ac_output is set to yes, then no output
2118# files are written.
2119
2120AC_DEFUN([AC_COIN_FINALIZE],
2121[
2122AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2123if test x$coin_skip_ac_output != xyes; then
2124
2125  FADDLIBS="$ADDLIBS"
2126  if test x"$coin_need_flibs" = xyes; then
2127    ADDLIBS="$ADDLIBS $FLIBS"
2128  fi
2129
2130  # library extension
2131  AC_SUBST(LIBEXT)
2132  case "$CC" in
2133    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2134         LIBEXT=lib ;;
2135      *) LIBEXT=a ;;
2136  esac
2137
2138  # Define VPATH_DISTCLEANFILES to be everything that needs to be
2139  # cleaned for distclean in a vpath configuration
2140  AC_SUBST(VPATH_DISTCLEANFILES)
2141  VPATH_DISTCLEANFILES="$coin_vpath_link_files"
2142
2143  # Take out subdirectories if their configuration concluded that they
2144  # don't need to be compiled
2145  if test x"$coin_ac_skip_subdirs" != x; then
2146    new_subdirs=
2147    for i in $subdirs; do
2148      skipme=no
2149      for j in $coin_ac_skip_subdirs; do
2150        if test $i = $j; then
2151          skipme=yes;
2152        fi
2153      done
2154      if test $skipme = no; then
2155        new_subdirs="$new_subdirs $i"
2156      fi
2157    done
2158    subdirs="$new_subdirs"
2159  fi
2160
2161  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])
2436AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
2437AC_REQUIRE([AC_PROG_LN_S])
2438
2439files=`cd $srcdir; ls $1`
2440# We need to do the following loop to make sure that are no newlines
2441# in the variable
2442for file in $files; do
2443  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2444done
2445if test $coin_vpath_config = yes; then
2446  lnkcmd=
2447  if test "$enable_doscompile" != no; then
2448    lnkcmd=cp
2449  fi
2450  case "$CC" in
2451    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2452      lnkcmd=cp ;;
2453  esac
2454  if test "x$lnkcmd" = xcp; then
2455    AC_MSG_NOTICE([Copying example files ($1)])
2456  else
2457    AC_MSG_NOTICE([Creating links to the example files ($1)])
2458    lnkcmd="$LN_S"
2459  fi
2460  for file in $EXAMPLE_FILES; do
2461    rm -f $file
2462    $lnkcmd $srcdir/$file $file
2463  done
2464  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2465else
2466  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2467fi
2468
2469# In case there are compressed files, we create a variable with the
2470# uncompressed names
2471EXAMPLE_UNCOMPRESSED_FILES=
2472for file in $EXAMPLE_FILES; do
2473  case $file in
2474    *.gz)
2475      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2476      ;;
2477  esac
2478done
2479
2480AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2481AC_SUBST(EXAMPLE_FILES)
2482AC_SUBST(EXAMPLE_CLEAN_FILES)
2483]) #AC_COIN_EXAMPLE_FILES
2484
2485###########################################################################
2486#                            COIN_HAS_PROJECT                             #
2487###########################################################################
2488
2489# This macro sets up usage of a Coin package.  It defines the
2490# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
2491# object directory of the package, respectively.  It also defines
2492# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
2493# argument should be the name (Pkg) of the project (in correct lower
2494# and upper case)
2495
2496AC_DEFUN([AC_COIN_HAS_PROJECT],
2497[AC_MSG_CHECKING([for COIN project $1])
2498
2499# First check, if the sub-project is actually available (ToDo: allow
2500# other locations)
2501
2502m4_tolower(coin_has_$1)=unavailable
2503if test x"$COIN_SKIP_PROJECTS" != x; then
2504  for dir in $COIN_SKIP_PROJECTS; do
2505    if test $dir = $1; then
2506      m4_tolower(coin_has_$1)=skipping
2507    fi
2508  done
2509fi
2510
2511if test $m4_tolower(coin_has_$1) != skipping; then
2512  if test $PACKAGE_TARNAME = m4_tolower($1); then
2513    m4_tolower(coin_has_$1)=.
2514  else
2515    if test -d $srcdir/../$1; then
2516      m4_tolower(coin_has_$1)=../$1
2517    fi
2518  fi
2519fi
2520
2521if test $m4_tolower(coin_has_$1) != unavailable &&
2522   test $m4_tolower(coin_has_$1) != skipping; then
2523  # Set the #define if the component is available
2524  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
2525
2526  # Set the variables for source and object code location
2527  AC_SUBST(m4_toupper($1SRCDIR))
2528  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
2529  AC_SUBST(m4_toupper($1OBJDIR))
2530  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
2531  AC_SUBST(m4_toupper($1DOCDIR))
2532  m4_toupper($1DOCDIR)=$abs_lib_dir/../share/doc/coin/$1
2533fi
2534
2535  # Define the Makefile conditional
2536AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2537               [test $m4_tolower(coin_has_$1) != unavailable &&
2538                test $m4_tolower(coin_has_$1) != skipping])
2539AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2540]) # AC_COIN_HAS_PROJECT
2541
2542###########################################################################
2543#                        COIN_HAS_USER_LIBRARY                            #
2544###########################################################################
2545# This macro sets up usage of a user library with header files. The assumption
2546# is that the header file(s) and library do not reside in standard system
2547# directories, hence both the include directory and link flags must be
2548# specified. There are two mandatory arguments and two optional arguments.
2549#
2550# The first argument (mandatory) should be a name (LibraryName) for the
2551# library.  The second argument (mandatory) should be an abbreviation in
2552# upper case letters (LBRY) for the library. Ultimately, the macro will
2553# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2554# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2555# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2556# directory containing include files for the library. LBRYLIB should specify
2557# the flags necessary to link to the library. A variable coin_has_lbry will
2558# be set to true or false, as appropriate. A variable lbry_libcheck will be
2559# be set to yes or no; no indicates link checks should not be attempted.
2560#
2561# The macro defines three configure arguments, --with-libraryname-incdir,
2562# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2563# LibraryName to lower case.
2564#
2565# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2566# part of the configure command using --with-libraryname-incdir and
2567# --with-libraryname-lib, respectively. Command line arguments override
2568# environment variables.
2569#
2570# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2571# macro will check for the presence of the file. If a fourth argument is given,
2572# it should specify a function name, `fname'.  The macro will attempt to link a
2573# trivial program containing a parameterless call to the function, `fname()',
2574# using the LBRYLIB flags. The link check uses C as the language; this has been
2575# adequate to date but has limitations. It is possible to disable the link
2576# check by specifying --disable-libraryname-libcheck. This is a workaround for
2577# instances where the link check does not work properly, for whatever reason.
2578# If you're trying to link to a Fortran library, consider using F77_FUNC or
2579# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2580# library, you're on your own unless the library declares some function with
2581# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2582# name.
2583
2584AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
2585[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2586  AC_MSG_CHECKING(if user provides library for $1)
2587
2588# Check for header file directory
2589
2590  AC_ARG_WITH(m4_tolower($1)-incdir,
2591      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2592                     [specify the header file directory for library $1]),
2593      [$2INCDIR=`cd $withval; pwd`])
2594
2595# Check for library directory
2596
2597  AC_ARG_WITH(m4_tolower($1)-lib,
2598      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2599                     [specify the flags used to link with the library $1]),
2600      [$2LIB=$withval])
2601
2602# Switch to disable library check if requested
2603
2604  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2605      AS_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2606                     [use disable-m4_tolower($1)-libcheck to skip the link
2607                      check at configuration time]),
2608      [m4_tolower($1)_libcheck=$enableval],
2609      [m4_tolower($1)_libcheck=yes])
2610
2611# At this point, if we're going to use the library, both LBRYINCDIR and
2612# LBRYLIB must be defined and not empty.
2613
2614  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2615    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2616      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.])
2617    fi
2618    m4_tolower(coin_has_$2)=true
2619    AC_MSG_RESULT(yes)
2620  else
2621    m4_tolower(coin_has_$2)=false
2622    AC_MSG_RESULT(no)
2623  fi
2624
2625# If we have instructions for use, consider header and link checks.
2626
2627  if test $m4_tolower(coin_has_$2) = true; then
2628
2629# If argument 3 (file) is given, check for the file. Typically this will be a
2630# header file, but that's not assumed.
2631
2632    m4_ifval([$3],
2633        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2634             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2635
2636# Now see if we can link the function. There are arguments for and against
2637# assuming argument 3 is a header file declaring the function. A correct
2638# function declaration is the main argument in favour. Having to cope with
2639# possible dependencies or other oddities are the main arguments against.
2640# Force the use of C as the best single choice amongst C++, C, and Fortran.
2641# Obviously, this has limits.
2642
2643    m4_ifvaln([$4],
2644        [if test x"$m4_tolower($1)_libcheck" != xno; then
2645           coin_save_LIBS="$LIBS"
2646           LIBS="$$2LIB $ADDLIBS"
2647           coin_$2_link=no
2648           AC_LANG_PUSH(C)
2649           for fnm in $4 ; do
2650             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2651             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2652                 [AC_MSG_RESULT(yes)
2653                  coin_$2_link=yes
2654                  break],
2655                 [AC_MSG_RESULT(no)])
2656           done
2657           AC_LANG_POP(C)
2658           if test x"$coin_$2_link" = xyes ; then
2659             LIBS="$coin_save_LIBS"
2660           else
2661             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2662           fi
2663         fi])
2664
2665# If we make it this far, we've verified the file and linked the function. Add
2666# the necessary link flags to ADDLIBS and define the preprocessor symbol
2667# COIN_HAS_LBRY.
2668
2669    ADDLIBS="$$2LIB $ADDLIBS"
2670    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2671  fi
2672
2673# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2674# automake conditional. These actions must occur unconditionally.
2675
2676  AC_SUBST($2INCDIR)
2677  AC_SUBST($2LIB)
2678  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2679]) #AC_COIN_HAS_USER_LIBRARY
2680
2681###########################################################################
2682#                               COIN_HAS_ASL                              #
2683###########################################################################
2684
2685# This macro checks if the user has provide arguments that say where
2686# the precompiled ASL files should be found (with the --with-asldir
2687# flag).  If this is not the case, we check if the ThirdParty/ASL
2688# directory has been configured, which indicates that the files will
2689# be in that directory and can be used.
2690
2691AC_DEFUN([AC_COIN_HAS_ASL],
2692[coin_aslobjdir=../ThirdParty/ASL
2693coin_aslsrcdir=$srcdir/$coin_aslobjdir
2694
2695# Determine the name of the ASL library
2696case "$CC" in
2697  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2698    ampllib=amplsolv.lib ;;
2699  *)
2700    ampllib=amplsolver.a ;;
2701esac
2702
2703AC_ARG_WITH([asldir],
2704            AC_HELP_STRING([--with-asldir],
2705                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
2706            [use_asldir=$withval], [use_asldir=])
2707
2708if test "$use_asldir" = BUILD; then
2709  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2710    # If we are configuring ThirdParty/ASL, don't check
2711    if test -r $coin_aslobjdir/.MakeOk; then :; else
2712      AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])
2713    fi
2714  fi
2715elif test -z "$use_asldir"; then
2716 # try to find sources - if not given don't compile
2717  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2718    if test -r $coin_aslobjdir/.MakeOk; then
2719      use_asldir=BUILD
2720    else
2721      use_asldir=no
2722    fi
2723  else
2724    use_asldir=no
2725  fi
2726elif test "$use_asldir" != "no"; then
2727  AC_COIN_CHECK_FILE([$use_asldir/$ampllib],[],
2728                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
2729  AC_COIN_CHECK_FILE([$use_asldir/asl.h],[],
2730                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
2731  use_asldir=`cd $use_asldir; pwd`
2732  case $build in
2733    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
2734  esac
2735fi
2736
2737# Variable containing ASL library (including full path)
2738AC_SUBST(ASLLIB)
2739# Variable containing flags for including ASL header files
2740AC_SUBST(ASL_CPPFLAGS)
2741
2742if test "$use_asldir" = BUILD; then
2743  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
2744  ASLLIB=`$CYGPATH_W $coin_aslobjdir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2745  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
2746  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir | sed -e sX\\\\\\\\X/Xg`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers | sed -e sX\\\\\\\\X/Xg`
2747elif test "$use_asldir" != no; then
2748  ASLLIB=`$CYGPATH_W $use_asldir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2749  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir | sed -e sX\\\\\\\\X/Xg`
2750fi
2751
2752if test "$use_asldir" != no; then
2753  AC_LANG_PUSH(C)
2754  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
2755  coin_has_asl=yes
2756  AC_DEFINE([COIN_HAS_ASL],[1],
2757            [If defined, the Ampl Solver Library is available.])
2758  AC_LANG_POP(C)
2759else
2760  coin_has_asl=no
2761fi
2762AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
2763]) # AC_COIN_HAS_ASL
2764
2765###########################################################################
2766#                            COIN_TRY_FLINK                               #
2767###########################################################################
2768
2769# Auxilliary macro to test if a Fortran function name can be linked,
2770# given the current settings of LIBS.  We determine from the context, what
2771# the currently active programming language is, and cast the name accordingly.
2772# The first argument is the name of the function/subroutine, in small letters,
2773# the second argument are the actions taken when the test works, and the
2774# third argument are the actions taken if the test fails.
2775
2776AC_DEFUN([AC_COIN_TRY_FLINK],
2777[case $ac_ext in
2778  f)
2779    AC_TRY_LINK(,[      call $1],[$2],[$3])
2780    ;;
2781  c)
2782    AC_F77_FUNC($1,cfunc$1)
2783    if test x"$coin_need_flibs" = xyes; then
2784      flink_try=no;
2785    else
2786      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2787                  [flink_try=yes],[flink_try=no])
2788    fi
2789    if test $flink_try = yes; then
2790      $2
2791    else
2792      if test x"$FLIBS" != x; then
2793        flink_save_libs="$LIBS"
2794        LIBS="$LIBS $FLIBS"
2795        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2796                    [LIBS="$flink_save_libs"
2797                     $2
2798                     coin_need_flibs=yes],
2799                    [LIBS="$flink_save_libs"
2800                     $3])
2801      else
2802        $3
2803      fi
2804    fi
2805    ;;
2806  cc|cpp)
2807    AC_F77_FUNC($1,cfunc$1)
2808    if test x"$coin_need_flibs" = xyes; then
2809      flink_try=no;
2810    else
2811      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2812                  [flink_try=yes],[flink_try=no])
2813    fi
2814    if test $flink_try = yes; then
2815      $2
2816    else
2817      if test x"$FLIBS" != x; then
2818        flink_save_libs="$LIBS"
2819        LIBS="$LIBS $FLIBS"
2820        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2821                    [LIBS="$flink_save_libs"
2822                     $2
2823                     coin_need_flibs=yes],
2824                    [LIBS="$flink_save_libs"
2825                     $3])
2826      else
2827        $3
2828      fi
2829    fi
2830    ;;
2831esac
2832]) # AC_COIN_TRY_FLINK
2833
2834###########################################################################
2835#                             COIN_HAS_BLAS                               #
2836###########################################################################
2837
2838# This macro checks for a library containing the BLAS library.  It
2839# tries standard libraries, and if none is found to be working, it
2840# checks whether the BLAS ThirdParty/Blas directory has been configured.
2841# It adds to ADDLIBS any flags required to link with an externally provided
2842# BLAS.  It defines the makefile conditional and preprocessor macro
2843# COIN_HAS_BLAS, if blas is available, and it defines the makefile conditional
2844# COIN_BUILD_BLAS, if blas is compiled within COIN.
2845
2846AC_DEFUN([AC_COIN_HAS_BLAS],
2847[if test "$PACKAGE_NAME" = ThirdPartyBlas || test "$PACKAGE_NAME" = ThirdPartyLapack || test "$PACKAGE_NAME" = ThirdPartyMumps; then
2848  coin_blasobjdir=../Blas
2849else
2850  coin_blasobjdir=../ThirdParty/Blas
2851fi
2852coin_blassrcdir=$srcdir/$coin_blasobjdir
2853
2854AC_ARG_WITH([blas],
2855            AC_HELP_STRING([--with-blas],
2856                           [specify BLAS library (or BUILD for compilation)]),
2857            [use_blas=$withval], [use_blas=])
2858
2859MAKEOKFILE=.MakeOk
2860# Check if user supplied option makes sense
2861if test x"$use_blas" != x; then
2862  if test "$use_blas" = "BUILD"; then
2863    # Don't check for course code if this is executed in ThirdParty/Blas
2864    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2865      if test -r $coin_blasobjdir/.MakeOk; then :; else
2866        AC_MSG_ERROR([option \"BUILD\" specified for Blas, but $coin_blasobjdir directory is not properly configured])
2867      fi
2868    fi
2869  elif test "$use_blas" != no ; then
2870    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2871    LIBS="$use_blas $LIBS"
2872    ADDLIBS="$use_blas $ADDLIBS"
2873    AC_COIN_TRY_FLINK([daxpy],
2874                      [AC_MSG_RESULT([yes])],
2875                      [AC_MSG_RESULT([no])
2876                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2877  fi
2878else
2879# Try to autodetect the library for blas based on build system
2880  #AC_MSG_CHECKING([default locations for BLAS])
2881  skip_lblas_check=no
2882  case $build in
2883    *-sgi-*)
2884      SAVE_LIBS="$LIBS"
2885      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2886      LIBS="-lcomplib.sgimath $LIBS"
2887      AC_COIN_TRY_FLINK([daxpy],
2888                        [AC_MSG_RESULT([yes])
2889                         use_blas=-lcomplib.sgimath;
2890                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2891                        [AC_MSG_RESULT([no])
2892                         SAVE_LIBS="$LIBS"])
2893      ;;
2894
2895# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
2896# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
2897# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
2898# that CC and cc will understand -library in Studio 13. The main extra
2899# function of -xlic_lib and -library is to arrange for the Fortran run-time
2900# libraries to be linked for C++ and C. We can arrange that explicitly.
2901    *-*-solaris*)
2902      SAVE_LIBS="$LIBS"
2903      AC_MSG_CHECKING([for BLAS in libsunperf])
2904      LIBS="-lsunperf $FLIBS $LIBS"
2905      AC_COIN_TRY_FLINK([daxpy],
2906                        [AC_MSG_RESULT([yes])
2907                         use_blas='-lsunperf'
2908                         ADDLIBS="-lsunperf $ADDLIBS"
2909                         coin_need_flibs=yes],
2910                        [AC_MSG_RESULT([no])
2911                         LIBS="$SAVE_LIBS"])
2912      ;;
2913    *-cygwin* | *-mingw*)
2914# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
2915# library will want to link with cygwin, hence won't run standalone in DOS.
2916      if test "$enable_doscompile" = mingw; then
2917        skip_lblas_check=yes
2918      fi
2919      case "$CC" in
2920        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2921          SAVE_LIBS="$LIBS"
2922          AC_MSG_CHECKING([for BLAS in MKL])
2923          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
2924          AC_COIN_TRY_FLINK([daxpy],
2925                            [AC_MSG_RESULT([yes])
2926                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
2927                             ADDLIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $ADDLIBS"],
2928                            [AC_MSG_RESULT([no])
2929                             LIBS="$SAVE_LIBS"])
2930          ;;
2931      esac
2932      ;;
2933  esac
2934
2935  if test -z "$use_blas" && test $skip_lblas_check = no; then
2936    SAVE_LIBS="$LIBS"
2937    AC_MSG_CHECKING([whether -lblas has BLAS])
2938    LIBS="-lblas $LIBS"
2939    AC_COIN_TRY_FLINK([daxpy],
2940                      [AC_MSG_RESULT([yes])
2941                       ADDLIBS="-lblas $ADDLIBS"
2942                       use_blas='-lblas'],
2943                      [AC_MSG_RESULT([no])
2944                       LIBS="$SAVE_LIBS"])
2945  fi
2946
2947# If we have no other ideas, consider building BLAS.
2948  if test -z "$use_blas"; then
2949    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2950      if test -r $coin_blasobjdir/.MakeOk; then
2951        use_blas=BUILD
2952      fi
2953    fi
2954  fi
2955fi
2956
2957if test "$use_blas" = BUILD; then
2958  coin_need_flibs=yes
2959fi
2960
2961AM_CONDITIONAL([COIN_HAS_BLAS],[test x"$use_blas" != x])
2962AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
2963
2964if test x"$use_blas" = x || test "$use_blas" = no; then
2965  coin_has_blas=no
2966else
2967  coin_has_blas=yes
2968  AC_DEFINE([COIN_HAS_BLAS],[1],
2969            [If defined, the BLAS Library is available.])
2970fi
2971]) # AC_COIN_HAS_BLAS
2972
2973###########################################################################
2974#                            COIN_HAS_LAPACK                              #
2975###########################################################################
2976
2977# This macro checks for a library containing the LAPACK library.  It
2978# tries standard libraries, and if none is found to be working, it
2979# checks whether the LAPACK ThirdParty/Lapack directory has been
2980# configured.  It adds to ADDLIBS any flags required to link with an
2981# externally provided LAPACK.  It defines the makefile conditional and
2982# preprocessor macro COIN_HAS_LAPACK, if lapack is available, and it
2983# defines the makefile conditional COIN_BUILD_LAPACK, if lapack is
2984# compiled within COIN.
2985
2986AC_DEFUN([AC_COIN_HAS_LAPACK],
2987[coin_lapackobjdir=../ThirdParty/Lapack
2988coin_lapacksrcdir=$srcdir/$coin_lapackobjdir
2989
2990AC_ARG_WITH([lapack],
2991            AC_HELP_STRING([--with-lapack],
2992                           [specify LAPACK library (or BUILD for compilation)]),
2993            [use_lapack=$withval], [use_lapack=])
2994
2995# Check if user supplied option makes sense
2996if test x"$use_lapack" != x; then
2997  if test "$use_lapack" = "BUILD"; then
2998    # Don't check for course code if this is executed in ThirdParty/Lapack
2999    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
3000      if test -r $coin_lapackobjdir/.MakeOk; then :; else
3001        AC_MSG_ERROR([option \"BUILD\" specified for LAPACK, but $coin_lapackobjdir directory is not configured])
3002      fi
3003    fi
3004  elif test "$use_lapack" != no; then
3005    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
3006    LIBS="$use_lapack $LIBS"
3007    ADDLIBS="$use_lapack $ADDLIBS"
3008    AC_COIN_TRY_FLINK([dsyev],
3009                      [AC_MSG_RESULT([yes])],
3010                      [AC_MSG_RESULT([no])
3011                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
3012  fi
3013else
3014  if test x$coin_has_blas = xyes; then
3015    # First try to see if LAPACK is already available with BLAS library
3016    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
3017    AC_COIN_TRY_FLINK([dsyev],
3018                      [AC_MSG_RESULT([yes]); use_lapack=ok],
3019                      [AC_MSG_RESULT([no])])
3020  fi
3021  skip_llapack_check=no
3022  if test -z "$use_lapack"; then
3023    # Try to autodetect the library for lapack based on build system
3024    case $build in
3025      *-sgi-*)
3026        SAVE_LIBS="$LIBS"
3027        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
3028        LIBS="-lcomplib.sgimath $LIBS"
3029        AC_COIN_TRY_FLINK([dsyev],
3030                          [AC_MSG_RESULT([yes])
3031                           use_lapack=-lcomplib.sgimath;
3032                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
3033                          [AC_MSG_RESULT([no])
3034                           SAVE_LIBS="$LIBS"])
3035        ;;
3036
3037# See comments in COIN_HAS_BLAS.
3038      *-*-solaris*)
3039      SAVE_LIBS="$LIBS"
3040      AC_MSG_CHECKING([for LAPACK in libsunperf])
3041      LIBS="-lsunperf $FLIBS $LIBS"
3042      AC_COIN_TRY_FLINK([dsyev],
3043                        [AC_MSG_RESULT([yes])
3044                         use_blas='-lsunperf'
3045                         ADDLIBS="-lsunperf $ADDLIBS"
3046                         coin_need_flibs=yes],
3047                        [AC_MSG_RESULT([no])
3048                         LIBS="$SAVE_LIBS"])
3049        ;;
3050# On cygwin, do this check only if doscompile is disabled. The prebuilt library
3051# will want to link with cygwin, hence won't run standalone in DOS.
3052      *-cygwin*)
3053        if test "$enable_doscompile" = mingw; then
3054          skip_llapack_check=yes
3055        fi
3056        ;;
3057    esac
3058  fi
3059
3060  if test -z "$use_lapack" && test $skip_llapack_check = no; then
3061    SAVE_LIBS="$LIBS"
3062    AC_MSG_CHECKING([whether -llapack has LAPACK])
3063    LIBS="-llapack $LIBS"
3064    AC_COIN_TRY_FLINK([dsyev],
3065                      [AC_MSG_RESULT([yes])
3066                       ADDLIBS="-llapack $ADDLIBS"
3067                       use_lapack='-llapack'],
3068                      [AC_MSG_RESULT([no])
3069                       LIBS="$SAVE_LIBS"])
3070  fi
3071
3072# If we have no other ideas, consider building LAPACK.
3073  if test -z "$use_lapack"; then
3074    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
3075      if test -r $coin_lapackobjdir/.MakeOk; then
3076        use_lapack=BUILD
3077      fi
3078    fi
3079  fi
3080fi
3081
3082if test "$use_lapack" = BUILD; then
3083  coin_need_flibs=yes
3084fi
3085
3086AM_CONDITIONAL([COIN_HAS_LAPACK],[test x"$use_lapack" != x])
3087AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
3088
3089if test x"$use_lapack" = x || test "$use_lapack" = no; then
3090  coin_has_lapack=no
3091else
3092  coin_has_lapack=yes
3093  AC_DEFINE([COIN_HAS_LAPACK],[1],
3094            [If defined, the LAPACK Library is available.])
3095fi
3096]) # AC_COIN_HAS_LAPACK
3097
3098###########################################################################
3099#                            COIN_HAS_MUMPS                               #
3100###########################################################################
3101
3102# This macro checks for a library containing the MUMPS library.  It
3103# checks if the user has provided an argument for the MUMPS library,
3104# and if not, it checks whether the MUMPS ThirdParty/Mumps directory has
3105# been configured.  It adds to ADDLIBS any flags required to link with
3106# an externally provided MUMPS.  It defines the makefile conditional
3107# and preprocessor macro COIN_HAS_MUMPS, if MUMPS is available, and it
3108# defines the makefile conditional COIN_BUILD_MUMPS, if MUMPS is
3109# compiled within COIN.
3110
3111AC_DEFUN([AC_COIN_HAS_MUMPS],
3112[
3113if test "$PACKAGE_NAME" = ThirdPartyMumps; then
3114  coin_mumpsobjdir=../Mumps
3115else
3116  coin_mumpsobjdir=../ThirdParty/Mumps
3117fi
3118coin_mumpssrcdir=$abs_source_dir/$coin_mumpsobjdir/MUMPS
3119
3120MAKEOKFILE=.MakeOk
3121
3122#check if user provides a MUMPS library (that works)
3123AC_LANG_PUSH(C)
3124SAVE_ADDLIBS="$ADDLIBS"
3125ADDLIBS="$ADDLIBS $FLIBS"
3126AC_COIN_HAS_USER_LIBRARY(mumps, MUMPS, dmumps_c.h, dmumps_c)
3127ADDLIBS="$SAVE_ADDLIBS"
3128AC_LANG_POP(C)
3129
3130if test "$coin_has_mumps" = "true"; then  # user provided mumps library
3131  use_mumps=yes
3132  coin_has_mumps=yes
3133
3134  MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $MUMPSINCDIR\`"
3135  ADDLIBS="$MUMPSLIB $ADDLIBS"
3136
3137else # no user provided library, so we try to build our own
3138  use_mumps=BUILD
3139
3140  # Check if the MUMPS' ThirdParty project has been configured
3141  if test "$PACKAGE_NAME" != ThirdPartyMumps; then
3142    if test -r $coin_mumpsobjdir/.MakeOk; then
3143      use_mumps=BUILD
3144      # Mumps needs pthreads
3145      AC_LANG_PUSH(C)
3146      save_LIBS="$LIBS"
3147      LIBS="$LIBS $FLIBS"
3148      AC_CHECK_LIB([pthread],[pthread_create],[LIBS="-lpthread $save_LIBS"; ADDLIBS="-lpthread $ADDLIBS"],[LIBS="save_LIBS"])
3149      AC_LANG_POP(C)
3150 
3151      MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $coin_mumpssrcdir/libseq\` -I\`\$(CYGPATH_W) $coin_mumpssrcdir/include\`"
3152    else
3153      use_mumps=
3154    fi
3155  fi
3156
3157  # if a user provided library is used, then COIN_HAS_USER_LIBRARY takes care of the COIN_HAS_MUMPS conditional and preprocessor symbol
3158  AM_CONDITIONAL([COIN_HAS_MUMPS],[test x"$use_mumps" != x])
3159  if test x"$use_mumps" != x; then
3160    AC_DEFINE([COIN_HAS_MUMPS],[1],[If defined, the MUMPS Library is available.])
3161    coin_has_mumps=yes
3162  else
3163    coin_has_mumps=no
3164  fi
3165  AC_MSG_CHECKING([whether MUMPS is available])
3166  AC_MSG_RESULT([$coin_has_mumps])
3167fi
3168
3169if test x"$use_mumps" != x; then
3170  # we need the Fortran runtime libraries if we want to link with C/C++
3171  coin_need_flibs=yes
3172
3173  AC_SUBST(MUMPS_INCFLAGS)
3174fi
3175
3176AM_CONDITIONAL([COIN_BUILD_MUMPS],[test "$use_mumps" = BUILD])
3177
3178]) # AC_COIN_HAS_MUMPS
3179
3180###########################################################################
3181#                            COIN_HAS_METIS                               #
3182###########################################################################
3183
3184# This macro checks for a library containing the METIS library.  It
3185# checks if the user has provided an argument for the METIS library,
3186# and if not, it checks whether the METIS ThirdParty/Metis directory has
3187# been configured.  It adds to ADDLIBS any flags required to link with
3188# an externally provided METIS.  It defines the makefile conditional
3189# and preprocessor macro COIN_HAS_METIS, if METIS is available, and it
3190# defines the makefile conditional COIN_BUILD_METIS, if METIS is
3191# compiled within COIN.
3192
3193AC_DEFUN([AC_COIN_HAS_METIS],
3194[
3195case "$PACKAGE_NAME" in
3196  ThirdParty*)
3197    coin_metisobjdir=../Metis
3198    ;;
3199  *)
3200    coin_metisobjdir=../ThirdParty/Metis
3201    ;;
3202esac
3203
3204MAKEOKFILE=.MakeOk
3205
3206#check if user provides a METIS library (that works)
3207AC_LANG_PUSH(C)
3208AC_ARG_WITH(metis,
3209   AS_HELP_STRING([--with-metis], [specify flags to link with METIS library]),
3210   [METISLIB="$withval"; coin_has_metis=true], [coin_has_metis=no])
3211
3212if test $coin_has_metis = true; then
3213  coin_save_LIBS="$LIBS"
3214  LIBS="$METISLIB $ADDLIBS"
3215  AC_MSG_CHECKING([whether symbol metis_nodend is available with ])
3216  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[metis_nodend()]])],
3217     [AC_MSG_RESULT(yes)],
3218     [AC_MSG_RESULT(no)
3219      AC_MSG_ERROR([User-supplied METIS library does not work])])
3220  LIBS="$coin_save_LIBS"
3221fi
3222AC_LANG_POP(C)
3223
3224if test "$coin_has_metis" = "true"; then  # user provided metis library
3225  use_metis=yes
3226  coin_has_metis=yes
3227
3228  ADDLIBS="$METISLIB $ADDLIBS"
3229
3230else # no user provided library, so we try to build our own
3231  use_metis=BUILD
3232
3233  # Check if the METIS' ThirdParty project has been configured
3234  if test "$PACKAGE_NAME" != ThirdPartyMetis; then
3235    if test -r $coin_metisobjdir/.MakeOk; then
3236      use_metis=BUILD
3237    else
3238      use_metis=
3239    fi
3240  fi
3241
3242  if test x"$use_metis" != x; then
3243    coin_has_metis=yes
3244  else
3245    coin_has_metis=no
3246  fi
3247  AC_MSG_CHECKING([whether METIS is available])
3248  AC_MSG_RESULT([$coin_has_metis])
3249fi
3250
3251AM_CONDITIONAL([COIN_HAS_METIS],[test $coin_has_metis = yes])
3252if test $coin_has_metis = yes; then
3253  AC_DEFINE([COIN_HAS_METIS],[1],[If defined, the METIS library is available.])
3254fi
3255
3256]) # AC_COIN_HAS_METIS
3257
3258
3259###########################################################################
3260#                             COIN_HAS_GLPK                               #
3261###########################################################################
3262#
3263# This macro checks for the GLPK package. GLPK provides two capabilities,
3264# an LP and MIP solver (GLPK) and the GNU Mathprog modelling language (GMPL).
3265# The macro checks for either Glpk or Gmpl, according to the value specified as
3266# the parameter. Use one of Glpk or Gmpl. Use *exactly* these strings, eh?
3267#
3268#
3269# The macro first uses COIN_HAS_USER_LIBRARY to see if the user has specified
3270# a preexisting library (this allows the use of any glpk version, if the user
3271# is fussy). The macro then checks for ThirdParty/Glpk.
3272#
3273# This macro will define the following variables for Glpk:
3274#   coin_has_glpk       true or false
3275#   GLPKLIB             link flags for GLPK (if user supplied)
3276#   GLPKINCDIR          location of glpk include files
3277#   COIN_HAS_GLPK       Preprocessor symbol, defined to 1
3278#   COIN_HAS_GLPK       Automake conditional
3279#   COIN_BUILD_GLPK     Automake conditional, defined only if Glpk is to be
3280#                       built in ThirdParty/Glpk
3281#
3282# With the exception of COIN_BUILD_GLPK, an identical set of variables is
3283# defined for Gmpl.
3284
3285AC_DEFUN([AC_COIN_HAS_GLPK],
3286[
3287if test "$PACKAGE_NAME" = ThirdPartyGlpk; then
3288  coin_glpkobjdir=../Glpk
3289else
3290  coin_glpkobjdir=../ThirdParty/Glpk
3291fi
3292coin_glpksrcdir=$abs_source_dir/$coin_glpkobjdir
3293
3294use_thirdpartyglpk=no
3295
3296# Check for the requested component. If the user specified an external glpk
3297# library don't force a ThirdParty build, let the error propagate.
3298
3299m4_if([$1],[Glpk],
3300[AC_COIN_HAS_USER_LIBRARY([Glpk],[GLPK],[glpk.h],
3301    [_glp_lpx_simplex glp_lpx_simplex])
3302 if test x"$coin_has_glpk" = xfalse && test x"$GLPKLIB" = x ; then
3303   use_thirdpartyglpk=try
3304 fi])
3305m4_if([$1],[Gmpl],
3306[AC_COIN_HAS_USER_LIBRARY([Gmpl],[GMPL],[glpmpl.h],
3307    [_glp_mpl_initialize glp_mpl_initialize])
3308 if test x"$coin_has_gmpl" = xfalse && test x"$GMPLLIB" = x ; then
3309   use_thirdpartyglpk=try
3310 fi])
3311
3312# If the user has supplied an external library, use it. Otherwise, consider
3313# a build in ThirdParty/Glpk. If we build, assume we get both glpk and gmpl.
3314
3315if test x"$use_thirdpartyglpk" = xtry ; then
3316  MAKEOKFILE=.MakeOk
3317  # Check if the Glpk's ThirdParty project has been configured
3318  if test "$PACKAGE_NAME" != ThirdPartyGlpk; then
3319    if test -r $coin_glpkobjdir/.MakeOk; then
3320      use_thirdpartyglpk=build
3321    else
3322      use_thirdpartyglpk=no
3323    fi
3324  else
3325    use_thirdpartyglpk=build
3326  fi
3327
3328# If we're building, set the library and include directory variables, create a
3329# preprocessor symbol, define a variable that says we're using glpk/gmpl, and
3330# another to indicate a link check is a bad idea (hard to do before the library
3331# exists).
3332
3333  if test x"$use_thirdpartyglpk" = xbuild ; then
3334    m4_toupper($1INCDIR)="$coin_glpksrcdir/glpk/include"
3335    AC_SUBST(m4_toupper($1INCDIR))
3336    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],
3337              [Define to 1 if $1 package is available])
3338    m4_tolower(coin_has_$1)=true
3339    m4_tolower($1_libcheck)=no
3340    m4_toupper($1OBJDIR)=`cd $coin_glpkobjdir; pwd`
3341    AC_SUBST(m4_toupper($1OBJDIR))
3342    AC_MSG_NOTICE([Using $1 in ThirdParty/Glpk])
3343  fi
3344fi
3345
3346# Define the necessary automake conditionals.
3347
3348AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3349               [test x"$m4_tolower(coin_has_$1)" = xtrue])
3350AM_CONDITIONAL([COIN_BUILD_GLPK],[test x"$use_thirdpartyglpk" = xbuild])
3351
3352]) # AC_COIN_HAS_GLPK
Note: See TracBrowser for help on using the repository browser.