source: stable/0.5/coin.m4 @ 1591

Last change on this file since 1591 was 1591, checked in by lou, 10 years ago

Add code to PROJECTDIR_INIT to define XXX_VERSION. Assumes the first parameter
is the project name. Nothing is defined if the first parameter is the null
string.

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