source: stable/0.5/coin.m4 @ 799

Last change on this file since 799 was 799, checked in by andreasw, 14 years ago

synchronized BuildTools?/stable/0.5 with trunk rev 798

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