source: trunk/coin.m4 @ 361

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

fix confdefs.h file for MSVC compiler - that exit function does not seem to make sense

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