source: stable/0.5/coin.m4 @ 1024

Last change on this file since 1024 was 1024, checked in by ladanyi, 13 years ago

changed default opt level to -O from -O3 for xlc

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