source: trunk/coin.m4 @ 1

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

first version

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