source: stable/0.6/coin.m4 @ 2037

Last change on this file since 2037 was 2037, checked in by stefan, 9 years ago

merge fix for X_DEPENDENCIES setup from trunk chgset 2036

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