source: trunk/coin.m4 @ 1877

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

in fallback mode, setup CFLAGS/LIBS_INSTALLED variables from parsing xxx.pc files that can be used to create addlibs files and examples Makefiles; change parsing of .pc files so that variables can be used inside .pc files; add automake conditional that says whether C++ compile is cl/icl

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