source: stable/0.6/coin.m4 @ 1697

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

rename some COIN_HAS macros to COIN_CHECK; remove old _MODULE_ macros; mark some old macros as deprecated

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