source: trunk/coin.m4 @ 440

Last change on this file since 440 was 440, checked in by andreasw, 12 years ago

fixing include directory definition for MUMPS in case user wants to user precompile MUMPS

  • Property svn:keywords set to Author Date Id Revision
File size: 104.0 KB
Line 
1# Copyright (C) 2006, 2007 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Common Public License.
4#
5## $Id: coin.m4 440 2007-08-01 23:49:26Z andreasw $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_PREREQ(2.59)
14
15###########################################################################
16#                           COIN_MAIN_SUBDIRS                             #
17###########################################################################
18
19# This macro sets up the recursion into configure scripts into
20# subdirectories.  Each possible subdirectory should be provided as a
21# new argument to this macro.  The current limit is 10 subdirectories.
22# This automatically also checks for the Data subdirectory.
23
24AC_DEFUN([AC_COIN_MAIN_SUBDIRS],
25[AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
26
27m4_ifvaln([$1],[AC_MSG_CHECKING(whether directory $1 is available)
28                coin_skip=no
29                if test x"$COIN_SKIP_PROJECTS" != x; then
30                  for dir in $COIN_SKIP_PROJECTS; do
31                    if test $dir = $1; then
32                      coin_skip=yes
33                    fi
34                  done
35                fi
36                if test $coin_skip = yes; then
37                  AC_MSG_RESULT(skipping)
38                elif test -r $srcdir/$1/configure; then
39                  coin_subdirs="$coin_subdirs $1"
40                  AC_MSG_RESULT(yes)
41                  AC_CONFIG_SUBDIRS($1)
42                else
43                  AC_MSG_RESULT(no)
44                fi])
45m4_ifvaln([$2],[AC_MSG_CHECKING(whether directory $2 is available)
46                coin_skip=no
47                if test x"$COIN_SKIP_PROJECTS" != x; then
48                  for dir in $COIN_SKIP_PROJECTS; do
49                    if test $dir = $2; then
50                      coin_skip=yes
51                    fi
52                  done
53                fi
54                if test $coin_skip = yes; then
55                  AC_MSG_RESULT(skipping)
56                elif test -r $srcdir/$2/configure; then
57                  coin_subdirs="$coin_subdirs $2"
58                  AC_MSG_RESULT(yes)
59                  AC_CONFIG_SUBDIRS($2)
60                else
61                  AC_MSG_RESULT(no)
62                fi])
63m4_ifvaln([$3],[AC_MSG_CHECKING(whether directory $3 is available)
64                coin_skip=no
65                if test x"$COIN_SKIP_PROJECTS" != x; then
66                  for dir in $COIN_SKIP_PROJECTS; do
67                    if test $dir = $3; then
68                      coin_skip=yes
69                    fi
70                  done
71                fi
72                if test $coin_skip = yes; then
73                  AC_MSG_RESULT(skipping)
74                elif test -r $srcdir/$3/configure; then
75                  coin_subdirs="$coin_subdirs $3"
76                  AC_MSG_RESULT(yes)
77                  AC_CONFIG_SUBDIRS($3)
78                else
79                  AC_MSG_RESULT(no)
80                fi])
81m4_ifvaln([$4],[AC_MSG_CHECKING(whether directory $4 is available)
82                coin_skip=no
83                if test x"$COIN_SKIP_PROJECTS" != x; then
84                  for dir in $COIN_SKIP_PROJECTS; do
85                    if test $dir = $4; then
86                      coin_skip=yes
87                    fi
88                  done
89                fi
90                if test $coin_skip = yes; then
91                  AC_MSG_RESULT(skipping)
92                elif test -r $srcdir/$4/configure; then
93                  coin_subdirs="$coin_subdirs $4"
94                  AC_MSG_RESULT(yes)
95                  AC_CONFIG_SUBDIRS($4)
96                else
97                  AC_MSG_RESULT(no)
98                fi])
99m4_ifvaln([$5],[AC_MSG_CHECKING(whether directory $5 is available)
100                coin_skip=no
101                if test x"$COIN_SKIP_PROJECTS" != x; then
102                  for dir in $COIN_SKIP_PROJECTS; do
103                    if test $dir = $5; then
104                      coin_skip=yes
105                    fi
106                  done
107                fi
108                if test $coin_skip = yes; then
109                  AC_MSG_RESULT(skipping)
110                elif test -r $srcdir/$5/configure; then
111                  coin_subdirs="$coin_subdirs $5"
112                  AC_MSG_RESULT(yes)
113                  AC_CONFIG_SUBDIRS($5)
114                else
115                  AC_MSG_RESULT(no)
116                fi])
117m4_ifvaln([$6],[AC_MSG_CHECKING(whether directory $6 is available)
118                coin_skip=no
119                if test x"$COIN_SKIP_PROJECTS" != x; then
120                  for dir in $COIN_SKIP_PROJECTS; do
121                    if test $dir = $6; then
122                      coin_skip=yes
123                    fi
124                  done
125                fi
126                if test $coin_skip = yes; then
127                  AC_MSG_RESULT(skipping)
128                elif test -r $srcdir/$6/configure; then
129                  coin_subdirs="$coin_subdirs $6"
130                  AC_MSG_RESULT(yes)
131                  AC_CONFIG_SUBDIRS($6)
132                else
133                  AC_MSG_RESULT(no)
134                fi])
135m4_ifvaln([$7],[AC_MSG_CHECKING(whether directory $7 is available)
136                coin_skip=no
137                if test x"$COIN_SKIP_PROJECTS" != x; then
138                  for dir in $COIN_SKIP_PROJECTS; do
139                    if test $dir = $7; then
140                      coin_skip=yes
141                    fi
142                  done
143                fi
144                if test $coin_skip = yes; then
145                  AC_MSG_RESULT(skipping)
146                elif test -r $srcdir/$7/configure; then
147                  coin_subdirs="$coin_subdirs $7"
148                  AC_MSG_RESULT(yes)
149                  AC_CONFIG_SUBDIRS($7)
150                else
151                  AC_MSG_RESULT(no)
152                fi])
153m4_ifvaln([$8],[AC_MSG_CHECKING(whether directory $8 is available)
154                coin_skip=no
155                if test x"$COIN_SKIP_PROJECTS" != x; then
156                  for dir in $COIN_SKIP_PROJECTS; do
157                    if test $dir = $8; then
158                      coin_skip=yes
159                    fi
160                  done
161                fi
162                if test $coin_skip = yes; then
163                  AC_MSG_RESULT(skipping)
164                elif test -r $srcdir/$8/configure; then
165                  coin_subdirs="$coin_subdirs $8"
166                  AC_MSG_RESULT(yes)
167                  AC_CONFIG_SUBDIRS($8)
168                else
169                  AC_MSG_RESULT(no)
170                fi])
171m4_ifvaln([$9],[AC_MSG_CHECKING(whether directory $9 is available)
172                coin_skip=no
173                if test x"$COIN_SKIP_PROJECTS" != x; then
174                  for dir in $COIN_SKIP_PROJECTS; do
175                    if test $dir = $9; then
176                      coin_skip=yes
177                    fi
178                  done
179                fi
180                if test $coin_skip = yes; then
181                  AC_MSG_RESULT(skipping)
182                elif test -r $srcdir/$9/configure; then
183                  coin_subdirs="$coin_subdirs $9"
184                  AC_MSG_RESULT(yes)
185                  AC_CONFIG_SUBDIRS($9)
186                else
187                  AC_MSG_RESULT(no)
188                fi])
189m4_ifvaln([$10],[AC_MSG_CHECKING(whether directory $10 is available)
190                coin_skip=no
191                if test x"$COIN_SKIP_PROJECTS" != x; then
192                  for dir in $COIN_SKIP_PROJECTS; do
193                    if test $dir = $10; then
194                      coin_skip=yes
195                    fi
196                  done
197                fi
198                if test $coin_skip = yes; then
199                  AC_MSG_RESULT(skipping)
200                elif test -r $srcdir/$10/configure; then
201                  coin_subdirs="$coin_subdirs $10"
202                  AC_MSG_RESULT(yes)
203                  AC_CONFIG_SUBDIRS($10)
204                else
205                  AC_MSG_RESULT(no)
206                fi])
207]) # AC_COIN_MAIN_SUBDIRS
208
209###########################################################################
210#                            COIN_CHECK_FILE                              #
211###########################################################################
212
213# A simple replacement for AC_CHECK_FILE that works for cross compilation
214
215AC_DEFUN([AC_COIN_CHECK_FILE],
216[if test -r $1; then
217  $2
218  :
219else
220  $3
221  :
222fi
223])
224
225###########################################################################
226#                        COIN_THIRDPARTY_SUBDIRS                          #
227###########################################################################
228
229# This macro sets up the recursion into the configure script in a
230# subdirectory for compilation of third party code.  The first
231# argument is just the string that appears in the configure output.
232# The second argument is the directory with the configure script, and
233# the third one is a file that should exists in that directory.  If
234# this file does not exist, we assume that the user has not downloaded
235# the code, and we are not going to compile it
236
237AC_DEFUN([AC_COIN_THIRDPARTY_SUBDIRS],
238[AC_MSG_CHECKING(whether code for third party package $1 is available)
239coin_skip=no
240if test x"$COIN_SKIP_PROJECTS" != x; then
241  for dir in $COIN_SKIP_PROJECTS; do
242    if test $dir = $2; then
243      coin_skip=yes
244    fi
245  done
246fi
247if test $coin_skip = yes; then
248  AC_MSG_RESULT(skipping)
249else
250  coin_tmp=`echo $srcdir/$2/$3`
251  # There is probably a more elegant way to get the first thing out here...
252  for i in $coin_tmp; do
253    coin_tmp2=$i
254    #break 1
255  done
256  if test -r $coin_tmp2; then
257    coin_subdirs="$coin_subdirs $2"
258    AC_MSG_RESULT(yes)
259    AC_CONFIG_SUBDIRS($2)
260  else
261    AC_MSG_RESULT(no)
262  fi
263fi
264]) # AC_COIN_THIRDPARTY_SUBDIRS
265
266###########################################################################
267#                           COIN_CHECK_VPATH                              #
268###########################################################################
269
270# This macro sets the variable coin_vpath_config to true if this is a
271# VPATH configuration, otherwise it sets it to false.
272AC_DEFUN([AC_COIN_CHECK_VPATH],
273[AC_MSG_CHECKING(whether this is a VPATH configuration)
274if test `cd $srcdir; pwd` != `pwd`; then
275  coin_vpath_config=yes;
276else
277  coin_vpath_config=no;
278fi
279AC_MSG_RESULT($coin_vpath_config)
280]) # AC_COIN_CHECK_VPATH
281
282###########################################################################
283#                         COIN_PROJECTDIR_INIT                            #
284###########################################################################
285
286# This macro does everything that is required in the early part in the
287# configure script, such as defining a few variables.  This should only
288# be used in the main directory of a project directory (the one under
289# which src is)
290
291AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
292[# Initialize the ADDLIBS variable
293ADDLIBS="-lm $LIBS"
294AC_SUBST(ADDLIBS)
295
296# Initialize the FADDLIBS variable (which is to be used with a fortran
297# compiler and will not include FLIBS)
298FADDLIBS="$LIBS"
299AC_SUBST(FADDLIBS)
300
301# A useful makefile conditional that is always false
302AM_CONDITIONAL(ALWAYS_FALSE, false)
303
304# We set the following variable so that we know later in AC_COIN_FINALIZE
305# that we are in a project main directory
306coin_projectdir=yes
307]) # AC_COIN_PROJECTDIR_INIT
308
309###########################################################################
310#                          COIN_DEBUG_COMPILE                             #
311###########################################################################
312
313# enable the configure flags --enable-debug and --enable-debug-prjct
314# (where prcjt is the name of the project in lower case) and set the
315# variable coin_debug_compile to true or false This is used by
316# COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77 to determine the
317# compilation flags.  This macro also makes the switches
318# --with-prjct-verbosity and --with-prjct-checklevel available, which
319# define the preprocessor macros COIN_PRJCT_VERBOSITY and
320# COIN_PRJCT_CHECKLEVEL to the specified value (default is 0).
321#
322# The project specific flags are only made available, if one gives the
323# name of the project as first argument to this macro.
324
325AC_DEFUN([AC_COIN_DEBUG_COMPILE],
326[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
327AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
328AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
329
330AC_MSG_CHECKING([whether we want to compile in debug mode])
331
332AC_ARG_ENABLE([debug],
333[AC_HELP_STRING([--enable-debug],
334                [compile all projects with debug options tests])],
335[case "${enableval}" in
336   yes) coin_debug_compile=true
337        if test "${enable_shared+set}" = set; then :; else
338          enable_shared=no
339        fi
340        ;;
341   no)  coin_debug_compile=false
342        ;;
343   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
344        ;;
345esac],
346[coin_debug_compile=false])
347
348m4_ifvaln([$1],
349[AC_ARG_ENABLE(debug-m4_tolower($1),
350 [AC_HELP_STRING([--enable-debug-m4_tolower($1)],
351                 [compile this project ($1) with debug options])],
352 [case "${enableval}" in
353    yes) coin_debug_compile=true
354         enable_shared=no
355         ;;
356    no)  coin_debug_compile=false
357         ;;
358    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
359         ;;
360 esac],[:])
361]) # m4_ifvaln([$1],
362
363if test $coin_debug_compile = true; then
364  AC_MSG_RESULT([yes])
365else
366  AC_MSG_RESULT([no])
367fi
368
369m4_ifvaln([$1],
370[AC_ARG_WITH(m4_tolower($1)-verbosity,
371             AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
372                            [specify the debug verbosity level for project $1]),
373             [if test "$withval" = yes; then
374                withval=1
375              fi
376              m4_tolower(coin_$1_verbosity)=$withval],
377             [m4_tolower(coin_$1_verbosity)=0])
378 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
379                    m4_tolower($coin_$1_verbosity),
380                    [Define to the debug verbosity level (0 is no output)])
381
382 AC_ARG_WITH(m4_tolower($1)-checklevel,
383             AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
384                            [specify the sanity check level for project $1]),
385             [if test "$withval" = yes; then
386                withval=1
387              fi
388              m4_tolower(coin_$1_checklevel)=$withval],
389             [m4_tolower(coin_$1_checklevel)=0])
390 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
391                    m4_tolower($coin_$1_checklevel),
392                    [Define to the debug sanity check level (0 is no test)])
393
394# We use the following variable to have a string with the upper case
395# version of the project name
396COIN_PRJCT=m4_toupper($1)
397
398]) # m4_ifvaln([$1],
399 
400]) # AC_COIN_DEBUG_COMPILE
401
402###########################################################################
403#                          COIN_MINGW_LD_FIX                              #
404###########################################################################
405
406# This macro is included by any PROG_compiler macro, to set the LD
407# environment variable on MinGW to the correct value (link). But note that
408# if we're building in cygwin with -mno-cygwin, we still want ld! If we're
409# building from cygwin with MSVC tools (cl/link), then we do want link and
410# you'd better have your PATH variable straight, else you'll be doing file
411# links instead of code links! Arguably, LDFLAGS should include -mno-cygwin
412# but in practice all linking seems to be handled through the compilers, so
413# CFLAGS and CXXFLAGS suffice.
414
415AC_DEFUN([AC_COIN_MINGW_LD_FIX],
416[case $build in
417  *-mingw*)
418    if test "${LD+set}" = set; then :; else
419      LD=link
420    fi
421    ;;
422 esac
423 case $enable_doscompile in
424   msvc)
425     if test "x${LD+set}" = xset; then :; else
426       LD=link
427     fi
428     ;;
429 esac
430])
431
432###########################################################################
433#                        COIN_ENABLE_DOSCOMPILE                           #
434###########################################################################
435
436# This macro is invoked by any PROG_compiler macro to establish the
437# --enable-doscompile option, used when one wants to compile an executable
438# under Cygwin which also runs directly under DOS (without requiring
439# Cygwin1.dll). The job of this macro is to make sure the option is correct and
440# to set enable_doscompile. Legal values are mingw, msvc, and no (disabled).
441# mingw: Fake mingw under cygwin, using GCC tools and -mno-cygwin. The most
442#        important thing here is that preprocess, compile, and link steps
443#        *all* see -mno-cygwin.
444# msvc:  Assume the presence of cl/link. It's the user's responsibility to
445#        make sure their PATH is correct. In particular, that MSVC link is
446#        found and not cygwin link (we want to do code linking, not file
447#        linking).
448# It's the responsibility of individual PROG_compiler macros to ensure that
449# they correctly set the compiler search list and preprocess, compile, and
450# link flags. This is tied to compiler setup because in practice invocations
451# of the preprocessor and linker are made through the compiler.
452
453AC_DEFUN([AC_COIN_ENABLE_DOSCOMPILE],
454[AC_REQUIRE([AC_CANONICAL_BUILD])
455 AC_ARG_ENABLE([doscompile],
456  [AC_HELP_STRING([--enable-doscompile],
457                  [Under Cygwin, compile so that executables run under DOS.
458                   Set to mingw to use gcc/g++/ld with -mno-cygwin.
459                   Set to msvc to use cl/link.
460                   Default when mentioned: mingw.
461                   Default when not mentioned: disabled.])],
462  [if test "$enable_doscompile" != no; then
463     case $build in
464       *-cygwin*) ;;
465       *) AC_MSG_ERROR([--enable-doscompile option makes sense only under Cygwin]) ;;
466     esac
467   fi],
468  [enable_doscompile=no])
469 case "$enable_doscompile" in
470   msvc|mingw|no) ;;
471   yes) enable_doscompile=mingw ;;
472   *) AC_MSG_ERROR([Invalid value $enable_doscompile for --enable-doscompile.
473                    Try configure --help=recursive.])
474      ;;
475  esac
476  if test "$enable_doscompile" != no ; then
477    AC_MSG_NOTICE([DOS compile style is: $enable_doscompile])
478  fi
479])
480
481###########################################################################
482#                             COIN_PROG_CXX                               #
483###########################################################################
484
485# Find the compile command by running AC_PROG_CXX (with compiler names for
486# different operating systems) and put it into CXX (unless it was given by the
487# user). Then find an appropriate value for CXXFLAGS. If either of CXXFLAGS or
488# PRJCT_CXXFLAGS is defined, that value is used (replace PRJCT with the upper
489# case name of this project).  It is possible to provide additional -D flags
490# in the variable CXXDEFS, and additional compilation flags with ADD_CXXFLAGS.
491
492AC_DEFUN([AC_COIN_PROG_CXX],
493[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
494AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
495AC_LANG_PUSH(C++)
496
497AC_ARG_VAR(CXXDEFS,[Additional -D flags to be used when compiling C++ code.])
498AC_ARG_VAR(ADD_CXXFLAGS,[Additional C++ compiler options])
499AC_ARG_VAR(DBG_CXXFLAGS,[Debug C++ compiler options])
500AC_ARG_VAR(OPT_CXXFLAGS,[Optimize C++ compiler options])
501
502coin_has_cxx=yes
503
504save_cxxflags="$CXXFLAGS"
505# For sparc-sun-solaris, promote Studio/Workshop compiler to front of list.
506case $build in
507  *-cygwin* | *-mingw*)
508             if test "$enable_doscompile" = msvc ; then
509               comps="cl"
510             else
511               comps="g++ cl"
512             fi ;;
513  sparc-sun-solaris*)
514             comps="CC xlC aCC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
515  *-darwin*) comps="g++ c++ CC" ;;
516          *) comps="xlC aCC CC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
517esac
518
519# We delete the cached value, since the test might not have been
520# performed with our choice of compilers earlier
521$as_unset ac_cv_prog_CXX || test "${ac_cv_prog_CXX+set}" != set || { ac_cv_prog_CXX=; export ac_cv_prog_CXX; }
522# AC_MSG_NOTICE([C++ compiler candidates: $comps])
523AC_PROG_CXX([$comps])
524if test -z "$CXX" ; then
525  AC_MSG_ERROR([Failed to find a C++ compiler!])
526fi
527
528# It seems that we need to cleanup something here for the Windows
529case "$CXX" in
530  cl* | */cl* | CL* | */CL* )
531    sed -e 's/^void exit (int);//' confdefs.h >> confdefs.hh
532    mv confdefs.hh confdefs.h
533    ;;
534esac
535
536# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
537case "$CXX" in
538  cl* | */cl* | CL* | */CL* )
539    if test "$ac_cv_prog_cxx_g" = yes ; then
540      ac_cv_prog_cxx_g=no
541      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
542    fi ;;
543esac
544CXXFLAGS="$save_cxxflags"
545
546# Check if a project specific CXXFLAGS variable has been set
547if test x$COIN_PRJCT != x; then
548  eval coin_tmp=\${${COIN_PRJCT}_CXXFLAGS+set}
549  if test x$coin_tmp = xset; then
550    eval CXXFLAGS=\${${COIN_PRJCT}_CXXFLAGS}
551  fi
552fi
553
554if test x"$CXXFLAGS" = x; then
555
556# ToDo decide whether we want -DNDEBUG for optimization
557  coin_add_cxxflags=
558  coin_opt_cxxflags=
559  coin_dbg_cxxflags=
560  coin_warn_cxxflags=
561
562  if test "$GXX" = "yes"; then
563    case "$CXX" in
564      icpc* | */icpc*)
565        ;;
566      *)
567# ToDo decide about unroll-loops
568        coin_opt_cxxflags="-O3 -fomit-frame-pointer"
569        coin_add_cxxflags="-pipe"
570        coin_dbg_cxxflags="-g"
571        coin_warn_cxxflags="-pedantic-errors -Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion"
572        case $enable_doscompile in
573          mingw)
574            CXXFLAGS="-mno-cygwin"
575            AC_TRY_LINK(,[int i=0; i++;],
576                        [coin_add_cxxflags="-mno-cygwin $coin_add_cxxflags"])
577            CXXFLAGS=
578            ;;
579        esac
580    esac
581  fi
582
583# Note that we do not need to cover GCC in the following tests.
584
585  if test -z "$coin_opt_cxxflags"; then
586    case $build in
587      *-cygwin* | *-mingw*)
588        case "$CXX" in
589          cl* | */cl* | CL* | */CL*)
590            # The MT and MTd options are mutually exclusive
591            coin_opt_cxxflags='-MT -O2'
592            coin_add_cxxflags='-nologo -EHsc -GR -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
593            coin_dbg_cxxflags='-MTd'
594            ;;
595        esac
596        ;;
597      *-linux-*)
598        case "$CXX" in
599          icpc* | */icpc*)
600            coin_opt_cxxflags="-O3 -ip"
601            coin_add_cxxflags=""
602            coin_dbg_cxxflags="-g"
603            # Check if -i_dynamic is necessary (for new glibc library)
604            CXXFLAGS=
605            AC_TRY_LINK(,[int i=0; i++;],[],
606                        [coin_add_cxxflags="-i_dynamic $coin_add_cxxflags"])
607            ;;
608          pgCC* | */pgCC*)
609            coin_opt_cxxflags="-fast"
610            coin_add_cxxflags="-Kieee -pc 64"
611            coin_dbg_cxxflags="-g"
612            ;;
613        esac
614        ;;
615      *-ibm-*)
616        case "$CXX" in
617          xlC* | */xlC* | mpxlC* | */mpxlC*)
618            coin_opt_cxxflags="-O3 -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
619            coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna"
620            coin_dbg_cxxflags="-g"
621            ;;
622        esac
623        ;;
624      *-hp-*)
625        case "$CXX" in
626          aCC* | */aCC* )
627            coin_opt_cxxflags="-O"
628            coin_add_cxxflags="-AA"
629            coin_dbg_cxxflags="-g"
630            ;;
631        esac
632        ;;
633      *-sun-*)
634          coin_opt_cxxflags="-O4"
635          coin_dbg_cxxflags="-g"
636        ;;
637    esac
638  fi
639
640# Generic flag settings. If these don't work, add a case above.
641
642  if test "$ac_cv_prog_cxx_g" = yes && test -z "$coin_dbg_cxxflags" ; then
643    coin_dbg_cxxflags="-g"
644  fi
645
646  if test -z "$coin_opt_cxxflags"; then
647    # Try if -O option works if nothing else is set
648    CXXFLAGS=-O
649    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cxxflags="-O"])
650  fi
651
652  # if PM doesn't want the warning messages, take them out
653  if test x"$coin_skip_warn_cxxflags" = xyes; then
654    coin_warn_cxxflags=
655  fi
656
657# Do final setup of flags based on values determined above.
658
659  if test x${DBG_CXXFLAGS+set} != xset; then
660    DBG_CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
661  fi
662  if test x${OPT_CXXFLAGS+set} != xset; then
663    OPT_CXXFLAGS="$coin_opt_cxxflags $coin_add_cxxflags -DNDEBUG $coin_warn_cxxflags"
664  fi
665
666  DBG_CXXFLAGS="$DBG_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
667  OPT_CXXFLAGS="$OPT_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
668
669  if test "$coin_debug_compile" = "true"; then
670    CXXFLAGS="$DBG_CXXFLAGS"
671  else
672    CXXFLAGS="$OPT_CXXFLAGS"
673  fi
674
675# Handle the case where CXXFLAGS was set externally.
676else
677  CXXFLAGS="$CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
678  if test x${DBG_CXXFLAGS+set} != xset; then
679    DBG_CXXFLAGS="$CXXFLAGS"
680  fi
681  if test x${OPT_CXXFLAGS+set} != xset; then
682    OPT_CXXFLAGS="$CXXFLAGS"
683  fi
684fi
685
686# If CXXFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
687
688case "$CXXFLAGS" in
689  *-mno-cygwin*)
690    if test x${CPPFLAGS+set} != xset ; then
691      CPPFLAGS="-mno-cygwin"
692    else
693      case "$CPPFLAGS" in
694        *-mno-cygwin*)
695          ;;
696        *)
697          CPPFLAGS="$CPPFLAGS -mno-cygwin"
698          ;;
699      esac
700    fi ;;
701esac
702
703# Try if CXXFLAGS works
704save_CXXFLAGS="$CXXFLAGS"
705AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
706if test -z "$CXXFLAGS"; then
707  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.])
708  CXXFLAGS='-O'
709  AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
710  if test -z "$CXXFLAGS"; then
711    AC_MSG_WARN([This value for CXXFLAGS does not work.  I will continue with empty CXXFLAGS, but you might want to set CXXFLAGS manually.])
712  fi
713fi
714
715AC_MSG_NOTICE([C++ compiler options are: $CXXFLAGS])
716
717AC_ARG_VAR(MPICXX,[C++ MPI Compiler])
718if test x"$MPICXX" = x; then :; else
719  AC_MSG_NOTICE([Will use MPI C++ compiler $MPICXX])
720  CXX="$MPICXX"
721fi
722
723case "$CXX" in
724  cl* | */cl* | CL* | */CL* )
725    AC_COIN_MINGW_LD_FIX
726    ;;
727esac
728
729AC_LANG_POP(C++)
730]) # AC_COIN_PROG_CXX
731
732
733###########################################################################
734#                             COIN_CXXLIBS                                #
735###########################################################################
736
737# Determine the C++ runtime libraries required for linking a C++ library
738# with a Fortran or C compiler.  The result is available in CXXLIBS.
739
740AC_DEFUN([AC_COIN_CXXLIBS],
741[AC_REQUIRE([AC_PROG_CXX])dnl
742AC_LANG_PUSH(C++)
743AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with Fortran compiler])
744if test -z "$CXXLIBS"; then
745  if test "$GXX" = "yes"; then
746    case "$CXX" in
747      icpc* | */icpc*)
748        CXXLIBS=""
749        ;;
750      *)
751        CXXLIBS="-lstdc++ -lm" # -lgcc"
752        ;;
753    esac
754  else
755    case $build in
756     *-mingw32 | *-cygwin* )
757      case "$CXX" in
758      cl* | */cl* | CL* | */CL*)
759        CXXLIBS=nothing;;
760      esac;;
761     *-linux-*)
762      case "$CXX" in
763      icpc* | */icpc*)
764        CXXLIBS=""
765             ;;
766      pgCC* | */pgCC*)
767        CXXLIBS="-lstd -lC -lc"
768             ;;
769      esac;;
770    *-ibm-*)
771      CXXLIBS="-lC -lc"
772      ;;
773    *-hp-*)
774      CXXLIBS="-L/opt/aCC/lib -l++ -lstd_v2 -lCsup_v2 -lm -lcl -lc"
775      ;;
776    *-sun-*)
777      CXXLIBS="-lCstd -lCrun"
778    esac
779  fi
780fi
781if test -z "$CXXLIBS"; then
782  AC_MSG_WARN([Could not automatically determine CXXLIBS (C++ link libraries; necessary if main program is in Fortran or C).])
783else
784  AC_MSG_NOTICE([Assuming that CXXLIBS is \"$CXXLIBS\".])
785fi
786if test x"$CXXLIBS" = xnothing; then
787  CXXLIBS=
788fi
789AC_LANG_POP(C++)
790]) # AC_COIN_CXXLIBS
791
792###########################################################################
793#                           COIN_CHECK_HEADER                             #
794###########################################################################
795
796# This macro checks for a header file, but it does so without the
797# standard header.  This avoids warning messages like:
798#
799# configure: WARNING: dlfcn.h: present but cannot be compiled
800# configure: WARNING: dlfcn.h:     check for missing prerequisite headers?
801# configure: WARNING: dlfcn.h: see the Autoconf documentation
802# configure: WARNING: dlfcn.h:     section "Present But Cannot Be Compiled"
803# configure: WARNING: dlfcn.h: proceeding with the preprocessor's result
804# configure: WARNING: dlfcn.h: in the future, the compiler will take precedence
805
806# My guess that the problem lay with CPPFLAGS seems to be correct. With this
807# macro reduced to a direct call to AC_CHECK_HEADERS, there are no warnings
808# now that CPPFLAGS contains -mno-cygwin when it needs it. -- lh, 061214 --
809
810# AW 070609: I restored the previous version, since otherwise the warnings
811# still pop up for the cl compiler
812
813AC_DEFUN([AC_COIN_CHECK_HEADER],
814[#if test x"$4" = x; then
815#  hdr="#include <$1>"
816#else
817#  hdr="$4"
818#fi
819#AC_CHECK_HEADERS([$1],[$2],[$3],[$hdr])
820AC_CHECK_HEADERS([$1],[$2],[$3],[$4])
821]) # AC_COIN_CHECK_HEADER
822
823###########################################################################
824#                       COIN_CHECK_CXX_CHEADER                             #
825###########################################################################
826
827# This macro checks for C header files that are used from C++.  For a give
828# stub (e.g., math), it first checks if the C++ library (cmath) is available.
829# If it is, it defines HAVE_CMATH (or whatever the stub is).  If it is not
830# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
831# if that one exists.
832
833AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
834[AC_LANG_PUSH(C++)
835AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
836if test "$ac_cv_header_c$1" != "yes"; then
837  AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
838fi
839AC_LANG_POP(C++)
840]) # AC_COIN_CHECK_CXX_CHEADER
841
842###########################################################################
843#                             COIN_PROG_CC                                #
844###########################################################################
845
846# Find the compile command by running AC_PROG_CC (with compiler names
847# for different operating systems) and put it into CC (unless it was
848# given my the user), and find an appropriate value for CFLAGS.  It is
849# possible to provide additional -D flags in the variable CDEFS.
850
851AC_DEFUN([AC_COIN_PROG_CC],
852[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
853AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
854AC_LANG_PUSH(C)
855
856# For consistency, we set the C compiler to the same value of the C++
857# compiler, if the C++ is set, but the C compiler isn't (only for CXX=cl)
858if test x"$CXX" != x; then
859  case "$CXX" in
860    cl* | */cl* | CL* | */CL*)
861      if test x"$CC" = x; then
862        CC="$CXX"
863        AC_MSG_WARN([C++ compiler name provided as $CXX, but CC is unset. Setting CC to $CXX])
864      fi
865      ;;
866  esac
867fi
868
869AC_ARG_VAR(CDEFS,[Additional -D flags to be used when compiling C code.])
870AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options])
871AC_ARG_VAR(DBG_CFLAGS,[Debug C compiler options])
872AC_ARG_VAR(OPT_CFLAGS,[Optimize C compiler options])
873
874coin_has_cc=yes
875
876save_cflags="$CFLAGS"
877# For sparc-sun-solaris, promote Studio/Workshop compiler to front of list.
878# ToDo: If Studio/Workshop cc is not present, we may find /usr/ucb/cc, which
879# is likely to be a non-functional shell. But many installations will have
880# both cc and gcc, so promoting gcc isn't good either. How to test reliably?
881case $build in
882  *-cygwin* | *-mingw*)
883             if test "$enable_doscompile" = msvc ; then
884               comps="cl"
885             else
886               comps="gcc cl"
887             fi ;;
888  sparc-sun-solaris*)
889             comps="cc xlc gcc pgcc icc" ;;
890  *-linux-*) comps="xlc gcc cc pgcc icc" ;;
891  *)         comps="xlc_r xlc cc gcc pgcc icc" ;;
892esac
893
894# We delete the cached value, since the test might not have been
895# performed with our choice of compilers earlier
896$as_unset ac_cv_prog_CC || test "${ac_cv_prog_CC+set}" != set || { ac_cv_prog_CC=; export ac_cv_prog_CC; }
897# AC_MSG_NOTICE([C compiler candidates: $comps])
898AC_PROG_CC([$comps])
899if test -z "$CC" ; then
900  AC_MSG_ERROR([Failed to find a C compiler!])
901fi
902# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
903case "$CC" in
904  cl* | */cl* | CL* | */CL* )
905    if test "$ac_cv_prog_cc_g" = yes ; then
906      ac_cv_prog_cc_g=no
907      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
908    fi ;;
909esac
910CFLAGS="$save_cflags"
911
912# Check if a project specific CFLAGS variable has been set
913if test x$COIN_PRJCT != x; then
914  eval coin_tmp=\${${COIN_PRJCT}_CFLAGS+set}
915  if test x$coin_tmp = xset; then
916    eval CFLAGS=\${${COIN_PRJCT}_CFLAGS}
917  fi
918fi
919
920if test x"$CFLAGS" = x; then
921
922  coin_add_cflags=
923  coin_opt_cflags=
924  coin_dbg_cflags=
925  coin_warn_cflags=
926
927  if test "$GCC" = "yes"; then
928    case "$CC" in
929      icc* | */icc*)
930        ;;
931      *)
932        coin_opt_cflags="-O3 -fomit-frame-pointer"
933        coin_add_cflags="-pipe"
934        coin_dbg_cflags="-g"
935        coin_warn_cflags="-pedantic-errors -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall"
936        case $enable_doscompile in
937          mingw)
938            CFLAGS="-mno-cygwin"
939            AC_TRY_LINK([],[int i=0; i++;],
940                        [coin_add_cflags="-mno-cygwin $coin_add_cflags"])
941            CFLAGS=
942          ;;
943        esac
944    esac
945  fi
946  if test -z "$coin_opt_cflags"; then
947    case $build in
948      *-cygwin* | *-mingw*)
949        case "$CC" in
950          cl* | */cl* | CL* | */CL*)
951            coin_opt_cflags='-MT -O2'
952            coin_add_cflags='-nologo -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
953            coin_dbg_cflags='-MTd'
954            ;;
955        esac
956        ;;
957      *-linux-*)
958        case "$CC" in
959          icc* | */icc*)
960            coin_opt_cflags="-O3 -ip"
961            coin_add_cflags=""
962            coin_dbg_cflags="-g"
963            # Check if -i_dynamic is necessary (for new glibc library)
964            CFLAGS=
965            AC_TRY_LINK([],[int i=0; i++;],[],
966                        [coin_add_cflags="-i_dynamic $coin_add_cflags"])
967            ;;
968          pgcc* | */pgcc*)
969            coin_opt_cflags="-fast"
970            coin_add_cflags="-Kieee -pc 64"
971            coin_dbg_cflags="-g"
972            ;;
973        esac
974        ;;
975      *-ibm-*)
976        case "$CC" in
977          xlc* | */xlc* | mpxlc* | */mpxlc*)
978            coin_opt_cflags="-O3 -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
979            coin_add_cflags="-bmaxdata:0x80000000"
980            coin_dbg_cflags="-g"
981          ;;
982        esac
983        ;;
984      *-hp-*)
985        coin_opt_cflags="-O"
986        coin_add_cflags="-Ae"
987        coin_dbg_cflags="-g"
988        ;;
989      *-sun-*)
990        coin_opt_cflags="-xO4"
991        coin_dbg_cflags="-g"
992        ;;
993      *-sgi-*)
994        coin_opt_cflags="-O -OPT:Olimit=0"
995        coin_dbg_cflags="-g"
996        ;;
997    esac
998  fi
999
1000  if test "$ac_cv_prog_cc_g" = yes && test -z "$coin_dbg_cflags" ; then
1001    coin_dbg_cflags="-g"
1002  fi
1003
1004  if test -z "$coin_opt_cflags"; then
1005    # Try if -O option works if nothing else is set
1006    CFLAGS="-O"
1007    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cflags="-O"])
1008  fi
1009
1010  # if PM doesn't want the warning messages, take them out
1011  if test x"$coin_skip_warn_cflags" = xyes; then
1012    coin_warn_cflags=
1013  fi
1014
1015  if test x${DBG_CFLAGS+set} != xset; then
1016    DBG_CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
1017  fi
1018  if test x${OPT_CFLAGS+set} != xset; then
1019    OPT_CFLAGS="$coin_opt_cflags $coin_add_cflags -DNDEBUG $coin_warn_cflags"
1020  fi
1021
1022  DBG_CFLAGS="$DBG_CFLAGS $ADD_CFLAGS $CDEFS"
1023  OPT_CFLAGS="$OPT_CFLAGS $ADD_CFLAGS $CDEFS"
1024
1025  if test "$coin_debug_compile" = "true"; then
1026    CFLAGS="$DBG_CFLAGS"
1027  else
1028    CFLAGS="$OPT_CFLAGS"
1029  fi
1030else
1031  CFLAGS="$CFLAGS $ADD_CFLAGS $CDEFS"
1032  if test x${DBG_CFLAGS+set} != xset; then
1033    DBG_CFLAGS="$CFLAGS"
1034  fi
1035  if test x${OPT_CFLAGS+set} != xset; then
1036    OPT_CFLAGS="$CFLAGS"
1037  fi
1038fi
1039
1040# If CFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
1041
1042case "$CFLAGS" in
1043  *-mno-cygwin*)
1044    if test x${CPPFLAGS+set} != xset ; then
1045      CPPFLAGS="-mno-cygwin"
1046    else
1047      case "$CPPFLAGS" in
1048        *-mno-cygwin*)
1049          ;;
1050        *)
1051          CPPFLAGS="$CPPFLAGS -mno-cygwin"
1052          ;;
1053      esac
1054    fi ;;
1055esac
1056
1057# Try if CFLAGS works
1058save_CFLAGS="$CFLAGS"
1059AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
1060if test -z "$CFLAGS"; then
1061  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.])
1062  CFLAGS='-O'
1063  AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
1064  if test -z "$CFLAGS"; then
1065    AC_MSG_WARN([This value for CFLAGS does not work.  I will continue with empty CFLAGS, but you might want to set CFLAGS manually.])
1066  fi
1067fi
1068
1069AC_MSG_NOTICE([C compiler options are: $CFLAGS])
1070
1071AC_ARG_VAR(MPICC,[C MPI Compiler])
1072if test x"$MPICC" = x; then :; else
1073  AC_MSG_NOTICE([Will use MPI C compiler $MPICC])
1074  CC="$MPICC"
1075fi
1076
1077# Correct ADDLIBS initialization if we are using the MS compiler
1078case "$CC" in
1079  cl* | */cl* | CL* | */CL*)
1080    ADDLIBS=
1081    AC_COIN_MINGW_LD_FIX
1082    ;;
1083esac
1084
1085AC_LANG_POP(C)
1086]) # AC_COIN_PROG_CC
1087
1088###########################################################################
1089#                             COIN_PROG_F77                               #
1090###########################################################################
1091
1092# Find the compile command by running AC_PROG_F77 (with compiler names
1093# for different operating systems) and put it into F77 (unless it was
1094# given by the user), and find an appropriate value for FFLAGS
1095
1096AC_DEFUN([AC_COIN_PROG_F77],
1097[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
1098AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1099AC_REQUIRE([AC_COIN_PROG_CC])
1100AC_REQUIRE([AC_COIN_F77_COMPS])
1101AC_LANG_PUSH([Fortran 77])
1102
1103AC_ARG_VAR(ADD_FFLAGS,[Additional Fortran compiler options])
1104AC_ARG_VAR(DBG_FFLAGS,[Debug Fortran compiler options])
1105AC_ARG_VAR(OPT_FFLAGS,[Optimize Fortran compiler options])
1106
1107coin_has_f77=yes
1108
1109save_fflags="$FFLAGS"
1110
1111# We delete the cached value, since the test might not have been
1112# performed with our choice of compilers earlier
1113$as_unset ac_cv_prog_F77 || test "${ac_cv_prog_F77+set}" != set || { ac_cv_prog_F77=; export ac_cv_prog_F77; }
1114
1115# This is a real belt-and-suspenders approach. AC_COIN_FIND_F77 will use
1116# coin_f77_comps to see if there's a program that matches one of the names.
1117# If there's no such program, F77 = unavailable. If we match the name,
1118# feed AC_PROG_F77 the same search list, just to be sure it's a functioning
1119# compiler.
1120# AC_MSG_NOTICE([Fortran compiler candidates: $coin_f77_comps])
1121AC_COIN_FIND_F77
1122if test "$F77" != "unavailable" ; then
1123  AC_PROG_F77($coin_f77_comps)
1124else
1125  AC_MSG_WARN([Failed to find a Fortran compiler!])
1126fi
1127
1128FFLAGS="$save_fflags"
1129
1130# Check if a project specific FFLAGS variable has been set
1131if test x$COIN_PRJCT != x; then
1132  eval coin_tmp=\${${COIN_PRJCT}_FFLAGS+set}
1133  if test x$coin_tmp = xset; then
1134    eval FFLAGS=\${${COIN_PRJCT}_FFLAGS}
1135  fi
1136fi
1137
1138if test "$F77" != "unavailable" && test x"$FFLAGS" = x ; then
1139
1140  coin_add_fflags=
1141  coin_opt_fflags=
1142  coin_dbg_fflags=
1143  coin_warn_fflags=
1144
1145  if test "$G77" = "yes"; then
1146    coin_opt_fflags="-O3 -fomit-frame-pointer"
1147    coin_add_fflags="-pipe"
1148    coin_dbg_fflags="-g"
1149    case $enable_doscompile in
1150      mingw)
1151        FFLAGS="-mno-cygwin"
1152        AC_TRY_LINK(,[      write(*,*) 'Hello world'],
1153                    [coin_add_fflags="-mno-cygwin $coin_add_fflags"])
1154        FFLAGS=
1155      ;;
1156    esac
1157  else
1158    case $build in
1159      *-cygwin* | *-mingw*)
1160        case $F77 in
1161          ifort* | */ifort* | IFORT* | */IFORT* )
1162            coin_opt_fflags='-O3'
1163            coin_add_fflags='-fpp -nologo -MT'
1164            coin_dbg_fflags='-debug'
1165          ;;
1166          compile_f2c*)
1167            coin_opt_fflags='-MT -O2'
1168            coin_add_fflags='-nologo -wd4996'
1169            coin_dbg_fflags='-MTd'
1170          ;;
1171        esac
1172        ;;
1173      *-linux-*)
1174        case $F77 in
1175          ifc* | */ifc* | ifort* | */ifort*)
1176            coin_opt_fflags="-O3 -ip"
1177            coin_add_fflags="-cm -w90 -w95"
1178            coin_dbg_fflags="-g -CA -CB -CS"
1179            # Check if -i_dynamic is necessary (for new glibc library)
1180            FFLAGS=
1181            AC_TRY_LINK(,[      write(*,*) 'Hello world'],[],
1182                        [coin_add_fflags="-i_dynamic $coin_add_fflags"])
1183            ;;
1184          pgf77* | */pgf77* | pgf90* | */pgf90*)
1185            coin_opt_fflags="-fast"
1186            coin_add_fflags="-Kieee -pc 64"
1187            coin_dbg_fflags="-g"
1188          ;;
1189        esac
1190        ;;
1191      *-ibm-*)
1192        case "$F77" in
1193          xlf* | */xlf* | mpxlf* | */mpxlf* )
1194            coin_opt_fflags="-O3 -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
1195            coin_add_fflags="-bmaxdata:0x80000000"
1196            coin_dbg_fflags="-g -C"
1197            ;;
1198        esac
1199        ;;
1200      *-hp-*)
1201        coin_opt_fflags="+O3"
1202        coin_add_fflags="+U77"
1203        coin_dbg_fflags="-C -g"
1204        ;;
1205      *-sun-*)
1206        coin_opt_fflags="-O4"
1207        coin_dbg_fflags="-g"
1208        ;;
1209      *-sgi-*)
1210        coin_opt_fflags="-O5 -OPT:Olimit=0"
1211        coin_dbg_fflags="-g"
1212        ;;
1213    esac
1214  fi
1215
1216  if test "$ac_cv_prog_f77_g" = yes && test -z "$coin_dbg_fflags" ; then
1217    coin_dbg_fflags="-g"
1218  fi
1219
1220  if test -z "$coin_opt_fflags"; then
1221    # Try if -O option works if nothing else is set
1222    FFLAGS=-O
1223    AC_TRY_LINK(,[      integer i], [coin_opt_fflags="-O"])
1224  fi
1225
1226  # if PM doesn't want the warning messages, take them out
1227  if test x"$coin_skip_warn_fflags" = xyes; then
1228    coin_warn_fflags=
1229  fi
1230
1231  if test x${DBG_FFLAGS+set} != xset; then
1232    DBG_FFLAGS="$coin_dbg_fflags $coin_add_fflags $coin_warn_fflags"
1233  fi
1234  if test x${OPT_FFLAGS+set} != xset; then
1235    OPT_FFLAGS="$coin_opt_fflags $coin_add_fflags $coin_warn_fflags"
1236  fi
1237
1238  DBG_FFLAGS="$DBG_FFLAGS $ADD_FFLAGS"
1239  OPT_FFLAGS="$OPT_FFLAGS $ADD_FFLAGS"
1240
1241  if test "$coin_debug_compile" = "true"; then
1242    FFLAGS="$DBG_FFLAGS"
1243  else
1244    FFLAGS="$OPT_FFLAGS"
1245  fi
1246else
1247  FFLAGS="$FFLAGS $ADD_FFLAGS"
1248  if test x${DBG_FFLAGS+set} != xset; then
1249    DBG_FFLAGS="$FFLAGS"
1250  fi
1251  if test x${OPT_FFLAGS+set} != xset; then
1252    OPT_FFLAGS="$FFLAGS"
1253  fi
1254fi
1255
1256# If FFLAGS contains -mno-cygwin, CPPFLAGS must have it.
1257case "$FFLAGS" in
1258  *-mno-cygwin*)
1259    if test x${CPPFLAGS+set} != xset ; then
1260      CPPFLAGS="-mno-cygwin"
1261    else
1262      case "$CPPFLAGS" in
1263        *-mno-cygwin*)
1264          ;;
1265        *)
1266          CPPFLAGS="$CPPFLAGS -mno-cygwin"
1267          ;;
1268      esac
1269    fi ;;
1270esac
1271
1272# Try if FFLAGS works
1273if test "$F77" != "unavailable" ; then
1274  AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1275  if test -z "$FFLAGS"; then
1276    AC_MSG_WARN([The flags FFLAGS="$FFLAGS" do not work.  I will now just try '-O', but you might want to set FFLAGS manually.])
1277    FFLAGS='-O'
1278    AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1279    if test -z "$FFLAGS"; then
1280      AC_MSG_WARN([This value for FFLAGS does not work.  I will continue with empty FFLAGS, but you might want to set FFLAGS manually.])
1281    fi
1282  fi
1283fi
1284
1285AC_MSG_NOTICE([Fortran compiler options are: $FFLAGS])
1286
1287AC_ARG_VAR(MPIF77,[Fortran MPI Compiler])
1288if test x"$MPIF77" = x; then :; else
1289  AC_MSG_NOTICE([Will use MPI Fortran compiler $MPIF77])
1290  F77="$MPIF77"
1291fi
1292
1293case "$F77" in
1294  ifort* | */ifort* | IFORT* | */IFORT*)
1295    AC_COIN_MINGW_LD_FIX
1296    ;;
1297esac
1298
1299AC_LANG_POP([Fortran 77])
1300]) # AC_COIN_PROG_F77
1301
1302###########################################################################
1303#                           COIN_F77_WRAPPERS                             #
1304###########################################################################
1305
1306# Calls autoconfs AC_F77_WRAPPERS and does additional corrections to FLIBS
1307
1308AC_DEFUN([AC_COIN_F77_WRAPPERS],
1309[AC_BEFORE([AC_COIN_PROG_F77],[$0])dnl
1310AC_BEFORE([AC_PROG_F77],[$0])dnl
1311
1312AC_LANG_PUSH([Fortran 77])
1313
1314save_FLIBS="$FLIBS"
1315
1316AC_F77_WRAPPERS
1317
1318if test x"$save_FLIBS" != x; then
1319  FLIBS="$save_FLIBS"
1320else
1321  # This is to correct a missing exclusion in autoconf 2.59
1322  if test x"$FLIBS" != x; then
1323    my_flibs=
1324    for flag in $FLIBS; do
1325      case $flag in
1326        -lcrt*.o) ;;
1327               *) my_flibs="$my_flibs $flag" ;;
1328      esac
1329    done
1330    FLIBS="$my_flibs"
1331  fi
1332
1333  case $build in
1334  # The following is a fix to define FLIBS for ifort on Windows
1335     *-cygwin* | *-mingw*)
1336       case "$F77" in
1337         ifort* | */ifort* | IFORT* | */IFORT*)
1338           FLIBS="-link libifcorert.lib $LIBS /NODEFAULTLIB:libc.lib";;
1339         compile_f2c*)
1340           FLIBS=`$F77 -FLIBS` ;;
1341       esac;;
1342     *-hp-*)
1343         FLIBS="$FLIBS -lm";;
1344     *-ibm-*)
1345         FLIBS=`echo $FLIBS | sed 's/-lc)/-lc/g'` ;;
1346     *-linux-*)
1347       case "$F77" in
1348         pgf77* | */pgf77* | pgf90* | */pgf90*)
1349# ask linker to go through the archives multiple times
1350# (the Fortran compiler seems to do that automatically...
1351           FLIBS="-Wl,--start-group $FLIBS -Wl,--end-group" ;;
1352       esac
1353  esac
1354  ac_cv_f77_libs="$FLIBS"
1355fi
1356
1357AC_LANG_POP([Fortran 77])
1358
1359]) # AC_COIN_F77_WRAPPERS
1360
1361###########################################################################
1362#                             COIN_FIND_F77                               #
1363###########################################################################
1364
1365# Attempt to preempt autoconf by locating an appropriate F77 program. This
1366# macro will not trigger a fatal error if a suitable compiler cannot be
1367# found. It should be called before COIN_PROG_F77 or COIN_TRY_FLINK.
1368
1369AC_DEFUN([AC_COIN_FIND_F77],
1370[AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1371AC_REQUIRE([AC_COIN_F77_COMPS])
1372AC_MSG_NOTICE([Trying to determine Fortran compiler name])
1373AC_CHECK_PROGS([F77],[$coin_f77_comps],[unavailable])
1374])
1375
1376# Auxilliary macro to make sure both COIN_PROG_F77 and COIN_FIND_F77 use
1377# the same search lists for compiler names.
1378# For sparc-sun-solaris, promote Studio/Workshop compilers to front of list.
1379AC_DEFUN([AC_COIN_F77_COMPS],
1380[case $build in
1381  *-cygwin* | *-mingw*)
1382     if test "$enable_doscompile" = msvc ; then
1383       coin_f77_comps="ifort fl32 compile_f2c"
1384     else
1385       coin_f77_comps="gfortran g77 ifort fl32 compile_f2c"
1386     fi ;;
1387  sparc-sun-solaris*)
1388     coin_f77_comps="f95 f90 f77 xlf fort77 gfortran g77 pgf90 pgf77 ifort ifc frt af77" ;;
1389  *) coin_f77_comps="xlf fort77 gfortran f77 g77 pgf90 pgf77 ifort ifc frt af77" ;;
1390 esac
1391])
1392
1393###########################################################################
1394#                          COIN_INIT_AUTOMAKE                             #
1395###########################################################################
1396
1397# This macro calls the regular INIT_AUTOMAKE and MAINTAINER_MODE
1398# macros, and defines additional variables and makefile conditionals,
1399# that are used in the maintainer parts of the makfile.  It also
1400# checks if the correct versions of the autotools are used.
1401#
1402# This also defines the AC_SUBST variables:
1403# abs_source_dir     absolute path to source code for this package
1404# abs_bin_dir        absolute path to the directory where binaries are
1405#                    going to be installed (prefix/bin)
1406# abs_lib_dir        absolute path to the directory where libraries are
1407#                    going to be installed (prefix/lib)
1408# abs_include_dir    absolute path to the directory where the header files
1409#                    are installed (prefix/include)
1410
1411AC_DEFUN([AC_COIN_INIT_AUTOMAKE],
1412[AC_REQUIRE([AC_PROG_EGREP])
1413
1414# AC_MSG_NOTICE([Beginning automake initialisation.])
1415# Stuff for automake
1416AM_INIT_AUTOMAKE
1417AM_MAINTAINER_MODE
1418
1419coin_have_externals=no
1420if test "$enable_maintainer_mode" = yes; then
1421
1422  # If maintainer mode is chosen, we make sure that the correct versions
1423  # of the tools are used, and that we know where libtool.m4 is (to
1424  # recreate acinclude.m4)
1425
1426  AC_SUBST(LIBTOOLM4)
1427  LIBTOOLM4=
1428  # Normally, $HOME
1429  AUTOTOOLS_DFLT=$HOME
1430
1431  AC_CACHE_CHECK([whether we are using the correct autotools],
1432                 [ac_cv_use_correct_autotools],
1433                 [ac_cv_use_correct_autotools=check])
1434
1435  if test $ac_cv_use_correct_autotools = check; then
1436    ac_cv_use_correct_autotools=yes
1437    # Check if we have autoconf
1438    AC_CHECK_PROG([have_autoconf],[autoconf],[yes],[no])
1439    if test $have_autoconf = no; then
1440      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find autoconf in your path.])
1441    fi
1442
1443    # Check whether autoconf is the correct version
1444    correct_version='2.59'
1445    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1446    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of autoconf])
1447    autoconf --version > confauto.out 2>&1
1448    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1449      AC_MSG_RESULT([yes])
1450    else
1451      rm -f confauto.out
1452      AC_MSG_RESULT([no])
1453      AC_MSG_ERROR([You don't have the correct version of autoconf as the first one in your path.])
1454    fi
1455    rm -f confauto.out
1456
1457    # Check if the executable autoconf is picked up from the correct location
1458    AC_MSG_CHECKING([whether autoconf is coming from the correct location])
1459    autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
1460    autoconf_dir=`cd $autoconf_dir; pwd`
1461    if test x$AUTOTOOLS_DIR = x; then
1462      want_dir=$AUTOTOOLS_DFLT/bin
1463    else
1464      want_dir=$AUTOTOOLS_DIR/bin
1465    fi
1466    if test $autoconf_dir = `cd $want_dir; pwd`; then
1467      AC_MSG_RESULT([yes])
1468    else
1469      rm -f confauto.out
1470      AC_MSG_RESULT([no])
1471      AC_MSG_ERROR([The autoconf executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1472    fi
1473
1474    # Check if we have automake
1475    AC_CHECK_PROG([have_automake],[automake],[yes],[no])
1476    if test $have_automake = no; then
1477      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find automake in your path.])
1478    fi
1479 
1480    # Check whether automake is the correct version
1481    correct_version='1.9.6'
1482    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1483    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of automake])
1484    automake --version > confauto.out 2>&1
1485    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1486      AC_MSG_RESULT([yes])
1487    else
1488      rm -f confauto.out
1489      AC_MSG_RESULT([no])
1490      AC_MSG_ERROR([You don't have the correct version of automake as the first one in your path.])
1491    fi
1492    rm -f confauto.out
1493
1494    # Check if the executable automake is picked up from the correct location
1495    AC_MSG_CHECKING([whether automake is coming from the correct location])
1496    automake_dir=`which automake | sed -e 's=/automake=='`
1497    automake_dir=`cd $automake_dir; pwd`
1498    if test x$AUTOTOOLS_DIR = x; then
1499      want_dir=$AUTOTOOLS_DFLT/bin
1500    else
1501      want_dir=$AUTOTOOLS_DIR/bin
1502    fi
1503    if test $automake_dir = `cd $want_dir; pwd`; then
1504      AC_MSG_RESULT([yes])
1505    else
1506      rm -f confauto.out
1507      AC_MSG_RESULT([no])
1508      AC_MSG_ERROR([The automake executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1509    fi
1510
1511    # Check if this is the correct version of libtool (with escaped dots)
1512    if test x$AUTOTOOLS_DIR = x; then
1513      want_dir=$AUTOTOOLS_DFLT/share
1514    else
1515      want_dir=$AUTOTOOLS_DIR/share
1516    fi
1517    correct_version='1.5.22'
1518    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1519    AC_COIN_CHECK_FILE([$want_dir/libtool/ltmain.sh],
1520                       [have_ltmain=yes],
1521                       [have_ltmain=no])
1522    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of libtool.])
1523    if test $have_ltmain = yes; then
1524    if $EGREP $grep_version $want_dir/libtool/ltmain.sh >/dev/null 2>&1; then
1525        AC_MSG_RESULT([yes])
1526      else
1527        AC_MSG_RESULT([no])
1528        AC_MSG_ERROR([You don't have the correct version of libtool.])
1529      fi
1530    else
1531      AC_MSG_RESULT([no])
1532      AC_MSG_ERROR([I cannot find the ltmain.sh file.])
1533    fi
1534  fi
1535
1536  # Check if we can find the libtool file
1537  if test x$AUTOTOOLS_DIR = x; then
1538    want_dir=$AUTOTOOLS_DFLT/share
1539  else
1540    want_dir=$AUTOTOOLS_DIR/share
1541  fi
1542  AC_COIN_CHECK_FILE([$want_dir/aclocal/libtool.m4],
1543                     [LIBTOOLM4="$want_dir/aclocal/libtool.m4"],
1544                     [AC_MSG_ERROR([I cannot find the libtool.m4 file.])])
1545
1546  # Check if we have an Externals file
1547  if test -r $srcdir/Externals; then
1548    coin_have_externals=yes
1549  fi
1550  # Check if subversion is installed and understands https
1551  AC_CHECK_PROG([have_svn],[svn],[yes],[no])
1552  if test x$have_svn = xyes; then
1553    AC_CACHE_CHECK([whether svn understands https],
1554                   [ac_cv_svn_understands_https],
1555                   [svn --version > confauto.out 2>&1
1556                    if $EGREP https confauto.out >/dev/null 2>&1; then
1557                      ac_cv_svn_understands_https=yes
1558                    else
1559                      ac_cv_svn_understands_https=no
1560                      have_svn=no
1561                      ac_cv_prog_have_svn=no
1562                    fi
1563                    rm -f confauto.out])
1564  fi
1565
1566  # Find the location of the BuildTools directory
1567  BUILDTOOLSDIR=
1568  if test -r $srcdir/BuildTools/coin.m4; then
1569    BUILDTOOLSDIR=$srcdir/BuildTools
1570  else
1571    if test -r $srcdir/../BuildTools/coin.m4; then
1572      BUILDTOOLSDIR=$srcdir/../BuildTools
1573    else
1574      if test -r $srcdir/../../BuildTools/coin.m4; then
1575        BUILDTOOLSDIR=$srcdir/../../BuildTools
1576      else
1577        AC_MSG_ERROR(Cannot find the BuildTools directory)
1578      fi
1579    fi
1580  fi
1581  AC_SUBST(BUILDTOOLSDIR)
1582
1583  # The following variable is set to the name of the directory where
1584  # the autotool scripts are located
1585  AC_SUBST(AUX_DIR)
1586  AUX_DIR=$ac_aux_dir
1587fi
1588
1589# helpful variable for the base directory of this package
1590abs_source_dir=`cd $srcdir; pwd`
1591AC_SUBST(abs_source_dir)
1592
1593# Stuff for example Makefiles
1594if test x$prefix = xNONE; then
1595  full_prefix=$ac_default_prefix
1596else
1597  full_prefix=$prefix
1598fi
1599full_prefix=`cd $full_prefix ; pwd`
1600AC_SUBST(abs_lib_dir)
1601abs_lib_dir=$full_prefix/lib
1602AC_SUBST(abs_include_dir)
1603abs_include_dir=$full_prefix/include
1604AC_SUBST(abs_bin_dir)
1605abs_bin_dir=$full_prefix/bin
1606
1607AM_CONDITIONAL(HAVE_EXTERNALS,
1608               test $coin_have_externals = yes && test x$have_svn = xyes)
1609
1610# AC_MSG_NOTICE([End automake initialisation.])
1611
1612]) # AC_COIN_INIT_AUTOMAKE
1613
1614###########################################################################
1615#                          COIN_CREATE_LIBTOOL                            #
1616###########################################################################
1617
1618# This does all the tests necessary to create the libtool script in the
1619# package base directory.  If this is used, then the COIN_INIT_AUTO_TOOLS
1620# test in the subdirectories will be able to skip the libtool tests and
1621# just use the one in the package base directory.
1622
1623m4_define([AC_COIN_CREATE_LIBTOOL],
1624[AC_CANONICAL_BUILD
1625
1626# Check if user wants to produce debugging code
1627AC_COIN_DEBUG_COMPILE
1628
1629# Get the name of the C compiler and appropriate compiler options
1630AC_COIN_PROG_CC
1631
1632# Get the name of the C++ compiler and appropriate compiler options
1633AC_COIN_PROG_CXX
1634
1635# Get the name of the Fortran compiler and appropriate compiler options
1636AC_COIN_PROG_F77
1637
1638# Initialize automake and libtool
1639# AC_MSG_NOTICE([Calling INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1640AC_COIN_INIT_AUTO_TOOLS
1641# AC_MSG_NOTICE([Finished INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1642])
1643
1644###########################################################################
1645#                         COIN_INIT_AUTO_TOOLS                            #
1646###########################################################################
1647
1648# Initialize the auto tools automake and libtool, with all
1649# modifications we want for COIN packages.
1650#
1651# RPATH_FLAGS        link flags for hardcoding path to shared objects
1652
1653# This is a trick to have this code before AC_COIN_PROG_LIBTOOL
1654AC_DEFUN([AC_COIN_DISABLE_STATIC],
1655[
1656# On Cygwin, building DLLs doesn't work
1657case $build in
1658  *-cygwin*)
1659    coin_disable_shared=yes
1660    platform=Cygwin
1661  ;;
1662  *-mingw*)
1663    coin_disable_shared=yes
1664    platform="Msys"
1665#    case "$CXX" in
1666#      cl*)
1667#        coin_disable_shared=yes
1668#        platform="Msys with cl"
1669#    ;;
1670#    esac
1671  ;;
1672esac
1673if test x"$coin_disable_shared" = xyes; then
1674  if test x"$enable_shared" = xyes; then
1675    AC_MSG_WARN([On $platform, shared objects are not supported. I'm disabling your choice.])
1676  fi
1677  enable_shared=no
1678fi
1679# By default, we only want the shared objects to be compiled
1680AC_DISABLE_STATIC
1681])
1682
1683m4_define([AC_COIN_INIT_AUTO_TOOLS],
1684[{AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1685AC_BEFORE([AC_COIN_PROG_CC],[$0])
1686AC_BEFORE([AC_COIN_PROG_F77],[$0])
1687
1688# START
1689AC_COIN_DISABLE_STATIC
1690
1691# Initialize automake
1692AC_COIN_INIT_AUTOMAKE
1693
1694LIBTOOL=
1695if test -r ../libtool; then
1696  coin_config_dir=..
1697  LIBTOOL='$(SHELL) $(top_builddir)/../libtool'
1698fi
1699if test "x$LIBTOOL" = x; then
1700  if test -r ../../libtool; then
1701    coin_config_dir=../..
1702    LIBTOOL='$(SHELL) $(top_builddir)/../../libtool'
1703  fi
1704fi
1705
1706if test "x$LIBTOOL" = x; then
1707# AC_MSG_NOTICE([Creating libtool script (calling COIN_PROG_LIBTOOL).])
1708  # Stuff for libtool
1709  AC_COIN_PROG_LIBTOOL
1710# AC_MSG_NOTICE([Finished COIN_PROG_LIBTOOL.])
1711  # set RPATH_FLAGS to the compiler link flags required to hardcode location
1712  # of the shared objects
1713  AC_COIN_RPATH_FLAGS($abs_lib_dir)
1714
1715else
1716
1717  AC_MSG_NOTICE([Using libtool script in directory $coin_config_dir])
1718  # get all missing information from the config.log file
1719
1720  # output variables and defines
1721  as_save_IFS=$IFS
1722  IFS='
1723'
1724  for oneline in `cat $coin_config_dir/config.status`; do
1725    case "$oneline" in
1726         # First some automake conditionals
1727      s,@am__fastdep* | s,@AR@* | s,@CPP@*  | s,@CPPFLAGS@* | s,@CXXCPP@*  | \
1728      s,@RANLIB@* | s,@STRIP@* | s,@ac_ct_AR@* | s,@ac_ct_RANLIB@* | \
1729      s,@ac_ct_STRIP@* | s,@host* | s,@LN_S@* | s,@RPATH_FLAGS@* | \
1730      s,@ac_c_preproc_warn_flag@* |  s,@ac_cxx_preproc_warn_flag@* )
1731        command=`echo $oneline | sed -e 's/^s,@//' -e 's/@,/="/' -e 's/,;t t/"/'`
1732#        echo "$command"
1733        eval "$command"
1734        ;;
1735      s,@DEFS@* )
1736        command=`echo $oneline | sed -e 's/^s,@DEFS@,/defsline="/' -e 's/,;t t/"/'`
1737#        echo "$command"
1738        eval "$command"
1739        ;;
1740    esac
1741  done
1742  IFS=$as_save_IFS
1743
1744  # And some defines (assuming here that the packages base dir
1745  # doesn't have a config.h file
1746  for word in $defsline; do
1747#    echo word $word
1748    case $word in
1749      -DHAVE_@<:@A-Z_@:>@*_H=1 | -DSTDC_HEADERS=1 )
1750        i=`echo $word | sed -e 's/-D/#define /' -e 's/=/ /'`
1751#        echo dd $i
1752        echo $i >>confdefs.h
1753        ;;
1754    esac
1755  done
1756fi
1757
1758# AC_MSG_NOTICE([End of INIT_AUTO_TOOLS.])
1759
1760# ToDo
1761# For now, don't use the -no-undefined flag, since the Makefiles are
1762# not yet set up that way.  But we need to fix this, when we want
1763# to comile DLLs under Windows.
1764LT_LDFLAGS=
1765AC_SUBST(LT_LDFLAGS)
1766
1767#END
1768}])
1769
1770
1771###########################################################################
1772#                           COIN_PROG_LIBTOOL                             #
1773###########################################################################
1774
1775# Setup the libtool stuff together with any modifications to make it
1776# work on additional platforms
1777
1778AC_DEFUN([AC_COIN_LIBTOOL_WRAPPER],
1779[AC_BEFORE([AC_COIN_BLA],[$0])
1780AC_PROG_LIBTOOL])
1781
1782AC_DEFUN([AC_COIN_BLA],[echo bla])
1783
1784AC_DEFUN([AC_COIN_PROG_LIBTOOL],
1785[# No longer needed now that CPPFLAGS is correctly set -- lh, 061214 --
1786 # AC_REQUIRE([AC_COIN_DLFCN_H])
1787
1788# NEW: If libtool exists in the directory higher up, we use that one
1789#      instead of creating a new one
1790
1791# It turns out that the code for AC_PROG_LIBTOOL is somehow AC_REQUIRED
1792# out in front of this macro body. You'll notice that LIBTOOL is already
1793# defined here.  We'll have to count on this macro not being called if libtool
1794# already exists, or at least move the libtool fixes outside the conditional.
1795# AC_MSG_NOTICE([Entering coin_prog_libtool, LIBTOOL = "$LIBTOOL".])
1796# This test is therefore removed.  -- lh, 061214 --
1797# if test "x$LIBTOOL" = x; then
1798
1799# AC_MSG_NOTICE([Calling PROG_LIBTOOL.])
1800  AC_PROG_LIBTOOL
1801# AC_MSG_NOTICE([Finished PROG_LIBTOOL.])
1802  AC_SUBST(ac_c_preproc_warn_flag)
1803  AC_SUBST(ac_cxx_preproc_warn_flag)
1804
1805# Fix bugs in libtool script for Windows native compilation:
1806# - cygpath is not correctly quoted in fix_srcfile_path
1807# - paths generated for .lib files is not run through cygpath -w
1808
1809
1810# - lib includes subdirectory information; we want to replace
1811#
1812# old_archive_cmds="lib /OUT:\$oldlib\$oldobjs\$old_deplibs"
1813#
1814# by
1815#
1816# old_archive_cmds="echo \$oldlib | grep .libs >/dev/null; if test \$? = 0; then cd .libs; lib /OUT:\`echo \$oldlib\$oldobjs\$old_deplibs | sed -e s@\.libs/@@g\`; cd .. ; else lib /OUT:\$oldlib\$oldobjs\$old_deplibs ; fi"
1817#
1818#          -e 's%old_archive_cmds="lib /OUT:\\\$oldlib\\\$oldobjs\\\$old_deplibs"%old_archive_cmds="echo \\\$oldlib \| grep .libs >/dev/null; if test \\\$? = 0; then cd .libs; lib /OUT:\\\`echo \\\$oldlib\\\$oldobjs\\\$old_deplibs \| sed -e s@\\.libs/@@g\\\`; cd .. ; else lib /OUT:\\\$oldlib\\\$oldobjs\\\$old_deplibs; fi"%' \
1819
1820# The following was a hack for chaniing @BACKSLASH to \
1821#          -e 'sYcompile_command=`\$echo "X\$compile_command" | \$Xsed -e '"'"'s%@OUTPUT@%'"'"'"\$output"'"'"'%g'"'"'`Ycompile_command=`\$echo "X\$compile_command" | \$Xsed -e '"'"'s%@OUTPUT@%'"'"'"\$output"'"'"'%g'"'"' | \$Xsed -e '"'"'s%@BACKSLASH@%\\\\\\\\\\\\\\\\%g'"'"'`Y' \
1822
1823  # Correct cygpath for minGW (ToDo!)
1824  AC_MSG_NOTICE([Build is "$build".])
1825  mydos2unix='| dos2unix'
1826  case $build in
1827    *-mingw*)
1828      CYGPATH_W=echo
1829      mydos2unix=
1830      ;;
1831  esac
1832
1833  case $build in
1834    *x86_64-*)
1835# Here we need to check if -m32 is specified.  If so, we need to correct sys_lib_search_path_spec
1836      if test "$GCC" = yes && (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm32' >& /dev/null); then
1837        AC_MSG_NOTICE(Applying patches to libtool for 32bit compilation)
1838        sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="/lib /usr/lib"|' libtool > conftest.bla
1839        mv conftest.bla libtool
1840        chmod 755 libtool 
1841      fi
1842      ;;
1843    *-cygwin* | *-mingw*)
1844    case "$CXX" in
1845      cl* | */cl* | CL* | */CL*)
1846        AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1847        sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1848            -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1849            -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1850            -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1851            -e 's%lib /OUT:%lib -OUT:%' \
1852            -e "s%cygpath -w%$CYGPATH_W%" \
1853            -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%' \
1854            -e 's/$AR t/lib -nologo -list/' \
1855            -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1856            -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1857            -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"%' \
1858        libtool > conftest.bla
1859
1860        mv conftest.bla libtool
1861        chmod 755 libtool
1862        ;;
1863      *)
1864        AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
1865        sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1866            -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1867            -e 's|libext="lib"|libext="a"|' \
1868        libtool > conftest.bla
1869
1870        mv conftest.bla libtool
1871        chmod 755 libtool
1872        ;;
1873    esac
1874    ;;
1875    *-darwin*)
1876      AC_MSG_NOTICE(Applying patches to libtool for Darwin)
1877      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"/' \
1878      libtool > conftest.bla
1879
1880      mv conftest.bla libtool
1881      chmod 755 libtool
1882      ;;
1883  esac
1884# This fi matches the commented `if test "x$LIBTOOL" = x;' up at the head of
1885# the macro. -- lh, 061214 --
1886# fi
1887
1888# AC_MSG_NOTICE([End libtool initialisation.])
1889]) # AC_COIN_PROG_LIBTOOL
1890
1891# This is a trick to force the check for the dlfcn header to be done before
1892# the checks for libtool
1893# No longer needed now that CPPFLAGS is correctly set.  -- lh, 061214 --
1894# ACDEFUN([AC_COIN_DLFCN_H],
1895# [AC_LANG_PUSH(C)
1896# AC_COIN_CHECK_HEADER([dlfcn.h])
1897# AC_LANG_POP(C)
1898# ]) # AC_COIN_DLFCN_H
1899
1900###########################################################################
1901#                            COIN_RPATH_FLAGS                             #
1902###########################################################################
1903
1904# This macro, in case shared objects are used, defines a variable
1905# RPATH_FLAGS that can be used by the linker to hardwire the library
1906# search path for the given directories.  This is useful for example
1907# Makefiles
1908
1909AC_DEFUN([AC_COIN_RPATH_FLAGS],
1910[RPATH_FLAGS=
1911
1912if test $enable_shared = yes; then
1913  case $build in
1914    *-linux-*)
1915      if test "$GXX" = "yes"; then
1916        RPATH_FLAGS=
1917        for dir in $1; do
1918          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1919        done
1920      fi ;;
1921    *-darwin*)
1922        RPATH_FLAGS=nothing ;;
1923    *-ibm-*)
1924      case "$CXX" in
1925      xlC* | */xlC* | mpxlC* | */mpxlC*)
1926        RPATH_FLAGS=nothing ;;
1927      esac ;;
1928    *-hp-*)
1929        RPATH_FLAGS=nothing ;;
1930    *-mingw32)
1931        RPATH_FLAGS=nothing ;;
1932    *-sun-*)
1933        RPATH_FLAGS=
1934        for dir in $1; do
1935          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
1936        done
1937  esac
1938
1939  if test "$RPATH_FLAGS" = ""; then
1940    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.])
1941  fi
1942  if test "$RPATH_FLAGS" = "nothing"; then
1943    RPATH_FLAGS=
1944  fi
1945fi
1946
1947AC_SUBST(RPATH_FLAGS)
1948]) # AC_COIN_RPATH_FLAGS
1949
1950###########################################################################
1951#                        COIN_LINK_INPUT_CMD                              #
1952###########################################################################
1953
1954# This macro determines which command should be used to "link" files
1955# that are input to the generated executables.  On Windows, the codes
1956# using the native Windows system libraries, cannot understand symbolic
1957# links, and a copy should be used instead of 'ln -s'.
1958# The result is stored in coin_link_input_cmd
1959
1960AC_DEFUN([AC_COIN_LINK_INPUT_CMD],
1961[AC_REQUIRE([AC_PROG_LN_S])
1962AC_BEFORE([AC_COIN_PROG_CC], [$0])
1963AC_BEFORE([AC_COIN_ENABLE_DOSCOMPILE], [$0])
1964
1965AC_MSG_CHECKING([which command should be used to link input files])
1966coin_link_input_cmd="$LN_S"
1967if test "$enable_doscompile" = mingw; then
1968  coin_link_input_cmd=cp
1969fi
1970case "$CC" in
1971  cl* | */cl* | CL* | */CL*)
1972    coin_link_input_cmd=cp ;;
1973esac
1974AC_MSG_RESULT($coin_link_input_cmd)
1975])
1976
1977###########################################################################
1978#                              COIN_FINALIZE                              #
1979###########################################################################
1980
1981# This macro should be called at the very end of the configure.ac file.
1982# It creates the output files (by using AC_OUTPUT), and might do some other
1983# things (such as generating links to data files in a VPATH configuration).
1984# It also prints the "success" message.
1985# Note: If the variable coin_skip_ac_output is set to yes, then no output
1986# files are written.
1987
1988AC_DEFUN([AC_COIN_FINALIZE],
1989[
1990AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
1991if test x$coin_skip_ac_output != xyes; then
1992
1993  FADDLIBS="$ADDLIBS"
1994  if test x"$coin_need_flibs" = xyes; then
1995    ADDLIBS="$ADDLIBS $FLIBS"
1996  fi
1997
1998  # library extension
1999  AC_SUBST(LIBEXT)
2000  case "$CC" in
2001    cl* | */cl* | CL* | */CL*)
2002         LIBEXT=lib ;;
2003      *) LIBEXT=a ;;
2004  esac
2005
2006  # Define VPATH_DISTCLEANFILES to be everything that needs to be
2007  # cleaned for distclean in a vpath configuration
2008  AC_SUBST(VPATH_DISTCLEANFILES)
2009  VPATH_DISTCLEANFILES="$coin_vpath_link_files"
2010
2011  # Take out subdirectories if their configuration concluded that they
2012  # don't need to be compiled
2013  if test x"$coin_ac_skip_subdirs" != x; then
2014    new_subdirs=
2015    for i in $subdirs; do
2016      skipme=no
2017      for j in $coin_ac_skip_subdirs; do
2018        if test $i = $j; then
2019          skipme=yes;
2020        fi
2021      done
2022      if test $skipme = no; then
2023        new_subdirs="$new_subdirs $i"
2024      fi
2025    done
2026    subdirs="$new_subdirs"
2027  fi
2028
2029  AC_OUTPUT
2030
2031  if test x"$coin_vpath_link_files" = x; then : ; else
2032    lnkcmd="$coin_link_input_cmd"
2033    if test "$lnkcmd" = cp; then
2034      AC_MSG_NOTICE(Copying data files for VPATH configuration)
2035    else
2036      AC_MSG_NOTICE(Creating VPATH links for data files)
2037    fi
2038    for file in $coin_vpath_link_files; do
2039      dir=`AS_DIRNAME(["./$file"])`
2040      if test -d $dir; then : ; else
2041        AS_MKDIR_P($dir)
2042      fi
2043      rm -f $file
2044      $lnkcmd $abs_source_dir/$file $file
2045    done
2046  fi
2047
2048  if test x$coin_projectdir = xyes; then
2049    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
2050  else
2051    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
2052  fi
2053else
2054  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
2055fi
2056
2057]) #AC_COIN_FINALIZE
2058
2059###########################################################################
2060#                             COIN_VPATH_LINK                             #
2061###########################################################################
2062
2063# This macro makes sure that a symbolic link is created to a file in
2064# the source code directory tree if we are in a VPATH compilation, and
2065# if this package is the main package to be installed
2066
2067AC_DEFUN([AC_COIN_VPATH_LINK],
2068[AC_REQUIRE([AC_COIN_CHECK_VPATH])
2069if test $coin_vpath_config = yes; then
2070  coin_vpath_link_files="$coin_vpath_link_files $1"
2071fi
2072]) #AC_COIN_VPATH_LINK
2073
2074###########################################################################
2075#                       COIN_ENABLE_GNU_PACKAGES                          #
2076###########################################################################
2077
2078# This macro defined the --enable-gnu-packages flag.  This can be used
2079# to check if a user wants to compile GNU packges (such as readline or
2080# zlib) into the executable.  By default, GNU packages are disabled.
2081# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
2082
2083AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
2084[AC_ARG_ENABLE([gnu-packages],
2085               [AC_HELP_STRING([--enable-gnu-packages],
2086                               [compile with GNU packages (disabled by default)])],
2087               [coin_enable_gnu=$enableval],
2088               [coin_enable_gnu=no])
2089]) # AC_COIN_ENABLE_GNU_PACKAGES
2090
2091###########################################################################
2092#                           COIN_CHECK_GNU_ZLIB                           #
2093###########################################################################
2094
2095# This macro checks for the libz library.
2096
2097AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2098[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2099AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2100AC_BEFORE([AC_COIN_PROG_CC],[$0])
2101AC_BEFORE([AC_COIN_PROG_F77],[$0])
2102AC_BEFORE([$0],[AC_COIN_FINISH])
2103
2104coin_has_zlib=no
2105if test $coin_enable_gnu = yes; then
2106  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2107
2108  if test $coin_has_zlib = yes; then
2109    AC_CHECK_LIB([z],[gzopen],
2110                 [ADDLIBS="-lz $ADDLIBS"],
2111                 [coin_has_zlib=no])
2112  fi
2113
2114  if test $coin_has_zlib = yes; then
2115    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2116  fi
2117fi
2118
2119AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2120]) # AC_COIN_CHECK_GNU_ZLIB
2121
2122
2123###########################################################################
2124#                          COIN_CHECK_GNU_BZLIB                           #
2125###########################################################################
2126
2127# This macro checks for the libbz2 library.
2128
2129AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2130[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2131AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2132AC_BEFORE([AC_COIN_PROG_CC],[$0])
2133AC_BEFORE([AC_COIN_PROG_F77],[$0])
2134AC_BEFORE([$0],[AC_COIN_FINISH])
2135
2136coin_has_bzlib=no
2137if test $coin_enable_gnu = yes; then
2138  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2139
2140  if test $coin_has_bzlib = yes; then
2141    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2142                 [ADDLIBS="-lbz2 $ADDLIBS"],
2143                 [coin_has_bzlib=no])
2144  fi
2145
2146  if test $coin_has_bzlib = yes; then
2147    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2148  fi
2149fi
2150]) # AC_COIN_CHECK_GNU_BZLIB
2151
2152
2153###########################################################################
2154#                         COIN_CHECK_GNU_READLINE                         #
2155###########################################################################
2156
2157# This macro checks for GNU's readline.  It verifies that the header
2158# readline/readline.h is available, and that the -lreadline library
2159# contains "readline".  It is assumed that #include <stdio.h> is included
2160# in the source file before the #include<readline/readline.h>
2161
2162AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2163[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2164AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2165AC_BEFORE([AC_COIN_PROG_CC],[$0])
2166AC_BEFORE([AC_COIN_PROG_F77],[$0])
2167AC_BEFORE([$0],[AC_COIN_FINISH])
2168
2169coin_has_readline=no
2170if test $coin_enable_gnu = yes; then
2171  AC_COIN_CHECK_HEADER([readline/readline.h],
2172                       [coin_has_readline=yes],[],
2173                       [#include <stdio.h>])
2174
2175  coin_save_LIBS="$LIBS"
2176  LIBS=
2177  # First we check if tputs and friends are available
2178  if test $coin_has_readline = yes; then
2179    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2180                   [coin_has_readline=no])
2181  fi
2182
2183  # Now we check for readline
2184  if test $coin_has_readline = yes; then
2185    AC_CHECK_LIB([readline],[readline],
2186                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
2187                 [coin_has_readline=no])
2188  fi
2189
2190  if test $coin_has_readline = yes; then
2191    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2192  fi
2193
2194  LIBS="$coin_save_LIBS"
2195fi
2196]) # AC_COIN_CHECK_GNU_READLINE
2197
2198###########################################################################
2199#                             COIN_DATA_PATH                              #
2200###########################################################################
2201
2202# This macro defines a preprocessor macro with the absolute path to a
2203# subdirectory of Data.  The argument of this macro is the name of the
2204# subdirectory (in correct case), and the name of the macro is
2205# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2206# the directory.  The path ends with a separator ("/" for linux and
2207# '\\' for Windows).  The default value for this path can be
2208# overwritten with the input variable with the same name
2209# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2210# $srcdir/../Data subdirectory.
2211
2212AC_DEFUN([AC_COIN_DATA_PATH],
2213[AC_MSG_CHECKING([absolute path to data directory $1])
2214
2215AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2216
2217if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2218  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2219fi
2220
2221# Under Cygwin, use Windows path.  Add separator
2222case $build in
2223  *-cygwin*)
2224    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2225    ;;
2226  *)
2227    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2228    ;;
2229esac
2230
2231if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2232  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2233            [Define to absolute path for Data subdirectory $1])
2234  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2235else
2236  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2237fi
2238]) # AC_COIN_HAS_DATA
2239
2240###########################################################################
2241#                          COIN_EXAMPLE_FILES                             #
2242###########################################################################
2243
2244# This macro determines the names of the example files (using the
2245# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2246# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2247# creates soft links to the example files.
2248
2249AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2250[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
2251AC_REQUIRE([AC_COIN_CHECK_VPATH])
2252files=`cd $srcdir; ls $1`
2253# We need to do the following loop to make sure that are no newlines
2254# in the variable
2255for file in $files; do
2256  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2257done
2258if test $coin_vpath_config = yes; then
2259  lnkcmd=
2260  if test "$enable_doscompile" != no; then
2261    lnkcmd=cp
2262  fi
2263  case "$CC" in
2264    cl* | */cl* | CL* | */CL*)
2265      lnkcmd=cp ;;
2266  esac
2267  if test "$lnkcmd" = cp; then
2268    AC_MSG_NOTICE([Copying example files ($1)])
2269  else
2270    AC_PROG_LN_S
2271    AC_MSG_NOTICE([Creating links to the example files ($1)])
2272    lnkcmd="$LN_S"
2273  fi
2274  for file in $EXAMPLE_FILES; do
2275    rm -f $file
2276    $lnkcmd $srcdir/$file $file
2277  done
2278  EXAMPLE_CLEAN_FILES='$1'
2279else
2280  EXAMPLE_CLEAN_FILES=
2281fi
2282
2283# In case there are compressed files, we create a variable with the
2284# uncompressed names
2285EXAMPLE_UNCOMPRESSED_FILES=
2286for file in $EXAMPLE_FILES; do
2287  case $file in
2288    *.gz)
2289      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2290      ;;
2291  esac
2292done
2293
2294AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2295AC_SUBST(EXAMPLE_FILES)
2296AC_SUBST(EXAMPLE_CLEAN_FILES)
2297]) #AC_COIN_EXAMPLE_FILES
2298
2299###########################################################################
2300#                            COIN_HAS_PROJECT                             #
2301###########################################################################
2302
2303# This macro sets up usage of a Coin package.  It defines the
2304# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
2305# object directory of the package, respectively.  It also defines
2306# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
2307# argument should be the name (Pkg) of the project (in correct lower
2308# and upper case)
2309
2310AC_DEFUN([AC_COIN_HAS_PROJECT],
2311[AC_MSG_CHECKING([for COIN project $1])
2312
2313# First check, if the sub-project is actually available (ToDo: allow
2314# other locations)
2315
2316m4_tolower(coin_has_$1)=unavailable
2317if test x"$COIN_SKIP_PROJECTS" != x; then
2318  for dir in $COIN_SKIP_PROJECTS; do
2319    if test $dir = $1; then
2320      m4_tolower(coin_has_$1)=skipping
2321    fi
2322  done
2323fi
2324
2325if test $m4_tolower(coin_has_$1) != skipping; then
2326  if test $PACKAGE_TARNAME = m4_tolower($1); then
2327    m4_tolower(coin_has_$1)=.
2328  else
2329    if test -d $srcdir/../$1; then
2330      m4_tolower(coin_has_$1)=../$1
2331    fi
2332  fi
2333fi
2334
2335if test $m4_tolower(coin_has_$1) != unavailable &&
2336   test $m4_tolower(coin_has_$1) != skipping; then
2337  # Set the #define if the component is available
2338  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
2339
2340  # Set the variables for source and object code location
2341  AC_SUBST(m4_toupper($1SRCDIR))
2342  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
2343  AC_SUBST(m4_toupper($1OBJDIR))
2344  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
2345fi
2346
2347  # Define the Makefile conditional
2348AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2349               [test $m4_tolower(coin_has_$1) != unavailable &&
2350                test $m4_tolower(coin_has_$1) != skipping])
2351AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2352]) # AC_COIN_HAS_PROJECT
2353
2354###########################################################################
2355#                        COIN_HAS_USER_LIBRARY                            #
2356###########################################################################
2357# This macro sets up usage of a user library with header files. The assumption
2358# is that the header file(s) and library do not reside in standard system
2359# directories, hence both the include directory and link flags must be
2360# specified. There are two mandatory arguments and two optional arguments.
2361#
2362# The first argument (mandatory) should be a name (LibraryName) for the
2363# library.  The second argument (mandatory) should be an abbreviation in
2364# upper case letters (LBRY) for the library. Ultimately, the macro will
2365# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2366# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2367# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2368# directory containing include files for the library. LBRYLIB should specify
2369# the flags necessary to link to the library. A variable coin_has_lbry will
2370# be set to true or false, as appropriate. A variable lbry_libcheck will be
2371# be set to yes or no; no indicates link checks should not be attempted.
2372#
2373# The macro defines three configure arguments, --with-libraryname-incdir,
2374# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2375# LibraryName to lower case.
2376#
2377# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2378# part of the configure command using --with-libraryname-incdir and
2379# --with-libraryname-lib, respectively. Command line arguments override
2380# environment variables.
2381#
2382# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2383# macro will check for the presence of the file. If a fourth argument is given,
2384# it should specify a function name, `fname'.  The macro will attempt to link a
2385# trivial program containing a parameterless call to the function, `fname()',
2386# using the LBRYLIB flags. The link check uses C as the language; this has been
2387# adequate to date but has limitations. It is possible to disable the link
2388# check by specifying --disable-libraryname-libcheck. This is a workaround for
2389# instances where the link check does not work properly, for whatever reason.
2390# If you're trying to link to a Fortran library, consider using F77_FUNC or
2391# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2392# library, you're on your own unless the library declares some function with
2393# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2394# name.
2395
2396AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
2397[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2398  AC_MSG_CHECKING(if user provides library for $1)
2399
2400# Check for header file directory
2401
2402  AC_ARG_WITH(m4_tolower($1)-incdir,
2403      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2404                     [specify the header file directory for library $1]),
2405      [$2INCDIR=`cd $withval; pwd`])
2406
2407# Check for library directory
2408
2409  AC_ARG_WITH(m4_tolower($1)-lib,
2410      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2411                     [specify the flags used to link with the library $1]),
2412      [$2LIB=$withval])
2413
2414# Switch to disable library check if requested
2415
2416  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2417      AS_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2418                     [use disable-m4_tolower($1)-libcheck to skip the link
2419                      check at configuration time]),
2420      [m4_tolower($1)_libcheck=$enableval],
2421      [m4_tolower($1)_libcheck=yes])
2422
2423# At this point, if we're going to use the library, both LBRYINCDIR and
2424# LBRYLIB must be defined and not empty.
2425
2426  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2427    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2428      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.])
2429    fi
2430    m4_tolower(coin_has_$2)=true
2431    AC_MSG_RESULT(yes)
2432  else
2433    m4_tolower(coin_has_$2)=false
2434    AC_MSG_RESULT(no)
2435  fi
2436
2437# If we have instructions for use, consider header and link checks.
2438
2439  if test $m4_tolower(coin_has_$2) = true; then
2440
2441# If argument 3 (file) is given, check for the file. Typically this will be a
2442# header file, but that's not assumed.
2443
2444    m4_ifval([$3],
2445        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2446             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2447
2448# Now see if we can link the function. There are arguments for and against
2449# assuming argument 3 is a header file declaring the function. A correct
2450# function declaration is the main argument in favour. Having to cope with
2451# possible dependencies or other oddities are the main arguments against.
2452# Force the use of C as the best single choice amongst C++, C, and Fortran.
2453# Obviously, this has limits.
2454
2455    m4_ifvaln([$4],
2456        [if test x"$m4_tolower($1)_libcheck" != xno; then
2457           coin_save_LIBS="$LIBS"
2458           LIBS="$$2LIB $ADDLIBS"
2459           coin_$2_link=no
2460           AC_LANG_PUSH(C)
2461           for fnm in $4 ; do
2462             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2463             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2464                 [AC_MSG_RESULT(yes)
2465                  coin_$2_link=yes
2466                  break],
2467                 [AC_MSG_RESULT(no)])
2468           done
2469           AC_LANG_POP(C)
2470           if test x"$coin_$2_link" = xyes ; then
2471             LIBS="$coin_save_LIBS"
2472           else
2473             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2474           fi
2475         fi])
2476
2477# If we make it this far, we've verified the file and linked the function. Add
2478# the necessary link flags to ADDLIBS and define the preprocessor symbol
2479# COIN_HAS_LBRY.
2480
2481    ADDLIBS="$$2LIB $ADDLIBS"
2482    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2483  fi
2484
2485# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2486# automake conditional. These actions must occur unconditionally.
2487
2488  AC_SUBST($2INCDIR)
2489  AC_SUBST($2LIB)
2490  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2491]) #AC_COIN_HAS_USER_LIBRARY
2492
2493###########################################################################
2494#                               COIN_HAS_ASL                              #
2495###########################################################################
2496
2497# This macro checks if the user has provide arguments that say where
2498# the precompiled ASL files should be found (with the --with-asldir
2499# flag).  If this is not the case, we check if the ThirdParty/ASL
2500# directory has been configured, which indicates that the files will
2501# be in that directory and can be used.
2502
2503AC_DEFUN([AC_COIN_HAS_ASL],
2504[coin_aslobjdir=../ThirdParty/ASL
2505coin_aslsrcdir=$srcdir/$coin_aslobjdir
2506
2507# Determine the name of the ASL library
2508case "$CC" in
2509  cl* | */cl* | CL* | */CL*)
2510    ampllib=amplsolv.lib ;;
2511  *)
2512    ampllib=amplsolver.a ;;
2513esac
2514
2515AC_ARG_WITH([asldir],
2516            AC_HELP_STRING([--with-asldir],
2517                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
2518            [use_asldir=$withval], [use_asldir=])
2519
2520if test "$use_asldir" = BUILD; then
2521  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2522    # If we are configuring ThirdParty/ASL, don't check
2523    if test -r $coin_aslobjdir/.MakeOk; then :; else
2524      AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])
2525    fi
2526  fi
2527elif test -z "$use_asldir"; then
2528 # try to find sources - if not given don't compile
2529  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2530    if test -r $coin_aslobjdir/.MakeOk; then
2531      use_asldir=BUILD
2532    else
2533      use_asldir=no
2534    fi
2535  else
2536    use_asldir=no
2537  fi
2538elif test "$use_asldir" != "no"; then
2539  AC_COIN_CHECK_FILE([$use_asldir/$ampllib],[],
2540                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
2541  AC_COIN_CHECK_FILE([$use_asldir/asl.h],[],
2542                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
2543  use_asldir=`cd $use_asldir; pwd`
2544  case $build in
2545    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
2546  esac
2547fi
2548
2549# Variable containing ASL library (including full path)
2550AC_SUBST(ASLLIB)
2551# Variable containing flags for including ASL header files
2552AC_SUBST(ASL_CPPFLAGS)
2553
2554if test "$use_asldir" = BUILD; then
2555  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
2556  ASLLIB=`$CYGPATH_W $coin_aslobjdir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2557  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
2558  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir | sed -e sX\\\\\\\\X/Xg`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers | sed -e sX\\\\\\\\X/Xg`
2559elif test "$use_asldir" != no; then
2560  ASLLIB=`$CYGPATH_W $use_asldir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2561  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir | sed -e sX\\\\\\\\X/Xg`
2562fi
2563
2564if test "$use_asldir" != no; then
2565  AC_LANG_PUSH(C)
2566  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
2567  coin_has_asl=yes
2568  AC_DEFINE([COIN_HAS_ASL],[1],
2569            [If defined, the Ampl Solver Library is available.])
2570  AC_LANG_POP(C)
2571else
2572  coin_has_asl=no
2573fi
2574AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
2575]) # AC_COIN_HAS_ASL
2576
2577###########################################################################
2578#                            COIN_TRY_FLINK                               #
2579###########################################################################
2580
2581# Auxilliary macro to test if a Fortran function name can be linked,
2582# given the current settings of LIBS.  We determine from the context, what
2583# the currently active programming language is, and cast the name accordingly.
2584# The first argument is the name of the function/subroutine, in small letters,
2585# the second argument are the actions taken when the test works, and the
2586# third argument are the actions taken if the test fails.
2587
2588AC_DEFUN([AC_COIN_TRY_FLINK],
2589[case $ac_ext in
2590  f)
2591    AC_TRY_LINK(,[      call $1],[$2],[$3])
2592    ;;
2593  c)
2594    AC_F77_FUNC($1,cfunc$1)
2595    if test x"$coin_need_flibs" = xyes; then
2596      flink_try=no;
2597    else
2598      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2599                  [flink_try=yes],[flink_try=no])
2600    fi
2601    if test $flink_try = yes; then
2602      $2
2603    else
2604      if test x"$FLIBS" != x; then
2605        flink_save_libs="$LIBS"
2606        LIBS="$LIBS $FLIBS"
2607        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2608                    [LIBS="$flink_save_libs"
2609                     $2
2610                     coin_need_flibs=yes],
2611                    [LIBS="$flink_save_libs"
2612                     $3])
2613      else
2614        $3
2615      fi
2616    fi
2617    ;;
2618  cc|cpp)
2619    AC_F77_FUNC($1,cfunc$1)
2620    if test x"$coin_need_flibs" = xyes; then
2621      flink_try=no;
2622    else
2623      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2624                  [flink_try=yes],[flink_try=no])
2625    fi
2626    if test $flink_try = yes; then
2627      $2
2628    else
2629      if test x"$FLIBS" != x; then
2630        flink_save_libs="$LIBS"
2631        LIBS="$LIBS $FLIBS"
2632        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2633                    [LIBS="$flink_save_libs"
2634                     $2
2635                     coin_need_flibs=yes],
2636                    [LIBS="$flink_save_libs"
2637                     $3])
2638      else
2639        $3
2640      fi
2641    fi
2642    ;;
2643esac
2644]) # AC_COIN_TRY_FLINK
2645
2646###########################################################################
2647#                             COIN_HAS_BLAS                               #
2648###########################################################################
2649
2650# This macro checks for a library containing the BLAS library.  It
2651# tries standard libraries, and if none is found to be working, it
2652# checks whether the BLAS ThirdParty/Blas directory has been configured.
2653# It adds to ADDLIBS any flags required to link with an externally provided
2654# BLAS.  It defines the makefile conditional and preprocessor macro
2655# COIN_HAS_BLAS, if blas is available, and it defines the makefile conditional
2656# COIN_BUILD_BLAS, if blas is compiled within COIN.
2657
2658AC_DEFUN([AC_COIN_HAS_BLAS],
2659[if test "$PACKAGE_NAME" = ThirdPartyBlas || test "$PACKAGE_NAME" = ThirdPartyLapack; then
2660  coin_blasobjdir=../Blas
2661else
2662  coin_blasobjdir=../ThirdParty/Blas
2663fi
2664coin_blassrcdir=$srcdir/$coin_blasobjdir
2665
2666AC_ARG_WITH([blas],
2667            AC_HELP_STRING([--with-blas],
2668                           [specify BLAS library (or BUILD for compilation)]),
2669            [use_blas=$withval], [use_blas=])
2670
2671MAKEOKFILE=.MakeOk
2672# Check if user supplied option makes sense
2673if test x"$use_blas" != x; then
2674  if test "$use_blas" = "BUILD"; then
2675    # Don't check for course code if this is executed in ThirdParty/Blas
2676    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2677      if test -r $coin_blasobjdir/.MakeOk; then :; else
2678        AC_MSG_ERROR([option \"BUILD\" specified for Blas, but $coin_blasobjdir directory is not properly configured])
2679      fi
2680    fi
2681  elif test "$use_blas" != no ; then
2682    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2683    LIBS="$use_blas $LIBS"
2684    ADDLIBS="$use_blas $ADDLIBS"
2685    AC_COIN_TRY_FLINK([daxpy],
2686                      [AC_MSG_RESULT([yes])],
2687                      [AC_MSG_RESULT([no])
2688                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2689  fi
2690else
2691# Try to autodetect the library for blas based on build system
2692  #AC_MSG_CHECKING([default locations for BLAS])
2693  skip_lblas_check=no
2694  case $build in
2695    *-sgi-*)
2696      SAVE_LIBS="$LIBS"
2697      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2698      LIBS="-lcomplib.sgimath $LIBS"
2699      AC_COIN_TRY_FLINK([daxpy],
2700                        [AC_MSG_RESULT([yes])
2701                         use_blas=-lcomplib.sgimath;
2702                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2703                        [AC_MSG_RESULT([no])
2704                         SAVE_LIBS="$LIBS"])
2705      ;;
2706    *-sun-*)
2707      SAVE_LIBS="$LIBS"
2708      AC_MSG_CHECKING([whether -xlic_lib=sunperf has BLAS])
2709      LIBS="-xlic_lib=sunperf $LIBS"
2710      AC_COIN_TRY_FLINK([daxpy],
2711                        [AC_MSG_RESULT([yes])
2712                         use_blas='-xlic_lib=sunperf'
2713                         ADDLIBS="-xlic_lib=sunperf $ADDLIBS"],
2714                        [AC_MSG_RESULT([no])
2715                         LIBS="$SAVE_LIBS"])
2716      ;;
2717# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
2718# library will want to link with cygwin, hence won't run standalone in DOS.
2719    *-cygwin*)
2720      if test "$enable_doscompile" = mingw; then
2721        skip_lblas_check=yes
2722      fi
2723      ;;
2724  esac
2725
2726  if test -z "$use_blas" && test $skip_lblas_check = no; then
2727    SAVE_LIBS="$LIBS"
2728    AC_MSG_CHECKING([whether -lblas has BLAS])
2729    LIBS="-lblas $LIBS"
2730    AC_COIN_TRY_FLINK([daxpy],
2731                      [AC_MSG_RESULT([yes])
2732                       ADDLIBS="-lblas $ADDLIBS"
2733                       use_blas='-lblas'],
2734                      [AC_MSG_RESULT([no])
2735                       LIBS="$SAVE_LIBS"])
2736  fi
2737
2738# If we have no other ideas, consider building BLAS.
2739  if test -z "$use_blas"; then
2740    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2741      if test -r $coin_blasobjdir/.MakeOk; then
2742        use_blas=BUILD
2743      fi
2744    fi
2745  fi
2746fi
2747
2748if test "$use_blas" = BUILD; then
2749  coin_need_flibs=yes
2750fi
2751
2752AM_CONDITIONAL([COIN_HAS_BLAS],[test x"$use_blas" != x])
2753AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
2754
2755if test x"$use_blas" = x || test "$use_blas" = no; then
2756  coin_has_blas=no
2757else
2758  coin_has_blas=yes
2759  AC_DEFINE([COIN_HAS_BLAS],[1],
2760            [If defined, the BLAS Library is available.])
2761fi
2762]) # AC_COIN_HAS_BLAS
2763
2764###########################################################################
2765#                            COIN_HAS_LAPACK                              #
2766###########################################################################
2767
2768# This macro checks for a library containing the LAPACK library.  It
2769# tries standard libraries, and if none is found to be working, it
2770# checks whether the LAPACK ThirdParty/Lapack directory has been
2771# configured.  It adds to ADDLIBS any flags required to link with an
2772# externally provided LAPACK.  It defines the makefile conditional and
2773# preprocessor macro COIN_HAS_LAPACK, if lapack is available, and it
2774# defines the makefile conditional COIN_BUILD_LAPACK, if lapack is
2775# compiled within COIN.
2776
2777AC_DEFUN([AC_COIN_HAS_LAPACK],
2778[coin_lapackobjdir=../ThirdParty/Lapack
2779coin_lapacksrcdir=$srcdir/$coin_lapackobjdir
2780
2781AC_ARG_WITH([lapack],
2782            AC_HELP_STRING([--with-lapack],
2783                           [specify LAPACK library (or BUILD for compilation)]),
2784            [use_lapack=$withval], [use_lapack=])
2785
2786# Check if user supplied option makes sense
2787if test x"$use_lapack" != x; then
2788  if test "$use_lapack" = "BUILD"; then
2789    # Don't check for course code if this is executed in ThirdParty/Lapack
2790    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
2791      if test -r $coin_lapackobjdir/.MakeOk; then :; else
2792        AC_MSG_ERROR([option \"BUILD\" specified for LAPACK, but $coin_lapackobjdir directory is not configured])
2793      fi
2794    fi
2795  else
2796    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
2797    LIBS="$use_lapack $LIBS"
2798    ADDLIBS="$use_lapack $ADDLIBS"
2799    AC_COIN_TRY_FLINK([dsyev],
2800                      [AC_MSG_RESULT([yes])],
2801                      [AC_MSG_RESULT([no])
2802                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
2803  fi
2804else
2805  if test x$coin_has_blas = xyes; then
2806    # First try to see if LAPACK is already available with BLAS library
2807    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
2808    AC_COIN_TRY_FLINK([dsyev],
2809                      [AC_MSG_RESULT([yes]); use_lapack=ok],
2810                      [AC_MSG_RESULT([no])])
2811  fi
2812  skip_llapack_check=no
2813  if test -z "$use_lapack"; then
2814    # Try to autodetect the library for lapack based on build system
2815    case $build in
2816      *-sgi-*)
2817        SAVE_LIBS="$LIBS"
2818        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
2819        LIBS="-lcomplib.sgimath $LIBS"
2820        AC_COIN_TRY_FLINK([dsyev],
2821                          [AC_MSG_RESULT([yes])
2822                           use_lapack=-lcomplib.sgimath;
2823                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2824                          [AC_MSG_RESULT([no])
2825                           SAVE_LIBS="$LIBS"])
2826        ;;
2827      *-sun-*)
2828        SAVE_LIBS="$LIBS"
2829        AC_MSG_CHECKING([whether -xlic_lib=sunperf has LAPACK])
2830        LIBS="-xlic_lib=sunperf $LIBS"
2831        AC_COIN_TRY_FLINK([dsyev],
2832                          [AC_MSG_RESULT([yes])
2833                           use_lapack='-xlic_lib=sunperf'
2834                           ADDLIBS="-xlic_lib=sunperf $ADDLIBS"],
2835                          [AC_MSG_RESULT([no])
2836                           LIBS="$SAVE_LIBS"])
2837        ;;
2838# On cygwin, do this check only if doscompile is disabled. The prebuilt library
2839# will want to link with cygwin, hence won't run standalone in DOS.
2840      *-cygwin*)
2841        if test "$enable_doscompile" = mingw; then
2842          skip_llapack_check=yes
2843        fi
2844        ;;
2845    esac
2846  fi
2847
2848  if test -z "$use_lapack" && test $skip_llapack_check = no; then
2849    SAVE_LIBS="$LIBS"
2850    AC_MSG_CHECKING([whether -llapack has LAPACK])
2851    LIBS="-llapack $LIBS"
2852    AC_COIN_TRY_FLINK([dsyev],
2853                      [AC_MSG_RESULT([yes])
2854                       ADDLIBS="-llapack $ADDLIBS"
2855                       use_lapack='-llapack'],
2856                      [AC_MSG_RESULT([no])
2857                       LIBS="$SAVE_LIBS"])
2858  fi
2859
2860# If we have no other ideas, consider building LAPACK.
2861  if test -z "$use_lapack"; then
2862    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
2863      if test -r $coin_lapackobjdir/.MakeOk; then
2864        use_lapack=BUILD
2865      fi
2866    fi
2867  fi
2868fi
2869
2870if test "$use_lapack" = BUILD; then
2871  coin_need_flibs=yes
2872fi
2873
2874AM_CONDITIONAL([COIN_HAS_LAPACK],[test x"$use_lapack" != x])
2875AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
2876
2877if test x"$use_lapack" = x; then
2878  coin_has_lapack=no
2879else
2880  coin_has_lapack=yes
2881  AC_DEFINE([COIN_HAS_LAPACK],[1],
2882            [If defined, the LAPACK Library is available.])
2883fi
2884]) # AC_COIN_HAS_LAPACK
2885
2886###########################################################################
2887#                            COIN_HAS_MUMPS                               #
2888###########################################################################
2889
2890# This macro checks for a library containing the MUMPS library.  It
2891# checks if the user has provided an argument for the MUMPS library,
2892# and if not, it checks whether the MUMPS ThirdParty/Mumps directory has
2893# been configured.  It adds to ADDLIBS any flags required to link with
2894# an externally provided MUMPS.  It defines the makefile conditional
2895# and preprocessor macro COIN_HAS_MUMPS, if MUMPS is available, and it
2896# defines the makefile conditional COIN_BUILD_MUMPS, if MUMPS is
2897# compiled within COIN.
2898
2899AC_DEFUN([AC_COIN_HAS_MUMPS],
2900[
2901if test "$PACKAGE_NAME" = ThirdPartyMumps; then
2902  coin_mumpsobjdir=../Mumps
2903else
2904  coin_mumpsobjdir=../ThirdParty/Mumps
2905fi
2906coin_mumpssrcdir=$abs_source_dir/$coin_mumpsobjdir
2907
2908MAKEOKFILE=.MakeOk
2909
2910AC_ARG_WITH([mumps-dir],
2911            AC_HELP_STRING([--with-mumps-dir],
2912                           [specify directory where MUMPS is installed]),
2913            [use_mumps="$withval"], [use_mumps=no])
2914
2915if test "$use_mumps" != "no"; then
2916  if test -d $use_mumps; then :; else
2917    AC_MSG_ERROR([User provided MUMPS directory $use_mumps does not exist.])
2918  fi
2919  mumps_dir=`cd $use_mumps; pwd`
2920
2921  # library extension
2922  AC_LANG_PUSH(C)
2923  save_LIBS="$LIBS"
2924  LIBS="$LIBS $FLIBS"
2925  AC_CHECK_LIB([pthread],[pthread_create],[LIBS="-lpthread $save_LIBS"; ADDLIBS="-lpthread $ADDLIBS"],[LIBS="$save_LIBS"])
2926  AC_LANG_POP(C)
2927
2928  case "$CC" in
2929    cl* | */cl* | CL* | */CL*)
2930         libe=lib ;;
2931      *) libe=a ;;
2932  esac
2933
2934  # Check if hearders are there
2935  AC_COIN_CHECK_FILE([$mumps_dir/include/dmumps_c.h],
2936                     [],
2937                     [AC_MSG_ERROR([I cannot find headers for MUMPS])])
2938  LIBS="$mumps_dir/lib/libdmumps.$libe $mumps_dir/lib/libpord.$libe $mumps_dir/libseq/libmpiseq.$libe $LIBS"
2939  ADDLIBS="$mumps_dir/lib/libdmumps.$libe $mumps_dir/lib/libpord.$libe $mumps_dir/libseq/libmpiseq.$libe $ADDLIBS"
2940  # Check if MUMPS actually works
2941  AC_LANG_PUSH(C)
2942  save_LIBS="$LIBS"
2943  LIBS="$LIBS $FLIBS"
2944  AC_TRY_LINK([void dmumps_c();],[dmumps_c()],[],
2945              [AC_MSG_ERROR([User provided MUMPS library doesn't work])])
2946  LIBS="$save_LIBS"
2947  AC_LANG_POP(C)
2948  coin_mumpssrcdir="$mumps_dir"
2949
2950else
2951  use_mumps=BUILD
2952
2953  # Check if the MUMPS' ThirdParty project has been configured
2954  if test "$PACKAGE_NAME" != ThirdPartyMumps; then
2955    if test -r $coin_mumpsobjdir/.MakeOk; then
2956      use_mumps=BUILD
2957      # Mumps needs pthreads
2958      AC_LANG_PUSH(C)
2959      save_LIBS="$LIBS"
2960      LIBS="$LIBS $FLIBS"
2961      AC_CHECK_LIB([pthread],[pthread_create],[LIBS="-lpthread $save_LIBS"; ADDLIBS="-lpthread $ADDLIBS"],[LIBS="save_LIBS"])
2962      AC_LANG_POP(C)
2963    else
2964      use_mumps=
2965    fi
2966  fi
2967fi
2968
2969if test x"$use_mumps" != x; then
2970
2971  # and we need the Fortran runtime libraries if we want to link with C/C++
2972  coin_need_flibs=yes
2973
2974  MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $coin_mumpssrcdir/MUMPS/libseq\` -I\`\$(CYGPATH_W) $coin_mumpssrcdir/MUMPS/include\`"
2975  AC_SUBST(MUMPS_INCFLAGS)
2976fi
2977
2978AM_CONDITIONAL([COIN_HAS_MUMPS],[test x"$use_mumps" != x])
2979AM_CONDITIONAL([COIN_BUILD_MUMPS],[test "$use_mumps" = BUILD])
2980
2981AC_MSG_CHECKING([whether MUMPS is available])
2982
2983if test x"$use_mumps" = x || test "$use_mumps" = no; then
2984  coin_has_mumps=no
2985else
2986  coin_has_mumps=yes
2987  AC_DEFINE([COIN_HAS_MUMPS],[1],
2988            [If defined, the MUMPS Library is available.])
2989fi
2990AC_MSG_RESULT([$coin_has_mumps])
2991]) # AC_COIN_HAS_MUMPS
2992
2993###########################################################################
2994#                             COIN_HAS_GLPK                               #
2995###########################################################################
2996#
2997# This macro checks for the GLPK package. GLPK provides two capabilities,
2998# an LP and MIP solver (GLPK) and the GNU Mathprog modelling language (GMPL).
2999# The macro checks for either Glpk or Gmpl, according to the value specified as
3000# the parameter. Use one of Glpk or Gmpl. Use *exactly* these strings, eh?
3001#
3002#
3003# The macro first uses COIN_HAS_USER_LIBRARY to see if the user has specified
3004# a preexisting library (this allows the use of any glpk version, if the user
3005# is fussy). The macro then checks for ThirdParty/Glpk.
3006#
3007# This macro will define the following variables for Glpk:
3008#   coin_has_glpk       true or false
3009#   GLPKLIB             location of the glpk library at build time; this is
3010#                       added to ADDLIBS
3011#   GLPKINCDIR          location of glpk include files
3012#   COIN_HAS_GLPK       Preprocessor symbol, defined to 1
3013#   COIN_HAS_GLPK       Automake conditional
3014#   COIN_BUILD_GLPK     Automake conditional, defined only if Glpk is to be
3015#                       built in ThirdParty/Glpk
3016#
3017# With the exception of COIN_BUILD_GLPK, an identical set of variables is
3018# defined for Gmpl.
3019
3020AC_DEFUN([AC_COIN_HAS_GLPK],
3021[
3022if test "$PACKAGE_NAME" = ThirdPartyGlpk; then
3023  coin_glpkobjdir=../Glpk
3024else
3025  coin_glpkobjdir=../ThirdParty/Glpk
3026fi
3027coin_glpksrcdir=$abs_source_dir/$coin_glpkobjdir
3028
3029use_thirdpartyglpk=no
3030
3031# Check for the requested component. If the user specified an external glpk
3032# library don't force a ThirdParty build, let the error propagate.
3033
3034m4_if([$1],[Glpk],
3035[AC_COIN_HAS_USER_LIBRARY([Glpk],[GLPK],[glpk.h],
3036    [_glp_lpx_simplex glp_lpx_simplex])
3037 if test x"$coin_has_glpk" = xfalse && test x"$GLPKLIB" = x ; then
3038   use_thirdpartyglpk=try
3039 fi])
3040m4_if([$1],[Gmpl],
3041[AC_COIN_HAS_USER_LIBRARY([Gmpl],[GMPL],[glpmpl.h],
3042    [_glp_mpl_initialize glp_mpl_initialize])
3043 if test x"$coin_has_gmpl" = xfalse && test x"$GMPLLIB" = x ; then
3044   use_thirdpartyglpk=try
3045 fi])
3046
3047# If the user has supplied an external library, use it. Otherwise, consider
3048# a build in ThirdParty/Glpk. If we build, assume we get both glpk and gmpl.
3049
3050if test x"$use_thirdpartyglpk" = xtry ; then
3051  MAKEOKFILE=.MakeOk
3052  # Check if the Glpk's ThirdParty project has been configured
3053  if test "$PACKAGE_NAME" != ThirdPartyGlpk; then
3054    if test -r $coin_glpkobjdir/.MakeOk; then
3055      use_thirdpartyglpk=build
3056    else
3057      use_thirdpartyglpk=no
3058    fi
3059  else
3060    use_thirdpartyglpk=build
3061  fi
3062
3063# If we're building, set the library and include directory variables, create a
3064# preprocessor symbol, define a variable that says we're using glpk/gmpl, and
3065# another to indicate a link check is a bad idea (hard to do before the library
3066# exists).
3067
3068  if test x"$use_thirdpartyglpk" = xbuild ; then
3069    m4_toupper($1LIB)=`cd $coin_glpkobjdir; pwd`/libcoinglpk.la
3070    AC_SUBST(m4_toupper($1LIB))
3071    ADDLIBS="$m4_toupper($1LIB) $ADDLIBS"
3072    m4_toupper($1INCDIR)="$coin_glpksrcdir/glpk/include"
3073    AC_SUBST(m4_toupper($1INCDIR))
3074    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],
3075              [Define to 1 if $1 package is available])
3076    m4_tolower(coin_has_$1)=true
3077    m4_tolower($1_libcheck)=no
3078    AC_MSG_NOTICE([Using $1 in ThirdParty/Glpk])
3079  fi
3080fi
3081
3082# Define the necessary automake conditionals.
3083
3084AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3085               [test x"$m4_tolower(coin_has_$1)" = xtrue])
3086AM_CONDITIONAL([COIN_BUILD_GLPK],[test x"$use_thirdpartyglpk" = xbuild])
3087
3088]) # AC_COIN_HAS_GLPK
Note: See TracBrowser for help on using the repository browser.