source: trunk/coin.m4 @ 325

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

added compile_f2c tool to compiler Fortran source with f2c and MSVC compiler; a few fixes to Cygwin

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