source: trunk/coin.m4 @ 1547

Last change on this file since 1547 was 1547, checked in by stefan, 11 years ago

directory may not yet exists if it is configured after the current project

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