source: trunk/coin.m4 @ 16

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

several fixes for Cygwin; corrected -no-undefined for Darwin

File size: 47.7 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  ;;
921  *-mingw*)
922    case $CXX in
923      cl)
924        coin_disable_shared=yes
925    ;;
926    esac
927  ;;
928esac
929if test x"$coin_disable_shared" = xyes; then
930  if test x"$enable_shared" = xyes; then
931    AC_MSG_WARN([On Cygwin, shared objects are not supported. I'm disabling your choice.])
932  fi
933  enable_shared=no
934fi
935# By default, we only want the shared objects to be compiled
936AC_DISABLE_STATIC
937])
938
939AC_DEFUN([AC_COIN_INIT_AUTO_TOOLS],
940[AC_BEFORE([AC_COIN_PROG_CXX],[$0])
941AC_BEFORE([AC_COIN_PROG_CC],[$0])
942AC_BEFORE([AC_COIN_PROG_F77],[$0])
943AC_REQUIRE([AC_COIN_DISABLE_STATIC])
944
945# Initialize automake
946AC_COIN_INIT_AUTOMAKE
947
948# Stuff for libtool
949AC_COIN_PROG_LIBTOOL
950
951# helpful variable for the base directory of this package
952pkg_source_dir=`cd $srcdir; pwd`
953
954# Stuff for example Makefiles
955full_prefix=`echo $exec_prefix | pwd`
956AC_SUBST(pkg_lib_dir)
957pkg_lib_dir=$full_prefix/lib
958AC_SUBST(pkg_include_dir)
959pkg_include_dir=$full_prefix/include
960AC_SUBST(pkg_bin_dir)
961pkg_bin_dir=$full_prefix/bin
962
963]) # AC_COIN_INIT_AUTO_TOOLS
964
965###########################################################################
966#                           COIN_PROG_LIBTOOL                             #
967###########################################################################
968
969# Setup the libtool stuff together with any modifications to make it
970# work on additional platforms
971
972AC_DEFUN([AC_COIN_PROG_LIBTOOL],
973[AC_REQUIRE([AC_COIN_DLFCN_H])
974
975# We check for this header here in a non-standard way to avoid warning
976# messages
977AC_PROG_LIBTOOL
978
979# Fix bugs in libtool script for Windows native compilation:
980# - cygpath is not correctly quoted in fix_srcfile_path
981# - paths generated for .lib files is not run through cygpath -w
982
983
984# - lib includes subdirectory information; we want to replace
985#
986# old_archive_cmds="lib /OUT:\$oldlib\$oldobjs\$old_deplibs"
987#
988# by
989#
990# 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"
991#
992#          -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"%' \
993
994# The following was a hack for chaniing @BACKSLASH to \
995#          -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' \
996
997# Correct cygpath for minGW (ToDo!)
998case $build in
999  *-mingw*)
1000    CYGPATH_W=echo
1001    ;;
1002esac
1003
1004case $build in
1005  *-cygwin* | *-mingw*)
1006  case "$CXX" in
1007    cl | */cl)
1008      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1009      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1010          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1011          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1012          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1013          -e 's%lib /OUT:%lib -OUT:%' \
1014          -e "s%cygpath -w%$CYGPATH_W%" \
1015          -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%' \
1016          -e 's/$AR t/lib -nologo -list/' \
1017          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1018      libtool > conftest.bla
1019
1020      mv conftest.bla libtool
1021      chmod 755 libtool
1022      ;;
1023   
1024  esac
1025esac
1026]) # AC_COIN_PROG_LIBTOOL
1027
1028# This is a trick to force the check for the dlfcn header to be done before
1029# the checks for libtool
1030AC_DEFUN([AC_COIN_DLFCN_H],
1031[AC_LANG_PUSH(C)
1032AC_COIN_CHECK_HEADER([dlfcn.h])
1033AC_LANG_POP(C)
1034]) # AC_COIN_DLFCN_H
1035
1036###########################################################################
1037#                            COIN_RPATH_FLAGS                             #
1038###########################################################################
1039
1040# This macro, in case shared objects are used, defines a variable
1041# RPATH_FLAGS that can be used by the linker to hardwire the library
1042# search path for the given directories.  This is useful for example
1043# Makefiles
1044
1045AC_DEFUN([AC_COIN_RPATH_FLAGS],
1046[RPATH_FLAGS=
1047
1048if test "$GXX" = "yes"; then
1049  RPATH_FLAGS=
1050  for dir in $1; do
1051    RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1052  done
1053else
1054  case $build in
1055    *-linux-*)
1056      case "$CXX" in
1057      icpc | */icpc)
1058        RPATH_FLAGS=
1059        for dir in $1; do
1060          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1061        done
1062      esac ;;
1063    *-ibm-*)
1064      case "$CXX" in
1065      xlC* | */xlC* | mpxlC* | */mpxlC*)
1066        RPATH_FLAGS=nothing ;;
1067      esac ;;
1068    *-hp-*)
1069        RPATH_FLAGS=nothing ;;
1070    *-mingw32)
1071        RPATH_FLAGS=nothing ;;
1072    *-sun-*)
1073        RPATH_FLAGS=
1074        for dir in $1; do
1075          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
1076        done
1077   esac
1078fi
1079
1080if test "$RPATH_FLAGS" = ""; then
1081  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.])
1082fi
1083if test "$RPATH_FLAGS" = "nothing"; then
1084  RPATH_FLAGS=
1085fi
1086
1087AC_SUBST(RPATH_FLAGS)
1088]) # AC_COIN_RPATH_FLAGS
1089
1090###########################################################################
1091#                        COIN_VPATH_CONFIG_LINK                           #
1092###########################################################################
1093
1094# This macro makes sure that a symbolic link is created to a file in
1095# the source code directory tree if we are in a VPATH compilation, and
1096# if this package is the main package to be installed
1097
1098AC_DEFUN([AC_COIN_VPATH_LINKS],
1099[AC_REQUIRE([AC_COIN_CHECK_VPATH])
1100if test $coin_vpath_config = yes; then
1101  AC_CONFIG_LINKS($1:$1)
1102fi
1103]) #AC_COIN_VPATH_CONFIG_LINK
1104
1105###########################################################################
1106#                       COIN_ENABLE_GNU_PACKAGES                          #
1107###########################################################################
1108
1109# This macro defined the --enable-gnu-packages flag.  This can be used
1110# to check if a user wants to compile GNU packges (such as readline or
1111# zlib) into the executable.  By default, GNU packages are disabled.
1112# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
1113
1114AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
1115[AC_ARG_ENABLE([gnu-packages],
1116               [AC_HELP_STRING([--enable-gnu-packages],
1117                               [compile with GNU packages (disabled by default)])],
1118               [coin_enable_gnu=$enableval],
1119               [coin_enable_gnu=no])
1120]) # AC_COIN_ENABLE_GNU_PACKAGES
1121
1122###########################################################################
1123#                             COIN_CHECK_ZLIB                             #
1124###########################################################################
1125
1126# This macro checks for the libz library.
1127
1128AC_DEFUN([AC_COIN_CHECK_ZLIB],
1129[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1130AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1131AC_BEFORE([AC_COIN_PROG_CC],[$0])
1132AC_BEFORE([AC_COIN_PROG_F77],[$0])
1133AC_BEFORE([$0],[AC_COIN_FINISH])
1134
1135coin_has_zlib=no
1136if test $coin_enable_gnu = yes; then
1137  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
1138
1139  if test $coin_has_zlib = yes; then
1140    AC_CHECK_LIB([z],[gzopen],
1141                 [ADDLIBS="-lz $ADDLIBS"],
1142                 [coin_has_zlib=no])
1143  fi
1144
1145  if test $coin_has_zlib = yes; then
1146    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
1147  fi
1148fi
1149
1150AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
1151]) # AC_COIN_CHECK_ZLIB
1152
1153
1154###########################################################################
1155#                            COIN_CHECK_BZLIB                             #
1156###########################################################################
1157
1158# This macro checks for the libbz2 library.
1159
1160AC_DEFUN([AC_COIN_CHECK_BZLIB],
1161[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1162AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1163AC_BEFORE([AC_COIN_PROG_CC],[$0])
1164AC_BEFORE([AC_COIN_PROG_F77],[$0])
1165AC_BEFORE([$0],[AC_COIN_FINISH])
1166
1167coin_has_bzlib=no
1168if test $coin_enable_gnu = yes; then
1169  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
1170
1171  if test $coin_has_bzlib = yes; then
1172    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
1173                 [ADDLIBS="-lbz2 $ADDLIBS"],
1174                 [coin_has_bzlib=no])
1175  fi
1176
1177  if test $coin_has_bzlib = yes; then
1178    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
1179  fi
1180fi
1181]) # AC_COIN_CHECK_BZLIB
1182
1183
1184###########################################################################
1185#                           COIN_CHECK_READLINE                           #
1186###########################################################################
1187
1188# This macro checks for GNU's readline.  It verifies that the header
1189# readline/readline.h is available, and that the -lreadline library
1190# contains "readline".  It is assumed that #include <stdio.h> is included
1191# in the source file before the #include<readline/readline.h>
1192
1193AC_DEFUN([AC_COIN_CHECK_READLINE],
1194[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
1195AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1196AC_BEFORE([AC_COIN_PROG_CC],[$0])
1197AC_BEFORE([AC_COIN_PROG_F77],[$0])
1198AC_BEFORE([$0],[AC_COIN_FINISH])
1199
1200coin_has_readline=no
1201if test $coin_enable_gnu = yes; then
1202  AC_COIN_CHECK_HEADER([readline/readline.h],
1203                       [coin_has_readline=yes],[],
1204                       [#include <stdio.h>])
1205
1206  coin_save_LIBS="$LIBS"
1207  LIBS=
1208  # First we check if tputs and friends are available
1209  if test $coin_has_readline = yes; then
1210    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
1211                   [coin_has_readline=no])
1212  fi
1213
1214  # Now we check for readline
1215  if test $coin_has_readline = yes; then
1216    AC_CHECK_LIB([readline],[readline],
1217                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
1218                 [coin_has_readline=no])
1219  fi
1220
1221  if test $coin_has_readline = yes; then
1222    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
1223  fi
1224
1225  LIBS="$coin_save_LIBS"
1226fi
1227]) # AC_COIN_CHECK_READLINE
1228
1229###########################################################################
1230#                             COIN_HAS_DATA                               #
1231###########################################################################
1232
1233# This macro makes sure that the data files in the Data subdirectory
1234# are available.  The argument is the subdirectory name in the Data
1235# COIN project.  This macro defines the preprocessor macro
1236# COIN_HAS_DATA_SUBDIR (where SUBDIR is the name of the subdirectory
1237# in capital letters) and the makefile conditional with the same name.
1238# If this is the base project, it also adds the directory to the
1239# recursive list.
1240
1241AC_DEFUN([AC_COIN_HAS_DATA],
1242[AC_MSG_CHECKING([whether Data directory $1 is available])
1243if test -r ../Data/$1; then
1244  AC_DEFINE(m4_toupper(COIN_HAS_DATA_$1),[1],
1245            [Define to 1 if Data subdirectory $1 is available])
1246  AC_MSG_RESULT(yes)
1247  have_data=yes
1248else
1249  have_data=no
1250fi
1251AC_MSG_RESULT($have_data)
1252AM_CONDITIONAL(m4_toupper(COIN_HAS_DATA_$1),test $have_data = yes)
1253]) # AC_COIN_HAS_DATA
1254
1255###########################################################################
1256#                          COIN_EXAMPLE_FILES                             #
1257###########################################################################
1258
1259# This macro determines the names of the example files (using the
1260# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
1261# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
1262# creates soft links to the example files.
1263
1264AC_DEFUN([AC_COIN_EXAMPLE_FILES],
1265[AC_REQUIRE([AC_COIN_CHECK_ZLIB])
1266AC_REQUIRE([AC_COIN_CHECK_VPATH])
1267files=`cd $srcdir; ls $1`
1268# We need to do the following loop to make sure that are no newlines
1269# in the variable
1270for file in $files; do
1271  EXAMPLE_FILES="$EXAMPLE_FILES $file"
1272done
1273if test $coin_vpath_config = yes; then
1274  AC_PROG_LN_S
1275  AC_MSG_NOTICE([Creating links to the example files ($1)])
1276  for file in $EXAMPLE_FILES; do
1277    rm -f $file
1278    $LN_S $srcdir/$file $file
1279  done
1280  EXAMPLE_CLEAN_FILES='$1'
1281else
1282  EXAMPLE_CLEAN_FILES=
1283fi
1284
1285# In case there are compressed files, we create a variable with the
1286# uncompressed names
1287EXAMPLE_UNCOMPRESSED_FILES=
1288for file in $EXAMPLE_FILES; do
1289  case $file in
1290    *.gz)
1291      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
1292      ;;
1293  esac
1294done
1295
1296AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
1297AC_SUBST(EXAMPLE_FILES)
1298AC_SUBST(EXAMPLE_CLEAN_FILES)
1299]) #AC_COIN_EXAMPLE_FILES
1300
1301###########################################################################
1302#                            COIN_HAS_PROJECT                             #
1303###########################################################################
1304
1305# This macro sets up usage of a Coin package.  It defines the
1306# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
1307# object directory of the package, respectively.  It also defines
1308# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
1309# argument should be the name (Pkg) of the project (in correct lower
1310# and upper case)
1311
1312AC_DEFUN([AC_COIN_HAS_PROJECT],
1313[AC_MSG_CHECKING([for COIN project $1])
1314
1315# First check, if the sub-project is actually available (ToDo: allow
1316# other locations)
1317
1318m4_tolower(coin_has_$1)=unavailable
1319if test $PACKAGE_TARNAME = m4_tolower($1); then
1320  m4_tolower(coin_has_$1)=.
1321else
1322  if test -d $srcdir/../$1; then
1323    m4_tolower(coin_has_$1)=../$1
1324  fi
1325fi
1326
1327if test $m4_tolower(coin_has_$1) != unavailable; then
1328  # Set the #define if the component is available
1329  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
1330
1331  # Set the variables for source and object code location
1332  AC_SUBST(m4_toupper($1SRCDIR))
1333  m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
1334  AC_SUBST(m4_toupper($1OBJDIR))
1335  m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
1336fi
1337
1338  # Define the Makefile conditional
1339AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
1340               test $m4_tolower(coin_has_$1) != unavailable)
1341AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
1342]) # AC_COIN_HAS
1343
1344###########################################################################
1345#                        COIN_HAS_USER_LIBRARY                            #
1346###########################################################################
1347
1348# This macro sets up usage of a library with header files.  It defines
1349# the LBRYINCDIR variable, and it defines COIN_HAS_LBRY preprocessor
1350# macro and makefile conditional.  The first argument should be the
1351# full name (LibraryName) of the library, and the second argument (in
1352# upper case letters) the abbreviation (LBRY).  This macro also
1353# introduces the configure arguments --with-libraryname-incdir and
1354# --with-libraryname-lib which have to be both given by a user to use
1355# this solver to tell the configure script where the include files and
1356# the library are located.  Those arguments can also be given as
1357# environement variables LBRYINCDIR and LBRYLIB, but a --with-*
1358# argument overwrites an environment variable.  If a third argument is
1359# given, it is assumed that this is the name of a header file that can
1360# be checked for in the given include directory, and if a fourth
1361# argument is given, it is assumed to be the name of a C function
1362# which is given and defined in the library, and a test is done to
1363# check if that symbol is defined in the library.
1364
1365AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
1366[AC_REQUIRE([AC_COIN_SRCDIR_INIT])
1367AC_MSG_CHECKING(if user provides library for $1)
1368
1369# Check for header file directory
1370AC_ARG_WITH(m4_tolower($1)-incdir,
1371            AC_HELP_STRING([--with-m4_tolower($1)-incdir],
1372                           [specify the directory with the header files for library $1]),
1373                           [$2INCDIR=`cd $withval; pwd`])
1374# Check for library directory
1375AC_ARG_WITH(m4_tolower($1)-lib,
1376            AC_HELP_STRING([--with-m4_tolower($1)-lib],
1377                           [specify the flags to link with the library $1]),
1378                           [$2LIB=$withval])
1379
1380if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
1381  m4_tolower(coin_has_$2)=true
1382else
1383  m4_tolower(coin_has_$2)=false
1384fi
1385
1386if test $m4_tolower(coin_has_$2) = true; then
1387# Check either both arguments or none are given
1388  if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
1389    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])
1390  fi
1391  AC_MSG_RESULT(yes)
1392  # Check if the given header file is there
1393  m4_ifvaln([$3],[AC_CHECK_FILE([$$2INCDIR/$3],[],
1394                 [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
1395  # Check if the symbol is provided in the library
1396  # ToDo: FOR NOW WE ASSUME THAT WE ARE USING THE C++ COMPILER
1397  m4_ifvaln([$4],[coin_save_LIBS="$LIBS"
1398                  LIBS="$$2LIB $ADDLIBS"
1399                  AC_MSG_CHECKING([whether symbol $4 is available with $2])
1400                  AC_TRY_LINK([extern "C" {void $4();}],[$4()],
1401                              [AC_MSG_RESULT(yes)],
1402                              [AC_MSG_RESULT(no)
1403                               AC_MSG_ERROR([Cannot find symbol $4 with $2])])
1404                  LIBS="$coin_save_LIBS"])
1405  ADDLIBS="$$2LIB $ADDLIBS"
1406  AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is used])
1407else
1408  AC_MSG_RESULT(no)
1409fi
1410
1411AC_SUBST($2INCDIR)
1412AC_SUBST($2LIB)
1413AM_CONDITIONAL(COIN_HAS_$2,
1414               test $m4_tolower(coin_has_$2) = true)
1415]) #AC_COIN_HAS_SOLVER
Note: See TracBrowser for help on using the repository browser.