source: stable/0.6/coin.m4 @ 2327

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

merge chgsets 2288 and 2291 from trunk

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