source: trunk/coin.m4 @ 46

Last change on this file since 46 was 46, checked in by andreasw, 15 years ago

Enabled Ampl executable for Cbc

File size: 55.4 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,v 1.1.2.1 2006/04/19 23:25:12 andreasw Exp $
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[m4_ifvaln([$1],[AC_MSG_CHECKING(whether directory $1 is available)
26                if test -r $srcdir/$1/configure; then
27                  coin_subdirs="$coin_subdirs $1"
28                  AC_MSG_RESULT(yes)
29                  AC_CONFIG_SUBDIRS($1)
30                else
31                  AC_MSG_RESULT(no)
32                fi])
33m4_ifvaln([$2],[AC_MSG_CHECKING(whether directory $2 is available)
34                if test -r $srcdir/$2/configure; then
35                  coin_subdirs="$coin_subdirs $2"
36                  AC_MSG_RESULT(yes)
37                  AC_CONFIG_SUBDIRS($2)
38                else
39                  AC_MSG_RESULT(no)
40                fi])
41m4_ifvaln([$3],[AC_MSG_CHECKING(whether directory $3 is available)
42                if test -r $srcdir/$3/configure; then
43                  coin_subdirs="$coin_subdirs $3"
44                  AC_MSG_RESULT(yes)
45                  AC_CONFIG_SUBDIRS($3)
46                else
47                  AC_MSG_RESULT(no)
48                fi])
49m4_ifvaln([$4],[AC_MSG_CHECKING(whether directory $4 is available)
50                if test -r $srcdir/$4/configure; then
51                  coin_subdirs="$coin_subdirs $4"
52                  AC_MSG_RESULT(yes)
53                  AC_CONFIG_SUBDIRS($4)
54                else
55                  AC_MSG_RESULT(no)
56                fi])
57m4_ifvaln([$5],[AC_MSG_CHECKING(whether directory $5 is available)
58                if test -r $srcdir/$5/configure; then
59                  coin_subdirs="$coin_subdirs $5"
60                  AC_MSG_RESULT(yes)
61                  AC_CONFIG_SUBDIRS($5)
62                else
63                  AC_MSG_RESULT(no)
64                fi])
65m4_ifvaln([$6],[AC_MSG_CHECKING(whether directory $6 is available)
66                if test -r $srcdir/$6/configure; then
67                  coin_subdirs="$coin_subdirs $6"
68                  AC_MSG_RESULT(yes)
69                  AC_CONFIG_SUBDIRS($6)
70                else
71                  AC_MSG_RESULT(no)
72                fi])
73m4_ifvaln([$7],[AC_MSG_CHECKING(whether directory $7 is available)
74                if test -r $srcdir/$7/configure; then
75                  coin_subdirs="$coin_subdirs $7"
76                  AC_MSG_RESULT(yes)
77                  AC_CONFIG_SUBDIRS($7)
78                else
79                  AC_MSG_RESULT(no)
80                fi])
81m4_ifvaln([$8],[AC_MSG_CHECKING(whether directory $8 is available)
82                if test -r $srcdir/$8/configure; then
83                  coin_subdirs="$coin_subdirs $8"
84                  AC_MSG_RESULT(yes)
85                  AC_CONFIG_SUBDIRS($8)
86                else
87                  AC_MSG_RESULT(no)
88                fi])
89m4_ifvaln([$9],[AC_MSG_CHECKING(whether directory $9 is available)
90                if test -r $srcdir/$9/configure; then
91                  coin_subdirs="$coin_subdirs $9"
92                  AC_MSG_RESULT(yes)
93                  AC_CONFIG_SUBDIRS($9)
94                else
95                  AC_MSG_RESULT(no)
96                fi])
97m4_ifvaln([$10],[AC_MSG_CHECKING(whether directory $10 is available)
98                if test -r $srcdir/$10/configure; then
99                  coin_subdirs="$coin_subdirs $10"
100                  AC_MSG_RESULT(yes)
101                  AC_CONFIG_SUBDIRS($10)
102                else
103                  AC_MSG_RESULT(no)
104                fi])
105]) # AC_COIN_MAIN_SUBDIRS
106
107###########################################################################
108#                        COIN_THIRDPARTY_SUBDIRS                          #
109###########################################################################
110
111# This macro sets up the recursion into the configure script in a
112# subdirectory for compilation of third party code.  The first
113# argument is just the string that appears in the configure output.
114# The second argument is the directory with the configure script, and
115# the third one is a file that should exists in that directory.  If
116# this file does not exist, we assume that the user has not downloaded
117# the code, and we are not going to compile it
118
119AC_DEFUN([AC_COIN_THIRDPARTY_SUBDIRS],
120[AC_MSG_CHECKING(whether code for third party package $1 is available)
121if test -r $srcdir/$2/$3; then
122  coin_subdirs="$coin_subdirs $2"
123  AC_MSG_RESULT(yes)
124  AC_CONFIG_SUBDIRS($2)
125else
126  AC_MSG_RESULT(no)
127fi
128]) # AC_COIN_THIRDPARTY_SUBDIRS
129
130###########################################################################
131#                           COIN_CHECK_VPATH                              #
132###########################################################################
133
134# This macro sets the variable coin_vpath_config to true if this is a
135# VPATH configuration, otherwise it sets it to false.
136AC_DEFUN([AC_COIN_CHECK_VPATH],
137[AC_MSG_CHECKING(whether this is a VPATH configuration)
138if test `cd $srcdir; pwd` != `pwd`; then
139  coin_vpath_config=yes;
140else
141  coin_vpath_config=no;
142fi
143AC_MSG_RESULT($coin_vpath_config)
144]) # AC_COIN_CHECK_VPATH
145
146###########################################################################
147#                         COIN_PROJECTDIR_INIT                            #
148###########################################################################
149
150# This macro does everything that is required in the early part in the
151# configure script, such as defining a few variables.  This should only
152# be used in the main directory of a project directory (the one under
153# which src is)
154
155AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
156[# Initialize the ADDLIBS variable
157ADDLIBS='-lm'
158AC_SUBST(ADDLIBS)
159
160# A useful makefile conditional that is always false
161AM_CONDITIONAL(ALWAYS_FALSE, false)
162
163# We set the following variable so that we know later in AC_COIN_FINALIZE
164# that we are in a project main directory
165
166]) # AC_COIN_PROJECTDIR_INIT
167
168###########################################################################
169#                          COIN_DEBUG_COMPILE                             #
170###########################################################################
171
172# enable the configure flag --enable-debug and set the variable
173# coin_debug_compile to true or false
174# This is used by COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77
175# to determine the compilation flags.
176# It defines the #define macro COIN_DEBUG if it is chosen, and the makefile
177# conditional COIN_DEBUG is defined
178
179AC_DEFUN([AC_COIN_DEBUG_COMPILE],
180[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
181AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
182AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
183
184AC_MSG_CHECKING([whether we want to compile in debug mode])
185
186AC_ARG_ENABLE([debug],
187[AC_HELP_STRING([--enable-debug],
188                [compile with debug options and runtime tests])],
189                [case "${enableval}" in
190                   yes) coin_debug_compile=true
191                     AC_DEFINE([COIN_DEBUG],[1],
192                               [If defined, debug sanity checks are performed during runtime])
193                     enable_shared=no
194                     ;;
195                   no)  coin_debug_compile=false
196                     ;;
197                    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
198                     ;;
199                 esac],
200                [coin_debug_compile=false])
201
202if test $coin_debug_compile = true; then
203  AC_MSG_RESULT([yes])
204else
205  AC_MSG_RESULT([no])
206fi
207
208AM_CONDITIONAL([COIN_DEBUG],[test "$coin_debug_compile" = true])
209]) # AC_COIN_DEBUG_COMPILE
210
211###########################################################################
212#                          COIN_MINGW_LD_FIX                              #
213###########################################################################
214
215# This macro is included by any PROG_compiler macro, to set the LD
216# environment variable on MinWG to the correct value (link)
217
218AC_DEFUN([AC_COIN_MINGW_LD_FIX],
219[case $build in
220  *-mingw*)
221    if test "${LD+set}" = set; then :; else
222      LD=link
223    fi
224    ;;
225esac
226])
227
228###########################################################################
229#                             COIN_PROG_CXX                               #
230###########################################################################
231
232# Find the compile command by running AC_PROG_CXX (with compiler names
233# for different operating systems) and put it into CXX (unless it was
234# given my the user), and find an appropriate value for CXXFLAGS.  It is
235# possible to provide additional -D flags in the variable CXXDEFS.
236
237AC_DEFUN([AC_COIN_PROG_CXX],
238[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
239AC_LANG_PUSH(C++)
240
241AC_ARG_VAR(CXXDEFS,[Additional -D flags to be used when compiling C++ code.])
242
243coin_has_cxx=yes
244
245save_cxxflags="$CXXFLAGS"
246case $build in
247  *-cygwin* | *-mingw*)
248             comps="g++ cl" ;;
249  *-darwin*) comps="g++ c++ CC" ;;
250          *) comps="xlC aCC CC g++ c++ pgCC icpc" ;;
251esac
252AC_PROG_CXX([$comps])
253CXXFLAGS="$save_cxxflags"
254
255AC_CACHE_CHECK([for C++ compiler options],[coin_cv_cxxflags],
256[if test x"$CXXFLAGS" = x; then
257
258# ToDo decide whether we want -DNDEBUG for optimization
259  coin_add_cxxflags=
260  coin_opt_cxxflags=
261  coin_dbg_cxxflags=
262  coin_warn_cxxflags=
263
264  if test "$GXX" = "yes"; then
265    case "$CXX" in
266      icpc* | */icpc*)
267        ;;
268      *)
269# ToDo decide about unroll-loops
270        coin_opt_cxxflags="-O3 -fomit-frame-pointer"
271        coin_add_cxxflags="-pipe"
272        coin_dbg_cxxflags="-g"
273        coin_warn_cxxflags="-pedantic-errors -Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion"
274
275        case $build in
276          *-cygwin*)
277            CXXFLAGS="-mno-cygwin"
278            AC_TRY_LINK([],[int i=0; i++;],
279                        [coin_add_cxxflags="-mno-cygwin $coin_add_cxxflags"])
280            CXXFLAGS=
281            ;;
282        esac
283        ;;
284    esac
285  fi
286  if test -z "$coin_opt_cxxflags"; then
287    case $build in
288      *-cygwin* | *-mingw*)
289        case "$CXX" in
290          cl* | */cl*)
291            coin_opt_cxxflags='-O2'
292            coin_add_cxxflags='-nologo -EHsc -GR -MT'
293            coin_dbg_cxxflags='-Yd'
294            ;;
295        esac
296        ;;
297      *-linux-*)
298        case "$CXX" in
299          icpc* | */icpc*)
300            coin_opt_cxxflags="-O3 -ip"
301            coin_add_cxxflags=""
302            coin_dbg_cxxflags="-g"
303            # Check if -i_dynamic is necessary (for new glibc library)
304            CXXFLAGS=
305            AC_TRY_LINK([],[int i=0; i++;],[],
306                        [coin_add_cxxflags="-i_dynamic $coin_add_cxxflags"])
307            ;;
308          pgCC* | */pgCC*)
309            coin_opt_cxxflags="-fast"
310            coin_add_cxxflags="-Kieee -pc 64"
311            coin_dbg_cxxflags="-g"
312            ;;
313        esac
314        ;;
315      *-ibm-*)
316        case "$CXX" in
317          xlC* | */xlC* | mpxlC* | */mpxlC*)
318            coin_opt_cxxflags="-O3 -qarch=auto -qcache=auto -qhot -qtune=auto -qmaxmem=-1"
319            coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna"
320            coin_dbg_cxxflags="-g"
321            ;;
322        esac
323        ;;
324      *-hp-*)
325        case "$CXX" in
326          aCC* | */aCC* )
327            coin_opt_cxxflags="-O"
328            coin_add_cxxflags="-AA"
329            coin_dbg_cxxflags="-g"
330            ;;
331        esac
332        ;;
333      *-sun-*)
334          coin_opt_cxxflags="-O4"
335          coin_dbg_cxxflags="-g"
336        ;;
337    esac
338  fi
339
340  if test "$ac_cv_prog_cxx_g" = yes && test -z "$coin_dbg_cxxflags" ; then
341    coin_dbg_cxxflags="-g"
342  fi
343
344  if test "$coin_debug_compile" = "true"; then
345    CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
346  else
347    if test -z "$coin_opt_cxxflags"; then
348      # Try if -O option works if nothing else is set
349      CXXFLAGS="-O"
350      AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cxxflags="-O"])
351    fi
352    CXXFLAGS="$coin_opt_cxxflags $coin_add_cxxflags -DNDEBUG $CXXDEFS $coin_warn_cxxflags"
353  fi
354fi
355
356# Try if CXXFLAGS works
357AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
358if test -z "$CXXFLAGS"; then
359  AC_MSG_WARN([The flags CXXFLAGS="$CXXFLAGS" do not work.  I will now just try '-O', but you might want to set CXXFLAGS manually.])
360  CXXFLAGS='-O'
361  AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
362  if test -z "$CXXFLAGS"; then
363    AC_MSG_WARN([This value for CXXFLAGS does not work.  I will continue with empty CXXFLAGS, but you might want to set CXXFLAGS manually.])
364  fi
365fi
366coin_cv_cxxflags="$CXXFLAGS"
367]) # AC_CACHE_CHECK([for C++ compiler options CXXFLAGS]
368CXXFLAGS="$coin_cv_cxxflags"
369
370AC_ARG_VAR(MPICXX,[C++ MPI Compiler])
371if test x"$MPICXX" = x; then :; else
372  AC_MSG_NOTICE([Will use MPI C++ compiler $MPICXX])
373  CXX="$MPICXX"
374fi
375
376case "$CXX" in
377  cl*)
378    AC_COIN_MINGW_LD_FIX
379    ;;
380esac
381
382AC_LANG_POP(C++)
383]) # AC_COIN_PROG_CXX
384
385
386###########################################################################
387#                             COIN_CXXLIBS                                #
388###########################################################################
389
390# Determine the C++ runtime libraries required for linking a C++ library
391# with a Fortran or C compiler.  The result is available in CXXLIBS.
392
393AC_DEFUN([AC_COIN_CXXLIBS],
394[AC_REQUIRE([AC_PROG_CXX])dnl
395AC_LANG_PUSH(C++)
396AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with Fortran compiler])
397if test -z "$CXXLIBS"; then
398  if test "$GXX" = "yes"; then
399    case "$CXX" in
400      icpc* | */icpc*)
401        CXXLIBS=""
402        ;;
403      *)
404        CXXLIBS="-lstdc++ -lm" # -lgcc"
405        ;;
406    esac
407  else
408    case $build in
409     *-linux-*)
410      case "$CXX" in
411      icpc* | */icpc*)
412        CXXLIBS=""
413             ;;
414      pgCC* | */pgCC*)
415        CXXLIBS="-lstd -lC -lc"
416             ;;
417      esac;;
418    *-ibm-*)
419      CXXLIBS="-lC -lc"
420      ;;
421    *-hp-*)
422      CXXLIBS="-L/opt/aCC/lib -l++ -lstd_v2 -lCsup_v2 -lm -lcl -lc"
423      ;;
424    *-sun-*)
425      CXXLIBS="-lCstd -lCrun"
426    esac
427  fi
428fi
429if test -z "$CXXLIBS"; then
430  AC_MSG_WARN([Could not automatically determine CXXLIBS (C++ link libraries; necessary if main program is in Fortran of C).])
431else
432  AC_MSG_NOTICE([Assuming that CXXLIBS is \"$CXXLIBS\".])
433fi
434AC_LANG_POP(C++)
435]) # AC_COIN_CXXLIBS
436
437###########################################################################
438#                           COIN_CHECK_HEADER                             #
439###########################################################################
440
441# This macro checks for a header file, but it does so without the
442# standard header.  This avoids warning messages like:
443#
444# configure: WARNING: dlfcn.h: present but cannot be compiled
445# configure: WARNING: dlfcn.h:     check for missing prerequisite headers?
446# configure: WARNING: dlfcn.h: see the Autoconf documentation
447# configure: WARNING: dlfcn.h:     section "Present But Cannot Be Compiled"
448# configure: WARNING: dlfcn.h: proceeding with the preprocessor's result
449# configure: WARNING: dlfcn.h: in the future, the compiler will take precedence
450
451AC_DEFUN([AC_COIN_CHECK_HEADER],
452[if test x"$4" = x; then
453  hdr="#include <$1>"
454else
455  hdr="$4"
456fi
457AC_CHECK_HEADERS([$1],[$2],[$3],[$hdr])
458]) # AC_COIN_CHECK_HEADER
459
460###########################################################################
461#                       COIN_CHECK_CXX_CHEADER                             #
462###########################################################################
463
464# This macro checks for C header files that are used from C++.  For a give
465# stub (e.g., math), it first checks if the C++ library (cmath) is available.
466# If it is, it defines HAVE_CMATH (or whatever the stub is).  If it is not
467# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
468# if that one exists.
469
470AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
471[AC_LANG_PUSH(C++)
472AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
473if test "$ac_cv_header_c$1" != "yes"; then
474  AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
475fi
476AC_LANG_POP(C++)
477]) # AC_COIN_CHECK_CXX_CHEADER
478
479###########################################################################
480#                             COIN_PROG_CC                                #
481###########################################################################
482
483# Find the compile command by running AC_PROG_CC (with compiler names
484# for different operating systems) and put it into CC (unless it was
485# given my the user), and find an appropriate value for CFLAGS.  It is
486# possible to provide additional -D flags in the variable CDEFS.
487
488AC_DEFUN([AC_COIN_PROG_CC],
489[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
490AC_LANG_PUSH(C)
491
492# For consistency, we set the C compiler to the same value of the C++
493# compiler, if the C++ is set, but the C compiler isn't (only for CXX=cl)
494if test x"$CXX" != x; then
495  case $CXX in
496    cl*)
497      if test x"$CC" = x; then
498        CC="$CXX"
499        AC_MSG_WARN([C++ compiler name provided as $CXX, but CC is unset. Setting CC to $CXX])
500      fi
501      ;;
502  esac
503fi
504
505AC_ARG_VAR(CDEFS,[Additional -D flags to be used when compiling C code.])
506
507coin_has_cc=yes
508
509save_cflags="$CFLAGS"
510case $build in
511  *-cygwin* | *-mingw*)
512             comps="gcc cl" ;;
513  *-linux-*) comps="xlc gcc cc pgcc icc" ;;
514  *)         comps="xlc cc gcc pgcc icc" ;;
515esac
516AC_PROG_CC([$comps])
517CFLAGS="$save_cflags"
518
519AC_CACHE_CHECK([for C compiler options],[coin_cv_cflags],
520[if test x"$CFLAGS" = x; then
521
522  coin_add_cflags=
523  coin_opt_cflags=
524  coin_dbg_cflags=
525  coin_warn_cflags=
526
527  if test "$GCC" = "yes"; then
528    case "$CC" in
529      icc* | */icc*)
530        ;;
531      *)
532        coin_opt_cflags="-O3 -fomit-frame-pointer"
533        coin_add_cflags="-pipe"
534        coin_dbg_cflags="-g"
535        coin_warn_cflags="-pedantic-errors -Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall"
536
537        case $build in
538          *-cygwin*)
539            CFLAGS="-mno-cygwin"
540            AC_TRY_LINK([],[int i=0; i++;],
541                        [coin_add_cflags="-mno-cygwin $coin_add_cflags"])
542            CFLAGS=
543          ;;
544        esac
545        ;;
546    esac
547  fi
548  if test -z "$coin_opt_cflags"; then
549    case $build in
550      *-cygwin* | *-mingw*)
551        case "$CC" in
552          cl* | */cl*)
553            coin_opt_cflags='-O2'
554            coin_add_cflags='-nologo'
555            coin_dbg_cflags='-Yd'
556            ;;
557        esac
558        ;;
559      *-linux-*)
560        case "$CC" in
561          icc* | */icc*)
562            coin_opt_cflags="-O3 -ip"
563            coin_add_cflags=""
564            coin_dbg_cflags="-g"
565            # Check if -i_dynamic is necessary (for new glibc library)
566            CFLAGS=
567            AC_TRY_LINK([],[int i=0; i++;],[],
568                        [coin_add_cflags="-i_dynamic $coin_add_cflags"])
569            ;;
570          pgcc* | */pgcc*)
571            coin_opt_cflags="-fast"
572            coin_add_cflags="-Kieee -pc 64"
573            coin_dbg_cflags="-g"
574            ;;
575        esac
576        ;;
577      *-ibm-*)
578        case "$CC" in
579          xlc* | */xlc* | mpxlc* | */mpxlc*)
580            coin_opt_cflags="-O3 -qarch=auto -qcache=auto -qhot -qtune=auto -qmaxmem=-1"
581            coin_add_cflags="-bmaxdata:0x80000000"
582            coin_dbg_cflags="-g"
583          ;;
584        esac
585        ;;
586      *-hp-*)
587        coin_opt_cflags="-O"
588        coin_add_cflags="-Ae"
589        coin_dbg_cflags="-g"
590        ;;
591      *-sun-*)
592        coin_opt_cflags="-xO4"
593        coin_dbg_cflags="-g"
594        ;;
595      *-sgi-*)
596        coin_opt_cflags="-O -OPT:Olimit=0"
597        coin_dbg_cflags="-g"
598        ;;
599    esac
600  fi
601
602  if test "$ac_cv_prog_cc_g" = yes && test -z "$coin_dbg_cflags" ; then
603    coin_dbg_cflags="-g"
604  fi
605
606  if test "$coin_debug_compile" = "true"; then
607    CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
608  else
609    if test -z "$coin_opt_cflags"; then
610      # Try if -O option works if nothing else is set
611      CFLAGS="-O"
612      AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cflags="-O"],[])
613    fi
614    CFLAGS="$coin_opt_cflags $coin_add_cflags -DNDEBUG $CDEFS $coin_warn_cflags"
615  fi
616fi
617
618# Try if CFLAGS works
619AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
620if test -z "$CFLAGS"; then
621  AC_MSG_WARN([The value CFLAGS="$CFLAGS" do not work.  I will now just try '-O', but you might want to set CFLAGS manually.])
622  CFLAGS='-O'
623  AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
624  if test -z "$CFLAGS"; then
625    AC_MSG_WARN([This value for CFLAGS does not work.  I will continue with empty CFLAGS, but you might want to set CFLAGS manually.])
626  fi
627fi
628coin_cv_cflags="$CFLAGS"
629]) # AC_CACHE_CHECK([for C compiler options CXXFLAGS]
630CFLAGS="$coin_cv_cflags"
631
632AC_ARG_VAR(MPICC,[C MPI Compiler])
633if test x"$MPICC" = x; then :; else
634  AC_MSG_NOTICE([Will use MPI C compiler $MPICC])
635  CC="$MPICC"
636fi
637
638# Correct ADDLIBS initialization if we are using the MS compiler
639case "$CC" in
640  cl*)
641    ADDLIBS=
642    AC_COIN_MINGW_LD_FIX
643    ;;
644esac
645
646AC_LANG_POP(C)
647]) # AC_COIN_PROG_CC
648
649###########################################################################
650#                             COIN_PROG_F77                               #
651###########################################################################
652
653# Find the compile command by running AC_PROG_F77 (with compiler names
654# for different operating systems) and put it into F77 (unless it was
655# given my the user), and find an appropriate value for FFLAGS
656
657AC_DEFUN([AC_COIN_PROG_F77],
658[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
659AC_LANG_PUSH([Fortran 77])
660
661coin_has_f77=yes
662
663save_fflags="$FFLAGS"
664case $build in
665  *-cygwin* | *-mingw*)
666             comps="gfortran g77 ifort" ;;
667  *)         comps="xlf fort77 gfortran f77 g77 pgf90 pgf77 ifort ifc" ;;
668esac
669AC_PROG_F77($comps)
670FFLAGS="$save_fflags"
671
672AC_CACHE_CHECK([for Fortran compiler options],[coin_cv_fflags],
673[if test x"$FFLAGS" = x; then
674
675  coin_add_fflags=
676  coin_opt_fflags=
677  coin_dbg_fflags=
678  coin_warn_fflags=
679
680  if test "$G77" = "yes"; then
681    coin_opt_fflags="-O3 -fomit-frame-pointer"
682    coin_add_fflags="-pipe"
683    coin_dbg_fflags="-g"
684    case $build in
685      *-cygwin*)
686        FFLAGS="-mno-cygwin"
687        AC_TRY_LINK([],[      write(*,*) 'Hello world'],
688                    [coin_add_fflags="-mno-cygwin $coin_add_fflags"])
689        FFLAGS=
690      ;;
691    esac
692  else
693    case $build in
694      *-cygwin* | *-mingw*)
695        case $F77 in
696          ifort* | */ifort*)
697            coin_opt_fflags='-O3'
698            coin_add_fflags='-nologo'
699            coin_dbg_fflags='-debug'
700          ;;
701        esac
702        ;;
703      *-linux-*)
704        case $F77 in
705          ifc* | */ifc* | ifort* | */ifort*)
706            coin_opt_fflags="-O3 -ip"
707            coin_add_fflags="-cm -w90 -w95"
708            coin_dbg_fflags="-g -CA -CB -CS"
709            # Check if -i_dynamic is necessary (for new glibc library)
710            FFLAGS=
711            AC_TRY_LINK([],[      write(*,*) 'Hello world'],[],
712                        [coin_add_fflags="-i_dynamic $coin_add_fflags"])
713            ;;
714          pgf77* | */pgf77* | pgf90* | */pgf90*)
715            coin_opt_fflags="-fast"
716            coin_add_fflags="-Kieee -pc 64"
717            coin_dbg_fflags="-g"
718          ;;
719        esac
720        ;;
721      *-ibm-*)
722        case $F77 in
723          xlf* | */xlf* | mpxlf* | */mpxlf* )
724            coin_opt_fflags="-O3 -qarch=auto -qcache=auto -qhot -qtune=auto -qmaxmem=-1"
725            coin_add_fflags="-bmaxdata:0x80000000"
726            coin_dbg_fflags="-g -C"
727            ;;
728        esac
729        ;;
730      *-hp-*)
731        coin_opt_fflags="+O3"
732        coin_add_fflags="+U77"
733        coin_dbg_fflags="-C -g"
734        ;;
735      *-sun-*)
736        coin_opt_fflags="-O4"
737        coin_dbg_fflags="-g"
738        ;;
739      *-sgi-*)
740        coin_opt_fflags="-O5 -OPT:Olimit=0"
741        coin_dbg_fflags="-g"
742        ;;
743    esac
744  fi
745
746  if test "$ac_cv_prog_f77_g" = yes && test -z "$coin_dbg_fflags" ; then
747    coin_dbg_fflags="-g"
748  fi
749
750  if test "$coin_debug_compile" = true; then
751    FFLAGS="$coin_dbg_fflags $coin_add_fflags $coin_warn_fflags"
752  else
753    if test -z "$coin_opt_fflags"; then
754      # Try if -O option works if nothing else is set
755      FFLAGS=-O
756      AC_TRY_LINK([],[      integer i],
757                  [coin_opt_fflags="-O"])
758    fi
759    FFLAGS="$coin_opt_fflags $coin_add_fflags $coin_warn_fflags"
760  fi
761fi
762
763# Try if FFLAGS works
764AC_TRY_LINK([],[      integer i],[],[FFLAGS=])
765if test -z "$FFLAGS"; then
766  AC_MSG_WARN([The flags FFLAGS="$FFLAGS" do not work.  I will now just try '-O', but you might want to set FFLAGS manually.])
767  FFLAGS='-O'
768  AC_TRY_LINK([],[      integer i],[],[FFLAGS=])
769  if test -z "$FFLAGS"; then
770    AC_MSG_WARN([This value for FFLAGS does not work.  I will continue with empty FFLAGS, but you might want to set FFLAGS manually.])
771  fi
772fi
773coin_cv_fflags="$FFLAGS"
774]) # AC_CACHE_CHECK([for Fortran compiler options FFLAGS]
775FFLAGS="$coin_cv_fflags"
776
777AC_ARG_VAR(MPIF77,[Fortran MPI Compiler])
778if test x"$MPIF77" = x; then :; else
779  AC_MSG_NOTICE([Will use MPI Fortran compiler $MPIF77])
780  F77="$MPIF77"
781fi
782
783case "$F77" in
784  ifort*)
785    AC_COIN_MINGW_LD_FIX
786    ;;
787esac
788
789AC_LANG_POP([Fortran 77])
790]) # AC_COIN_PROG_F77
791
792###########################################################################
793#                           COIN_F77_WRAPPERS                             #
794###########################################################################
795
796# Calls autoconfs AC_F77_WRAPPERS and does additional corrections to FLIBS
797
798AC_DEFUN([AC_COIN_F77_WRAPPERS],
799[AC_BEFORE([AC_COIN_PROG_F77],[$0])dnl
800AC_BEFORE([AC_PROG_F77],[$0])dnl
801
802AC_LANG_PUSH([Fortran 77])
803
804AC_F77_WRAPPERS
805
806# This is to correct a missing exclusion in autoconf 2.59
807if test x"$FLIBS" != x; then
808  my_flibs=
809  for flag in $FLIBS; do
810    case flag in
811      -lcrt*.o) ;;
812             *) my_flibs="$my_flibs $flag" ;;
813    esac
814  done
815  FLIBS="$my_flibs"
816fi
817
818case $build in
819# The following is a fix to define FLIBS for ifort on Windows
820   *-cygwin* | *-mingw*)
821     case $F77 in
822       ifort* | */ifort*)
823           FLIBS="/link libifcorert.lib $LIBS /NODEFAULTLIB:libc.lib";;
824     esac;;
825   *-hp-*)
826       FLIBS="$FLIBS -lm";;
827   *-ibm-*)
828       FLIBS=`echo $FLIBS | sed 's/-lc)/-lc/g'` ;;
829   *-linux-*)
830     case "$F77" in
831       pgf77* | */pgf77* | pgf90* | */pgf90*)
832# ask linker to go through the archives multiple times
833# (the Fortran compiler seems to do that automatically...
834         FLIBS="-Wl,--start-group $FLIBS -Wl,--end-group" ;;
835     esac
836esac
837
838]) # AC_COIN_F77_WRAPPERS
839
840
841###########################################################################
842#                          COIN_INIT_AUTOMAKE                             #
843###########################################################################
844
845# This macro calls the regular INIT_AUTOMAKE and MAINTAINER_MODE
846# macros, and defines additional variables and makefile conditionals,
847# that are used in the maintainer parts of the makfile.  It also
848# checks if the correct versions of the autotools are used.
849#
850# This also defines the AC_SUBST variables:
851# abs_source_dir     absolute path to source code for this package
852# abs_bin_dir        absolute path to the directory where binaries are
853#                    going to be installed (prefix/bin)
854# abs_lib_dir        absolute path to the directory where libraries are
855#                    going to be installed (prefix/lib)
856# abs_include_dir    absolute path to the directory where the header files
857#                    are installed (prefix/include)
858
859AC_DEFUN([AC_COIN_INIT_AUTOMAKE],
860[AC_REQUIRE([AC_PROG_EGREP])
861# Stuff for automake
862AM_INIT_AUTOMAKE
863AM_MAINTAINER_MODE
864
865coin_have_externals=no
866if test "$enable_maintainer_mode" = yes; then
867
868  # If maintainer mode is chosen, we make sure that the correct versions
869  # of the tools are used, and that we know where libtoo.m4 is (to
870  # recreate acinclude.m4)
871
872  AC_SUBST(LIBTOOLM4)
873  LIBTOOLM4=
874
875  # Check if we have autoconf
876  AC_CHECK_PROG([have_autoconf],[autoconf],[yes],[no])
877  if test $have_autoconf = no; then
878    AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find autoconf in your path.])
879  fi
880
881  # Check whether autoconf is the correct version
882  correct_version='2.59'
883  grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
884  AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of autoconf])
885  autoconf --version > confauto.out 2>&1
886  if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
887    AC_MSG_RESULT([yes])
888  else
889    rm -f confauto.out
890    AC_MSG_RESULT([no])
891    AC_MSG_ERROR([You don't have the correct version of autoconf as the first one in your path.])
892  fi
893  rm -f confauto.out
894
895  # Check if the executable autoconf is picked up from the correct location
896  AC_MSG_CHECKING([whether autoconf is coming from the correct location])
897  autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
898  autoconf_dir=`cd $autoconf_dir; pwd`
899  if test x$AUTOTOOLS_DIR = x; then
900    want_dir=$HOME/bin
901  else
902    want_dir=$AUTOTOOLS_DIR/bin
903  fi
904  if test $autoconf_dir = `cd $want_dir; pwd`; then
905    AC_MSG_RESULT([yes])
906  else
907    rm -f confauto.out
908    AC_MSG_RESULT([no])
909    AC_MSG_ERROR([The autoconf executable should be picked up from \$HOME/bin or \$AUTOTOOLS_DIR/bin.])
910  fi
911
912  # Check if we have automake
913  AC_CHECK_PROG([have_automake],[automake],[yes],[no])
914  if test $have_automake = no; then
915    AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find automake in your path.])
916  fi
917 
918  # Check whether automake is the correct version
919  correct_version='1.9.6'
920  grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
921  AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of automake])
922  automake --version > confauto.out 2>&1
923  if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
924    AC_MSG_RESULT([yes])
925  else
926    rm -f confauto.out
927    AC_MSG_RESULT([no])
928    AC_MSG_ERROR([You don't have the correct version of automake as the first one in your path.])
929  fi
930  rm -f confauto.out
931
932  # Check if the executable automake is picked up from the correct location
933  AC_MSG_CHECKING([whether automake is coming from the correct location])
934  automake_dir=`which automake | sed -e 's=/automake=='`
935  automake_dir=`cd $automake_dir; pwd`
936  if test x$AUTOTOOLS_DIR = x; then
937    want_dir=$HOME/bin
938  else
939    want_dir=$AUTOTOOLS_DIR/bin
940  fi
941  if test $automake_dir = `cd $want_dir; pwd`; then
942    AC_MSG_RESULT([yes])
943  else
944    rm -f confauto.out
945    AC_MSG_RESULT([no])
946    AC_MSG_ERROR([The automake executable should be picked up from \$HOME/bin or \$AUTOTOOLS_DIR/bin.])
947  fi
948
949  # Check if we can find the libtool file
950  if test x$AUTOTOOLS_DIR = x; then
951    want_dir=$HOME/share
952  else
953    want_dir=$AUTOTOOLS_DIR/share
954  fi
955  AC_CHECK_FILE([$want_dir/aclocal/libtool.m4],
956                [LIBTOOLM4="$want_dir/aclocal/libtool.m4"],
957                [AC_MSG_ERROR([I cannot find the libtool.m4 file.])])
958
959  # Check if this is the correct version of libtool (with escaped dots)
960  correct_version='1.5.22'
961  grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
962  AC_CHECK_FILE([$want_dir/libtool/ltmain.sh],
963                [have_ltmain=yes],
964                [have_ltmain=no])
965  AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of libtool.])
966  if test $have_ltmain = yes; then
967    if $EGREP $grep_version $want_dir/libtool/ltmain.sh >/dev/null 2>&1; then
968      AC_MSG_RESULT([yes])
969    else
970      AC_MSG_RESULT([no])
971      AC_MSG_ERROR([You don't have the correct version of libtool.])
972    fi
973  else
974    AC_MSG_RESULT([no])
975    AC_MSG_ERROR([I cannot find the ltmain.sh file.])
976  fi 
977
978  # Check if we have an Externals file
979  if test -r $srcdir/Externals; then
980    coin_have_externals=yes
981  fi
982  # Check if subversion is installed and understands https
983  AC_CHECK_PROG([have_svn],[svn],[yes],[no])
984  if test x$have_svn = xyes; then
985    AC_MSG_CHECKING([svn understands https])
986    svn --version > confauto.out 2>&1
987    if $EGREP https confauto.out >/dev/null 2>&1; then
988      AC_MSG_RESULT(yes)
989    else
990      AC_MSG_RESULT(no)
991      have_svn=no
992    fi
993    rm -f confauto.out
994  fi
995
996  # Find the location of the BuildTools directory
997  BUILDTOOLSDIR=
998  if test -r $srcdir/BuildTools/coin.m4; then
999    BUILDTOOLSDIR=$srcdir/BuildTools
1000  else
1001    if test -r $srcdir/../BuildTools/coin.m4; then
1002      BUILDTOOLSDIR=$srcdir/../BuildTools
1003    else
1004      if test -r $srcdir/../../BuildTools/coin.m4; then
1005        BUILDTOOLSDIR=$srcdir/../../BuildTools
1006      else
1007        AC_MSG_ERROR(Cannot find the BuildTools directory)
1008      fi
1009    fi
1010  fi
1011  AC_SUBST(BUILDTOOLSDIR)
1012
1013  # The following variable is set to the name of the directory where
1014  # the autotool scripts are located
1015  AC_SUBST(AUX_DIR)
1016  AUX_DIR=$ac_aux_dir
1017fi
1018
1019# helpful variable for the base directory of this package
1020abs_source_dir=`cd $srcdir; pwd`
1021AC_SUBST(abs_source_dir)
1022
1023# Stuff for example Makefiles
1024if test x$prefix = xNONE; then
1025  full_prefix=$ac_default_prefix
1026else
1027  full_prefix=$prefix
1028fi
1029full_prefix=`cd $full_prefix ; pwd`
1030AC_SUBST(abs_lib_dir)
1031abs_lib_dir=$full_prefix/lib
1032AC_SUBST(abs_include_dir)
1033abs_include_dir=$full_prefix/include
1034AC_SUBST(abs_bin_dir)
1035abs_bin_dir=$full_prefix/bin
1036
1037AM_CONDITIONAL(HAVE_EXTERNALS,
1038               test $coin_have_externals = yes && test x$have_svn = xyes)
1039]) # AC_COIN_INIT_AUTOMAKE
1040
1041###########################################################################
1042#                         COIN_INIT_AUTO_TOOLS                            #
1043###########################################################################
1044
1045# Initialize the auto tools automake and libtool, with all
1046# modifications we want for COIN packages.
1047#
1048# RPATH_FLAGS        link flags for hardcoding path to shared objects
1049
1050# This is a trick to have this code before AC_COIN_PROG_LIBTOOL
1051AC_DEFUN([AC_COIN_DISABLE_STATIC],
1052[
1053# On Cygwin, building DLLs doesn't work
1054case $build in
1055  *-cygwin*)
1056    coin_disable_shared=yes
1057    platform=Cygwin
1058  ;;
1059  *-mingw*)
1060    case "$CXX" in
1061      cl*)
1062        coin_disable_shared=yes
1063        platform="Msys with cl"
1064    ;;
1065    esac
1066  ;;
1067esac
1068if test x"$coin_disable_shared" = xyes; then
1069  if test x"$enable_shared" = xyes; then
1070    AC_MSG_WARN([On $platform, shared objects are not supported. I'm disabling your choice.])
1071  fi
1072  enable_shared=no
1073fi
1074# By default, we only want the shared objects to be compiled
1075AC_DISABLE_STATIC
1076])
1077
1078AC_DEFUN([AC_COIN_INIT_AUTO_TOOLS],
1079[AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1080AC_BEFORE([AC_COIN_PROG_CC],[$0])
1081AC_BEFORE([AC_COIN_PROG_F77],[$0])
1082AC_REQUIRE([AC_COIN_DISABLE_STATIC])
1083
1084# Initialize automake
1085AC_COIN_INIT_AUTOMAKE
1086
1087# Stuff for libtool
1088AC_COIN_PROG_LIBTOOL
1089
1090# set RPATH_FLAGS to the compiler link flags required to hardcode location
1091# of the shared objects
1092AC_COIN_RPATH_FLAGS($abs_lib_dir)
1093]) # AC_COIN_INIT_AUTO_TOOLS
1094
1095###########################################################################
1096#                           COIN_PROG_LIBTOOL                             #
1097###########################################################################
1098
1099# Setup the libtool stuff together with any modifications to make it
1100# work on additional platforms
1101
1102AC_DEFUN([AC_COIN_PROG_LIBTOOL],
1103[AC_REQUIRE([AC_COIN_DLFCN_H])
1104
1105# We check for this header here in a non-standard way to avoid warning
1106# messages
1107AC_PROG_LIBTOOL
1108
1109# Fix bugs in libtool script for Windows native compilation:
1110# - cygpath is not correctly quoted in fix_srcfile_path
1111# - paths generated for .lib files is not run through cygpath -w
1112
1113
1114# - lib includes subdirectory information; we want to replace
1115#
1116# old_archive_cmds="lib /OUT:\$oldlib\$oldobjs\$old_deplibs"
1117#
1118# by
1119#
1120# 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"
1121#
1122#          -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"%' \
1123
1124# The following was a hack for chaniing @BACKSLASH to \
1125#          -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' \
1126
1127# Correct cygpath for minGW (ToDo!)
1128case $build in
1129  *-mingw*)
1130    CYGPATH_W=echo
1131    ;;
1132esac
1133
1134case $build in
1135  *-cygwin* | *-mingw*)
1136  case "$CXX" in
1137    cl* | */cl*)
1138      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1139      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1140          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1141          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1142          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1143          -e 's%lib /OUT:%lib -OUT:%' \
1144          -e "s%cygpath -w%$CYGPATH_W%" \
1145          -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%' \
1146          -e 's/$AR t/lib -nologo -list/' \
1147          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1148          -e  's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1149      libtool > conftest.bla
1150
1151      mv conftest.bla libtool
1152      chmod 755 libtool
1153      ;;
1154   
1155  esac
1156esac
1157
1158# ToDo
1159# For now, don't use the -no-undefined flag, since the Makefiles are
1160# not yet set up that way.  But we need to fix this, when we want
1161# to comile DLLs under Windows.
1162LT_LDFLAGS=
1163AC_SUBST(LT_LDFLAGS)
1164]) # AC_COIN_PROG_LIBTOOL
1165
1166# This is a trick to force the check for the dlfcn header to be done before
1167# the checks for libtool
1168AC_DEFUN([AC_COIN_DLFCN_H],
1169[AC_LANG_PUSH(C)
1170AC_COIN_CHECK_HEADER([dlfcn.h])
1171AC_LANG_POP(C)
1172]) # AC_COIN_DLFCN_H
1173
1174###########################################################################
1175#                            COIN_RPATH_FLAGS                             #
1176###########################################################################
1177
1178# This macro, in case shared objects are used, defines a variable
1179# RPATH_FLAGS that can be used by the linker to hardwire the library
1180# search path for the given directories.  This is useful for example
1181# Makefiles
1182
1183AC_DEFUN([AC_COIN_RPATH_FLAGS],
1184[RPATH_FLAGS=
1185
1186if test $enable_shared = yes; then
1187  if test "$GXX" = "yes"; then
1188    RPATH_FLAGS=
1189    for dir in $1; do
1190      RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1191    done
1192  else
1193    case $build in
1194      *-linux-*)
1195        case "$CXX" in
1196        icpc* | */icpc*)
1197          RPATH_FLAGS=
1198          for dir in $1; do
1199            RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1200          done
1201        esac ;;
1202      *-ibm-*)
1203        case "$CXX" in
1204        xlC* | */xlC* | mpxlC* | */mpxlC*)
1205          RPATH_FLAGS=nothing ;;
1206        esac ;;
1207      *-hp-*)
1208          RPATH_FLAGS=nothing ;;
1209      *-mingw32)
1210          RPATH_FLAGS=nothing ;;
1211      *-sun-*)
1212          RPATH_FLAGS=
1213          for dir in $1; do
1214            RPATH_FLAGS="$RPATH_FLAGS -R$dir"
1215          done
1216     esac
1217  fi
1218
1219  if test "$RPATH_FLAGS" = ""; then
1220    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 or LIBDIR variable manually.])
1221  fi
1222  if test "$RPATH_FLAGS" = "nothing"; then
1223    RPATH_FLAGS=
1224  fi
1225fi
1226
1227AC_SUBST(RPATH_FLAGS)
1228]) # AC_COIN_RPATH_FLAGS
1229
1230###########################################################################
1231#                              COIN_FINALIZE                              #
1232###########################################################################
1233
1234# This macro should be called at the very end of the configure.ac file.
1235# It creates the output files (by using AC_OUTPUT), and might do some other
1236# things (such as generating links to data files in a VPATH configuration).
1237# It also prints the "success" message.
1238
1239AC_DEFUN([AC_COIN_FINALIZE],
1240[
1241AC_OUTPUT
1242
1243if test x"$coin_vpath_link_files" = x; then : ; else
1244  AC_MSG_NOTICE(Creating VPATH links for data files)
1245  for file in $coin_vpath_link_files; do
1246    rm -f $file
1247    $LN_S $srcdir/$file $file
1248  done
1249fi
1250
1251# Define VPATH_DISTCLEANFILES to be everything that needs to be
1252# cleaned for distclean in a vpath configuration
1253AC_SUBST(VPATH_DISTCLEANFILES)
1254VPATH_DISTCLEANFILES="$coin_vpath_link_files"
1255
1256if test x$coin_projectdir = xyes; then
1257  AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
1258else
1259  AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
1260fi
1261]) #AC_COIN_FINALIZE
1262
1263###########################################################################
1264#                             COIN_VPATH_LINK                             #
1265###########################################################################
1266
1267# This macro makes sure that a symbolic link is created to a file in
1268# the source code directory tree if we are in a VPATH compilation, and
1269# if this package is the main package to be installed
1270
1271AC_DEFUN([AC_COIN_VPATH_LINK],
1272[AC_REQUIRE([AC_COIN_CHECK_VPATH])
1273if test $coin_vpath_config = yes; then
1274  coin_vpath_link_files="$coin_vpath_link_files $1"
1275fi
1276]) #AC_COIN_VPATH_LINK
1277
1278###########################################################################
1279#                       COIN_ENABLE_GNU_PACKAGES                          #
1280###########################################################################
1281
1282# This macro defined the --enable-gnu-packages flag.  This can be used
1283# to check if a user wants to compile GNU packges (such as readline or
1284# zlib) into the executable.  By default, GNU packages are disabled.
1285# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
1286
1287AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
1288[AC_ARG_ENABLE([gnu-packages],
1289               [AC_HELP_STRING([--enable-gnu-packages],
1290                               [compile with GNU packages (disabled by default)])],
1291               [coin_enable_gnu=$enableval],
1292               [coin_enable_gnu=no])
1293]) # AC_COIN_ENABLE_GNU_PACKAGES
1294
1295###########################################################################
1296#                           COIN_CHECK_GNU_ZLIB                           #
1297###########################################################################
1298
1299# This macro checks for the libz library.
1300
1301AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
1302[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1303AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1304AC_BEFORE([AC_COIN_PROG_CC],[$0])
1305AC_BEFORE([AC_COIN_PROG_F77],[$0])
1306AC_BEFORE([$0],[AC_COIN_FINISH])
1307
1308coin_has_zlib=no
1309if test $coin_enable_gnu = yes; then
1310  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
1311
1312  if test $coin_has_zlib = yes; then
1313    AC_CHECK_LIB([z],[gzopen],
1314                 [ADDLIBS="-lz $ADDLIBS"],
1315                 [coin_has_zlib=no])
1316  fi
1317
1318  if test $coin_has_zlib = yes; then
1319    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
1320  fi
1321fi
1322
1323AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
1324]) # AC_COIN_CHECK_GNU_ZLIB
1325
1326
1327###########################################################################
1328#                          COIN_CHECK_GNU_BZLIB                           #
1329###########################################################################
1330
1331# This macro checks for the libbz2 library.
1332
1333AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
1334[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1335AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1336AC_BEFORE([AC_COIN_PROG_CC],[$0])
1337AC_BEFORE([AC_COIN_PROG_F77],[$0])
1338AC_BEFORE([$0],[AC_COIN_FINISH])
1339
1340coin_has_bzlib=no
1341if test $coin_enable_gnu = yes; then
1342  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
1343
1344  if test $coin_has_bzlib = yes; then
1345    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
1346                 [ADDLIBS="-lbz2 $ADDLIBS"],
1347                 [coin_has_bzlib=no])
1348  fi
1349
1350  if test $coin_has_bzlib = yes; then
1351    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
1352  fi
1353fi
1354]) # AC_COIN_CHECK_GNU_BZLIB
1355
1356
1357###########################################################################
1358#                         COIN_CHECK_GNU_READLINE                         #
1359###########################################################################
1360
1361# This macro checks for GNU's readline.  It verifies that the header
1362# readline/readline.h is available, and that the -lreadline library
1363# contains "readline".  It is assumed that #include <stdio.h> is included
1364# in the source file before the #include<readline/readline.h>
1365
1366AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
1367[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1368AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1369AC_BEFORE([AC_COIN_PROG_CC],[$0])
1370AC_BEFORE([AC_COIN_PROG_F77],[$0])
1371AC_BEFORE([$0],[AC_COIN_FINISH])
1372
1373coin_has_readline=no
1374if test $coin_enable_gnu = yes; then
1375  AC_COIN_CHECK_HEADER([readline/readline.h],
1376                       [coin_has_readline=yes],[],
1377                       [#include <stdio.h>])
1378
1379  coin_save_LIBS="$LIBS"
1380  LIBS=
1381  # First we check if tputs and friends are available
1382  if test $coin_has_readline = yes; then
1383    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
1384                   [coin_has_readline=no])
1385  fi
1386
1387  # Now we check for readline
1388  if test $coin_has_readline = yes; then
1389    AC_CHECK_LIB([readline],[readline],
1390                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
1391                 [coin_has_readline=no])
1392  fi
1393
1394  if test $coin_has_readline = yes; then
1395    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
1396  fi
1397
1398  LIBS="$coin_save_LIBS"
1399fi
1400]) # AC_COIN_CHECK_GNU_READLINE
1401
1402###########################################################################
1403#                             COIN_HAS_DATA                               #
1404###########################################################################
1405
1406# This macro makes sure that the data files in the Data subdirectory
1407# are available.  The argument is the subdirectory name in the Data
1408# COIN project.  This macro defines the preprocessor macro
1409# COIN_HAS_DATA_SUBDIR (where SUBDIR is the name of the subdirectory
1410# in capital letters) and the makefile conditional with the same name.
1411# If this is the base project, it also adds the directory to the
1412# recursive list.
1413
1414AC_DEFUN([AC_COIN_HAS_DATA],
1415[AC_MSG_CHECKING([whether Data directory $1 is available])
1416if test -r ../Data/$1; then
1417  AC_DEFINE(m4_toupper(COIN_HAS_DATA_$1),[1],
1418            [Define to 1 if Data subdirectory $1 is available])
1419  AC_MSG_RESULT(yes)
1420  have_data=yes
1421else
1422  have_data=no
1423fi
1424AC_MSG_RESULT($have_data)
1425AM_CONDITIONAL(m4_toupper(COIN_HAS_DATA_$1),test $have_data = yes)
1426]) # AC_COIN_HAS_DATA
1427
1428###########################################################################
1429#                          COIN_EXAMPLE_FILES                             #
1430###########################################################################
1431
1432# This macro determines the names of the example files (using the
1433# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
1434# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
1435# creates soft links to the example files.
1436
1437AC_DEFUN([AC_COIN_EXAMPLE_FILES],
1438[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
1439AC_REQUIRE([AC_COIN_CHECK_VPATH])
1440files=`cd $srcdir; ls $1`
1441# We need to do the following loop to make sure that are no newlines
1442# in the variable
1443for file in $files; do
1444  EXAMPLE_FILES="$EXAMPLE_FILES $file"
1445done
1446if test $coin_vpath_config = yes; then
1447  AC_PROG_LN_S
1448  AC_MSG_NOTICE([Creating links to the example files ($1)])
1449  for file in $EXAMPLE_FILES; do
1450    rm -f $file
1451    $LN_S $srcdir/$file $file
1452  done
1453  EXAMPLE_CLEAN_FILES='$1'
1454else
1455  EXAMPLE_CLEAN_FILES=
1456fi
1457
1458# In case there are compressed files, we create a variable with the
1459# uncompressed names
1460EXAMPLE_UNCOMPRESSED_FILES=
1461for file in $EXAMPLE_FILES; do
1462  case $file in
1463    *.gz)
1464      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
1465      ;;
1466  esac
1467done
1468
1469AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
1470AC_SUBST(EXAMPLE_FILES)
1471AC_SUBST(EXAMPLE_CLEAN_FILES)
1472]) #AC_COIN_EXAMPLE_FILES
1473
1474###########################################################################
1475#                            COIN_HAS_PROJECT                             #
1476###########################################################################
1477
1478# This macro sets up usage of a Coin package.  It defines the
1479# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
1480# object directory of the package, respectively.  It also defines
1481# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
1482# argument should be the name (Pkg) of the project (in correct lower
1483# and upper case)
1484
1485AC_DEFUN([AC_COIN_HAS_PROJECT],
1486[AC_MSG_CHECKING([for COIN project $1])
1487
1488# First check, if the sub-project is actually available (ToDo: allow
1489# other locations)
1490
1491m4_tolower(coin_has_$1)=unavailable
1492if test $PACKAGE_TARNAME = m4_tolower($1); then
1493  m4_tolower(coin_has_$1)=.
1494else
1495  if test -d $srcdir/../$1; then
1496    m4_tolower(coin_has_$1)=../$1
1497  fi
1498fi
1499
1500if test $m4_tolower(coin_has_$1) != unavailable; then
1501  # Set the #define if the component is available
1502  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
1503
1504  # Set the variables for source and object code location
1505  AC_SUBST(m4_toupper($1SRCDIR))
1506  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
1507  AC_SUBST(m4_toupper($1OBJDIR))
1508  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
1509fi
1510
1511  # Define the Makefile conditional
1512AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
1513               test $m4_tolower(coin_has_$1) != unavailable)
1514AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
1515]) # AC_COIN_HAS
1516
1517###########################################################################
1518#                        COIN_HAS_USER_LIBRARY                            #
1519###########################################################################
1520
1521# This macro sets up usage of a library with header files.  It defines
1522# the LBRYINCDIR variable, and it defines COIN_HAS_LBRY preprocessor
1523# macro and makefile conditional.  The first argument should be the
1524# full name (LibraryName) of the library, and the second argument (in
1525# upper case letters) the abbreviation (LBRY).  This macro also
1526# introduces the configure arguments --with-libraryname-incdir and
1527# --with-libraryname-lib which have to be both given by a user to use
1528# this solver to tell the configure script where the include files and
1529# the library are located.  Those arguments can also be given as
1530# environement variables LBRYINCDIR and LBRYLIB, but a --with-*
1531# argument overwrites an environment variable.  If a third argument is
1532# given, it is assumed that this is the name of a header file that can
1533# be checked for in the given include directory, and if a fourth
1534# argument is given, it is assumed to be the name of a C function
1535# which is given and defined in the library, and a test is done to
1536# check if that symbol is defined in the library.
1537
1538AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
1539[AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
1540AC_MSG_CHECKING(if user provides library for $1)
1541
1542# Check for header file directory
1543AC_ARG_WITH(m4_tolower($1)-incdir,
1544            AC_HELP_STRING([--with-m4_tolower($1)-incdir],
1545                           [specify the directory with the header files for library $1]),
1546                           [$2INCDIR=`cd $withval; pwd`])
1547# Check for library directory
1548AC_ARG_WITH(m4_tolower($1)-lib,
1549            AC_HELP_STRING([--with-m4_tolower($1)-lib],
1550                           [specify the flags to link with the library $1]),
1551                           [$2LIB=$withval])
1552
1553if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
1554  m4_tolower(coin_has_$2)=true
1555else
1556  m4_tolower(coin_has_$2)=false
1557fi
1558
1559if test $m4_tolower(coin_has_$2) = true; then
1560# Check either both arguments or none are given
1561  if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
1562    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])
1563  fi
1564  AC_MSG_RESULT(yes)
1565  # Check if the given header file is there
1566  m4_ifvaln([$3],[AC_CHECK_FILE([$$2INCDIR/$3],[],
1567                 [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
1568  # Check if the symbol is provided in the library
1569  # ToDo: FOR NOW WE ASSUME THAT WE ARE USING THE C++ COMPILER
1570  m4_ifvaln([$4],[coin_save_LIBS="$LIBS"
1571                  LIBS="$$2LIB $ADDLIBS"
1572                  AC_MSG_CHECKING([whether symbol $4 is available with $2])
1573# ToDo find out what to do about extern "C"
1574#                  AC_TRY_LINK([extern "C" {void $4();}],[$4()],
1575                  AC_TRY_LINK([void $4();],[$4()],
1576                              [AC_MSG_RESULT(yes)],
1577                              [AC_MSG_RESULT(no)
1578                               AC_MSG_ERROR([Cannot find symbol $4 with $2])])
1579                  LIBS="$coin_save_LIBS"])
1580  ADDLIBS="$$2LIB $ADDLIBS"
1581  AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is used])
1582else
1583  AC_MSG_RESULT(no)
1584fi
1585
1586AC_SUBST($2INCDIR)
1587AC_SUBST($2LIB)
1588AM_CONDITIONAL(COIN_HAS_$2,
1589               test $m4_tolower(coin_has_$2) = true)
1590]) #AC_COIN_HAS_SOLVER
1591
1592###########################################################################
1593#                               COIN_HAS_ASL                              #
1594###########################################################################
1595
1596# This macro checks if the user has provide arguments that say where
1597# the precompiled ASL files should be found (with the --with-asldir
1598# flag).  If this is not the case, we check if the ThirdParty/ASL
1599# directory has been configured, which indicates that the files will
1600# be in that directory and can be used.
1601
1602AC_DEFUN([AC_COIN_HAS_ASL],
1603[coin_aslobjdir=../ThirdParty/ASL
1604coin_aslsrcdir=$srcdir/$coin_aslobjdir
1605
1606# Determine the name of the ASL library
1607case "$CXX" in
1608  cl* | */cl*)
1609    ampllib=amplsolv.lib ;;
1610  *)
1611    ampllib=amplsolver.a ;;
1612esac
1613
1614AC_ARG_WITH([asldir],
1615            AC_HELP_STRING([--with-asldir],
1616                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
1617            [use_asldir=$withval], [use_asldir=])
1618
1619if test "$use_asldir" = BUILD; then
1620  AC_CHECK_FILE([$coin_aslobjdir/Makefile],[],
1621                [AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])])
1622elif test -z "$use_asldir"; then
1623 # try to find sources - if not given don't compile
1624  AC_CHECK_FILE([$coin_aslobjdir/Makefile],[use_asldir=BUILD],[use_asldir=no])
1625elif test "$use_asldir" != "no"; then
1626  AC_CHECK_FILE([$use_asldir/$ampllib],[],
1627                [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
1628  AC_CHECK_FILE([$use_asldir/asl.h],[],
1629                [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
1630  use_asldir=`cd $use_asldir; pwd`
1631  case $build in
1632    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
1633  esac
1634fi
1635
1636# Variable containing ASL library (including full path)
1637AC_SUBST(ASLLIB)
1638# Variable containing flags for including ASL header files
1639AC_SUBST(ASL_CPPFLAGS)
1640
1641if test "$use_asldir" = BUILD; then
1642  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
1643  ASLLIB="$coin_aslobjdir/$ampllib"
1644  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
1645  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers`
1646elif test "$use_asldir" != no; then
1647  ASLLIB="$use_asldir/$ampllib"
1648  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir`
1649fi
1650
1651if test "$use_asldir" != no; then
1652  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
1653  coin_has_asl=yes
1654  AC_DEFINE([COIN_HAS_ASL],[1],
1655            [If defined, the Ampl Solver Library is available.])
1656else
1657  coin_has_asl=no
1658fi
1659AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
1660]) # AC_COIN_HAS_ASL
Note: See TracBrowser for help on using the repository browser.