source: branches/devel/coin.m4 @ 721

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

removed -DNDEBUG from FFLAGS

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