source: trunk/coin.m4 @ 3249

Last change on this file since 3249 was 3249, checked in by stefan, 7 years ago

add back AC_COIN_DOXYGEN

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