source: trunk/coin.m4 @ 156

Last change on this file since 156 was 156, checked in by andreasw, 13 years ago

make sure trunk has stable version of coin.m4

  • Property svn:keywords set to Author Date Id Revision
File size: 78.3 KB
Line 
1# Copyright (C) 2006 International Business Machines..
2# All Rights Reserved.
3# This file is distributed under the Common Public License.
4#
5## $Id: coin.m4 156 2006-11-29 20:33:53Z andreasw $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_PREREQ(2.59)
14
15###########################################################################
16#                           COIN_MAIN_SUBDIRS                             #
17###########################################################################
18
19# This macro sets up the recursion into configure scripts into
20# subdirectories.  Each possible subdirectory should be provided as a
21# new argument to this macro.  The current limit is 10 subdirectories.
22# This automatically also checks for the Data subdirectory.
23
24AC_DEFUN([AC_COIN_MAIN_SUBDIRS],
25[AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
26
27m4_ifvaln([$1],[AC_MSG_CHECKING(whether directory $1 is available)
28                coin_skip=no
29                if test x"$COIN_SKIP_PROJECTS" != x; then
30                  for dir in $COIN_SKIP_PROJECTS; do
31                    if test $dir = $1; then
32                      coin_skip=yes
33                    fi
34                  done
35                fi
36                if test $coin_skip = yes; then
37                  AC_MSG_RESULT(skipping)
38                elif test -r $srcdir/$1/configure; then
39                  coin_subdirs="$coin_subdirs $1"
40                  AC_MSG_RESULT(yes)
41                  AC_CONFIG_SUBDIRS($1)
42                else
43                  AC_MSG_RESULT(no)
44                fi])
45m4_ifvaln([$2],[AC_MSG_CHECKING(whether directory $2 is available)
46                coin_skip=no
47                if test x"$COIN_SKIP_PROJECTS" != x; then
48                  for dir in $COIN_SKIP_PROJECTS; do
49                    if test $dir = $2; then
50                      coin_skip=yes
51                    fi
52                  done
53                fi
54                if test $coin_skip = yes; then
55                  AC_MSG_RESULT(skipping)
56                elif test -r $srcdir/$2/configure; then
57                  coin_subdirs="$coin_subdirs $2"
58                  AC_MSG_RESULT(yes)
59                  AC_CONFIG_SUBDIRS($2)
60                else
61                  AC_MSG_RESULT(no)
62                fi])
63m4_ifvaln([$3],[AC_MSG_CHECKING(whether directory $3 is available)
64                coin_skip=no
65                if test x"$COIN_SKIP_PROJECTS" != x; then
66                  for dir in $COIN_SKIP_PROJECTS; do
67                    if test $dir = $3; then
68                      coin_skip=yes
69                    fi
70                  done
71                fi
72                if test $coin_skip = yes; then
73                  AC_MSG_RESULT(skipping)
74                elif test -r $srcdir/$3/configure; then
75                  coin_subdirs="$coin_subdirs $3"
76                  AC_MSG_RESULT(yes)
77                  AC_CONFIG_SUBDIRS($3)
78                else
79                  AC_MSG_RESULT(no)
80                fi])
81m4_ifvaln([$4],[AC_MSG_CHECKING(whether directory $4 is available)
82                coin_skip=no
83                if test x"$COIN_SKIP_PROJECTS" != x; then
84                  for dir in $COIN_SKIP_PROJECTS; do
85                    if test $dir = $4; then
86                      coin_skip=yes
87                    fi
88                  done
89                fi
90                if test $coin_skip = yes; then
91                  AC_MSG_RESULT(skipping)
92                elif test -r $srcdir/$4/configure; then
93                  coin_subdirs="$coin_subdirs $4"
94                  AC_MSG_RESULT(yes)
95                  AC_CONFIG_SUBDIRS($4)
96                else
97                  AC_MSG_RESULT(no)
98                fi])
99m4_ifvaln([$5],[AC_MSG_CHECKING(whether directory $5 is available)
100                coin_skip=no
101                if test x"$COIN_SKIP_PROJECTS" != x; then
102                  for dir in $COIN_SKIP_PROJECTS; do
103                    if test $dir = $5; then
104                      coin_skip=yes
105                    fi
106                  done
107                fi
108                if test $coin_skip = yes; then
109                  AC_MSG_RESULT(skipping)
110                elif test -r $srcdir/$5/configure; then
111                  coin_subdirs="$coin_subdirs $5"
112                  AC_MSG_RESULT(yes)
113                  AC_CONFIG_SUBDIRS($5)
114                else
115                  AC_MSG_RESULT(no)
116                fi])
117m4_ifvaln([$6],[AC_MSG_CHECKING(whether directory $6 is available)
118                coin_skip=no
119                if test x"$COIN_SKIP_PROJECTS" != x; then
120                  for dir in $COIN_SKIP_PROJECTS; do
121                    if test $dir = $6; then
122                      coin_skip=yes
123                    fi
124                  done
125                fi
126                if test $coin_skip = yes; then
127                  AC_MSG_RESULT(skipping)
128                elif test -r $srcdir/$6/configure; then
129                  coin_subdirs="$coin_subdirs $6"
130                  AC_MSG_RESULT(yes)
131                  AC_CONFIG_SUBDIRS($6)
132                else
133                  AC_MSG_RESULT(no)
134                fi])
135m4_ifvaln([$7],[AC_MSG_CHECKING(whether directory $7 is available)
136                coin_skip=no
137                if test x"$COIN_SKIP_PROJECTS" != x; then
138                  for dir in $COIN_SKIP_PROJECTS; do
139                    if test $dir = $7; then
140                      coin_skip=yes
141                    fi
142                  done
143                fi
144                if test $coin_skip = yes; then
145                  AC_MSG_RESULT(skipping)
146                elif test -r $srcdir/$7/configure; then
147                  coin_subdirs="$coin_subdirs $7"
148                  AC_MSG_RESULT(yes)
149                  AC_CONFIG_SUBDIRS($7)
150                else
151                  AC_MSG_RESULT(no)
152                fi])
153m4_ifvaln([$8],[AC_MSG_CHECKING(whether directory $8 is available)
154                coin_skip=no
155                if test x"$COIN_SKIP_PROJECTS" != x; then
156                  for dir in $COIN_SKIP_PROJECTS; do
157                    if test $dir = $8; then
158                      coin_skip=yes
159                    fi
160                  done
161                fi
162                if test $coin_skip = yes; then
163                  AC_MSG_RESULT(skipping)
164                elif test -r $srcdir/$8/configure; then
165                  coin_subdirs="$coin_subdirs $8"
166                  AC_MSG_RESULT(yes)
167                  AC_CONFIG_SUBDIRS($8)
168                else
169                  AC_MSG_RESULT(no)
170                fi])
171m4_ifvaln([$9],[AC_MSG_CHECKING(whether directory $9 is available)
172                coin_skip=no
173                if test x"$COIN_SKIP_PROJECTS" != x; then
174                  for dir in $COIN_SKIP_PROJECTS; do
175                    if test $dir = $9; then
176                      coin_skip=yes
177                    fi
178                  done
179                fi
180                if test $coin_skip = yes; then
181                  AC_MSG_RESULT(skipping)
182                elif test -r $srcdir/$9/configure; then
183                  coin_subdirs="$coin_subdirs $9"
184                  AC_MSG_RESULT(yes)
185                  AC_CONFIG_SUBDIRS($9)
186                else
187                  AC_MSG_RESULT(no)
188                fi])
189m4_ifvaln([$10],[AC_MSG_CHECKING(whether directory $10 is available)
190                coin_skip=no
191                if test x"$COIN_SKIP_PROJECTS" != x; then
192                  for dir in $COIN_SKIP_PROJECTS; do
193                    if test $dir = $10; then
194                      coin_skip=yes
195                    fi
196                  done
197                fi
198                if test $coin_skip = yes; then
199                  AC_MSG_RESULT(skipping)
200                elif test -r $srcdir/$10/configure; then
201                  coin_subdirs="$coin_subdirs $10"
202                  AC_MSG_RESULT(yes)
203                  AC_CONFIG_SUBDIRS($10)
204                else
205                  AC_MSG_RESULT(no)
206                fi])
207]) # AC_COIN_MAIN_SUBDIRS
208
209###########################################################################
210#                        COIN_THIRDPARTY_SUBDIRS                          #
211###########################################################################
212
213# This macro sets up the recursion into the configure script in a
214# subdirectory for compilation of third party code.  The first
215# argument is just the string that appears in the configure output.
216# The second argument is the directory with the configure script, and
217# the third one is a file that should exists in that directory.  If
218# this file does not exist, we assume that the user has not downloaded
219# the code, and we are not going to compile it
220
221AC_DEFUN([AC_COIN_THIRDPARTY_SUBDIRS],
222[AC_MSG_CHECKING(whether code for third party package $1 is available)
223coin_skip=no
224if test x"$COIN_SKIP_PROJECTS" != x; then
225  for dir in $COIN_SKIP_PROJECTS; do
226    if test $dir = $2; then
227      coin_skip=yes
228    fi
229  done
230fi
231if test $coin_skip = yes; then
232  AC_MSG_RESULT(skipping)
233elif test -r $srcdir/$2/$3; then
234  coin_subdirs="$coin_subdirs $2"
235  AC_MSG_RESULT(yes)
236  AC_CONFIG_SUBDIRS($2)
237else
238  AC_MSG_RESULT(no)
239fi
240]) # AC_COIN_THIRDPARTY_SUBDIRS
241
242###########################################################################
243#                           COIN_CHECK_VPATH                              #
244###########################################################################
245
246# This macro sets the variable coin_vpath_config to true if this is a
247# VPATH configuration, otherwise it sets it to false.
248AC_DEFUN([AC_COIN_CHECK_VPATH],
249[AC_MSG_CHECKING(whether this is a VPATH configuration)
250if test `cd $srcdir; pwd` != `pwd`; then
251  coin_vpath_config=yes;
252else
253  coin_vpath_config=no;
254fi
255AC_MSG_RESULT($coin_vpath_config)
256]) # AC_COIN_CHECK_VPATH
257
258###########################################################################
259#                         COIN_PROJECTDIR_INIT                            #
260###########################################################################
261
262# This macro does everything that is required in the early part in the
263# configure script, such as defining a few variables.  This should only
264# be used in the main directory of a project directory (the one under
265# which src is)
266
267AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
268[# Initialize the ADDLIBS variable
269ADDLIBS='-lm'
270AC_SUBST(ADDLIBS)
271
272# Initialize the FADDLIBS variable (which is to be used with a fortran
273# compiler and will not include FLIBS)
274FADDLIBS=
275AC_SUBST(FADDLIBS)
276
277# A useful makefile conditional that is always false
278AM_CONDITIONAL(ALWAYS_FALSE, false)
279
280# We set the following variable so that we know later in AC_COIN_FINALIZE
281# that we are in a project main directory
282coin_projectdir=yes
283]) # AC_COIN_PROJECTDIR_INIT
284
285###########################################################################
286#                          COIN_DEBUG_COMPILE                             #
287###########################################################################
288
289# enable the configure flags --enable-debug and --enable-debug-prjct
290# (where prcjt is the name of the project in lower case) and set the
291# variable coin_debug_compile to true or false This is used by
292# COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77 to determine the
293# compilation flags.  This macro also makes the switches
294# --with-prjct-verbosity and --with-prjct-checklevel available, which
295# define the preprocessor macros COIN_PRJCT_VERBOSITY and
296# COIN_PRJCT_CHECKLEVEL to the specified value (default is 0).
297#
298# The project specific flags are only made available, if one gives the
299# name of the project as first argument to this macro.
300
301AC_DEFUN([AC_COIN_DEBUG_COMPILE],
302[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
303AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
304AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
305
306AC_MSG_CHECKING([whether we want to compile in debug mode])
307
308AC_ARG_ENABLE([debug],
309[AC_HELP_STRING([--enable-debug],
310                [compile all projects with debug options tests])],
311[case "${enableval}" in
312   yes) coin_debug_compile=true
313        enable_shared=no
314        ;;
315   no)  coin_debug_compile=false
316        ;;
317   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
318        ;;
319esac],
320[coin_debug_compile=false])
321
322m4_ifvaln([$1],
323[AC_ARG_ENABLE(debug-m4_tolower($1),
324 [AC_HELP_STRING([--enable-debug-m4_tolower($1)],
325                 [compile this project ($1) with debug options])],
326 [case "${enableval}" in
327    yes) coin_debug_compile=true
328         enable_shared=no
329         ;;
330    no)  coin_debug_compile=false
331         ;;
332    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
333         ;;
334 esac],[:])
335]) # m4_ifvaln([$1],
336
337if test $coin_debug_compile = true; then
338  AC_MSG_RESULT([yes])
339else
340  AC_MSG_RESULT([no])
341fi
342
343m4_ifvaln([$1],
344[AC_ARG_WITH(m4_tolower($1)-verbosity,
345             AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
346                            [specify the debug verbosity level for project $1]),
347             [m4_tolower(coin_$1_verbosity)=$withval],
348             [m4_tolower(coin_$1_verbosity)=0])
349 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
350                    m4_tolower($coin_$1_verbosity),
351                    [Define to the debug verbosity level (0 is no output)])
352
353 AC_ARG_WITH(m4_tolower($1)-checklevel,
354             AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
355                            [specify the sanity check level for project $1]),
356             [m4_tolower(coin_$1_checklevel)=$withval],
357             [m4_tolower(coin_$1_checklevel)=0])
358 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
359                    m4_tolower($coin_$1_checklevel),
360                    [Define to the debug sanity check level (0 is no test)])
361
362# We use the following variable to have a string with the upper case
363# version of the project name
364COIN_PRJCT=m4_toupper($1)
365
366]) # m4_ifvaln([$1],
367 
368]) # AC_COIN_DEBUG_COMPILE
369
370###########################################################################
371#                          COIN_MINGW_LD_FIX                              #
372###########################################################################
373
374# This macro is included by any PROG_compiler macro, to set the LD
375# environment variable on MinWG to the correct value (link)
376
377AC_DEFUN([AC_COIN_MINGW_LD_FIX],
378[case $build in
379  *-mingw*)
380    if test "${LD+set}" = set; then :; else
381      LD=link
382    fi
383    ;;
384esac
385])
386
387###########################################################################
388#                        COIN_ENABLE_DOSCOMPILE                           #
389###########################################################################
390
391# This macro is included by any PROG_compiler macro, to enable the
392# --enable-doscompile options which is to be used when one wants to
393# compile an executable under Cygwin which also runs directly under
394# does (without requiring Cygwin1.dll).  Essentially, if enabled and
395# the GNU compilers are used, it switches the --mno-cygwin flag on.
396
397AC_DEFUN([AC_COIN_ENABLE_DOSCOMPILE],
398[AC_ARG_ENABLE([doscompile],
399[AC_HELP_STRING([--enable-doscompile],
400                [Under Cygwin, compile so that executables run under DOS (default: disabled)])],
401[if test "$enable_doscompile = yes"; then
402  case $build in
403    *-cygwin*) ;;
404    *) AC_MSG_ERROR([--enable-doscompile option makes only sense under Cygwin]) ;;
405  esac
406fi],
407[enable_doscompile=no])
408])
409
410###########################################################################
411#                             COIN_PROG_CXX                               #
412###########################################################################
413
414# Find the compile command by running AC_PROG_CXX (with compiler names
415# for different operating systems) and put it into CXX (unless it was
416# given my the user), and find an appropriate value for CXXFLAGS.  It is
417# possible to provide additional -D flags in the variable CXXDEFS.
418
419AC_DEFUN([AC_COIN_PROG_CXX],
420[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
421AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
422AC_LANG_PUSH(C++)
423
424AC_ARG_VAR(CXXDEFS,[Additional -D flags to be used when compiling C++ code.])
425AC_ARG_VAR(ADD_CXXFLAGS,[Additional C++ compiler options])
426AC_ARG_VAR(DBG_CXXFLAGS,[Debug C++ compiler options])
427AC_ARG_VAR(OPT_CXXFLAGS,[Optimize C++ compiler options])
428
429coin_has_cxx=yes
430
431save_cxxflags="$CXXFLAGS"
432case $build in
433  *-cygwin* | *-mingw*)
434             comps="g++ cl" ;;
435  *-darwin*) comps="g++ c++ CC" ;;
436          *) comps="xlC aCC CC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
437esac
438
439# We delete the cached value, since the test might not have been
440# performed with out choise of compilers earlier
441$as_unset ac_cv_prog_CXX || test "${ac_cv_prog_CXX+set}" != set || { ac_cv_prog_CXX=; export ac_cv_prog_CXX; }
442AC_PROG_CXX([$comps])
443CXXFLAGS="$save_cxxflags"
444
445# Check if a project specific CXXFLAGS variable has been set
446if test x$COIN_PRJCT != x; then
447  eval coin_tmp=\${${COIN_PRJCT}_CXXFLAGS+set}
448  if test x$coin_tmp = xset; then
449    eval CXXFLAGS=\${${COIN_PRJCT}_CXXFLAGS}
450  fi
451fi
452
453if test x"$CXXFLAGS" = x; then
454
455# ToDo decide whether we want -DNDEBUG for optimization
456  coin_add_cxxflags=
457  coin_opt_cxxflags=
458  coin_dbg_cxxflags=
459  coin_warn_cxxflags=
460
461  if test "$GXX" = "yes"; then
462    case "$CXX" in
463      icpc* | */icpc*)
464        ;;
465      *)
466# ToDo decide about unroll-loops
467        coin_opt_cxxflags="-O3 -fomit-frame-pointer"
468        coin_add_cxxflags="-pipe"
469        coin_dbg_cxxflags="-g"
470        coin_warn_cxxflags="-pedantic-errors -Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion"
471        if test "$enable_doscompile" = yes; then
472          case $build in
473            *-cygwin*)
474              CXXFLAGS="-mno-cygwin"
475              AC_TRY_LINK([],[int i=0; i++;],
476                          [coin_add_cxxflags="-mno-cygwin $coin_add_cxxflags"])
477              CXXFLAGS=
478              ;;
479          esac
480        fi
481    esac
482  fi
483  if test -z "$coin_opt_cxxflags"; then
484    case $build in
485      *-cygwin* | *-mingw*)
486        case "$CXX" in
487          cl* | */cl*)
488            coin_opt_cxxflags='-O2'
489            coin_add_cxxflags='-nologo -EHsc -GR -MT'
490            coin_dbg_cxxflags='-Yd'
491            ;;
492        esac
493        ;;
494      *-linux-*)
495        case "$CXX" in
496          icpc* | */icpc*)
497            coin_opt_cxxflags="-O3 -ip"
498            coin_add_cxxflags=""
499            coin_dbg_cxxflags="-g"
500            # Check if -i_dynamic is necessary (for new glibc library)
501            CXXFLAGS=
502            AC_TRY_LINK([],[int i=0; i++;],[],
503                        [coin_add_cxxflags="-i_dynamic $coin_add_cxxflags"])
504            ;;
505          pgCC* | */pgCC*)
506            coin_opt_cxxflags="-fast"
507            coin_add_cxxflags="-Kieee -pc 64"
508            coin_dbg_cxxflags="-g"
509            ;;
510        esac
511        ;;
512      *-ibm-*)
513        case "$CXX" in
514          xlC* | */xlC* | mpxlC* | */mpxlC*)
515            coin_opt_cxxflags="-O3 -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
516            coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna"
517            coin_dbg_cxxflags="-g"
518            ;;
519        esac
520        ;;
521      *-hp-*)
522        case "$CXX" in
523          aCC* | */aCC* )
524            coin_opt_cxxflags="-O"
525            coin_add_cxxflags="-AA"
526            coin_dbg_cxxflags="-g"
527            ;;
528        esac
529        ;;
530      *-sun-*)
531          coin_opt_cxxflags="-O4"
532          coin_dbg_cxxflags="-g"
533        ;;
534    esac
535  fi
536
537  if test "$ac_cv_prog_cxx_g" = yes && test -z "$coin_dbg_cxxflags" ; then
538    coin_dbg_cxxflags="-g"
539  fi
540
541  if test -z "$coin_opt_cxxflags"; then
542    # Try if -O option works if nothing else is set
543    CXXFLAGS=-O
544    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cxxflags="-O"])
545  fi
546
547  # if PM doesn't want the warning messages, take them out
548  if test x"$coin_skip_warn_cxxflags" = xyes; then
549    coin_warn_cxxflags=
550  fi
551
552  if test x${DBG_CXXFLAGS+set} != xset; then
553    DBG_CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
554  fi
555  if test x${OPT_CXXFLAGS+set} != xset; then
556    OPT_CXXFLAGS="$coin_opt_cxxflags $coin_add_cxxflags -DNDEBUG $coin_warn_cxxflags"
557  fi
558
559  DBG_CXXFLAGS="$DBG_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
560  OPT_CXXFLAGS="$OPT_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
561
562  if test "$coin_debug_compile" = "true"; then
563    CXXFLAGS="$DBG_CXXFLAGS"
564  else
565    CXXFLAGS="$OPT_CXXFLAGS"
566  fi
567else
568  CXXFLAGS="$CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
569  if test x${DBG_CXXFLAGS+set} != xset; then
570    DBG_CXXFLAGS="$CXXFLAGS"
571  fi
572  if test x${OPT_CXXFLAGS+set} != xset; then
573    OPT_CXXFLAGS="$CXXFLAGS"
574  fi
575fi
576
577# Try if CXXFLAGS works
578save_CXXFLAGS="$CXXFLAGS"
579AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
580if test -z "$CXXFLAGS"; then
581  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.])
582  CXXFLAGS='-O'
583  AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
584  if test -z "$CXXFLAGS"; then
585    AC_MSG_WARN([This value for CXXFLAGS does not work.  I will continue with empty CXXFLAGS, but you might want to set CXXFLAGS manually.])
586  fi
587fi
588
589AC_MSG_NOTICE([C++ compiler options are: $CXXFLAGS])
590
591AC_ARG_VAR(MPICXX,[C++ MPI Compiler])
592if test x"$MPICXX" = x; then :; else
593  AC_MSG_NOTICE([Will use MPI C++ compiler $MPICXX])
594  CXX="$MPICXX"
595fi
596
597case "$CXX" in
598  cl*)
599    AC_COIN_MINGW_LD_FIX
600    ;;
601esac
602
603AC_LANG_POP(C++)
604]) # AC_COIN_PROG_CXX
605
606
607###########################################################################
608#                             COIN_CXXLIBS                                #
609###########################################################################
610
611# Determine the C++ runtime libraries required for linking a C++ library
612# with a Fortran or C compiler.  The result is available in CXXLIBS.
613
614AC_DEFUN([AC_COIN_CXXLIBS],
615[AC_REQUIRE([AC_PROG_CXX])dnl
616AC_LANG_PUSH(C++)
617AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with Fortran compiler])
618if test -z "$CXXLIBS"; then
619  if test "$GXX" = "yes"; then
620    case "$CXX" in
621      icpc* | */icpc*)
622        CXXLIBS=""
623        ;;
624      *)
625        CXXLIBS="-lstdc++ -lm" # -lgcc"
626        ;;
627    esac
628  else
629    case $build in
630     *-mingw32 | *-cygwin-* )
631      case "$CXX" in
632      cl*)
633        CXXLIBS=nothing;;
634      esac;;
635     *-linux-*)
636      case "$CXX" in
637      icpc* | */icpc*)
638        CXXLIBS=""
639             ;;
640      pgCC* | */pgCC*)
641        CXXLIBS="-lstd -lC -lc"
642             ;;
643      esac;;
644    *-ibm-*)
645      CXXLIBS="-lC -lc"
646      ;;
647    *-hp-*)
648      CXXLIBS="-L/opt/aCC/lib -l++ -lstd_v2 -lCsup_v2 -lm -lcl -lc"
649      ;;
650    *-sun-*)
651      CXXLIBS="-lCstd -lCrun"
652    esac
653  fi
654fi
655if test -z "$CXXLIBS"; then
656  AC_MSG_WARN([Could not automatically determine CXXLIBS (C++ link libraries; necessary if main program is in Fortran of C).])
657else
658  AC_MSG_NOTICE([Assuming that CXXLIBS is \"$CXXLIBS\".])
659fi
660if test x"$CXXLIBS" = xnothing; then
661  CXXLIBS=
662fi
663AC_LANG_POP(C++)
664]) # AC_COIN_CXXLIBS
665
666###########################################################################
667#                           COIN_CHECK_HEADER                             #
668###########################################################################
669
670# This macro checks for a header file, but it does so without the
671# standard header.  This avoids warning messages like:
672#
673# configure: WARNING: dlfcn.h: present but cannot be compiled
674# configure: WARNING: dlfcn.h:     check for missing prerequisite headers?
675# configure: WARNING: dlfcn.h: see the Autoconf documentation
676# configure: WARNING: dlfcn.h:     section "Present But Cannot Be Compiled"
677# configure: WARNING: dlfcn.h: proceeding with the preprocessor's result
678# configure: WARNING: dlfcn.h: in the future, the compiler will take precedence
679
680AC_DEFUN([AC_COIN_CHECK_HEADER],
681[if test x"$4" = x; then
682  hdr="#include <$1>"
683else
684  hdr="$4"
685fi
686AC_CHECK_HEADERS([$1],[$2],[$3],[$hdr])
687]) # AC_COIN_CHECK_HEADER
688
689###########################################################################
690#                       COIN_CHECK_CXX_CHEADER                             #
691###########################################################################
692
693# This macro checks for C header files that are used from C++.  For a give
694# stub (e.g., math), it first checks if the C++ library (cmath) is available.
695# If it is, it defines HAVE_CMATH (or whatever the stub is).  If it is not
696# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
697# if that one exists.
698
699AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
700[AC_LANG_PUSH(C++)
701AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
702if test "$ac_cv_header_c$1" != "yes"; then
703  AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
704fi
705AC_LANG_POP(C++)
706]) # AC_COIN_CHECK_CXX_CHEADER
707
708###########################################################################
709#                             COIN_PROG_CC                                #
710###########################################################################
711
712# Find the compile command by running AC_PROG_CC (with compiler names
713# for different operating systems) and put it into CC (unless it was
714# given my the user), and find an appropriate value for CFLAGS.  It is
715# possible to provide additional -D flags in the variable CDEFS.
716
717AC_DEFUN([AC_COIN_PROG_CC],
718[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
719AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
720AC_LANG_PUSH(C)
721
722# For consistency, we set the C compiler to the same value of the C++
723# compiler, if the C++ is set, but the C compiler isn't (only for CXX=cl)
724if test x"$CXX" != x; then
725  case "$CXX" in
726    cl*)
727      if test x"$CC" = x; then
728        CC="$CXX"
729        AC_MSG_WARN([C++ compiler name provided as $CXX, but CC is unset. Setting CC to $CXX])
730      fi
731      ;;
732  esac
733fi
734
735AC_ARG_VAR(CDEFS,[Additional -D flags to be used when compiling C code.])
736AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options])
737AC_ARG_VAR(DBG_CFLAGS,[Debug C compiler options])
738AC_ARG_VAR(OPT_CFLAGS,[Optimize C compiler options])
739
740coin_has_cc=yes
741
742save_cflags="$CFLAGS"
743case $build in
744  *-cygwin* | *-mingw*)
745             comps="gcc cl" ;;
746  *-linux-*) comps="xlc gcc cc pgcc icc" ;;
747  *)         comps="xlc_r xlc cc gcc pgcc icc" ;;
748esac
749
750# We delete the cached value, since the test might not have been
751# performed with out choise of compilers earlier
752$as_unset ac_cv_prog_CC || test "${ac_cv_prog_CC+set}" != set || { ac_cv_prog_CC=; export ac_cv_prog_CC; }
753AC_PROG_CC([$comps])
754CFLAGS="$save_cflags"
755
756# Check if a project specific CFLAGS variable has been set
757if test x$COIN_PRJCT != x; then
758  eval coin_tmp=\${${COIN_PRJCT}_CFLAGS+set}
759  if test x$coin_tmp = xset; then
760    eval CFLAGS=\${${COIN_PRJCT}_CFLAGS}
761  fi
762fi
763
764if test x"$CFLAGS" = x; then
765
766  coin_add_cflags=
767  coin_opt_cflags=
768  coin_dbg_cflags=
769  coin_warn_cflags=
770
771  if test "$GCC" = "yes"; then
772    case "$CC" in
773      icc* | */icc*)
774        ;;
775      *)
776        coin_opt_cflags="-O3 -fomit-frame-pointer"
777        coin_add_cflags="-pipe"
778        coin_dbg_cflags="-g"
779        coin_warn_cflags="-pedantic-errors -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall"
780        if test "$enable_doscompile" = yes; then
781          case $build in
782            *-cygwin*)
783              CFLAGS="-mno-cygwin"
784              AC_TRY_LINK([],[int i=0; i++;],
785                          [coin_add_cflags="-mno-cygwin $coin_add_cflags"])
786              CFLAGS=
787            ;;
788          esac
789        fi
790    esac
791  fi
792  if test -z "$coin_opt_cflags"; then
793    case $build in
794      *-cygwin* | *-mingw*)
795        case "$CC" in
796          cl* | */cl*)
797            coin_opt_cflags='-O2'
798            coin_add_cflags='-nologo'
799            coin_dbg_cflags='-Yd'
800            ;;
801        esac
802        ;;
803      *-linux-*)
804        case "$CC" in
805          icc* | */icc*)
806            coin_opt_cflags="-O3 -ip"
807            coin_add_cflags=""
808            coin_dbg_cflags="-g"
809            # Check if -i_dynamic is necessary (for new glibc library)
810            CFLAGS=
811            AC_TRY_LINK([],[int i=0; i++;],[],
812                        [coin_add_cflags="-i_dynamic $coin_add_cflags"])
813            ;;
814          pgcc* | */pgcc*)
815            coin_opt_cflags="-fast"
816            coin_add_cflags="-Kieee -pc 64"
817            coin_dbg_cflags="-g"
818            ;;
819        esac
820        ;;
821      *-ibm-*)
822        case "$CC" in
823          xlc* | */xlc* | mpxlc* | */mpxlc*)
824            coin_opt_cflags="-O3 -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
825            coin_add_cflags="-bmaxdata:0x80000000"
826            coin_dbg_cflags="-g"
827          ;;
828        esac
829        ;;
830      *-hp-*)
831        coin_opt_cflags="-O"
832        coin_add_cflags="-Ae"
833        coin_dbg_cflags="-g"
834        ;;
835      *-sun-*)
836        coin_opt_cflags="-xO4"
837        coin_dbg_cflags="-g"
838        ;;
839      *-sgi-*)
840        coin_opt_cflags="-O -OPT:Olimit=0"
841        coin_dbg_cflags="-g"
842        ;;
843    esac
844  fi
845
846  if test "$ac_cv_prog_cc_g" = yes && test -z "$coin_dbg_cflags" ; then
847    coin_dbg_cflags="-g"
848  fi
849
850  if test -z "$coin_opt_cflags"; then
851    # Try if -O option works if nothing else is set
852    CFLAGS="-O"
853    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cflags="-O"])
854  fi
855
856  # if PM doesn't want the warning messages, take them out
857  if test x"$coin_skip_warn_cflags" = xyes; then
858    coin_warn_cflags=
859  fi
860
861  if test x${DBG_CFLAGS+set} != xset; then
862    DBG_CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
863  fi
864  if test x${OPT_CFLAGS+set} != xset; then
865    OPT_CFLAGS="$coin_opt_cflags $coin_add_cflags -DNDEBUG $coin_warn_cflags"
866  fi
867
868  DBG_CFLAGS="$DBG_CFLAGS $ADD_CFLAGS $CDEFS"
869  OPT_CFLAGS="$OPT_CFLAGS $ADD_CFLAGS $CDEFS"
870
871  if test "$coin_debug_compile" = "true"; then
872    CFLAGS="$DBG_CFLAGS"
873  else
874    CFLAGS="$OPT_CFLAGS"
875  fi
876else
877  CFLAGS="$CFLAGS $ADD_CFLAGS $CDEFS"
878  if test x${DBG_CFLAGS+set} != xset; then
879    DBG_CFLAGS="$CFLAGS"
880  fi
881  if test x${OPT_CFLAGS+set} != xset; then
882    OPT_CFLAGS="$CFLAGS"
883  fi
884fi
885
886# Check if user wants to have additional CFLAGS options
887AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options])
888if test x"$ADD_CFLAGS" != x; then
889  CFLAGS="$CFLAGS $ADD_CFLAGS"
890fi
891
892# Try if CFLAGS works
893save_CFLAGS="$CFLAGS"
894AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
895if test -z "$CFLAGS"; then
896  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.])
897  CFLAGS='-O'
898  AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
899  if test -z "$CFLAGS"; then
900    AC_MSG_WARN([This value for CFLAGS does not work.  I will continue with empty CFLAGS, but you might want to set CFLAGS manually.])
901  fi
902fi
903
904AC_MSG_NOTICE([C compiler options are: $CFLAGS])
905
906AC_ARG_VAR(MPICC,[C MPI Compiler])
907if test x"$MPICC" = x; then :; else
908  AC_MSG_NOTICE([Will use MPI C compiler $MPICC])
909  CC="$MPICC"
910fi
911
912# Correct ADDLIBS initialization if we are using the MS compiler
913case "$CC" in
914  cl*)
915    ADDLIBS=
916    AC_COIN_MINGW_LD_FIX
917    ;;
918esac
919
920AC_LANG_POP(C)
921]) # AC_COIN_PROG_CC
922
923###########################################################################
924#                             COIN_PROG_F77                               #
925###########################################################################
926
927# Find the compile command by running AC_PROG_F77 (with compiler names
928# for different operating systems) and put it into F77 (unless it was
929# given my the user), and find an appropriate value for FFLAGS
930
931AC_DEFUN([AC_COIN_PROG_F77],
932[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
933AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
934AC_REQUIRE([AC_COIN_PROG_CC])
935AC_LANG_PUSH([Fortran 77])
936
937AC_ARG_VAR(ADD_FFLAGS,[Additional Fortran compiler options])
938AC_ARG_VAR(DBG_FFLAGS,[Debug Fortran compiler options])
939AC_ARG_VAR(OPT_FFLAGS,[Optimize Fortran compiler options])
940
941coin_has_f77=yes
942
943save_fflags="$FFLAGS"
944case $build in
945  *-cygwin* | *-mingw*)
946             comps="gfortran g77 ifort fl32" ;;
947  *)         comps="xlf fort77 gfortran f77 g77 pgf90 pgf77 ifort ifc frt af77" ;;
948esac
949
950# We delete the cached value, since the test might not have been
951# performed with out choise of compilers earlier
952$as_unset ac_cv_prog_F77 || test "${ac_cv_prog_F77+set}" != set || { ac_cv_prog_F77=; export ac_cv_prog_F77; }
953AC_PROG_F77($comps)
954FFLAGS="$save_fflags"
955
956# Check if a project specific FFLAGS variable has been set
957if test x$COIN_PRJCT != x; then
958  eval coin_tmp=\${${COIN_PRJCT}_FFLAGS+set}
959  if test x$coin_tmp = xset; then
960    eval FFLAGS=\${${COIN_PRJCT}_FFLAGS}
961  fi
962fi
963
964if test x"$FFLAGS" = x; then
965
966  coin_add_fflags=
967  coin_opt_fflags=
968  coin_dbg_fflags=
969  coin_warn_fflags=
970
971  if test "$G77" = "yes"; then
972    coin_opt_fflags="-O3 -fomit-frame-pointer"
973    coin_add_fflags="-pipe"
974    coin_dbg_fflags="-g"
975    if test "$enable_doscompile" = yes; then
976      case $build in
977        *-cygwin*)
978          FFLAGS="-mno-cygwin"
979          AC_TRY_LINK([],[      write(*,*) 'Hello world'],
980                      [coin_add_fflags="-mno-cygwin $coin_add_fflags"])
981          FFLAGS=
982        ;;
983      esac
984    fi
985  else
986    case $build in
987      *-cygwin* | *-mingw*)
988        case $F77 in
989          ifort* | */ifort*)
990            coin_opt_fflags='-O3'
991            coin_add_fflags='-nologo -MT'
992            coin_dbg_fflags='-debug'
993          ;;
994        esac
995        ;;
996      *-linux-*)
997        case $F77 in
998          ifc* | */ifc* | ifort* | */ifort*)
999            coin_opt_fflags="-O3 -ip"
1000            coin_add_fflags="-cm -w90 -w95"
1001            coin_dbg_fflags="-g -CA -CB -CS"
1002            # Check if -i_dynamic is necessary (for new glibc library)
1003            FFLAGS=
1004            AC_TRY_LINK([],[      write(*,*) 'Hello world'],[],
1005                        [coin_add_fflags="-i_dynamic $coin_add_fflags"])
1006            ;;
1007          pgf77* | */pgf77* | pgf90* | */pgf90*)
1008            coin_opt_fflags="-fast"
1009            coin_add_fflags="-Kieee -pc 64"
1010            coin_dbg_fflags="-g"
1011          ;;
1012        esac
1013        ;;
1014      *-ibm-*)
1015        case "$F77" in
1016          xlf* | */xlf* | mpxlf* | */mpxlf* )
1017            coin_opt_fflags="-O3 -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
1018            coin_add_fflags="-bmaxdata:0x80000000"
1019            coin_dbg_fflags="-g -C"
1020            ;;
1021        esac
1022        ;;
1023      *-hp-*)
1024        coin_opt_fflags="+O3"
1025        coin_add_fflags="+U77"
1026        coin_dbg_fflags="-C -g"
1027        ;;
1028      *-sun-*)
1029        coin_opt_fflags="-O4"
1030        coin_dbg_fflags="-g"
1031        ;;
1032      *-sgi-*)
1033        coin_opt_fflags="-O5 -OPT:Olimit=0"
1034        coin_dbg_fflags="-g"
1035        ;;
1036    esac
1037  fi
1038
1039  if test "$ac_cv_prog_f77_g" = yes && test -z "$coin_dbg_fflags" ; then
1040    coin_dbg_fflags="-g"
1041  fi
1042
1043  if test -z "$coin_opt_fflags"; then
1044    # Try if -O option works if nothing else is set
1045    FFLAGS=-O
1046    AC_TRY_LINK([],[      integer i], [coin_opt_fflags="-O"])
1047  fi
1048
1049  # if PM doesn't want the warning messages, take them out
1050  if test x"$coin_skip_warn_fflags" = xyes; then
1051    coin_warn_fflags=
1052  fi
1053
1054  if test x${DBG_FFLAGS+set} != xset; then
1055    DBG_FFLAGS="$coin_dbg_fflags $coin_add_fflags $coin_warn_fflags"
1056  fi
1057  if test x${OPT_FFLAGS+set} != xset; then
1058    OPT_FFLAGS="$coin_opt_fflags $coin_add_fflags $coin_warn_fflags"
1059  fi
1060
1061  DBG_FFLAGS="$DBG_FFLAGS $ADD_FFLAGS"
1062  OPT_FFLAGS="$OPT_FFLAGS $ADD_FFLAGS"
1063
1064  if test "$coin_debug_compile" = "true"; then
1065    FFLAGS="$DBG_FFLAGS"
1066  else
1067    FFLAGS="$OPT_FFLAGS"
1068  fi
1069else
1070  FFLAGS="$FFLAGS $ADD_FFLAGS"
1071  if test x${DBG_FFLAGS+set} != xset; then
1072    DBG_FFLAGS="$FFLAGS"
1073  fi
1074  if test x${OPT_FFLAGS+set} != xset; then
1075    OPT_FFLAGS="$FFLAGS"
1076  fi
1077fi
1078
1079# Try if FFLAGS works
1080AC_TRY_LINK([],[      integer i],[],[FFLAGS=])
1081if test -z "$FFLAGS"; then
1082  AC_MSG_WARN([The flags FFLAGS="$FFLAGS" do not work.  I will now just try '-O', but you might want to set FFLAGS manually.])
1083  FFLAGS='-O'
1084  AC_TRY_LINK([],[      integer i],[],[FFLAGS=])
1085  if test -z "$FFLAGS"; then
1086    AC_MSG_WARN([This value for FFLAGS does not work.  I will continue with empty FFLAGS, but you might want to set FFLAGS manually.])
1087  fi
1088fi
1089
1090AC_MSG_NOTICE([Fortran compiler options are: $FFLAGS])
1091
1092AC_ARG_VAR(MPIF77,[Fortran MPI Compiler])
1093if test x"$MPIF77" = x; then :; else
1094  AC_MSG_NOTICE([Will use MPI Fortran compiler $MPIF77])
1095  F77="$MPIF77"
1096fi
1097
1098case "$F77" in
1099  ifort*)
1100    AC_COIN_MINGW_LD_FIX
1101    ;;
1102esac
1103
1104AC_LANG_POP([Fortran 77])
1105]) # AC_COIN_PROG_F77
1106
1107###########################################################################
1108#                           COIN_F77_WRAPPERS                             #
1109###########################################################################
1110
1111# Calls autoconfs AC_F77_WRAPPERS and does additional corrections to FLIBS
1112
1113AC_DEFUN([AC_COIN_F77_WRAPPERS],
1114[AC_BEFORE([AC_COIN_PROG_F77],[$0])dnl
1115AC_BEFORE([AC_PROG_F77],[$0])dnl
1116
1117AC_LANG_PUSH([Fortran 77])
1118
1119AC_F77_WRAPPERS
1120
1121# This is to correct a missing exclusion in autoconf 2.59
1122if test x"$FLIBS" != x; then
1123  my_flibs=
1124  for flag in $FLIBS; do
1125    case flag in
1126      -lcrt*.o) ;;
1127             *) my_flibs="$my_flibs $flag" ;;
1128    esac
1129  done
1130  FLIBS="$my_flibs"
1131fi
1132
1133case $build in
1134# The following is a fix to define FLIBS for ifort on Windows
1135   *-cygwin* | *-mingw*)
1136     case "$F77" in
1137       ifort* | */ifort*)
1138           FLIBS="-link libifcorert.lib $LIBS /NODEFAULTLIB:libc.lib";;
1139     esac;;
1140   *-hp-*)
1141       FLIBS="$FLIBS -lm";;
1142   *-ibm-*)
1143       FLIBS=`echo $FLIBS | sed 's/-lc)/-lc/g'` ;;
1144   *-linux-*)
1145     case "$F77" in
1146       pgf77* | */pgf77* | pgf90* | */pgf90*)
1147# ask linker to go through the archives multiple times
1148# (the Fortran compiler seems to do that automatically...
1149         FLIBS="-Wl,--start-group $FLIBS -Wl,--end-group" ;;
1150     esac
1151esac
1152
1153]) # AC_COIN_F77_WRAPPERS
1154
1155
1156###########################################################################
1157#                          COIN_INIT_AUTOMAKE                             #
1158###########################################################################
1159
1160# This macro calls the regular INIT_AUTOMAKE and MAINTAINER_MODE
1161# macros, and defines additional variables and makefile conditionals,
1162# that are used in the maintainer parts of the makfile.  It also
1163# checks if the correct versions of the autotools are used.
1164#
1165# This also defines the AC_SUBST variables:
1166# abs_source_dir     absolute path to source code for this package
1167# abs_bin_dir        absolute path to the directory where binaries are
1168#                    going to be installed (prefix/bin)
1169# abs_lib_dir        absolute path to the directory where libraries are
1170#                    going to be installed (prefix/lib)
1171# abs_include_dir    absolute path to the directory where the header files
1172#                    are installed (prefix/include)
1173
1174AC_DEFUN([AC_COIN_INIT_AUTOMAKE],
1175[AC_REQUIRE([AC_PROG_EGREP])
1176# Stuff for automake
1177AM_INIT_AUTOMAKE
1178AM_MAINTAINER_MODE
1179
1180coin_have_externals=no
1181if test "$enable_maintainer_mode" = yes; then
1182
1183  # If maintainer mode is chosen, we make sure that the correct versions
1184  # of the tools are used, and that we know where libtoo.m4 is (to
1185  # recreate acinclude.m4)
1186
1187  AC_SUBST(LIBTOOLM4)
1188  LIBTOOLM4=
1189
1190  # Check if we have autoconf
1191  AC_CHECK_PROG([have_autoconf],[autoconf],[yes],[no])
1192  if test $have_autoconf = no; then
1193    AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find autoconf in your path.])
1194  fi
1195
1196  # Check whether autoconf is the correct version
1197  correct_version='2.59'
1198  grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1199  AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of autoconf])
1200  autoconf --version > confauto.out 2>&1
1201  if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1202    AC_MSG_RESULT([yes])
1203  else
1204    rm -f confauto.out
1205    AC_MSG_RESULT([no])
1206    AC_MSG_ERROR([You don't have the correct version of autoconf as the first one in your path.])
1207  fi
1208  rm -f confauto.out
1209
1210  # Check if the executable autoconf is picked up from the correct location
1211  AC_MSG_CHECKING([whether autoconf is coming from the correct location])
1212  autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
1213  autoconf_dir=`cd $autoconf_dir; pwd`
1214  if test x$AUTOTOOLS_DIR = x; then
1215    want_dir=$HOME/bin
1216  else
1217    want_dir=$AUTOTOOLS_DIR/bin
1218  fi
1219  if test $autoconf_dir = `cd $want_dir; pwd`; then
1220    AC_MSG_RESULT([yes])
1221  else
1222    rm -f confauto.out
1223    AC_MSG_RESULT([no])
1224    AC_MSG_ERROR([The autoconf executable should be picked up from \$HOME/bin or \$AUTOTOOLS_DIR/bin.])
1225  fi
1226
1227  # Check if we have automake
1228  AC_CHECK_PROG([have_automake],[automake],[yes],[no])
1229  if test $have_automake = no; then
1230    AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find automake in your path.])
1231  fi
1232 
1233  # Check whether automake is the correct version
1234  correct_version='1.9.6'
1235  grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1236  AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of automake])
1237  automake --version > confauto.out 2>&1
1238  if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1239    AC_MSG_RESULT([yes])
1240  else
1241    rm -f confauto.out
1242    AC_MSG_RESULT([no])
1243    AC_MSG_ERROR([You don't have the correct version of automake as the first one in your path.])
1244  fi
1245  rm -f confauto.out
1246
1247  # Check if the executable automake is picked up from the correct location
1248  AC_MSG_CHECKING([whether automake is coming from the correct location])
1249  automake_dir=`which automake | sed -e 's=/automake=='`
1250  automake_dir=`cd $automake_dir; pwd`
1251  if test x$AUTOTOOLS_DIR = x; then
1252    want_dir=$HOME/bin
1253  else
1254    want_dir=$AUTOTOOLS_DIR/bin
1255  fi
1256  if test $automake_dir = `cd $want_dir; pwd`; then
1257    AC_MSG_RESULT([yes])
1258  else
1259    rm -f confauto.out
1260    AC_MSG_RESULT([no])
1261    AC_MSG_ERROR([The automake executable should be picked up from \$HOME/bin or \$AUTOTOOLS_DIR/bin.])
1262  fi
1263
1264  # Check if we can find the libtool file
1265  if test x$AUTOTOOLS_DIR = x; then
1266    want_dir=$HOME/share
1267  else
1268    want_dir=$AUTOTOOLS_DIR/share
1269  fi
1270  AC_CHECK_FILE([$want_dir/aclocal/libtool.m4],
1271                [LIBTOOLM4="$want_dir/aclocal/libtool.m4"],
1272                [AC_MSG_ERROR([I cannot find the libtool.m4 file.])])
1273
1274  # Check if this is the correct version of libtool (with escaped dots)
1275  correct_version='1.5.22'
1276  grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1277  AC_CHECK_FILE([$want_dir/libtool/ltmain.sh],
1278                [have_ltmain=yes],
1279                [have_ltmain=no])
1280  AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of libtool.])
1281  if test $have_ltmain = yes; then
1282    if $EGREP $grep_version $want_dir/libtool/ltmain.sh >/dev/null 2>&1; then
1283      AC_MSG_RESULT([yes])
1284    else
1285      AC_MSG_RESULT([no])
1286      AC_MSG_ERROR([You don't have the correct version of libtool.])
1287    fi
1288  else
1289    AC_MSG_RESULT([no])
1290    AC_MSG_ERROR([I cannot find the ltmain.sh file.])
1291  fi 
1292
1293  # Check if we have an Externals file
1294  if test -r $srcdir/Externals; then
1295    coin_have_externals=yes
1296  fi
1297  # Check if subversion is installed and understands https
1298  AC_CHECK_PROG([have_svn],[svn],[yes],[no])
1299  if test x$have_svn = xyes; then
1300    AC_MSG_CHECKING([svn understands https])
1301    svn --version > confauto.out 2>&1
1302    if $EGREP https confauto.out >/dev/null 2>&1; then
1303      AC_MSG_RESULT(yes)
1304    else
1305      AC_MSG_RESULT(no)
1306      have_svn=no
1307    fi
1308    rm -f confauto.out
1309  fi
1310
1311  # Find the location of the BuildTools directory
1312  BUILDTOOLSDIR=
1313  if test -r $srcdir/BuildTools/coin.m4; then
1314    BUILDTOOLSDIR=$srcdir/BuildTools
1315  else
1316    if test -r $srcdir/../BuildTools/coin.m4; then
1317      BUILDTOOLSDIR=$srcdir/../BuildTools
1318    else
1319      if test -r $srcdir/../../BuildTools/coin.m4; then
1320        BUILDTOOLSDIR=$srcdir/../../BuildTools
1321      else
1322        AC_MSG_ERROR(Cannot find the BuildTools directory)
1323      fi
1324    fi
1325  fi
1326  AC_SUBST(BUILDTOOLSDIR)
1327
1328  # The following variable is set to the name of the directory where
1329  # the autotool scripts are located
1330  AC_SUBST(AUX_DIR)
1331  AUX_DIR=$ac_aux_dir
1332fi
1333
1334# helpful variable for the base directory of this package
1335abs_source_dir=`cd $srcdir; pwd`
1336AC_SUBST(abs_source_dir)
1337
1338# Stuff for example Makefiles
1339if test x$prefix = xNONE; then
1340  full_prefix=$ac_default_prefix
1341else
1342  full_prefix=$prefix
1343fi
1344full_prefix=`cd $full_prefix ; pwd`
1345AC_SUBST(abs_lib_dir)
1346abs_lib_dir=$full_prefix/lib
1347AC_SUBST(abs_include_dir)
1348abs_include_dir=$full_prefix/include
1349AC_SUBST(abs_bin_dir)
1350abs_bin_dir=$full_prefix/bin
1351
1352AM_CONDITIONAL(HAVE_EXTERNALS,
1353               test $coin_have_externals = yes && test x$have_svn = xyes)
1354]) # AC_COIN_INIT_AUTOMAKE
1355
1356###########################################################################
1357#                         COIN_INIT_AUTO_TOOLS                            #
1358###########################################################################
1359
1360# Initialize the auto tools automake and libtool, with all
1361# modifications we want for COIN packages.
1362#
1363# RPATH_FLAGS        link flags for hardcoding path to shared objects
1364
1365# This is a trick to have this code before AC_COIN_PROG_LIBTOOL
1366AC_DEFUN([AC_COIN_DISABLE_STATIC],
1367[
1368# On Cygwin, building DLLs doesn't work
1369case $build in
1370  *-cygwin*)
1371    coin_disable_shared=yes
1372    platform=Cygwin
1373  ;;
1374  *-mingw*)
1375    coin_disable_shared=yes
1376    platform="Msys"
1377#    case "$CXX" in
1378#      cl*)
1379#        coin_disable_shared=yes
1380#        platform="Msys with cl"
1381#    ;;
1382#    esac
1383  ;;
1384esac
1385if test x"$coin_disable_shared" = xyes; then
1386  if test x"$enable_shared" = xyes; then
1387    AC_MSG_WARN([On $platform, shared objects are not supported. I'm disabling your choice.])
1388  fi
1389  enable_shared=no
1390fi
1391# By default, we only want the shared objects to be compiled
1392AC_DISABLE_STATIC
1393])
1394
1395AC_DEFUN([AC_COIN_INIT_AUTO_TOOLS],
1396[AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1397AC_BEFORE([AC_COIN_PROG_CC],[$0])
1398AC_BEFORE([AC_COIN_PROG_F77],[$0])
1399AC_REQUIRE([AC_COIN_DISABLE_STATIC])
1400
1401# Initialize automake
1402AC_COIN_INIT_AUTOMAKE
1403
1404# Stuff for libtool
1405AC_COIN_PROG_LIBTOOL
1406
1407# set RPATH_FLAGS to the compiler link flags required to hardcode location
1408# of the shared objects
1409AC_COIN_RPATH_FLAGS($abs_lib_dir)
1410]) # AC_COIN_INIT_AUTO_TOOLS
1411
1412###########################################################################
1413#                           COIN_PROG_LIBTOOL                             #
1414###########################################################################
1415
1416# Setup the libtool stuff together with any modifications to make it
1417# work on additional platforms
1418
1419AC_DEFUN([AC_COIN_PROG_LIBTOOL],
1420[AC_REQUIRE([AC_COIN_DLFCN_H])
1421
1422# We check for this header here in a non-standard way to avoid warning
1423# messages
1424AC_PROG_LIBTOOL
1425
1426# Fix bugs in libtool script for Windows native compilation:
1427# - cygpath is not correctly quoted in fix_srcfile_path
1428# - paths generated for .lib files is not run through cygpath -w
1429
1430
1431# - lib includes subdirectory information; we want to replace
1432#
1433# old_archive_cmds="lib /OUT:\$oldlib\$oldobjs\$old_deplibs"
1434#
1435# by
1436#
1437# old_archive_cmds="echo \$oldlib | grep .libs >/dev/null; if test \$? = 0; then cd .libs; lib /OUT:\`echo \$oldlib\$oldobjs\$old_deplibs | sed -e s@\.libs/@@g\`; cd .. ; else lib /OUT:\$oldlib\$oldobjs\$old_deplibs ; fi"
1438#
1439#          -e 's%old_archive_cmds="lib /OUT:\\\$oldlib\\\$oldobjs\\\$old_deplibs"%old_archive_cmds="echo \\\$oldlib \| grep .libs >/dev/null; if test \\\$? = 0; then cd .libs; lib /OUT:\\\`echo \\\$oldlib\\\$oldobjs\\\$old_deplibs \| sed -e s@\\.libs/@@g\\\`; cd .. ; else lib /OUT:\\\$oldlib\\\$oldobjs\\\$old_deplibs; fi"%' \
1440
1441# The following was a hack for chaniing @BACKSLASH to \
1442#          -e 'sYcompile_command=`\$echo "X\$compile_command" | \$Xsed -e '"'"'s%@OUTPUT@%'"'"'"\$output"'"'"'%g'"'"'`Ycompile_command=`\$echo "X\$compile_command" | \$Xsed -e '"'"'s%@OUTPUT@%'"'"'"\$output"'"'"'%g'"'"' | \$Xsed -e '"'"'s%@BACKSLASH@%\\\\\\\\\\\\\\\\%g'"'"'`Y' \
1443
1444# Correct cygpath for minGW (ToDo!)
1445case $build in
1446  *-mingw*)
1447    CYGPATH_W=echo
1448    ;;
1449esac
1450
1451case $build in
1452  *-cygwin* | *-mingw*)
1453  case "$CXX" in
1454    cl* | */cl*)
1455      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1456      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1457          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1458          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1459          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1460          -e 's%lib /OUT:%lib -OUT:%' \
1461          -e "s%cygpath -w%$CYGPATH_W%" \
1462          -e 's%$AR x \\$f_ex_an_ar_oldlib%bla=\\`lib -nologo -list \\$f_ex_an_ar_oldlib | xargs echo\\`; echo \\$bla; for i in \\$bla; do lib -nologo -extract:\\$i \\$f_ex_an_ar_oldlib; done%' \
1463          -e 's/$AR t/lib -nologo -list/' \
1464          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1465          -e  's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1466      libtool > conftest.bla
1467
1468      mv conftest.bla libtool
1469      chmod 755 libtool
1470      ;;
1471    *)
1472      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
1473      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1474          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1475          -e 's|libext="lib"|libext="a"|' \
1476      libtool > conftest.bla
1477
1478      mv conftest.bla libtool
1479      chmod 755 libtool
1480      ;;
1481  esac
1482esac
1483
1484# ToDo
1485# For now, don't use the -no-undefined flag, since the Makefiles are
1486# not yet set up that way.  But we need to fix this, when we want
1487# to comile DLLs under Windows.
1488LT_LDFLAGS=
1489AC_SUBST(LT_LDFLAGS)
1490]) # AC_COIN_PROG_LIBTOOL
1491
1492# This is a trick to force the check for the dlfcn header to be done before
1493# the checks for libtool
1494AC_DEFUN([AC_COIN_DLFCN_H],
1495[AC_LANG_PUSH(C)
1496AC_COIN_CHECK_HEADER([dlfcn.h])
1497AC_LANG_POP(C)
1498]) # AC_COIN_DLFCN_H
1499
1500###########################################################################
1501#                            COIN_RPATH_FLAGS                             #
1502###########################################################################
1503
1504# This macro, in case shared objects are used, defines a variable
1505# RPATH_FLAGS that can be used by the linker to hardwire the library
1506# search path for the given directories.  This is useful for example
1507# Makefiles
1508
1509AC_DEFUN([AC_COIN_RPATH_FLAGS],
1510[RPATH_FLAGS=
1511
1512if test $enable_shared = yes; then
1513  case $build in
1514    *-linux-*)
1515      if test "$GXX" = "yes"; then
1516        RPATH_FLAGS=
1517        for dir in $1; do
1518          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1519        done
1520      fi ;;
1521    *-darwin*)
1522        RPATH_FLAGS=nothing ;;
1523    *-ibm-*)
1524      case "$CXX" in
1525      xlC* | */xlC* | mpxlC* | */mpxlC*)
1526        RPATH_FLAGS=nothing ;;
1527      esac ;;
1528    *-hp-*)
1529        RPATH_FLAGS=nothing ;;
1530    *-mingw32)
1531        RPATH_FLAGS=nothing ;;
1532    *-sun-*)
1533        RPATH_FLAGS=
1534        for dir in $1; do
1535          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
1536        done
1537  esac
1538
1539  if test "$RPATH_FLAGS" = ""; then
1540    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.])
1541  fi
1542  if test "$RPATH_FLAGS" = "nothing"; then
1543    RPATH_FLAGS=
1544  fi
1545fi
1546
1547AC_SUBST(RPATH_FLAGS)
1548]) # AC_COIN_RPATH_FLAGS
1549
1550###########################################################################
1551#                              COIN_FINALIZE                              #
1552###########################################################################
1553
1554# This macro should be called at the very end of the configure.ac file.
1555# It creates the output files (by using AC_OUTPUT), and might do some other
1556# things (such as generating links to data files in a VPATH configuration).
1557# It also prints the "success" message.
1558
1559AC_DEFUN([AC_COIN_FINALIZE],
1560[
1561FADDLIBS="$ADDLIBS"
1562if test x"$coin_need_flibs" = xyes; then
1563  ADDLIBS="$ADDLIBS $FLIBS"
1564fi
1565
1566# library extension
1567AC_SUBST(LIBEXT)
1568case "$CC" in
1569  cl*) LIBEXT=lib ;;
1570    *) LIBEXT=a ;;
1571esac
1572
1573# Define VPATH_DISTCLEANFILES to be everything that needs to be
1574# cleaned for distclean in a vpath configuration
1575AC_SUBST(VPATH_DISTCLEANFILES)
1576VPATH_DISTCLEANFILES="$coin_vpath_link_files"
1577
1578AC_OUTPUT
1579
1580if test x"$coin_vpath_link_files" = x; then : ; else
1581  lnkcmd=
1582  if test "$enable_doscompile" = yes; then
1583    lnkcmd=cp
1584  fi
1585  case "$CC" in
1586    cl* | */cl*)
1587      lnkcmd=cp ;;
1588  esac
1589  if test "$lnkcmd" = cp; then
1590    AC_MSG_NOTICE(Copying data files for VPATH configuration)
1591  else
1592    AC_PROG_LN_S
1593    AC_MSG_NOTICE(Creating VPATH links for data files)
1594    lnkcmd="$LN_S"
1595  fi
1596  for file in $coin_vpath_link_files; do
1597    dir=`AS_DIRNAME(["./$file"])`
1598    if test -d $dir; then : ; else
1599      AS_MKDIR_P($dir)
1600    fi
1601    rm -f $file
1602    $lnkcmd $abs_source_dir/$file $file
1603  done
1604fi
1605
1606if test x$coin_projectdir = xyes; then
1607  AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
1608else
1609  AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
1610fi
1611]) #AC_COIN_FINALIZE
1612
1613###########################################################################
1614#                             COIN_VPATH_LINK                             #
1615###########################################################################
1616
1617# This macro makes sure that a symbolic link is created to a file in
1618# the source code directory tree if we are in a VPATH compilation, and
1619# if this package is the main package to be installed
1620
1621AC_DEFUN([AC_COIN_VPATH_LINK],
1622[AC_REQUIRE([AC_COIN_CHECK_VPATH])
1623if test $coin_vpath_config = yes; then
1624  coin_vpath_link_files="$coin_vpath_link_files $1"
1625fi
1626]) #AC_COIN_VPATH_LINK
1627
1628###########################################################################
1629#                       COIN_ENABLE_GNU_PACKAGES                          #
1630###########################################################################
1631
1632# This macro defined the --enable-gnu-packages flag.  This can be used
1633# to check if a user wants to compile GNU packges (such as readline or
1634# zlib) into the executable.  By default, GNU packages are disabled.
1635# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
1636
1637AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
1638[AC_ARG_ENABLE([gnu-packages],
1639               [AC_HELP_STRING([--enable-gnu-packages],
1640                               [compile with GNU packages (disabled by default)])],
1641               [coin_enable_gnu=$enableval],
1642               [coin_enable_gnu=no])
1643]) # AC_COIN_ENABLE_GNU_PACKAGES
1644
1645###########################################################################
1646#                           COIN_CHECK_GNU_ZLIB                           #
1647###########################################################################
1648
1649# This macro checks for the libz library.
1650
1651AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
1652[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1653AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1654AC_BEFORE([AC_COIN_PROG_CC],[$0])
1655AC_BEFORE([AC_COIN_PROG_F77],[$0])
1656AC_BEFORE([$0],[AC_COIN_FINISH])
1657
1658coin_has_zlib=no
1659if test $coin_enable_gnu = yes; then
1660  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
1661
1662  if test $coin_has_zlib = yes; then
1663    AC_CHECK_LIB([z],[gzopen],
1664                 [ADDLIBS="-lz $ADDLIBS"],
1665                 [coin_has_zlib=no])
1666  fi
1667
1668  if test $coin_has_zlib = yes; then
1669    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
1670  fi
1671fi
1672
1673AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
1674]) # AC_COIN_CHECK_GNU_ZLIB
1675
1676
1677###########################################################################
1678#                          COIN_CHECK_GNU_BZLIB                           #
1679###########################################################################
1680
1681# This macro checks for the libbz2 library.
1682
1683AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
1684[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1685AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1686AC_BEFORE([AC_COIN_PROG_CC],[$0])
1687AC_BEFORE([AC_COIN_PROG_F77],[$0])
1688AC_BEFORE([$0],[AC_COIN_FINISH])
1689
1690coin_has_bzlib=no
1691if test $coin_enable_gnu = yes; then
1692  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
1693
1694  if test $coin_has_bzlib = yes; then
1695    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
1696                 [ADDLIBS="-lbz2 $ADDLIBS"],
1697                 [coin_has_bzlib=no])
1698  fi
1699
1700  if test $coin_has_bzlib = yes; then
1701    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
1702  fi
1703fi
1704]) # AC_COIN_CHECK_GNU_BZLIB
1705
1706
1707###########################################################################
1708#                         COIN_CHECK_GNU_READLINE                         #
1709###########################################################################
1710
1711# This macro checks for GNU's readline.  It verifies that the header
1712# readline/readline.h is available, and that the -lreadline library
1713# contains "readline".  It is assumed that #include <stdio.h> is included
1714# in the source file before the #include<readline/readline.h>
1715
1716AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
1717[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1718AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1719AC_BEFORE([AC_COIN_PROG_CC],[$0])
1720AC_BEFORE([AC_COIN_PROG_F77],[$0])
1721AC_BEFORE([$0],[AC_COIN_FINISH])
1722
1723coin_has_readline=no
1724if test $coin_enable_gnu = yes; then
1725  AC_COIN_CHECK_HEADER([readline/readline.h],
1726                       [coin_has_readline=yes],[],
1727                       [#include <stdio.h>])
1728
1729  coin_save_LIBS="$LIBS"
1730  LIBS=
1731  # First we check if tputs and friends are available
1732  if test $coin_has_readline = yes; then
1733    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
1734                   [coin_has_readline=no])
1735  fi
1736
1737  # Now we check for readline
1738  if test $coin_has_readline = yes; then
1739    AC_CHECK_LIB([readline],[readline],
1740                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
1741                 [coin_has_readline=no])
1742  fi
1743
1744  if test $coin_has_readline = yes; then
1745    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
1746  fi
1747
1748  LIBS="$coin_save_LIBS"
1749fi
1750]) # AC_COIN_CHECK_GNU_READLINE
1751
1752###########################################################################
1753#                             COIN_DATA_PATH                              #
1754###########################################################################
1755
1756# This macro defines a preprocessor macro with the absolute path to a
1757# subdirectory of Data.  The argument of this macro is the name of the
1758# subdirectory (in correct case), and the name of the macro is
1759# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
1760# the directory.  The path ends with a separator ("/" for linux and
1761# '\\' for Windows).  The default value for this path can be
1762# overwritten with the input variable with the same name
1763# (COIN_DATA_DIR_PATH).  At this point we chech only for the
1764# $srcdir/../Data subdirectory.
1765
1766AC_DEFUN([AC_COIN_DATA_PATH],
1767[AC_MSG_CHECKING([absolute path to data directory $1])
1768
1769AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
1770
1771if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
1772  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
1773fi
1774
1775# Under Cygwin, use Windows path.  Add separator
1776case $build in
1777  *-cygwin*)
1778    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
1779    ;;
1780  *)
1781    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
1782    ;;
1783esac
1784
1785if test -r $m4_toupper(COIN_DATA_$1_PATH); then
1786  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
1787            [Define to absolute path for Data subdirectory $1])
1788  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
1789else
1790  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
1791fi
1792]) # AC_COIN_HAS_DATA
1793
1794###########################################################################
1795#                          COIN_EXAMPLE_FILES                             #
1796###########################################################################
1797
1798# This macro determines the names of the example files (using the
1799# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
1800# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
1801# creates soft links to the example files.
1802
1803AC_DEFUN([AC_COIN_EXAMPLE_FILES],
1804[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
1805AC_REQUIRE([AC_COIN_CHECK_VPATH])
1806files=`cd $srcdir; ls $1`
1807# We need to do the following loop to make sure that are no newlines
1808# in the variable
1809for file in $files; do
1810  EXAMPLE_FILES="$EXAMPLE_FILES $file"
1811done
1812if test $coin_vpath_config = yes; then
1813  lnkcmd=
1814  if test "$enable_doscompile" = yes; then
1815    lnkcmd=cp
1816  fi
1817  case "$CC" in
1818    cl* | */cl*)
1819      lnkcmd=cp ;;
1820  esac
1821  if test "$lnkcmd" = cp; then
1822    AC_MSG_NOTICE([Copying example files ($1)])
1823  else
1824    AC_PROG_LN_S
1825    AC_MSG_NOTICE([Creating links to the example files ($1)])
1826    lnkcmd="$LN_S"
1827  fi
1828  for file in $EXAMPLE_FILES; do
1829    rm -f $file
1830    $lnkcmd $srcdir/$file $file
1831  done
1832  EXAMPLE_CLEAN_FILES='$1'
1833else
1834  EXAMPLE_CLEAN_FILES=
1835fi
1836
1837# In case there are compressed files, we create a variable with the
1838# uncompressed names
1839EXAMPLE_UNCOMPRESSED_FILES=
1840for file in $EXAMPLE_FILES; do
1841  case $file in
1842    *.gz)
1843      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
1844      ;;
1845  esac
1846done
1847
1848AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
1849AC_SUBST(EXAMPLE_FILES)
1850AC_SUBST(EXAMPLE_CLEAN_FILES)
1851]) #AC_COIN_EXAMPLE_FILES
1852
1853###########################################################################
1854#                            COIN_HAS_PROJECT                             #
1855###########################################################################
1856
1857# This macro sets up usage of a Coin package.  It defines the
1858# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
1859# object directory of the package, respectively.  It also defines
1860# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
1861# argument should be the name (Pkg) of the project (in correct lower
1862# and upper case)
1863
1864AC_DEFUN([AC_COIN_HAS_PROJECT],
1865[AC_MSG_CHECKING([for COIN project $1])
1866
1867# First check, if the sub-project is actually available (ToDo: allow
1868# other locations)
1869
1870m4_tolower(coin_has_$1)=unavailable
1871if test x"$COIN_SKIP_PROJECTS" != x; then
1872  for dir in $COIN_SKIP_PROJECTS; do
1873    if test $dir = $1; then
1874      m4_tolower(coin_has_$1)=skipping
1875    fi
1876  done
1877fi
1878
1879if test $m4_tolower(coin_has_$1) != skipping; then
1880  if test $PACKAGE_TARNAME = m4_tolower($1); then
1881    m4_tolower(coin_has_$1)=.
1882  else
1883    if test -d $srcdir/../$1; then
1884      m4_tolower(coin_has_$1)=../$1
1885    fi
1886  fi
1887fi
1888
1889if test $m4_tolower(coin_has_$1) != unavailable &&
1890   test $m4_tolower(coin_has_$1) != skipping; then
1891  # Set the #define if the component is available
1892  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
1893
1894  # Set the variables for source and object code location
1895  AC_SUBST(m4_toupper($1SRCDIR))
1896  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
1897  AC_SUBST(m4_toupper($1OBJDIR))
1898  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
1899fi
1900
1901  # Define the Makefile conditional
1902AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
1903               [test $m4_tolower(coin_has_$1) != unavailable &&
1904                test $m4_tolower(coin_has_$1) != skipping])
1905AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
1906]) # AC_COIN_HAS
1907
1908###########################################################################
1909#                        COIN_HAS_USER_LIBRARY                            #
1910###########################################################################
1911
1912# This macro sets up usage of a library with header files.  It defines
1913# the LBRYINCDIR variable, and it defines COIN_HAS_LBRY preprocessor
1914# macro and makefile conditional.  The first argument should be the
1915# full name (LibraryName) of the library, and the second argument (in
1916# upper case letters) the abbreviation (LBRY).  This macro also
1917# introduces the configure arguments --with-libraryname-incdir and
1918# --with-libraryname-lib which have to be both given by a user to use
1919# this solver to tell the configure script where the include files and
1920# the library are located.  Those arguments can also be given as
1921# environement variables LBRYINCDIR and LBRYLIB, but a --with-*
1922# argument overwrites an environment variable.  If a third argument is
1923# given, it is assumed that this is the name of a header file that can
1924# be checked for in the given include directory, and if a fourth
1925# argument is given, it is assumed to be the name of a C function
1926# which is given and defined in the library, and a test is done to
1927# check if that symbol is defined in the library.
1928# If it possible to disable the check, by specifying
1929# --disable-libraryname-libcheck - this is a workaround for platforms
1930# where checks don't work (yet) properly.
1931
1932AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
1933[AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
1934AC_MSG_CHECKING(if user provides library for $1)
1935
1936# Check for header file directory
1937AC_ARG_WITH(m4_tolower($1)-incdir,
1938            AC_HELP_STRING([--with-m4_tolower($1)-incdir],
1939                           [specify the directory with the header files for library $1]),
1940                           [$2INCDIR=`cd $withval; pwd`])
1941# Check for library directory
1942AC_ARG_WITH(m4_tolower($1)-lib,
1943            AC_HELP_STRING([--with-m4_tolower($1)-lib],
1944                           [specify the flags to link with the library $1]),
1945                           [$2LIB=$withval])
1946# Switch to disable library check if requested
1947AC_ARG_ENABLE(m4_tolower($1)-libcheck,
1948              AC_HELP_STRING([--enable-m4_tolower($1)-libcheck],
1949                             [use disable-m4_tolower($1)-libcheck to skip the link check at configuration time]),
1950              [m4_tolower($1)_libcheck=$enableval],
1951              [m4_tolower($1)_libcheck=yes])
1952
1953if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
1954  m4_tolower(coin_has_$2)=true
1955else
1956  m4_tolower(coin_has_$2)=false
1957fi
1958
1959if test $m4_tolower(coin_has_$2) = true; then
1960# Check either both arguments or none are given
1961  if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
1962    AC_MSG_ERROR([You need to specify both --with-m4_tolower($1)-incdir and --with-m4_tolower($1)-lib if you want to use library $1])
1963  fi
1964  AC_MSG_RESULT(yes)
1965  # Check if the given header file is there
1966  m4_ifvaln([$3],[AC_CHECK_FILE([$$2INCDIR/$3],[],
1967                 [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
1968  # Check if the symbol is provided in the library
1969  # ToDo: FOR NOW WE ASSUME THAT WE ARE USING THE C++ COMPILER
1970  m4_ifvaln([$4],[if test x"$m4_tolower($1)_libcheck" != xno; then
1971                    coin_save_LIBS="$LIBS"
1972                    LIBS="$$2LIB $ADDLIBS"
1973                    AC_MSG_CHECKING([whether symbol $4 is available with $2])
1974# ToDo find out what to do about extern "C"
1975#                    AC_TRY_LINK([extern "C" {void $4();}],[$4()],
1976                    AC_TRY_LINK([void $4();],[$4()],
1977                                [AC_MSG_RESULT(yes)],
1978                                [AC_MSG_RESULT(no)
1979                                 AC_MSG_ERROR([Cannot find symbol $4 with $2])])
1980                    LIBS="$coin_save_LIBS"
1981                  fi])
1982  ADDLIBS="$$2LIB $ADDLIBS"
1983  AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is used])
1984else
1985  AC_MSG_RESULT(no)
1986fi
1987
1988AC_SUBST($2INCDIR)
1989AC_SUBST($2LIB)
1990AM_CONDITIONAL(COIN_HAS_$2,
1991               test $m4_tolower(coin_has_$2) = true)
1992]) #AC_COIN_HAS_SOLVER
1993
1994###########################################################################
1995#                               COIN_HAS_ASL                              #
1996###########################################################################
1997
1998# This macro checks if the user has provide arguments that say where
1999# the precompiled ASL files should be found (with the --with-asldir
2000# flag).  If this is not the case, we check if the ThirdParty/ASL
2001# directory has been configured, which indicates that the files will
2002# be in that directory and can be used.
2003
2004AC_DEFUN([AC_COIN_HAS_ASL],
2005[coin_aslobjdir=../ThirdParty/ASL
2006coin_aslsrcdir=$srcdir/$coin_aslobjdir
2007
2008# Determine the name of the ASL library
2009case "$CXX" in
2010  cl* | */cl*)
2011    ampllib=amplsolv.lib ;;
2012  *)
2013    ampllib=amplsolver.a ;;
2014esac
2015
2016AC_ARG_WITH([asldir],
2017            AC_HELP_STRING([--with-asldir],
2018                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
2019            [use_asldir=$withval], [use_asldir=])
2020
2021if test "$use_asldir" = BUILD; then
2022  AC_CHECK_FILE([$coin_aslobjdir/Makefile],[],
2023                [AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])])
2024elif test -z "$use_asldir"; then
2025 # try to find sources - if not given don't compile
2026  AC_CHECK_FILE([$coin_aslobjdir/Makefile],[use_asldir=BUILD],[use_asldir=no])
2027elif test "$use_asldir" != "no"; then
2028  AC_CHECK_FILE([$use_asldir/$ampllib],[],
2029                [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
2030  AC_CHECK_FILE([$use_asldir/asl.h],[],
2031                [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
2032  use_asldir=`cd $use_asldir; pwd`
2033  case $build in
2034    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
2035  esac
2036fi
2037
2038# Variable containing ASL library (including full path)
2039AC_SUBST(ASLLIB)
2040# Variable containing flags for including ASL header files
2041AC_SUBST(ASL_CPPFLAGS)
2042
2043if test "$use_asldir" = BUILD; then
2044  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
2045  ASLLIB=`$CYGPATH_W $coin_aslobjdir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2046  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
2047  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir | sed -e sX\\\\\\\\X/Xg`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers | sed -e sX\\\\\\\\X/Xg`
2048elif test "$use_asldir" != no; then
2049  ASLLIB=`$CYGPATH_W $use_asldir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2050  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir | sed -e sX\\\\\\\\X/Xg`
2051fi
2052
2053if test "$use_asldir" != no; then
2054  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
2055  coin_has_asl=yes
2056  AC_DEFINE([COIN_HAS_ASL],[1],
2057            [If defined, the Ampl Solver Library is available.])
2058else
2059  coin_has_asl=no
2060fi
2061AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
2062]) # AC_COIN_HAS_ASL
2063
2064###########################################################################
2065#                            COIN_TRY_FLINK                               #
2066###########################################################################
2067
2068# Auxilliary macro to test if a Fortran function name can be linked,
2069# given the current settings of LIBS.  We determine from the context, what
2070# the currently active programming language is, and cast the name accordingly.
2071# The first argument is the name of the function/subroutine, in small letters,
2072# the second argument are the actions taken when the test works, and the
2073# third argument are the actions taken if the test fails.
2074
2075AC_DEFUN([AC_COIN_TRY_FLINK],
2076[case $ac_ext in
2077  f)
2078    AC_TRY_LINK([],[      call $1],[$2],[$3])
2079    ;;
2080  c)
2081    AC_F77_FUNC($1,cfunc$1)
2082    if test x"$coin_need_flibs" = xyes; then
2083      flink_try=no;
2084    else
2085      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2086                  [flink_try=yes],[flink_try=no])
2087    fi
2088    if test $flink_try = yes; then
2089      $2
2090    else
2091      if test x"$FLIBS" != x; then
2092        flink_save_libs="$LIBS"
2093        LIBS="$LIBS $FLIBS"
2094        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2095                    [LIBS="$flink_save_libs"
2096                     $2
2097                     coin_need_flibs=yes],
2098                    [LIBS="$flink_save_libs"
2099                     $3])
2100      else
2101        $3
2102      fi
2103    fi
2104    ;;
2105  cc)
2106    AC_F77_FUNC($1,cfunc$1)
2107    if test x"$coin_need_flibs" = xyes; then
2108      flink_try=no;
2109    else
2110      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2111                  [flink_try=yes],[flink_try=no])
2112    fi
2113    if test $flink_try = yes; then
2114      $2
2115    else
2116      if test x"$FLIBS" != x; then
2117        flink_save_libs="$LIBS"
2118        LIBS="$LIBS $FLIBS"
2119        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2120                    [LIBS="$flink_save_libs"
2121                     $2
2122                     coin_need_flibs=yes],
2123                    [LIBS="$flink_save_libs"
2124                     $3])
2125      else
2126        $3
2127      fi
2128    fi
2129    ;;
2130esac
2131]) # AC_COIN_TRY_FLINK
2132
2133###########################################################################
2134#                             COIN_HAS_BLAS                               #
2135###########################################################################
2136
2137# This macro checks for a library containing the BLAS library.  It
2138# tried standard libraries, and if none is found to be working, it
2139# checks whether the BLAS ThirdParty/Blas directory has been configured.
2140# It adds to ADDLIBS any flags required to link with an externally provided
2141# BLAS.  It defines the makefile conditional and preprocessor macro
2142# COIN_HAS_BLAS, if blas is available, and it defines the makefile conditional
2143# COIN_BUILD_BLAS, if blas is compiled within COIN.
2144
2145AC_DEFUN([AC_COIN_HAS_BLAS],
2146[coin_blasobjdir=../ThirdParty/Blas
2147coin_blassrcdir=$srcdir/$coin_blasobjdir
2148
2149AC_ARG_WITH([blas],
2150            AC_HELP_STRING([--with-blas],
2151                           [specify BLAS library (or BUILD for compilation)]),
2152            [use_blas=$withval], [use_blas=])
2153
2154# Check if user supplied option makes sense
2155if test x"$use_blas" != x; then
2156  if test "$use_blas" = "BUILD"; then
2157    AC_CHECK_FILE([$coin_blasobjdir/Makefile],[],
2158                  [AC_MSG_ERROR([option \"BUILD\" specified for Blas, but $coin_blasobjdir directory is not configured])])
2159  else
2160    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2161    LIBS="$use_blas $LIBS"
2162    ADDLIBS="$use_blas $ADDLIBS"
2163    AC_COIN_TRY_FLINK([daxpy],
2164                      [AC_MSG_RESULT([yes])],
2165                      [AC_MSG_RESULT([no])
2166                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2167  fi
2168else
2169# Try to autodetect the library for blas based on build system
2170  case $build in
2171    *-sgi-*)
2172      SAVE_LIBS="$LIBS"
2173      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2174      LIBS="-lcomplib.sgimath $LIBS"
2175      AC_COIN_TRY_FLINK([daxpy],
2176                        [AC_MSG_RESULT([yes])
2177                         use_blas=-lcomplib.sgimath;
2178                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2179                        [AC_MSG_RESULT([no])
2180                         SAVE_LIBS="$LIBS"])
2181      ;;
2182    *-sun-*)
2183      SAVE_LIBS="$LIBS"
2184      AC_MSG_CHECKING([whether -xlic_lib=sunperf has BLAS])
2185      LIBS="-xlic_lib=sunperf $LIBS"
2186      AC_COIN_TRY_FLINK([daxpy],
2187                        [AC_MSG_RESULT([yes])
2188                         use_blas='-xlic_lib=sunperf'
2189                         ADDLIBS="-xlic_lib=sunperf $ADDLIBS"],
2190                        [AC_MSG_RESULT([no])
2191                         LIBS="$SAVE_LIBS"])
2192      ;;
2193  esac
2194  # On cygwin, if enable_doscompile is used, recompile blas because it
2195  # otherwise links with the cygwin blas which doesn't run under DOS
2196  if test "$enable_doscompile" != yes; then
2197    if test -z "$use_blas"; then
2198      SAVE_LIBS="$LIBS"
2199      AC_MSG_CHECKING([whether -lblas has BLAS])
2200      LIBS="-lblas $LIBS"
2201      AC_COIN_TRY_FLINK([daxpy],
2202                        [AC_MSG_RESULT([yes])
2203                         ADDLIBS="-lblas $ADDLIBS"
2204                         use_blas='-lblas'],
2205                        [AC_MSG_RESULT([no])
2206                         LIBS="$SAVE_LIBS"])
2207    fi
2208  fi
2209  if test -z "$use_blas"; then
2210    AC_CHECK_FILE([$coin_blasobjdir/Makefile],[use_blas=BUILD])
2211  fi
2212fi
2213
2214AM_CONDITIONAL([COIN_HAS_BLAS],[test x"$use_blas" != x])
2215AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
2216
2217if test x"$use_blas" = x; then
2218  coin_has_blas=no
2219else
2220  coin_has_blas=yes
2221  AC_DEFINE([COIN_HAS_BLAS],[1],
2222            [If defined, the BLAS Library is available.])
2223fi
2224]) # AC_COIN_HAS_BLAS
2225
2226###########################################################################
2227#                            COIN_HAS_LAPACK                              #
2228###########################################################################
2229
2230# This macro checks for a library containing the LAPACK library.  It
2231# tried standard libraries, and if none is found to be working, it
2232# checks whether the LAPACK ThirdParty/Lapack directory has been
2233# configured.  It adds to ADDLIBS any flags required to link with an
2234# externally provided LAPACK.  It defines the makefile conditional and
2235# preprocessor macro COIN_HAS_LAPACK, if lapack is available, and it
2236# defines the makefile conditional COIN_BUILD_LAPACK, if lapack is
2237# compiled within COIN.
2238
2239AC_DEFUN([AC_COIN_HAS_LAPACK],
2240[coin_lapackobjdir=../ThirdParty/Lapack
2241coin_lapacksrcdir=$srcdir/$coin_lapackobjdir
2242
2243AC_ARG_WITH([lapack],
2244            AC_HELP_STRING([--with-lapack],
2245                           [specify LAPACK library (or BUILD for compilation)]),
2246            [use_lapack=$withval], [use_lapack=])
2247
2248# Check if user supplied option makes sense
2249if test x"$use_lapack" != x; then
2250  if test "$use_lapack" = "BUILD"; then
2251    AC_CHECK_FILE([$coin_lapackobjdir/Makefile],[],
2252                  [AC_MSG_ERROR([option \"BUILD\" specified for Lapack, but $coin_lapackobjdir directory is not configured])])
2253  else
2254    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
2255    LIBS="$use_lapack $LIBS"
2256    ADDLIBS="$use_lapack $ADDLIBS"
2257    AC_COIN_TRY_FLINK([dsyev],
2258                      [AC_MSG_RESULT([yes])],
2259                      [AC_MSG_RESULT([no])
2260                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
2261  fi
2262else
2263  if test x$coin_has_blas = xyes; then
2264    # First try to see if LAPACK is already available with BLAS library
2265    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
2266    AC_COIN_TRY_FLINK([dsyev],
2267                      [AC_MSG_RESULT([yes]); use_lapack=ok],
2268                      [AC_MSG_RESULT([no])])
2269  fi
2270  if test -z "$use_lapack"; then
2271    # Try to autodetect the library for lapack based on build system
2272    case $build in
2273      *-sgi-*)
2274        SAVE_LIBS="$LIBS"
2275        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
2276        LIBS="-lcomplib.sgimath $LIBS"
2277        AC_COIN_TRY_FLINK([dsyev],
2278                          [AC_MSG_RESULT([yes])
2279                           use_lapack=-lcomplib.sgimath;
2280                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2281                          [AC_MSG_RESULT([no])
2282                           SAVE_LIBS="$LIBS"])
2283        ;;
2284      *-sun-*)
2285        SAVE_LIBS="$LIBS"
2286        AC_MSG_CHECKING([whether -xlic_lib=sunperf has LAPACK])
2287        LIBS="-xlic_lib=sunperf $LIBS"
2288        AC_COIN_TRY_FLINK([dsyev],
2289                          [AC_MSG_RESULT([yes])
2290                           use_lapack='-xlic_lib=sunperf'
2291                           ADDLIBS="-xlic_lib=sunperf $ADDLIBS"],
2292                          [AC_MSG_RESULT([no])
2293                           LIBS="$SAVE_LIBS"])
2294        ;;
2295    esac
2296  fi
2297  # On cygwin, if enable_doscompile is used, recompile lapack because it
2298  # otherwise links with the cygwin lapack which doesn't run under DOS
2299  if test "$enable_doscompile" != yes; then
2300    if test -z "$use_lapack"; then
2301      SAVE_LIBS="$LIBS"
2302      AC_MSG_CHECKING([whether -llapack has LAPACK])
2303      LIBS="-llapack $LIBS"
2304      AC_COIN_TRY_FLINK([dsyev],
2305                        [AC_MSG_RESULT([yes])
2306                         ADDLIBS="-llapack $ADDLIBS"
2307                         use_lapack='-llapack'],
2308                        [AC_MSG_RESULT([no])
2309                         LIBS="$SAVE_LIBS"])
2310    fi
2311  fi
2312  if test -z "$use_lapack"; then
2313    AC_CHECK_FILE([$coin_lapackobjdir/Makefile],[use_lapack=BUILD])
2314  fi
2315fi
2316
2317AM_CONDITIONAL([COIN_HAS_LAPACK],[test x"$use_lapack" != x])
2318AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
2319
2320if test x"$use_lapack" = x; then
2321  coin_has_lapack=no
2322else
2323  coin_has_lapack=yes
2324  AC_DEFINE([COIN_HAS_LAPACK],[1],
2325            [If defined, the LAPACK Library is available.])
2326fi
2327]) # AC_COIN_HAS_LAPACK
Note: See TracBrowser for help on using the repository browser.