source: trunk/coin.m4 @ 3665

Last change on this file since 3665 was 3665, checked in by stefan, 3 years ago

change default compiler flags (empty of -DNDEBUG)

  • Property svn:keywords set to Author Date Id Revision
File size: 48.1 KB
Line 
1# Copyright (C) 2013-2016
2# All Rights Reserved.
3# This file is distributed under the Eclipse Public License.
4#
5# This file defines the common autoconf macros for COIN-OR
6#
7
8# Check requirements
9AC_PREREQ(2.69)
10
11
12###########################################################################
13#                            COIN_CHECK_ISFINITE                          #
14###########################################################################
15
16# This macro checks for a usable implementation of a function to check
17# whether a given floating point number is finite.
18# If a function is found, then the macro defines the symbol
19# toupper($1)_C_FINITE to the name of this function.
20
21AC_DEFUN([AC_COIN_CHECK_ISFINITE],[
22
23AC_LANG_PUSH(C++)
24
25#AC_COIN_CHECK_CXX_CHEADER(math)
26#AC_COIN_CHECK_CXX_CHEADER(float)
27#AC_COIN_CHECK_CXX_CHEADER(ieeefp)
28AC_CHECK_HEADERS([cmath])
29if test "$ac_cv_header_cmath" != "yes"; then
30  AC_CHECK_HEADERS([math.h])
31fi
32AC_CHECK_HEADERS([cfloat])
33if test "$ac_cv_header_cfloat" != "yes"; then
34  AC_CHECK_HEADERS([float.h])
35fi
36AC_CHECK_HEADERS([cieeefp])
37if test "$ac_cv_header_cieeefp" != "yes"; then
38  AC_CHECK_HEADERS([ieeefp.h])
39fi
40
41COIN_C_FINITE=
42AC_CHECK_DECL([isfinite],[COIN_C_FINITE=isfinite],,[
43#ifdef HAVE_CMATH
44# include <cmath>
45#else
46# ifdef HAVE_MATH_H
47#  include <math.h>
48# endif
49#endif
50#ifdef HAVE_CFLOAT
51# include <cfloat>
52#else
53# ifdef HAVE_FLOAT_H
54#  include <float.h>
55# endif
56#endif
57#ifdef HAVE_CIEEEFP
58# include <cieeefp>
59#else
60# ifdef HAVE_IEEEFP_H
61#  include <ieeefp.h>
62# endif
63#endif])
64if test -z "$COIN_C_FINITE"; then
65  AC_CHECK_DECL([finite],[COIN_C_FINITE=finite],,[
66#ifdef HAVE_CMATH
67# include <cmath>
68#else
69# ifdef HAVE_MATH_H
70#  include <math.h>
71# endif
72#endif
73#ifdef HAVE_CFLOAT
74# include <cfloat>
75#else
76# ifdef HAVE_FLOAT_H
77#  include <float.h>
78# endif
79#endif
80#ifdef HAVE_CIEEEFP
81# include <cieeefp>
82#else
83# ifdef HAVE_IEEEFP_H
84#  include <ieeefp.h>
85# endif
86#endif])
87  if test -z "$COIN_C_FINITE"; then
88    AC_CHECK_DECL([_finite],[COIN_C_FINITE=_finite],,[
89#ifdef HAVE_CMATH
90# include <cmath>
91#else
92# ifdef HAVE_MATH_H
93#  include <math.h>
94# endif
95#endif
96#ifdef HAVE_CFLOAT
97# include <cfloat>
98#else
99# ifdef HAVE_FLOAT_H
100#  include <float.h>
101# endif
102#endif
103#ifdef HAVE_CIEEEFP
104# include <cieeefp>
105#else
106# ifdef HAVE_IEEEFP_H
107#  include <ieeefp.h>
108# endif
109#endif])
110  fi
111fi
112if test -z "$COIN_C_FINITE"; then
113  AC_MSG_WARN(Cannot find C-function for checking Inf.)
114else
115  AC_DEFINE_UNQUOTED(COIN_C_FINITE,[$COIN_C_FINITE],
116                     [Define to be the name of C-function for Inf check])
117fi
118
119AC_LANG_POP(C++)
120])
121
122###########################################################################
123#                              COIN_CHECK_ISNAN                           #
124###########################################################################
125
126# This macro checks for a usable implementation of a function to check
127# whether a given floating point number represents NaN.
128# If a function is found, then the macro defines the symbol COIN_C_ISNAN
129# to the name of this function.
130
131AC_DEFUN([AC_COIN_CHECK_ISNAN],[
132
133AC_LANG_PUSH(C++)
134
135#AC_COIN_CHECK_CXX_CHEADER(math)
136#AC_COIN_CHECK_CXX_CHEADER(float)
137#AC_COIN_CHECK_CXX_CHEADER(ieeefp)
138AC_CHECK_HEADERS([cmath])
139if test "$ac_cv_header_cmath" != "yes"; then
140  AC_CHECK_HEADERS([math.h])
141fi
142AC_CHECK_HEADERS([cfloat])
143if test "$ac_cv_header_cfloat" != "yes"; then
144  AC_CHECK_HEADERS([float.h])
145fi
146AC_CHECK_HEADERS([cieeefp])
147if test "$ac_cv_header_cieeefp" != "yes"; then
148  AC_CHECK_HEADERS([ieeefp.h])
149fi
150
151COIN_C_ISNAN=
152AC_CHECK_DECL([isnan],[COIN_C_ISNAN=isnan],,[
153#ifdef HAVE_CMATH
154# include <cmath>
155#else
156# ifdef HAVE_MATH_H
157#  include <math.h>
158# endif
159#endif
160#ifdef HAVE_CFLOAT
161# include <cfloat>
162#else
163# ifdef HAVE_FLOAT_H
164#  include <float.h>
165# endif
166#endif
167#ifdef HAVE_CIEEEFP
168# include <cieeefp>
169#else
170# ifdef HAVE_IEEEFP_H
171#  include <ieeefp.h>
172# endif
173#endif])
174
175# It appears that for some systems (e.g., Mac OSX), cmath will provide only
176# std::isnan, and bare isnan will be unavailable. Typically we need a parameter
177# in the test to allow C++ to do overload resolution.
178# With newer autoconf, this parameter now gets interpreted as a typecast.
179
180if test -z "$COIN_C_ISNAN"; then
181  AC_CHECK_DECL([std::isnan(double)],[COIN_C_ISNAN=std::isnan],,[
182#ifdef HAVE_CMATH
183# include <cmath>
184#else
185# ifdef HAVE_MATH_H
186#  include <math.h>
187# endif
188#endif
189#ifdef HAVE_CFLOAT
190# include <cfloat>
191#else
192# ifdef HAVE_FLOAT_H
193#  include <float.h>
194# endif
195#endif
196#ifdef HAVE_CIEEEFP
197# include <cieeefp>
198#else
199# ifdef HAVE_IEEEFP_H
200#  include <ieeefp.h>
201# endif
202#endif])
203fi
204
205if test -z "$COIN_C_ISNAN"; then
206  AC_CHECK_DECL([_isnan],[COIN_C_ISNAN=_isnan],,[
207#ifdef HAVE_CMATH
208# include <cmath>
209#else
210# ifdef HAVE_MATH_H
211#  include <math.h>
212# endif
213#endif
214#ifdef HAVE_CFLOAT
215# include <cfloat>
216#else
217# ifdef HAVE_FLOAT_H
218#  include <float.h>
219# endif
220#endif
221#ifdef HAVE_CIEEEFP
222# include <cieeefp>
223#else
224# ifdef HAVE_IEEEFP_H
225#  include <ieeefp.h>
226# endif
227#endif])
228fi
229if test -z "$COIN_C_ISNAN"; then
230  AC_CHECK_DECL([isnand],[COIN_C_ISNAN=isnand],,[
231#ifdef HAVE_CMATH
232# include <cmath>
233#else
234# ifdef HAVE_MATH_H
235#  include <math.h>
236# endif
237#endif
238#ifdef HAVE_CFLOAT
239# include <cfloat>
240#else
241# ifdef HAVE_FLOAT_H
242#  include <float.h>
243# endif
244#endif
245#ifdef HAVE_CIEEEFP
246# include <cieeefp>
247#else
248# ifdef HAVE_IEEEFP_H
249#  include <ieeefp.h>
250# endif
251#endif])
252fi
253if test -z "$COIN_C_ISNAN"; then
254  AC_MSG_WARN(Cannot find C-function for checking NaN.)
255else
256  AC_DEFINE_UNQUOTED(COIN_C_ISNAN,[$COIN_C_ISNAN],
257                     [Define to be the name of C-function for NaN check])
258fi
259
260AC_LANG_POP(C++)
261])
262
263###########################################################################
264#                          COIN_EXAMPLE_FILES                             #
265###########################################################################
266
267# This macro determines the names of the example files (using the
268# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
269# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
270# creates soft links to the example files.
271
272AC_DEFUN([AC_COIN_EXAMPLE_FILES],
273[
274#AC_REQUIRE([AC_COIN_CHECK_VPATH])
275#AC_REQUIRE([AC_COIN_ENABLE_MSVC])
276#AC_REQUIRE([AC_PROG_LN_S])
277
278files=`cd $srcdir; ls $1`
279# We need to do the following loop to make sure that there are no newlines
280# in the variable
281for file in $files; do
282  EXAMPLE_FILES="$EXAMPLE_FILES $file"
283  # using AC_CONFIG_LINKS is much simpler here, but due to a bug
284  # in autoconf (even latest autoconf), the AC_COIN_EXAMPLE_FILES
285  # macro can only be called once if the links are made this way
286  # (otherwise autoconf thinks $file is a duplicate...)
287  AC_CONFIG_LINKS([$file:$file])
288done
289
290# potentially add some of this back as needed:
291#if test $coin_vpath_config = yes; then
292#  lnkcmd=
293#  if test "$enable_msvc" != no; then
294#    lnkcmd=cp
295#  fi
296#  case "$CC" in
297#    clang* ) ;;
298#    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
299#      lnkcmd=cp ;;
300#  esac
301#  if test "x$lnkcmd" = xcp; then
302#    AC_MSG_NOTICE([Copying example files ($1)])
303#  else
304#    AC_MSG_NOTICE([Creating links to the example files ($1)])
305#    lnkcmd="$LN_S"
306#  fi
307#  for file in $EXAMPLE_FILES; do
308#    rm -f $file
309#    $lnkcmd $srcdir/$file $file
310#  done
311#  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
312#else
313#  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
314#fi
315#
316# In case there are compressed files, we create a variable with the
317# uncompressed names
318#EXAMPLE_UNCOMPRESSED_FILES=
319#for file in $EXAMPLE_FILES; do
320#  case $file in
321#    *.gz)
322#      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
323#      ;;
324#  esac
325#done
326#
327#AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
328AC_SUBST(EXAMPLE_FILES)
329#AC_SUBST(EXAMPLE_CLEAN_FILES)
330]) #AC_COIN_EXAMPLE_FILES
331
332
333###########################################################################
334#                          COIN_PROJECTVERSION                            #
335###########################################################################
336
337# This macro is used by COIN_PROJECTDIR_INIT and sets up variables related
338# to versioning numbers of the project.
339
340AC_DEFUN([AC_COIN_PROJECTVERSION],
341[m4_ifvaln([$1],[
342  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION), ["$PACKAGE_VERSION"],[Version number of project])
343 
344  [coin_majorver=`echo $PACKAGE_VERSION | sed -n -e 's/^\([0-9]*\).*/\1/gp'`]
345  [coin_minorver=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.\([0-9]*\).*/\1/gp'`]
346  [coin_releasever=`echo $PACKAGE_VERSION | sed -n -e 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/gp'`]
347  test -z "$coin_majorver"   && coin_majorver=9999
348  test -z "$coin_minorver"   && coin_minorver=9999
349  test -z "$coin_releasever" && coin_releasever=9999
350  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MAJOR),   [$coin_majorver],   [Major Version number of project])
351  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_MINOR),   [$coin_minorver],   [Minor Version number of project])
352  AC_DEFINE_UNQUOTED(m4_toupper($1_VERSION_RELEASE), [$coin_releasever], [Release Version number of project])
353
354  # We use the following variable to have a string with the upper case
355  # version of the project name
356  COIN_PRJCT=m4_toupper($1)
357
358  # Set the project's SVN revision number. The complicated sed expression
359  # (made worse by quadrigraphs) ensures that things like 4123:4168MS end up
360  # as a single number.
361  AC_CHECK_PROG([have_svnversion],[svnversion],[yes],[no])
362  if test "x$have_svnversion" = xyes; then
363    AC_SUBST(m4_toupper($1_SVN_REV))
364    svn_rev_tmp=`LANG=en_EN svnversion $srcdir 2>/dev/null`
365    if test "x$svn_rev_tmp" != xexported -a "x$svn_rev_tmp" != x -a "x$svn_rev_tmp" != "xUnversioned directory"; then
366      m4_toupper($1_SVN_REV)=`echo $svn_rev_tmp | sed -n -e 's/^@<:@0-9@:>@*://' -e 's/\(@<:@0-9@:>@\)@<:@^0-9@:>@*$/\1/p'`
367      AC_DEFINE_UNQUOTED(m4_toupper($1_SVN_REV), $m4_toupper($1_SVN_REV), [SVN revision number of project])
368    fi
369  fi
370 ])
371 
372# Capture libtool library version, if given.
373 m4_ifvaln([$2],[coin_libversion=$2],[])
374])
375
376###########################################################################
377#                            COIN_INITALIZE                               #
378###########################################################################
379
380# This macro does everything that is required in the early part in the
381# configure script, such as defining a few variables.
382# The first parameter is the project name.
383# The second (optional) is the libtool library version (important for releases,
384# less so for stable or trunk).
385
386AC_DEFUN([AC_COIN_INITIALIZE],
387[
388# required autoconf version
389AC_PREREQ(2.69)
390
391# Set the project's version numbers
392AC_COIN_PROJECTVERSION($1, $2)
393
394# A useful makefile conditional that is always false
395AM_CONDITIONAL(ALWAYS_FALSE, false)
396
397# Where should everything be installed by default?  Here, we want it
398# to be installed directly in 'bin', 'lib', 'include' subdirectories
399# of the directory where configure is run.  The default would be
400# /usr/local.     
401AC_PREFIX_DEFAULT([`pwd`])
402
403# Get the system type
404AC_CANONICAL_BUILD
405
406# initialize automake
407# - don't define PACKAGE or VERSION
408# - disable dist target
409# - enable all automake warnings
410AM_INIT_AUTOMAKE([no-define no-dist -Wall])
411
412# make silent build rules the default (https://www.gnu.org/software/automake/manual/html_node/Automake-Silent-Rules.html)
413AM_SILENT_RULES([yes])
414
415# disable automatic rebuild of configure/Makefile
416AM_MAINTAINER_MODE
417
418# setup libtool parameters (https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html)
419LT_INIT([disable-static])
420
421# create libtool
422AC_PROG_LIBTOOL
423
424# change default compiler flags (should we have an enable-debug again?)
425# - some compilers doesn't understand -g
426# - set -DNDEBUG for C/C++ code
427: ${FFLAGS:=""}
428: ${FCFLAGS:=""}
429: ${CFLAGS:="-DNDEBUG"}
430: ${CXXFLAGS:="-DNDEBUG"}
431])
432
433###########################################################################
434#                              COIN_FINALIZE                              #
435###########################################################################
436
437# This macro should be called at the very end of the configure.ac file.
438# It creates the output files (by using AC_OUTPUT), and might do some other
439# things (such as generating links to data files in a VPATH configuration).
440# It also prints the "success" message.
441# Note: If the variable coin_skip_ac_output is set to yes, then no output
442# files are written.
443
444AC_DEFUN([AC_COIN_FINALIZE],
445[
446AC_OUTPUT
447
448AC_MSG_NOTICE([In case of trouble, first consult the troubleshooting page at https://projects.coin-or.org/BuildTools/wiki/user-troubleshooting])
449AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
450
451]) #AC_COIN_FINALIZE
452
453
454###########################################################################
455#                           COIN_HAS_PKGCONFIG                            #
456###########################################################################
457
458# This macro checks whether a pkg-config tool with a minimal version number
459# is available.  If so, then the variable PKGCONFIG is set to its path.
460# If not, PKGCONFIG is set to "".  The minimal version number can be given
461# as first parameter, by default it is 0.16.0, since COIN-OR .pc files now
462# include an URL field, which breaks pkg-config version <= 0.15.
463# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
464# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
465# AC_SUBST'ed.  Finally, the search path for .pc files is assembled from the
466# value of $prefix and $PKG_CONFIG_PATH in a variable COIN_PKG_CONFIG_PATH,
467# which is also AC_SUBST'ed.
468
469AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
470[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
471
472AC_ARG_ENABLE([pkg-config],
473  [AC_HELP_STRING([--disable-pkg-config],[disable use of pkg-config (if available)])],
474  [use_pkgconfig="$enableval"],
475  [#if test x$coin_cc_is_cl = xtrue; then
476   #  use_pkgconfig=no
477   #else
478     use_pkgconfig=yes
479   #fi
480  ])
481
482if test $use_pkgconfig = yes ; then
483  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
484    AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
485  fi
486  if test -n "$PKG_CONFIG"; then
487    _pkg_min_version=m4_default([$1], [0.16.0])
488    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
489    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
490      AC_MSG_RESULT([yes])
491    else
492      AC_MSG_RESULT([no])
493      PKG_CONFIG=""
494    fi
495  fi
496
497  # check if pkg-config supports the short-errors flag
498  if test -n "$PKG_CONFIG" && \
499    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
500    pkg_short_errors=" --short-errors "
501  else
502    pkg_short_errors=""
503  fi
504fi
505
506AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
507AC_SUBST(PKG_CONFIG)
508
509# assemble pkg-config search path
510COIN_PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"
511AC_SUBST(COIN_PKG_CONFIG_PATH)
512
513# let's assume that when installing into $prefix, then the user may have installed some other coin projects there before, so it's worth to have a look into there
514# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
515# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
516if test "x${prefix}" = xNONE ; then
517  COIN_PKG_CONFIG_PATH="${ac_default_prefix}/lib64/pkgconfig:${ac_default_prefix}/lib/pkgconfig:${ac_default_prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
518else
519  COIN_PKG_CONFIG_PATH="${prefix}/lib64/pkgconfig:${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
520fi
521
522])
523
524
525###########################################################################
526#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
527###########################################################################
528
529# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
530#
531# Check to see whether a particular set of packages exists.
532# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
533#
534AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
535[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
536if test -n "$PKG_CONFIG" ; then
537  if $PKG_CONFIG --exists "$2"; then
538    m4_toupper($1)[]_VERSIONS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`
539    $3
540  else
541    m4_toupper($1)_PKG_ERRORS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
542    $4
543  fi
544else
545  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
546fi
547])
548
549###########################################################################
550#                            COIN_CHECK_PACKAGE                           #
551###########################################################################
552
553AC_DEFUN([AC_COIN_CHECK_PACKAGE],
554[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
555AC_MSG_CHECKING([for COIN-OR package $1])
556
557m4_tolower(coin_has_$1)=notGiven
558
559# check if user wants to skip package in any case
560if test x"$COIN_SKIP_PROJECTS" != x; then
561  for dir in $COIN_SKIP_PROJECTS; do
562    if test $dir = "$1"; then
563      m4_tolower(coin_has_$1)=skipping
564    fi
565  done
566fi
567
568if test "$m4_tolower(coin_has_$1)" != skipping; then
569  AC_ARG_WITH([m4_tolower($1)],,
570    [if test "$withval" = no ; then
571       m4_tolower(coin_has_$1)=skipping
572     fi
573    ])
574fi
575
576m4_toupper($1_LIBS)=
577m4_toupper($1_CFLAGS)=
578m4_toupper($1_DATA)=
579m4_toupper($1_PCREQUIRES)=
580AC_SUBST(m4_toupper($1_LIBS))
581AC_SUBST(m4_toupper($1_CFLAGS))
582AC_SUBST(m4_toupper($1_DATA))
583m4_foreach_w([myvar], [$3], [
584  AC_SUBST(m4_toupper(myvar)_LIBS)
585  AC_SUBST(m4_toupper(myvar)_CFLAGS)
586  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
587])
588
589#check if user provided LIBS for package or disables use of package
590if test $m4_tolower(coin_has_$1) != skipping; then
591  AC_ARG_WITH([m4_tolower($1)-lib],
592    AC_HELP_STRING([--with-m4_tolower($1)-lib],
593                   [linker flags for using package $1]),
594    [if test "$withval" = no ; then
595       m4_tolower(coin_has_$1)=skipping
596     else
597       m4_tolower(coin_has_$1)=yes
598       m4_toupper($1_LIBS)="$withval"
599       m4_foreach_w([myvar], [$3], [
600         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
601       ])
602     fi
603    ],
604    [])
605fi
606
607#check if user provided INCDIR for package or disables use of package
608if test $m4_tolower(coin_has_$1) != skipping; then
609  AC_ARG_WITH([m4_tolower($1)-incdir],
610    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
611                   [directory with header files for using package $1]),
612    [if test "$withval" = no ; then
613       m4_tolower(coin_has_$1)=skipping
614     else
615       m4_tolower(coin_has_$1)=yes
616       m4_toupper($1_CFLAGS)="-I$withval"
617       m4_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="-I$withval $m4_toupper(myvar)_CFLAGS"])
618     fi
619    ],
620    [])
621fi
622
623#check if user provided DATADIR for package or disables use of package
624if test $m4_tolower(coin_has_$1) != skipping; then
625  AC_ARG_WITH([m4_tolower($1)-datadir],
626    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
627                   [directory with data files for using package $1]),
628    [if test "$withval" = no ; then
629       m4_tolower(coin_has_$1)=skipping
630     else
631       m4_tolower(coin_has_$1)=yes
632       m4_toupper($1_DATA)="$withval"
633     fi
634    ],
635    [])
636fi
637
638# now use pkg-config, if nothing of the above applied
639if test $m4_tolower(coin_has_$1) = notGiven; then
640  if test -n "$PKG_CONFIG" ; then
641   
642    # let pkg-config do it's magic
643    AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
644      [ m4_tolower(coin_has_$1)=yes
645        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
646
647        m4_toupper($1_DATA)=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --variable=datadir $2 2>/dev/null`
648       
649        m4_toupper($1_PCREQUIRES)="$2"
650        # augment X_PCREQUIRES for each build target X in $3
651        m4_foreach_w([myvar], [$3], [
652          m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
653        ])
654      ],
655      [ m4_tolower(coin_has_$1)=notGiven
656        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
657      ])
658
659  else
660    AC_MSG_ERROR([skipped check via pkg-config, redirect to fallback... -- oops, not there yet])
661    # TODO
662    #AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
663  fi
664
665else
666  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
667fi
668
669if test $m4_tolower(coin_has_$1) != skipping &&
670   test $m4_tolower(coin_has_$1) != notGiven ; then
671  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
672 
673  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
674    if test -n "$m4_toupper($1)_DATA" ; then
675      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
676    fi
677    if test -n "$m4_toupper($1)_PCREQUIRES" ; then
678      AC_MSG_NOTICE([$1 PCREQUIRES are $m4_toupper($1)_PCREQUIRES])
679    fi
680  fi
681 
682fi
683
684# Define the Makefile conditional
685AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
686               [test $m4_tolower(coin_has_$1) != notGiven &&
687                test $m4_tolower(coin_has_$1) != skipping])
688])
689
690###########################################################################
691#                           COIN_FINALIZE_FLAGS                           #
692###########################################################################
693
694# TODO this could be moved into COIN_FINALIZE, if we were able to remember
695#   for which variables we need to run pkg-config
696AC_DEFUN([AC_COIN_FINALIZE_FLAGS],[
697
698# do pkg-config calls to complete LIBS and CFLAGS
699m4_foreach_w([myvar],[$1],[
700  if test -n "${m4_toupper(myvar)_PCREQUIRES}" ; then
701    temp_CFLAGS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --cflags ${m4_toupper(myvar)_PCREQUIRES}`
702    temp_LIBS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --libs ${m4_toupper(myvar)_PCREQUIRES}`
703    m4_toupper(myvar)_CFLAGS="$temp_CFLAGS ${m4_toupper(myvar)_CFLAGS}"
704    m4_toupper(myvar)_LIBS="$temp_LIBS ${m4_toupper(myvar)_LIBS}"
705  fi
706
707  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
708    if test -n "${m4_toupper(myvar)_CFLAGS}" ; then
709      AC_MSG_NOTICE([myvar CFLAGS are ${m4_toupper(myvar)_CFLAGS}])
710    fi
711    if test -n "${m4_toupper(myvar)_LIBS}" ; then
712      AC_MSG_NOTICE([myvar LIBS   are ${m4_toupper(myvar)_LIBS}])
713    fi
714  fi
715])
716
717])
718
719
720###########################################################################
721#                            COIN_TRY_FLINK                               #
722###########################################################################
723
724# Auxilliary macro to test if a Fortran function name can be linked,
725# given the current settings of LIBS.  We determine from the context, what
726# the currently active programming language is, and cast the name accordingly.
727# The first argument is the name of the function/subroutine, in small letters,
728# the second argument are the actions taken when the test works, and the
729# third argument are the actions taken if the test fails.
730
731AC_DEFUN([AC_COIN_TRY_FLINK],[
732case $ac_ext in
733  f)
734    AC_TRY_LINK(,[      call $1],[flink_try=yes],[flink_try=no])
735    ;;
736  c)
737    coin_need_flibs=no
738    flink_try=no
739    AC_F77_FUNC($1,cfunc$1)
740    AC_LINK_IFELSE(
741      [AC_LANG_PROGRAM([void $cfunc$1();],[$cfunc$1()])],
742      [flink_try=yes],
743      [if test x"$FLIBS" != x; then
744         flink_save_libs="$LIBS"
745         LIBS="$LIBS $FLIBS"
746         AC_LINK_IFELSE(
747           [AC_LANG_PROGRAM([void $cfunc$1();],[$cfunc$1()])],
748           [coin_need_flibs=yes
749            flint_try=yes]
750         )
751         LIBS="$flink_save_libs"
752       fi
753      ]
754    )
755    ;;
756  cc|cpp)
757    coin_need_flibs=no
758    flink_try=no
759    AC_F77_FUNC($1,cfunc$1)
760    AC_LINK_IFELSE(
761      [AC_LANG_PROGRAM([extern "C" {void $cfunc$1();}],[$cfunc$1()])],
762      [flink_try=yes],
763      [if test x"$FLIBS" != x; then
764         flink_save_libs="$LIBS"
765         LIBS="$LIBS $FLIBS"
766         AC_LINK_IFELSE(
767           [AC_LANG_PROGRAM([extern "C" {void $cfunc$1();}],[$cfunc$1()])],
768           [coin_need_flibs=yes
769            flink_try=yes]
770         )
771         LIBS="$flink_save_libs"
772       fi
773      ]
774    )
775    ;;
776esac
777if test $flink_try = yes; then
778  $2
779else
780  $3
781fi
782]) # AC_COIN_TRY_FLINK
783
784###########################################################################
785#                         COIN_CHECK_PACKAGE_BLAS                         #
786###########################################################################
787
788# This macro checks for a library containing the BLAS library.  It
789# 1. checks the --with-blas argument
790# 2. if --with-blas=BUILD has been specified goes to point 5
791# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
792#    to its value
793# 4. tries standard libraries
794# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
795#    ThirdParty/Blas
796# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
797# BLAS_LIBS is set to the flags required to link with a Blas library.
798# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
799# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
800# In case 5, Blas is added to X_PCREQUIRES.
801
802AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
803[
804AC_ARG_WITH([blas],
805            AC_HELP_STRING([--with-blas],
806                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
807            [use_blas="$withval"], [use_blas=])
808
809# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
810# preference
811AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
812
813# Check if user supplied option makes sense
814if test x"$use_blas" != x; then
815  if test "$use_blas" = "BUILD"; then
816    # we come to this later
817    :
818  elif test "$use_blas" != "no"; then
819    coin_save_LIBS="$LIBS"
820    LIBS="$use_blas $LIBS"
821    if test "$F77" != unavailable ; then
822      coin_need_flibs=no
823      AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
824      AC_COIN_TRY_FLINK([daxpy],
825                        [if test $coin_need_flibs = yes ; then
826                           use_blas="$use_blas $FLIBS"
827                         fi
828                         AC_MSG_RESULT([yes: $use_blas])],
829                        [AC_MSG_RESULT([no])
830                         AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
831      use_blas="$use_blas $FLIBS"
832    else
833      AC_MSG_NOTICE([checking whether user supplied BLASLIB=\"$use_blas\" works with C linkage])
834      AC_LANG_PUSH(C)
835      AC_CHECK_FUNC([daxpy],[],[AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
836      AC_LANG_POP(C)
837    fi
838    LIBS="$coin_save_LIBS"
839  fi
840else
841# Try to autodetect the library for blas based on build system
842  #AC_MSG_CHECKING([default locations for BLAS])
843  case $build in
844    *-sgi-*)
845      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
846      coin_need_flibs=no
847      coin_save_LIBS="$LIBS"
848      LIBS="-lcomplib.sgimath $LIBS"
849      AC_COIN_TRY_FLINK([daxpy],
850                        [use_blas="-lcomplib.sgimath"
851                         if test $coin_need_flibs = yes ; then
852                           use_blas="$use_blas $FLIBS"
853                         fi
854                         AC_MSG_RESULT([yes: $use_blas])
855                        ],
856                        [AC_MSG_RESULT([no])])
857      LIBS="$coin_save_LIBS"
858      ;;
859
860    *-*-solaris*)
861      AC_MSG_CHECKING([for BLAS in libsunperf])
862      # Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
863      # cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
864      # recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
865      # that CC and cc will understand -library in Studio 13. The main extra
866      # function of -xlic_lib and -library is to arrange for the Fortran run-time
867      # libraries to be linked for C++ and C. We can arrange that explicitly.
868      coin_need_flibs=no
869      coin_save_LIBS="$LIBS"
870      LIBS="-lsunperf $FLIBS $LIBS"
871      AC_COIN_TRY_FLINK([daxpy],
872                        [use_blas='-lsunperf'
873                         if test $coin_need_flibs = yes ; then
874                           use_blas="$use_blas $FLIBS"
875                         fi
876                         AC_MSG_RESULT([yes: $use_blas])
877                        ],
878                        [AC_MSG_RESULT([no])])
879      LIBS="$coin_save_LIBS"
880      ;;
881     
882    *-cygwin* | *-mingw*)
883      case "$CC" in
884        clang* ) ;;
885        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
886          coin_save_LIBS="$LIBS"
887          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
888          if test "$F77" != unavailable ; then
889            AC_MSG_CHECKING([for BLAS in MKL (32bit)])
890            AC_COIN_TRY_FLINK([daxpy],
891                              [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
892                               AC_MSG_RESULT([yes: $use_blas])
893                              ],
894                              [AC_MSG_RESULT([no])])
895          else
896            AC_MSG_NOTICE([for BLAS in MKL (32bit) using C linkage])
897            AC_LANG_PUSH(C)
898            AC_CHECK_FUNC([daxpy],[use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'])
899            AC_LANG_POP(C)
900          fi
901          LIBS="$coin_save_LIBS"
902         
903          if test "x$use_blas" = x ; then
904            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
905            if test "$F77" != unavailable ; then
906              AC_MSG_CHECKING([for BLAS in MKL (64bit)])
907              AC_COIN_TRY_FLINK([daxpy],
908                                [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
909                                 AC_MSG_RESULT([yes: $use_blas])
910                                ],
911                                [AC_MSG_RESULT([no])])
912            else
913              AC_MSG_NOTICE([for BLAS in MKL (64bit) using C linkage])
914              # unset cached outcome of test with 32bit MKL
915              unset ac_cv_func_daxpy
916              AC_LANG_PUSH(C)
917              AC_CHECK_FUNC([daxpy],[use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'])
918              AC_LANG_POP(C)
919            fi
920            LIBS="$coin_save_LIBS"
921          fi
922          ;;
923      esac
924      ;;
925     
926     *-darwin*)
927      AC_MSG_CHECKING([for BLAS in Veclib])
928      coin_need_flibs=no
929      coin_save_LIBS="$LIBS"
930      LIBS="-framework Accelerate $LIBS"
931      AC_COIN_TRY_FLINK([daxpy],
932                        [use_blas='-framework Accelerate'
933                         if test $coin_need_flibs = yes ; then
934                           use_blas="$use_blas $FLIBS"
935                         fi
936                         AC_MSG_RESULT([yes: $use_blas])
937                        ],
938                        [AC_MSG_RESULT([no])])
939      LIBS="$coin_save_LIBS"
940      ;;
941  esac
942
943  if test -z "$use_blas" ; then
944    AC_MSG_CHECKING([whether -lblas has BLAS])
945    coin_need_flibs=no
946    coin_save_LIBS="$LIBS"
947    LIBS="-lblas $LIBS"
948    AC_COIN_TRY_FLINK([daxpy],
949                      [use_blas='-lblas'
950                       if test $coin_need_flibs = yes ; then
951                         use_blas="$use_blas $FLIBS"
952                       fi
953                       AC_MSG_RESULT([yes: $use_blas])
954                      ],
955                      [AC_MSG_RESULT([no])])
956    LIBS="$coin_save_LIBS"
957  fi
958
959  # If we have no other ideas, consider building BLAS.
960  if test -z "$use_blas" ; then
961    use_blas=BUILD
962  fi
963fi
964
965if test "x$use_blas" = xBUILD ; then
966  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
967 
968elif test "x$use_blas" != x && test "$use_blas" != no; then
969  coin_has_blas=yes
970  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
971  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
972  BLAS_LIBS="$use_blas"
973  BLAS_CFLAGS=
974  BLAS_DATA=
975  AC_SUBST(BLAS_LIBS)
976  AC_SUBST(BLAS_CFLAGS)
977  AC_SUBST(BLAS_DATA)
978  m4_foreach_w([myvar], [$1], [
979    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
980  ])
981 
982else
983  coin_has_blas=no
984  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
985fi
986
987m4_foreach_w([myvar], [$1], [
988  AC_SUBST(m4_toupper(myvar)_LIBS)
989])
990
991]) # AC_COIN_CHECK_PACKAGE_BLAS
992
993###########################################################################
994#                       COIN_CHECK_PACKAGE_LAPACK                         #
995###########################################################################
996
997# This macro checks for a library containing the LAPACK library.  It
998# 1. checks the --with-lapack argument
999# 2. if --with-lapack=BUILD has been specified goes to point 5
1000# 3. if --with-lapack has been specified to a working library, sets
1001#    LAPACK_LIBS to its value
1002# 4. tries standard libraries
1003# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
1004#    ThirdParty/Lapack
1005# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
1006# LAPACK_LIBS is set to the flags required to link with a Lapack library.
1007# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
1008# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
1009# In case 5, Lapack is added to X_PCREQUIRES.
1010#
1011# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
1012#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
1013#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
1014#   then we will get Blas as dependency of coinlapack.
1015
1016AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
1017[
1018AC_ARG_WITH([lapack],
1019            AC_HELP_STRING([--with-lapack],
1020                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
1021            [use_lapack=$withval], [use_lapack=])
1022
1023#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
1024AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
1025
1026# Check if user supplied option makes sense
1027if test x"$use_lapack" != x; then
1028  if test "$use_lapack" = "BUILD"; then
1029    # we come to this later
1030    :
1031  elif test "$use_lapack" != no; then
1032    use_lapack="$use_lapack $BLAS_LIBS"
1033    coin_save_LIBS="$LIBS"
1034    LIBS="$use_lapack $LIBS"
1035    if test "$F77" != unavailable; then
1036      AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
1037      coin_need_flibs=no
1038      AC_COIN_TRY_FLINK([dsyev],
1039                        [if test $coin_need_flibs = yes ; then
1040                           use_lapack="$use_lapack $FLIBS"
1041                         fi
1042                         AC_MSG_RESULT([yes: $use_lapack])
1043                        ],
1044                        [AC_MSG_RESULT([no])
1045                         AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
1046    else
1047      AC_MSG_NOTICE([whether user supplied LAPACKLIB=\"$use_lapack\" works with C linkage])
1048      AC_LANG_PUSH(C)
1049      AC_CHECK_FUNC([dsyev],[],[AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
1050      AC_LANG_POP(C)
1051    fi
1052    LIBS="$coin_save_LIBS"
1053  fi
1054else
1055  if test x$coin_has_blas = xyes; then
1056    # First try to see if LAPACK is already available with BLAS library
1057    coin_save_LIBS="$LIBS"
1058    LIBS="$BLAS_LIBS $LIBS"
1059    if test "$F77" != unavailable; then
1060      coin_need_flibs=no
1061      AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
1062      AC_COIN_TRY_FLINK([dsyev],
1063                        [use_lapack="$BLAS_LIBS"
1064                         if test $coin_need_flibs = yes ; then
1065                           use_lapack="$use_lapack $FLIBS"
1066                         fi
1067                         AC_MSG_RESULT([yes: $use_lapack])
1068                        ],
1069                        [AC_MSG_RESULT([no])])
1070    else
1071      AC_MSG_NOTICE([checking whether LAPACK is already available with BLAS library])
1072      AC_LANG_PUSH(C)
1073      AC_CHECK_FUNC([dsyev],[use_lapack="$BLAS_LIBS"])
1074      AC_LANG_POP(C)
1075    fi
1076    LIBS="$coin_save_LIBS"
1077  fi
1078  if test -z "$use_lapack"; then
1079    # Try to autodetect the library for lapack based on build system
1080    case $build in
1081      # TODO: Is this check actually needed here, since -lcomplib.sigmath should have been recognized as Blas library,
1082      #       and above it is checked whether the Blas library already contains Lapack
1083      *-sgi-*)
1084        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
1085        coin_save_LIBS="$LIBS"
1086        coin_need_flibs=no
1087        LIBS="-lcomplib.sgimath $BLAS_LIBS $LIBS"
1088        AC_COIN_TRY_FLINK([dsyev],
1089                          [use_lapack="-lcomplib.sgimath $BLAS_LIBS"
1090                           if test $coin_need_flibs = yes ; then
1091                             use_lapack="$use_lapack $FLIBS"
1092                           fi
1093                           AC_MSG_RESULT([yes: $use_lapack])
1094                          ],
1095                          [AC_MSG_RESULT([no])])
1096        LIBS="$coin_save_LIBS"
1097        ;;
1098
1099      # See comments in COIN_CHECK_PACKAGE_BLAS.
1100      # TODO: Is this check actually needed here, since -lsunperf should have been recognized as Blas library,
1101      #       and above it is checked whether the Blas library already contains Lapack
1102      *-*-solaris*)
1103        AC_MSG_CHECKING([for LAPACK in libsunperf])
1104        coin_need_flibs=no
1105        coin_save_LIBS="$LIBS"
1106        LIBS="-lsunperf $BLAS_LIBS $FLIBS $LIBS"
1107        AC_COIN_TRY_FLINK([dsyev],
1108                          [use_lapack='-lsunperf $BLAS_LIBS'
1109                           if test $coin_need_flibs = yes ; then
1110                             use_lapack="$use_lapack $FLIBS"
1111                           fi
1112                           AC_MSG_RESULT([yes: $use_lapack])
1113                          ],
1114                          [AC_MSG_RESULT([no])])
1115        LIBS="$coin_save_LIBS"
1116        ;;
1117        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
1118        # will want to link with cygwin, hence won't run standalone in DOS.
1119    esac
1120  fi
1121
1122  if test -z "$use_lapack" ; then
1123    AC_MSG_CHECKING([whether -llapack has LAPACK])
1124    coin_need_flibs=no
1125    coin_save_LIBS="$LIBS"
1126    LIBS="-llapack $BLAS_LIBS $LIBS"
1127    AC_COIN_TRY_FLINK([dsyev],
1128                      [use_lapack='-llapack'
1129                       if test $coin_need_flibs = yes ; then
1130                         use_lapack="$use_lapack $FLIBS"
1131                       fi
1132                       AC_MSG_RESULT([yes: $use_lapack])
1133                      ],
1134                      [AC_MSG_RESULT([no])])
1135    LIBS="$coin_save_LIBS"
1136  fi
1137
1138  # If we have no other ideas, consider building LAPACK.
1139  if test -z "$use_lapack" ; then
1140    use_lapack=BUILD
1141  fi
1142fi
1143
1144if test "x$use_lapack" = xBUILD ; then
1145  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
1146
1147elif test "x$use_lapack" != x && test "$use_lapack" != no; then
1148  coin_has_lapack=yes
1149  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
1150  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
1151  LAPACK_LIBS="$use_lapack"
1152  LAPACK_CFLAGS=
1153  LAPACK_DATA=
1154  AC_SUBST(LAPACK_LIBS)
1155  AC_SUBST(LAPACK_CFLAGS)
1156  AC_SUBST(LAPACK_DATA)
1157  m4_foreach_w([myvar], [$1], [
1158    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
1159  ])
1160 
1161else
1162  coin_has_lapack=no
1163  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
1164fi
1165
1166m4_foreach_w([myvar], [$1], [
1167  AC_SUBST(m4_toupper(myvar)_LIBS)
1168])
1169
1170]) # AC_COIN_CHECK_PACKAGE_LAPACK
1171
1172
1173#######################################################################
1174#                           COIN_CHECK_LIBM                           #
1175#######################################################################
1176
1177# Check for the math library.
1178# For a (space separated) list of arguments X, this macro adds the flags
1179# for linking against the math library to a X_LIBS.
1180
1181AC_DEFUN([AC_COIN_CHECK_LIBM],
1182[AC_REQUIRE([AC_PROG_CC])
1183
1184coin_save_LIBS="$LIBS"
1185
1186AC_LANG_PUSH(C)
1187AC_SEARCH_LIBS([cos],[m],
1188  [m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"])]
1189)
1190AC_LANG_POP(C)
1191
1192LIBS="$coin_save_LIBS"
1193
1194]) # AC_COIN_CHECK_LIBM
1195
1196###########################################################################
1197#                           COIN_CHECK_ZLIB                               #
1198###########################################################################
1199
1200# This macro checks for the libz library.  If found, it sets the automake
1201# conditional COIN_HAS_ZLIB and defines the C preprocessor variable
1202# COIN_HAS_ZLIB.  Further, for a (space separated) list of arguments X,
1203# it adds the linker flag to the variables X_LIBS.
1204
1205AC_DEFUN([AC_COIN_CHECK_ZLIB],
1206[AC_REQUIRE([AC_PROG_CC])
1207
1208coin_has_zlib=no
1209
1210AC_ARG_ENABLE([zlib],
1211              [AC_HELP_STRING([--disable-zlib],[do not compile with compression library zlib])],
1212              [coin_enable_zlib=$enableval],
1213              [coin_enable_zlib=yes])
1214
1215if test $coin_enable_zlib = yes; then
1216  AC_LANG_PUSH(C)
1217  AC_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
1218
1219  if test $coin_has_zlib = yes; then
1220    AC_CHECK_LIB([z],[gzopen],[:],[coin_has_zlib=no])
1221  fi
1222
1223  if test $coin_has_zlib = yes; then
1224    m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"])
1225    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
1226  fi
1227  AC_LANG_POP(C)
1228fi
1229
1230AM_CONDITIONAL(COIN_HAS_ZLIB, test x$coin_has_zlib = xyes)
1231]) # AC_COIN_CHECK_ZLIB
1232
1233
1234###########################################################################
1235#                            COIN_CHECK_BZLIB                             #
1236###########################################################################
1237
1238# This macro checks for the libbz2 library.  If found, it defines the C
1239# preprocessor variable COIN_HAS_BZLIB.  Further, for a (space separated) list
1240# of arguments X, it adds the linker flag to the variables X_LIBS.
1241
1242AC_DEFUN([AC_COIN_CHECK_BZLIB],
1243[AC_REQUIRE([AC_PROG_CC])
1244
1245AC_ARG_ENABLE([bzlib],
1246              [AC_HELP_STRING([--disable-bzlib],[do not compile with compression library bzlib])],
1247              [coin_enable_bzlib=$enableval],
1248              [coin_enable_bzlib=yes])
1249
1250coin_has_bzlib=no
1251if test $coin_enable_bzlib = yes; then
1252  AC_LANG_PUSH(C)
1253  AC_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
1254
1255  if test $coin_has_bzlib = yes; then
1256    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],[:],[coin_has_bzlib=no])
1257  fi
1258
1259  if test $coin_has_bzlib = yes; then
1260    m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"])
1261    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
1262  fi
1263  AC_LANG_POP(C)
1264fi
1265]) # AC_COIN_CHECK_BZLIB
1266
1267
1268###########################################################################
1269#                         COIN_CHECK_GNU_READLINE                         #
1270###########################################################################
1271
1272# This macro checks for GNU's readline.  It verifies that the header
1273# readline/readline.h is available, and that the -lreadline library
1274# contains "readline".  It is assumed that #include <stdio.h> is included
1275# in the source file before the #include<readline/readline.h>
1276# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
1277# Further, for a (space separated) list of arguments X, it adds the
1278# linker flag to the variable X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
1279
1280AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
1281[AC_REQUIRE([AC_PROG_CC])
1282
1283AC_ARG_ENABLE([readline],
1284              [AC_HELP_STRING([--disable-readline],[do not compile with readline library])],
1285              [coin_enable_readline=$enableval],
1286              [coin_enable_readline=yes])
1287
1288coin_has_readline=no
1289if test $coin_enable_readline = yes; then
1290  AC_LANG_PUSH(C)
1291  AC_CHECK_HEADER([readline/readline.h],[coin_has_readline=yes],[],[#include <stdio.h>])
1292
1293  coin_save_LIBS="$LIBS"
1294  LIBS=
1295  # First we check if tputs and friends are available
1296  if test $coin_has_readline = yes; then
1297    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],[coin_has_readline=no])
1298  fi
1299
1300  # Now we check for readline
1301  if test $coin_has_readline = yes; then
1302    AC_CHECK_LIB([readline],[readline],[],[coin_has_readline=no])
1303  fi
1304
1305  if test $coin_has_readline = yes; then
1306    m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lreadline $m4_toupper(myvar)_LIBS"])
1307    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
1308  fi
1309
1310  LIBS="$coin_save_LIBS"
1311  AC_LANG_POP(C)
1312fi
1313]) # AC_COIN_CHECK_GNU_READLINE
1314
1315###########################################################################
1316#                              COIN_CHECK_GMP                             #
1317###########################################################################
1318
1319# This macro checks for the gmp library.  If found, it defines the C
1320# preprocessor variable COIN_HAS_GMP.  Further, for a (space separated) list
1321# of arguments X, it adds the linker flag to the variables X_LIBS.
1322
1323AC_DEFUN([AC_COIN_CHECK_GMP],
1324[AC_REQUIRE([AC_PROG_CC])
1325
1326AC_ARG_ENABLE([gmp],
1327              [AC_HELP_STRING([--disable-gmp],[do not compile with GNU multiple precision library])],
1328              [coin_enable_gmp=$enableval],
1329              [coin_enable_gmp=yes])
1330
1331coin_has_gmp=no
1332if test $coin_enable_gmp = yes; then
1333  AC_LANG_PUSH(C)
1334  AC_CHECK_HEADER([gmp.h],[AC_CHECK_LIB([gmp],[__gmpz_init],[coin_has_gmp=yes])])
1335 
1336  if test $coin_has_gmp = yes ; then
1337    m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lgmp $m4_toupper(myvar)_LIBS"])
1338    AC_DEFINE([COIN_HAS_GMP],[1],[Define to 1 if GMP is available])
1339  fi
1340  AC_LANG_POP(C)
1341fi
1342]) # AC_COIN_CHECK_GMP
1343
1344
1345###########################################################################
1346#                           COIN_DOXYGEN                                  #
1347###########################################################################
1348#
1349# This macro determines the configuration information for doxygen, the tool
1350# used to generate online documentation of COIN code. It takes one parameter,
1351# a list of projects (mixed-case, to match the directory names) that should
1352# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
1353#
1354# This macro will define the following variables:
1355#  coin_have_doxygen    Yes if doxygen is found, no otherwise
1356#  coin_doxy_usedot     Defaults to `yes'; --with-dot will still check to see
1357#                       if dot is available
1358#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
1359#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
1360#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
1361#                       doxygen documentation
1362#  coin_doxy_excludes   Directories to exclude from doxygen processing
1363
1364AC_DEFUN([AC_COIN_DOXYGEN],
1365[
1366
1367AC_MSG_NOTICE([configuring doxygen documentation options])
1368
1369# Check to see if doxygen is available.
1370
1371AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
1372AC_CHECK_PROG([coin_have_latex],[latex],[yes],[no])
1373
1374# Look for the dot tool from the graphviz package, unless the user has
1375# disabled it.
1376
1377AC_ARG_WITH([dot],
1378  AS_HELP_STRING([--with-dot],
1379                 [use dot (from graphviz) when creating documentation with
1380                  doxygen if available; --without-dot to disable]),
1381  [],[withval=yes])
1382if test x"$withval" = xno ; then
1383  coin_doxy_usedot=NO
1384  AC_MSG_CHECKING([for dot ])
1385  AC_MSG_RESULT([disabled])
1386else
1387  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
1388fi
1389
1390# Generate a tag file name and a log file name
1391
1392AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
1393AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
1394AM_CONDITIONAL(COIN_HAS_DOXYGEN, [test $coin_have_doxygen = yes])
1395AM_CONDITIONAL(COIN_HAS_LATEX, [test $coin_have_latex = yes])
1396
1397# Process the list of project names and massage them into possible doxygen
1398# doc'n directories. Prefer 1) classic external, source processed using
1399# a project-specific doxygen.conf, we use the tag file; 2) classic
1400# external, source processed using package doxygen.conf; 3) installed
1401# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
1402# configured, which we can't know unless this is the package base configure,
1403# since coin_subdirs is only set there. Hence it's sufficient to check for
1404# membership. If we use a tag file from a classic external, exclude the
1405# source from doxygen processing when doxygen runs in the base directory.
1406
1407coin_doxy_tagfiles=
1408coin_doxy_excludes=
1409tmp="$1"
1410for proj in $tmp ; do
1411  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
1412  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
1413  doxytag=${lc_proj}_doxy.tag
1414  doxyfound=no
1415  # proj will be configured, hence doxydoc present in build tree
1416  doxysrcdir="${srcdir}/../${proj}"
1417  # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
1418  if test -d "$doxysrcdir" ; then
1419    # with a doxydoc directory?
1420    doxydir="$doxysrcdir/doxydoc"
1421    # AC_MSG_NOTICE([Considering $doxydir (base)])
1422    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
1423    if test -d "$doxydir" ; then
1424      # use tag file; don't process source
1425      doxydir="../${proj}/doxydoc"
1426      coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=../../$doxydir/html"
1427      AC_MSG_RESULT([$doxydir (tag)])
1428      coin_doxy_excludes="$coin_doxy_excludes */${proj}"
1429    else
1430      # will process the source -- nothing further to be done here
1431      AC_MSG_RESULT([$doxysrcdir (src)])
1432    fi
1433    doxyfound=yes
1434  fi
1435  # Not built, fall back to installed tag file
1436  if test $doxyfound = no ; then
1437    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
1438    # AC_MSG_NOTICE([Considering $doxydir (install)])
1439    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
1440    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
1441    AC_MSG_RESULT([$doxydir (tag)])
1442  fi
1443done
1444AC_SUBST([coin_doxy_tagfiles])
1445AC_SUBST([coin_doxy_excludes])
1446
1447]) # AC_COIN_DOXYGEN
Note: See TracBrowser for help on using the repository browser.