source: trunk/coin.m4 @ 206

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

corrected flibs correction

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