source: trunk/coin.m4 @ 17

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

temporarily allow shared objects on Cygwin and Msys

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