source: trunk/coin.m4 @ 419

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

making COIN_HEADERS a noop thingy again

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