source: trunk/coin.m4 @ 3667

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

make sure CFLAGS defaults are set before C compiler is checked (seems to be a required check of libtool or so)

  • Property svn:keywords set to Author Date Id Revision
File size: 48.2 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
380AC_DEFUN([AC_COIN_COMPFLAGS_DEFAULTS],
381[
382# change default compiler flags (should we have an enable-debug again?)
383# - some compilers doesn't understand -g
384# - set -DNDEBUG for C/C++ code
385: ${FFLAGS:=""}
386: ${FCFLAGS:=""}
387: ${CFLAGS:="-DNDEBUG"}
388: ${CXXFLAGS:="-DNDEBUG"}
389])
390
391# This macro does everything that is required in the early part in the
392# configure script, such as defining a few variables.
393# The first parameter is the project name.
394# The second (optional) is the libtool library version (important for releases,
395# less so for stable or trunk).
396
397AC_DEFUN([AC_COIN_INITIALIZE],
398[
399AC_REQUIRE([AC_COIN_COMPFLAGS_DEFAULTS])
400
401# required autoconf version
402AC_PREREQ(2.69)
403
404# Set the project's version numbers
405AC_COIN_PROJECTVERSION($1, $2)
406
407# A useful makefile conditional that is always false
408AM_CONDITIONAL(ALWAYS_FALSE, false)
409
410# Where should everything be installed by default?  Here, we want it
411# to be installed directly in 'bin', 'lib', 'include' subdirectories
412# of the directory where configure is run.  The default would be
413# /usr/local.     
414AC_PREFIX_DEFAULT([`pwd`])
415
416# Get the system type
417AC_CANONICAL_BUILD
418
419# initialize automake
420# - don't define PACKAGE or VERSION
421# - disable dist target
422# - enable all automake warnings
423AM_INIT_AUTOMAKE([no-define no-dist -Wall])
424
425# make silent build rules the default (https://www.gnu.org/software/automake/manual/html_node/Automake-Silent-Rules.html)
426AM_SILENT_RULES([yes])
427
428# disable automatic rebuild of configure/Makefile
429AM_MAINTAINER_MODE
430
431# setup libtool parameters (https://www.gnu.org/software/libtool/manual/html_node/LT_005fINIT.html)
432LT_INIT([disable-static])
433
434# create libtool
435AC_PROG_LIBTOOL
436])
437
438###########################################################################
439#                              COIN_FINALIZE                              #
440###########################################################################
441
442# This macro should be called at the very end of the configure.ac file.
443# It creates the output files (by using AC_OUTPUT), and might do some other
444# things (such as generating links to data files in a VPATH configuration).
445# It also prints the "success" message.
446# Note: If the variable coin_skip_ac_output is set to yes, then no output
447# files are written.
448
449AC_DEFUN([AC_COIN_FINALIZE],
450[
451AC_OUTPUT
452
453AC_MSG_NOTICE([In case of trouble, first consult the troubleshooting page at https://projects.coin-or.org/BuildTools/wiki/user-troubleshooting])
454AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
455
456]) #AC_COIN_FINALIZE
457
458
459###########################################################################
460#                           COIN_HAS_PKGCONFIG                            #
461###########################################################################
462
463# This macro checks whether a pkg-config tool with a minimal version number
464# is available.  If so, then the variable PKGCONFIG is set to its path.
465# If not, PKGCONFIG is set to "".  The minimal version number can be given
466# as first parameter, by default it is 0.16.0, since COIN-OR .pc files now
467# include an URL field, which breaks pkg-config version <= 0.15.
468# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4.
469# Further, the AM_CONDITIONAL COIN_HAS_PKGCONFIG is set and PKGCONFIG is
470# AC_SUBST'ed.  Finally, the search path for .pc files is assembled from the
471# value of $prefix and $PKG_CONFIG_PATH in a variable COIN_PKG_CONFIG_PATH,
472# which is also AC_SUBST'ed.
473
474AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
475[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
476
477AC_ARG_ENABLE([pkg-config],
478  [AC_HELP_STRING([--disable-pkg-config],[disable use of pkg-config (if available)])],
479  [use_pkgconfig="$enableval"],
480  [#if test x$coin_cc_is_cl = xtrue; then
481   #  use_pkgconfig=no
482   #else
483     use_pkgconfig=yes
484   #fi
485  ])
486
487if test $use_pkgconfig = yes ; then
488  if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
489    AC_CHECK_TOOL([PKG_CONFIG], [pkg-config])
490  fi
491  if test -n "$PKG_CONFIG"; then
492    _pkg_min_version=m4_default([$1], [0.16.0])
493    AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
494    if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
495      AC_MSG_RESULT([yes])
496    else
497      AC_MSG_RESULT([no])
498      PKG_CONFIG=""
499    fi
500  fi
501
502  # check if pkg-config supports the short-errors flag
503  if test -n "$PKG_CONFIG" && \
504    $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
505    pkg_short_errors=" --short-errors "
506  else
507    pkg_short_errors=""
508  fi
509fi
510
511AM_CONDITIONAL([COIN_HAS_PKGCONFIG], [test -n "$PKG_CONFIG"])
512AC_SUBST(PKG_CONFIG)
513
514# assemble pkg-config search path
515COIN_PKG_CONFIG_PATH="${PKG_CONFIG_PATH}"
516AC_SUBST(COIN_PKG_CONFIG_PATH)
517
518# 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
519# best would actually to use ${libdir}, since .pc files get installed into ${libdir}/pkgconfig,
520# unfortunately, ${libdir} expands to ${exec_prefix}/lib and ${exec_prefix} to ${prefix}...
521if test "x${prefix}" = xNONE ; then
522  COIN_PKG_CONFIG_PATH="${ac_default_prefix}/lib64/pkgconfig:${ac_default_prefix}/lib/pkgconfig:${ac_default_prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
523else
524  COIN_PKG_CONFIG_PATH="${prefix}/lib64/pkgconfig:${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig:${COIN_PKG_CONFIG_PATH}"
525fi
526
527])
528
529
530###########################################################################
531#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
532###########################################################################
533
534# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
535#
536# Check to see whether a particular set of packages exists.
537# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
538#
539AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
540[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
541if test -n "$PKG_CONFIG" ; then
542  if $PKG_CONFIG --exists "$2"; then
543    m4_toupper($1)[]_VERSIONS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --modversion "$2" 2>/dev/null | tr '\n' ' '`
544    $3
545  else
546    m4_toupper($1)_PKG_ERRORS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "$2"`
547    $4
548  fi
549else
550  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
551fi
552])
553
554###########################################################################
555#                            COIN_CHECK_PACKAGE                           #
556###########################################################################
557
558AC_DEFUN([AC_COIN_CHECK_PACKAGE],
559[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
560AC_MSG_CHECKING([for COIN-OR package $1])
561
562m4_tolower(coin_has_$1)=notGiven
563
564# check if user wants to skip package in any case
565if test x"$COIN_SKIP_PROJECTS" != x; then
566  for dir in $COIN_SKIP_PROJECTS; do
567    if test $dir = "$1"; then
568      m4_tolower(coin_has_$1)=skipping
569    fi
570  done
571fi
572
573if test "$m4_tolower(coin_has_$1)" != skipping; then
574  AC_ARG_WITH([m4_tolower($1)],,
575    [if test "$withval" = no ; then
576       m4_tolower(coin_has_$1)=skipping
577     fi
578    ])
579fi
580
581m4_toupper($1_LIBS)=
582m4_toupper($1_CFLAGS)=
583m4_toupper($1_DATA)=
584m4_toupper($1_PCREQUIRES)=
585AC_SUBST(m4_toupper($1_LIBS))
586AC_SUBST(m4_toupper($1_CFLAGS))
587AC_SUBST(m4_toupper($1_DATA))
588m4_foreach_w([myvar], [$3], [
589  AC_SUBST(m4_toupper(myvar)_LIBS)
590  AC_SUBST(m4_toupper(myvar)_CFLAGS)
591  AC_SUBST(m4_toupper(myvar)_PCREQUIRES)
592])
593
594#check if user provided LIBS for package or disables use of package
595if test $m4_tolower(coin_has_$1) != skipping; then
596  AC_ARG_WITH([m4_tolower($1)-lib],
597    AC_HELP_STRING([--with-m4_tolower($1)-lib],
598                   [linker flags for using package $1]),
599    [if test "$withval" = no ; then
600       m4_tolower(coin_has_$1)=skipping
601     else
602       m4_tolower(coin_has_$1)=yes
603       m4_toupper($1_LIBS)="$withval"
604       m4_foreach_w([myvar], [$3], [
605         m4_toupper(myvar)_LIBS="$withval $m4_toupper(myvar)_LIBS"
606       ])
607     fi
608    ],
609    [])
610fi
611
612#check if user provided INCDIR for package or disables use of package
613if test $m4_tolower(coin_has_$1) != skipping; then
614  AC_ARG_WITH([m4_tolower($1)-incdir],
615    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
616                   [directory with header files for using package $1]),
617    [if test "$withval" = no ; then
618       m4_tolower(coin_has_$1)=skipping
619     else
620       m4_tolower(coin_has_$1)=yes
621       m4_toupper($1_CFLAGS)="-I$withval"
622       m4_foreach_w([myvar], [$3], [m4_toupper(myvar)_CFLAGS="-I$withval $m4_toupper(myvar)_CFLAGS"])
623     fi
624    ],
625    [])
626fi
627
628#check if user provided DATADIR for package or disables use of package
629if test $m4_tolower(coin_has_$1) != skipping; then
630  AC_ARG_WITH([m4_tolower($1)-datadir],
631    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
632                   [directory with data files for using package $1]),
633    [if test "$withval" = no ; then
634       m4_tolower(coin_has_$1)=skipping
635     else
636       m4_tolower(coin_has_$1)=yes
637       m4_toupper($1_DATA)="$withval"
638     fi
639    ],
640    [])
641fi
642
643# now use pkg-config, if nothing of the above applied
644if test $m4_tolower(coin_has_$1) = notGiven; then
645  if test -n "$PKG_CONFIG" ; then
646   
647    # let pkg-config do it's magic
648    AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
649      [ m4_tolower(coin_has_$1)=yes
650        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
651
652        m4_toupper($1_DATA)=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --variable=datadir $2 2>/dev/null`
653       
654        m4_toupper($1_PCREQUIRES)="$2"
655        # augment X_PCREQUIRES for each build target X in $3
656        m4_foreach_w([myvar], [$3], [
657          m4_toupper(myvar)_PCREQUIRES="$2 $m4_toupper(myvar)_PCREQUIRES"
658        ])
659      ],
660      [ m4_tolower(coin_has_$1)=notGiven
661        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
662      ])
663
664  else
665    AC_MSG_ERROR([skipped check via pkg-config, redirect to fallback... -- oops, not there yet])
666    # TODO
667    #AC_COIN_CHECK_PACKAGE_FALLBACK([$1], [$2], [$3])
668  fi
669
670else
671  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
672fi
673
674if test $m4_tolower(coin_has_$1) != skipping &&
675   test $m4_tolower(coin_has_$1) != notGiven ; then
676  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is available])
677 
678  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
679    if test -n "$m4_toupper($1)_DATA" ; then
680      AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
681    fi
682    if test -n "$m4_toupper($1)_PCREQUIRES" ; then
683      AC_MSG_NOTICE([$1 PCREQUIRES are $m4_toupper($1)_PCREQUIRES])
684    fi
685  fi
686 
687fi
688
689# Define the Makefile conditional
690AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
691               [test $m4_tolower(coin_has_$1) != notGiven &&
692                test $m4_tolower(coin_has_$1) != skipping])
693])
694
695###########################################################################
696#                           COIN_FINALIZE_FLAGS                           #
697###########################################################################
698
699# TODO this could be moved into COIN_FINALIZE, if we were able to remember
700#   for which variables we need to run pkg-config
701AC_DEFUN([AC_COIN_FINALIZE_FLAGS],[
702
703# do pkg-config calls to complete LIBS and CFLAGS
704m4_foreach_w([myvar],[$1],[
705  if test -n "${m4_toupper(myvar)_PCREQUIRES}" ; then
706    temp_CFLAGS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --cflags ${m4_toupper(myvar)_PCREQUIRES}`
707    temp_LIBS=`PKG_CONFIG_PATH="$COIN_PKG_CONFIG_PATH" $PKG_CONFIG --libs ${m4_toupper(myvar)_PCREQUIRES}`
708    m4_toupper(myvar)_CFLAGS="$temp_CFLAGS ${m4_toupper(myvar)_CFLAGS}"
709    m4_toupper(myvar)_LIBS="$temp_LIBS ${m4_toupper(myvar)_LIBS}"
710  fi
711
712  if test 1 = 0 ; then  #change this test to enable a bit of debugging output
713    if test -n "${m4_toupper(myvar)_CFLAGS}" ; then
714      AC_MSG_NOTICE([myvar CFLAGS are ${m4_toupper(myvar)_CFLAGS}])
715    fi
716    if test -n "${m4_toupper(myvar)_LIBS}" ; then
717      AC_MSG_NOTICE([myvar LIBS   are ${m4_toupper(myvar)_LIBS}])
718    fi
719  fi
720])
721
722])
723
724
725###########################################################################
726#                            COIN_TRY_FLINK                               #
727###########################################################################
728
729# Auxilliary macro to test if a Fortran function name can be linked,
730# given the current settings of LIBS.  We determine from the context, what
731# the currently active programming language is, and cast the name accordingly.
732# The first argument is the name of the function/subroutine, in small letters,
733# the second argument are the actions taken when the test works, and the
734# third argument are the actions taken if the test fails.
735
736AC_DEFUN([AC_COIN_TRY_FLINK],[
737case $ac_ext in
738  f)
739    AC_TRY_LINK(,[      call $1],[flink_try=yes],[flink_try=no])
740    ;;
741  c)
742    coin_need_flibs=no
743    flink_try=no
744    AC_F77_FUNC($1,cfunc$1)
745    AC_LINK_IFELSE(
746      [AC_LANG_PROGRAM([void $cfunc$1();],[$cfunc$1()])],
747      [flink_try=yes],
748      [if test x"$FLIBS" != x; then
749         flink_save_libs="$LIBS"
750         LIBS="$LIBS $FLIBS"
751         AC_LINK_IFELSE(
752           [AC_LANG_PROGRAM([void $cfunc$1();],[$cfunc$1()])],
753           [coin_need_flibs=yes
754            flint_try=yes]
755         )
756         LIBS="$flink_save_libs"
757       fi
758      ]
759    )
760    ;;
761  cc|cpp)
762    coin_need_flibs=no
763    flink_try=no
764    AC_F77_FUNC($1,cfunc$1)
765    AC_LINK_IFELSE(
766      [AC_LANG_PROGRAM([extern "C" {void $cfunc$1();}],[$cfunc$1()])],
767      [flink_try=yes],
768      [if test x"$FLIBS" != x; then
769         flink_save_libs="$LIBS"
770         LIBS="$LIBS $FLIBS"
771         AC_LINK_IFELSE(
772           [AC_LANG_PROGRAM([extern "C" {void $cfunc$1();}],[$cfunc$1()])],
773           [coin_need_flibs=yes
774            flink_try=yes]
775         )
776         LIBS="$flink_save_libs"
777       fi
778      ]
779    )
780    ;;
781esac
782if test $flink_try = yes; then
783  $2
784else
785  $3
786fi
787]) # AC_COIN_TRY_FLINK
788
789###########################################################################
790#                         COIN_CHECK_PACKAGE_BLAS                         #
791###########################################################################
792
793# This macro checks for a library containing the BLAS library.  It
794# 1. checks the --with-blas argument
795# 2. if --with-blas=BUILD has been specified goes to point 5
796# 3. if --with-blas has been specified to a working library, sets BLAS_LIBS
797#    to its value
798# 4. tries standard libraries
799# 5. calls COIN_CHECK_PACKAGE(Blas, [coinblas], [$1]) to check for
800#    ThirdParty/Blas
801# The makefile conditional and preprocessor macro COIN_HAS_BLAS is defined.
802# BLAS_LIBS is set to the flags required to link with a Blas library.
803# For each build target X in $1, X_LIBS is extended with $BLAS_LIBS.
804# In case 3 and 4, the flags to link to Blas are added to X_PCLIBS too.
805# In case 5, Blas is added to X_PCREQUIRES.
806
807AC_DEFUN([AC_COIN_CHECK_PACKAGE_BLAS],
808[
809AC_ARG_WITH([blas],
810            AC_HELP_STRING([--with-blas],
811                           [specify BLAS library (or BUILD to enforce use of ThirdParty/Blas)]),
812            [use_blas="$withval"], [use_blas=])
813
814# if user specified --with-blas-lib, then we should give COIN_CHECK_PACKAGE
815# preference
816AC_ARG_WITH([blas-lib],,[use_blas=BUILD])
817
818# Check if user supplied option makes sense
819if test x"$use_blas" != x; then
820  if test "$use_blas" = "BUILD"; then
821    # we come to this later
822    :
823  elif test "$use_blas" != "no"; then
824    coin_save_LIBS="$LIBS"
825    LIBS="$use_blas $LIBS"
826    if test "$F77" != unavailable ; then
827      coin_need_flibs=no
828      AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
829      AC_COIN_TRY_FLINK([daxpy],
830                        [if test $coin_need_flibs = yes ; then
831                           use_blas="$use_blas $FLIBS"
832                         fi
833                         AC_MSG_RESULT([yes: $use_blas])],
834                        [AC_MSG_RESULT([no])
835                         AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
836      use_blas="$use_blas $FLIBS"
837    else
838      AC_MSG_NOTICE([checking whether user supplied BLASLIB=\"$use_blas\" works with C linkage])
839      AC_LANG_PUSH(C)
840      AC_CHECK_FUNC([daxpy],[],[AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
841      AC_LANG_POP(C)
842    fi
843    LIBS="$coin_save_LIBS"
844  fi
845else
846# Try to autodetect the library for blas based on build system
847  #AC_MSG_CHECKING([default locations for BLAS])
848  case $build in
849    *-sgi-*)
850      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
851      coin_need_flibs=no
852      coin_save_LIBS="$LIBS"
853      LIBS="-lcomplib.sgimath $LIBS"
854      AC_COIN_TRY_FLINK([daxpy],
855                        [use_blas="-lcomplib.sgimath"
856                         if test $coin_need_flibs = yes ; then
857                           use_blas="$use_blas $FLIBS"
858                         fi
859                         AC_MSG_RESULT([yes: $use_blas])
860                        ],
861                        [AC_MSG_RESULT([no])])
862      LIBS="$coin_save_LIBS"
863      ;;
864
865    *-*-solaris*)
866      AC_MSG_CHECKING([for BLAS in libsunperf])
867      # Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
868      # cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
869      # recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
870      # that CC and cc will understand -library in Studio 13. The main extra
871      # function of -xlic_lib and -library is to arrange for the Fortran run-time
872      # libraries to be linked for C++ and C. We can arrange that explicitly.
873      coin_need_flibs=no
874      coin_save_LIBS="$LIBS"
875      LIBS="-lsunperf $FLIBS $LIBS"
876      AC_COIN_TRY_FLINK([daxpy],
877                        [use_blas='-lsunperf'
878                         if test $coin_need_flibs = yes ; then
879                           use_blas="$use_blas $FLIBS"
880                         fi
881                         AC_MSG_RESULT([yes: $use_blas])
882                        ],
883                        [AC_MSG_RESULT([no])])
884      LIBS="$coin_save_LIBS"
885      ;;
886     
887    *-cygwin* | *-mingw*)
888      case "$CC" in
889        clang* ) ;;
890        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
891          coin_save_LIBS="$LIBS"
892          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
893          if test "$F77" != unavailable ; then
894            AC_MSG_CHECKING([for BLAS in MKL (32bit)])
895            AC_COIN_TRY_FLINK([daxpy],
896                              [use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
897                               AC_MSG_RESULT([yes: $use_blas])
898                              ],
899                              [AC_MSG_RESULT([no])])
900          else
901            AC_MSG_NOTICE([for BLAS in MKL (32bit) using C linkage])
902            AC_LANG_PUSH(C)
903            AC_CHECK_FUNC([daxpy],[use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'])
904            AC_LANG_POP(C)
905          fi
906          LIBS="$coin_save_LIBS"
907         
908          if test "x$use_blas" = x ; then
909            LIBS="mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib $LIBS"
910            if test "$F77" != unavailable ; then
911              AC_MSG_CHECKING([for BLAS in MKL (64bit)])
912              AC_COIN_TRY_FLINK([daxpy],
913                                [use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'
914                                 AC_MSG_RESULT([yes: $use_blas])
915                                ],
916                                [AC_MSG_RESULT([no])])
917            else
918              AC_MSG_NOTICE([for BLAS in MKL (64bit) using C linkage])
919              # unset cached outcome of test with 32bit MKL
920              unset ac_cv_func_daxpy
921              AC_LANG_PUSH(C)
922              AC_CHECK_FUNC([daxpy],[use_blas='mkl_intel_lp64.lib mkl_sequential.lib mkl_core.lib'])
923              AC_LANG_POP(C)
924            fi
925            LIBS="$coin_save_LIBS"
926          fi
927          ;;
928      esac
929      ;;
930     
931     *-darwin*)
932      AC_MSG_CHECKING([for BLAS in Veclib])
933      coin_need_flibs=no
934      coin_save_LIBS="$LIBS"
935      LIBS="-framework Accelerate $LIBS"
936      AC_COIN_TRY_FLINK([daxpy],
937                        [use_blas='-framework Accelerate'
938                         if test $coin_need_flibs = yes ; then
939                           use_blas="$use_blas $FLIBS"
940                         fi
941                         AC_MSG_RESULT([yes: $use_blas])
942                        ],
943                        [AC_MSG_RESULT([no])])
944      LIBS="$coin_save_LIBS"
945      ;;
946  esac
947
948  if test -z "$use_blas" ; then
949    AC_MSG_CHECKING([whether -lblas has BLAS])
950    coin_need_flibs=no
951    coin_save_LIBS="$LIBS"
952    LIBS="-lblas $LIBS"
953    AC_COIN_TRY_FLINK([daxpy],
954                      [use_blas='-lblas'
955                       if test $coin_need_flibs = yes ; then
956                         use_blas="$use_blas $FLIBS"
957                       fi
958                       AC_MSG_RESULT([yes: $use_blas])
959                      ],
960                      [AC_MSG_RESULT([no])])
961    LIBS="$coin_save_LIBS"
962  fi
963
964  # If we have no other ideas, consider building BLAS.
965  if test -z "$use_blas" ; then
966    use_blas=BUILD
967  fi
968fi
969
970if test "x$use_blas" = xBUILD ; then
971  AC_COIN_CHECK_PACKAGE(Blas, [coinblas], [$1])
972 
973elif test "x$use_blas" != x && test "$use_blas" != no; then
974  coin_has_blas=yes
975  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 0])
976  AC_DEFINE([COIN_HAS_BLAS],[1], [If defined, the BLAS Library is available.])
977  BLAS_LIBS="$use_blas"
978  BLAS_CFLAGS=
979  BLAS_DATA=
980  AC_SUBST(BLAS_LIBS)
981  AC_SUBST(BLAS_CFLAGS)
982  AC_SUBST(BLAS_DATA)
983  m4_foreach_w([myvar], [$1], [
984    m4_toupper(myvar)_LIBS="$BLAS_LIBS $m4_toupper(myvar)_LIBS"
985  ])
986 
987else
988  coin_has_blas=no
989  AM_CONDITIONAL([COIN_HAS_BLAS],[test 0 = 1])
990fi
991
992m4_foreach_w([myvar], [$1], [
993  AC_SUBST(m4_toupper(myvar)_LIBS)
994])
995
996]) # AC_COIN_CHECK_PACKAGE_BLAS
997
998###########################################################################
999#                       COIN_CHECK_PACKAGE_LAPACK                         #
1000###########################################################################
1001
1002# This macro checks for a library containing the LAPACK library.  It
1003# 1. checks the --with-lapack argument
1004# 2. if --with-lapack=BUILD has been specified goes to point 5
1005# 3. if --with-lapack has been specified to a working library, sets
1006#    LAPACK_LIBS to its value
1007# 4. tries standard libraries
1008# 5. calls COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]) to check for
1009#    ThirdParty/Lapack
1010# The makefile conditional and preprocessor macro COIN_HAS_LAPACK is defined.
1011# LAPACK_LIBS is set to the flags required to link with a Lapack library.
1012# For each build target X in $1, X_LIBS is extended with $LAPACK_LIBS.
1013# In case 3 and 4, the flags to link to Lapack are added to X_PCLIBS too.
1014# In case 5, Lapack is added to X_PCREQUIRES.
1015#
1016# TODO: Lapack usually depends on Blas, so if we check for a system lapack library,
1017#   shouldn't we include AC_COIN_CHECK_PACKAGE_BLAS first?
1018#   However, if we look for coinlapack via AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1]),
1019#   then we will get Blas as dependency of coinlapack.
1020
1021AC_DEFUN([AC_COIN_CHECK_PACKAGE_LAPACK],
1022[
1023AC_ARG_WITH([lapack],
1024            AC_HELP_STRING([--with-lapack],
1025                           [specify LAPACK library (or BUILD to enforce use of ThirdParty/Lapack)]),
1026            [use_lapack=$withval], [use_lapack=])
1027
1028#if user specified --with-lapack-lib, then we should give COIN_HAS_PACKAGE preference
1029AC_ARG_WITH([lapack-lib],,[use_lapack=BUILD])
1030
1031# Check if user supplied option makes sense
1032if test x"$use_lapack" != x; then
1033  if test "$use_lapack" = "BUILD"; then
1034    # we come to this later
1035    :
1036  elif test "$use_lapack" != no; then
1037    use_lapack="$use_lapack $BLAS_LIBS"
1038    coin_save_LIBS="$LIBS"
1039    LIBS="$use_lapack $LIBS"
1040    if test "$F77" != unavailable; then
1041      AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
1042      coin_need_flibs=no
1043      AC_COIN_TRY_FLINK([dsyev],
1044                        [if test $coin_need_flibs = yes ; then
1045                           use_lapack="$use_lapack $FLIBS"
1046                         fi
1047                         AC_MSG_RESULT([yes: $use_lapack])
1048                        ],
1049                        [AC_MSG_RESULT([no])
1050                         AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
1051    else
1052      AC_MSG_NOTICE([whether user supplied LAPACKLIB=\"$use_lapack\" works with C linkage])
1053      AC_LANG_PUSH(C)
1054      AC_CHECK_FUNC([dsyev],[],[AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
1055      AC_LANG_POP(C)
1056    fi
1057    LIBS="$coin_save_LIBS"
1058  fi
1059else
1060  if test x$coin_has_blas = xyes; then
1061    # First try to see if LAPACK is already available with BLAS library
1062    coin_save_LIBS="$LIBS"
1063    LIBS="$BLAS_LIBS $LIBS"
1064    if test "$F77" != unavailable; then
1065      coin_need_flibs=no
1066      AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
1067      AC_COIN_TRY_FLINK([dsyev],
1068                        [use_lapack="$BLAS_LIBS"
1069                         if test $coin_need_flibs = yes ; then
1070                           use_lapack="$use_lapack $FLIBS"
1071                         fi
1072                         AC_MSG_RESULT([yes: $use_lapack])
1073                        ],
1074                        [AC_MSG_RESULT([no])])
1075    else
1076      AC_MSG_NOTICE([checking whether LAPACK is already available with BLAS library])
1077      AC_LANG_PUSH(C)
1078      AC_CHECK_FUNC([dsyev],[use_lapack="$BLAS_LIBS"])
1079      AC_LANG_POP(C)
1080    fi
1081    LIBS="$coin_save_LIBS"
1082  fi
1083  if test -z "$use_lapack"; then
1084    # Try to autodetect the library for lapack based on build system
1085    case $build in
1086      # TODO: Is this check actually needed here, since -lcomplib.sigmath should have been recognized as Blas library,
1087      #       and above it is checked whether the Blas library already contains Lapack
1088      *-sgi-*)
1089        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
1090        coin_save_LIBS="$LIBS"
1091        coin_need_flibs=no
1092        LIBS="-lcomplib.sgimath $BLAS_LIBS $LIBS"
1093        AC_COIN_TRY_FLINK([dsyev],
1094                          [use_lapack="-lcomplib.sgimath $BLAS_LIBS"
1095                           if test $coin_need_flibs = yes ; then
1096                             use_lapack="$use_lapack $FLIBS"
1097                           fi
1098                           AC_MSG_RESULT([yes: $use_lapack])
1099                          ],
1100                          [AC_MSG_RESULT([no])])
1101        LIBS="$coin_save_LIBS"
1102        ;;
1103
1104      # See comments in COIN_CHECK_PACKAGE_BLAS.
1105      # TODO: Is this check actually needed here, since -lsunperf should have been recognized as Blas library,
1106      #       and above it is checked whether the Blas library already contains Lapack
1107      *-*-solaris*)
1108        AC_MSG_CHECKING([for LAPACK in libsunperf])
1109        coin_need_flibs=no
1110        coin_save_LIBS="$LIBS"
1111        LIBS="-lsunperf $BLAS_LIBS $FLIBS $LIBS"
1112        AC_COIN_TRY_FLINK([dsyev],
1113                          [use_lapack='-lsunperf $BLAS_LIBS'
1114                           if test $coin_need_flibs = yes ; then
1115                             use_lapack="$use_lapack $FLIBS"
1116                           fi
1117                           AC_MSG_RESULT([yes: $use_lapack])
1118                          ],
1119                          [AC_MSG_RESULT([no])])
1120        LIBS="$coin_save_LIBS"
1121        ;;
1122        # On cygwin, do this check only if doscompile is disabled. The prebuilt library
1123        # will want to link with cygwin, hence won't run standalone in DOS.
1124    esac
1125  fi
1126
1127  if test -z "$use_lapack" ; then
1128    AC_MSG_CHECKING([whether -llapack has LAPACK])
1129    coin_need_flibs=no
1130    coin_save_LIBS="$LIBS"
1131    LIBS="-llapack $BLAS_LIBS $LIBS"
1132    AC_COIN_TRY_FLINK([dsyev],
1133                      [use_lapack='-llapack'
1134                       if test $coin_need_flibs = yes ; then
1135                         use_lapack="$use_lapack $FLIBS"
1136                       fi
1137                       AC_MSG_RESULT([yes: $use_lapack])
1138                      ],
1139                      [AC_MSG_RESULT([no])])
1140    LIBS="$coin_save_LIBS"
1141  fi
1142
1143  # If we have no other ideas, consider building LAPACK.
1144  if test -z "$use_lapack" ; then
1145    use_lapack=BUILD
1146  fi
1147fi
1148
1149if test "x$use_lapack" = xBUILD ; then
1150  AC_COIN_CHECK_PACKAGE(Lapack, [coinlapack], [$1])
1151
1152elif test "x$use_lapack" != x && test "$use_lapack" != no; then
1153  coin_has_lapack=yes
1154  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 0])
1155  AC_DEFINE([COIN_HAS_LAPACK],[1], [If defined, the LAPACK Library is available.])
1156  LAPACK_LIBS="$use_lapack"
1157  LAPACK_CFLAGS=
1158  LAPACK_DATA=
1159  AC_SUBST(LAPACK_LIBS)
1160  AC_SUBST(LAPACK_CFLAGS)
1161  AC_SUBST(LAPACK_DATA)
1162  m4_foreach_w([myvar], [$1], [
1163    m4_toupper(myvar)_LIBS="$LAPACK_LIBS $m4_toupper(myvar)_LIBS"
1164  ])
1165 
1166else
1167  coin_has_lapack=no
1168  AM_CONDITIONAL([COIN_HAS_LAPACK],[test 0 = 1])
1169fi
1170
1171m4_foreach_w([myvar], [$1], [
1172  AC_SUBST(m4_toupper(myvar)_LIBS)
1173])
1174
1175]) # AC_COIN_CHECK_PACKAGE_LAPACK
1176
1177
1178#######################################################################
1179#                           COIN_CHECK_LIBM                           #
1180#######################################################################
1181
1182# Check for the math library.
1183# For a (space separated) list of arguments X, this macro adds the flags
1184# for linking against the math library to a X_LIBS.
1185
1186AC_DEFUN([AC_COIN_CHECK_LIBM],
1187[AC_REQUIRE([AC_PROG_CC])
1188
1189coin_save_LIBS="$LIBS"
1190
1191AC_LANG_PUSH(C)
1192AC_SEARCH_LIBS([cos],[m],
1193  [m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lm $m4_toupper(myvar)_LIBS"])]
1194)
1195AC_LANG_POP(C)
1196
1197LIBS="$coin_save_LIBS"
1198
1199]) # AC_COIN_CHECK_LIBM
1200
1201###########################################################################
1202#                           COIN_CHECK_ZLIB                               #
1203###########################################################################
1204
1205# This macro checks for the libz library.  If found, it sets the automake
1206# conditional COIN_HAS_ZLIB and defines the C preprocessor variable
1207# COIN_HAS_ZLIB.  Further, for a (space separated) list of arguments X,
1208# it adds the linker flag to the variables X_LIBS.
1209
1210AC_DEFUN([AC_COIN_CHECK_ZLIB],
1211[AC_REQUIRE([AC_PROG_CC])
1212
1213coin_has_zlib=no
1214
1215AC_ARG_ENABLE([zlib],
1216              [AC_HELP_STRING([--disable-zlib],[do not compile with compression library zlib])],
1217              [coin_enable_zlib=$enableval],
1218              [coin_enable_zlib=yes])
1219
1220if test $coin_enable_zlib = yes; then
1221  AC_LANG_PUSH(C)
1222  AC_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
1223
1224  if test $coin_has_zlib = yes; then
1225    AC_CHECK_LIB([z],[gzopen],[:],[coin_has_zlib=no])
1226  fi
1227
1228  if test $coin_has_zlib = yes; then
1229    m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lz $m4_toupper(myvar)_LIBS"])
1230    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
1231  fi
1232  AC_LANG_POP(C)
1233fi
1234
1235AM_CONDITIONAL(COIN_HAS_ZLIB, test x$coin_has_zlib = xyes)
1236]) # AC_COIN_CHECK_ZLIB
1237
1238
1239###########################################################################
1240#                            COIN_CHECK_BZLIB                             #
1241###########################################################################
1242
1243# This macro checks for the libbz2 library.  If found, it defines the C
1244# preprocessor variable COIN_HAS_BZLIB.  Further, for a (space separated) list
1245# of arguments X, it adds the linker flag to the variables X_LIBS.
1246
1247AC_DEFUN([AC_COIN_CHECK_BZLIB],
1248[AC_REQUIRE([AC_PROG_CC])
1249
1250AC_ARG_ENABLE([bzlib],
1251              [AC_HELP_STRING([--disable-bzlib],[do not compile with compression library bzlib])],
1252              [coin_enable_bzlib=$enableval],
1253              [coin_enable_bzlib=yes])
1254
1255coin_has_bzlib=no
1256if test $coin_enable_bzlib = yes; then
1257  AC_LANG_PUSH(C)
1258  AC_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
1259
1260  if test $coin_has_bzlib = yes; then
1261    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],[:],[coin_has_bzlib=no])
1262  fi
1263
1264  if test $coin_has_bzlib = yes; then
1265    m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lbz2 $m4_toupper(myvar)_LIBS"])
1266    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
1267  fi
1268  AC_LANG_POP(C)
1269fi
1270]) # AC_COIN_CHECK_BZLIB
1271
1272
1273###########################################################################
1274#                         COIN_CHECK_GNU_READLINE                         #
1275###########################################################################
1276
1277# This macro checks for GNU's readline.  It verifies that the header
1278# readline/readline.h is available, and that the -lreadline library
1279# contains "readline".  It is assumed that #include <stdio.h> is included
1280# in the source file before the #include<readline/readline.h>
1281# If found, it defines the C preprocessor variable COIN_HAS_READLINE.
1282# Further, for a (space separated) list of arguments X, it adds the
1283# linker flag to the variable X_LIBS, X_PCLIBS, and X_LIBS_INSTALLED.
1284
1285AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
1286[AC_REQUIRE([AC_PROG_CC])
1287
1288AC_ARG_ENABLE([readline],
1289              [AC_HELP_STRING([--disable-readline],[do not compile with readline library])],
1290              [coin_enable_readline=$enableval],
1291              [coin_enable_readline=yes])
1292
1293coin_has_readline=no
1294if test $coin_enable_readline = yes; then
1295  AC_LANG_PUSH(C)
1296  AC_CHECK_HEADER([readline/readline.h],[coin_has_readline=yes],[],[#include <stdio.h>])
1297
1298  coin_save_LIBS="$LIBS"
1299  LIBS=
1300  # First we check if tputs and friends are available
1301  if test $coin_has_readline = yes; then
1302    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],[coin_has_readline=no])
1303  fi
1304
1305  # Now we check for readline
1306  if test $coin_has_readline = yes; then
1307    AC_CHECK_LIB([readline],[readline],[],[coin_has_readline=no])
1308  fi
1309
1310  if test $coin_has_readline = yes; then
1311    m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lreadline $m4_toupper(myvar)_LIBS"])
1312    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
1313  fi
1314
1315  LIBS="$coin_save_LIBS"
1316  AC_LANG_POP(C)
1317fi
1318]) # AC_COIN_CHECK_GNU_READLINE
1319
1320###########################################################################
1321#                              COIN_CHECK_GMP                             #
1322###########################################################################
1323
1324# This macro checks for the gmp library.  If found, it defines the C
1325# preprocessor variable COIN_HAS_GMP.  Further, for a (space separated) list
1326# of arguments X, it adds the linker flag to the variables X_LIBS.
1327
1328AC_DEFUN([AC_COIN_CHECK_GMP],
1329[AC_REQUIRE([AC_PROG_CC])
1330
1331AC_ARG_ENABLE([gmp],
1332              [AC_HELP_STRING([--disable-gmp],[do not compile with GNU multiple precision library])],
1333              [coin_enable_gmp=$enableval],
1334              [coin_enable_gmp=yes])
1335
1336coin_has_gmp=no
1337if test $coin_enable_gmp = yes; then
1338  AC_LANG_PUSH(C)
1339  AC_CHECK_HEADER([gmp.h],[AC_CHECK_LIB([gmp],[__gmpz_init],[coin_has_gmp=yes])])
1340 
1341  if test $coin_has_gmp = yes ; then
1342    m4_foreach_w([myvar], [$1], [m4_toupper(myvar)_LIBS="-lgmp $m4_toupper(myvar)_LIBS"])
1343    AC_DEFINE([COIN_HAS_GMP],[1],[Define to 1 if GMP is available])
1344  fi
1345  AC_LANG_POP(C)
1346fi
1347]) # AC_COIN_CHECK_GMP
1348
1349
1350###########################################################################
1351#                           COIN_DOXYGEN                                  #
1352###########################################################################
1353#
1354# This macro determines the configuration information for doxygen, the tool
1355# used to generate online documentation of COIN code. It takes one parameter,
1356# a list of projects (mixed-case, to match the directory names) that should
1357# be processed as external tag files. E.g., COIN_DOXYGEN([Clp Osi]).
1358#
1359# This macro will define the following variables:
1360#  coin_have_doxygen    Yes if doxygen is found, no otherwise
1361#  coin_doxy_usedot     Defaults to `yes'; --with-dot will still check to see
1362#                       if dot is available
1363#  coin_doxy_tagname    Name of doxygen tag file (placed in doxydoc directory)
1364#  coin_doxy_logname    Name of doxygen log file (placed in doxydoc directory)
1365#  coin_doxy_tagfiles   List of doxygen tag files used to reference other
1366#                       doxygen documentation
1367#  coin_doxy_excludes   Directories to exclude from doxygen processing
1368
1369AC_DEFUN([AC_COIN_DOXYGEN],
1370[
1371
1372AC_MSG_NOTICE([configuring doxygen documentation options])
1373
1374# Check to see if doxygen is available.
1375
1376AC_CHECK_PROG([coin_have_doxygen],[doxygen],[yes],[no])
1377AC_CHECK_PROG([coin_have_latex],[latex],[yes],[no])
1378
1379# Look for the dot tool from the graphviz package, unless the user has
1380# disabled it.
1381
1382AC_ARG_WITH([dot],
1383  AS_HELP_STRING([--with-dot],
1384                 [use dot (from graphviz) when creating documentation with
1385                  doxygen if available; --without-dot to disable]),
1386  [],[withval=yes])
1387if test x"$withval" = xno ; then
1388  coin_doxy_usedot=NO
1389  AC_MSG_CHECKING([for dot ])
1390  AC_MSG_RESULT([disabled])
1391else
1392  AC_CHECK_PROG([coin_doxy_usedot],[dot],[YES],[NO])
1393fi
1394
1395# Generate a tag file name and a log file name
1396
1397AC_SUBST([coin_doxy_tagname],[doxydoc/${PACKAGE}_doxy.tag])
1398AC_SUBST([coin_doxy_logname],[doxydoc/${PACKAGE}_doxy.log])
1399AM_CONDITIONAL(COIN_HAS_DOXYGEN, [test $coin_have_doxygen = yes])
1400AM_CONDITIONAL(COIN_HAS_LATEX, [test $coin_have_latex = yes])
1401
1402# Process the list of project names and massage them into possible doxygen
1403# doc'n directories. Prefer 1) classic external, source processed using
1404# a project-specific doxygen.conf, we use the tag file; 2) classic
1405# external, source processed using package doxygen.conf; 3) installed
1406# doxydoc. Alternatives 1) and 2) are only possible if the directory will be
1407# configured, which we can't know unless this is the package base configure,
1408# since coin_subdirs is only set there. Hence it's sufficient to check for
1409# membership. If we use a tag file from a classic external, exclude the
1410# source from doxygen processing when doxygen runs in the base directory.
1411
1412coin_doxy_tagfiles=
1413coin_doxy_excludes=
1414tmp="$1"
1415for proj in $tmp ; do
1416  lc_proj=`echo $proj | [tr [A-Z] [a-z]]`
1417  AC_MSG_CHECKING([for doxygen doc'n for $proj ])
1418  doxytag=${lc_proj}_doxy.tag
1419  doxyfound=no
1420  # proj will be configured, hence doxydoc present in build tree
1421  doxysrcdir="${srcdir}/../${proj}"
1422  # AC_MSG_NOTICE([Considering $doxysrcdir (base)])
1423  if test -d "$doxysrcdir" ; then
1424    # with a doxydoc directory?
1425    doxydir="$doxysrcdir/doxydoc"
1426    # AC_MSG_NOTICE([Considering $doxydir (base)])
1427    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
1428    if test -d "$doxydir" ; then
1429      # use tag file; don't process source
1430      doxydir="../${proj}/doxydoc"
1431      coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=../../$doxydir/html"
1432      AC_MSG_RESULT([$doxydir (tag)])
1433      coin_doxy_excludes="$coin_doxy_excludes */${proj}"
1434    else
1435      # will process the source -- nothing further to be done here
1436      AC_MSG_RESULT([$doxysrcdir (src)])
1437    fi
1438    doxyfound=yes
1439  fi
1440  # Not built, fall back to installed tag file
1441  if test $doxyfound = no ; then
1442    eval doxydir="${datadir}/coin/doc/${proj}/doxydoc"
1443    # AC_MSG_NOTICE([Considering $doxydir (install)])
1444    # AC_MSG_NOTICE([Subdirs: $coin_subdirs)])
1445    coin_doxy_tagfiles="$coin_doxy_tagfiles $doxydir/$doxytag=$doxydir/html"
1446    AC_MSG_RESULT([$doxydir (tag)])
1447  fi
1448done
1449AC_SUBST([coin_doxy_tagfiles])
1450AC_SUBST([coin_doxy_excludes])
1451
1452]) # AC_COIN_DOXYGEN
Note: See TracBrowser for help on using the repository browser.