source: stable/BSPsplit/coin.m4 @ 1432

Last change on this file since 1432 was 1432, checked in by stefan, 12 years ago

add REQUIREDPACKAGES variable

  • Property svn:keywords set to Author Date Id Revision
File size: 134.0 KB
Line 
1# Copyright (C) 2006, 2009 International Business Machines.
2# All Rights Reserved.
3# This file is distributed under the Common Public License.
4#
5## $Id: coin.m4 1432 2009-11-01 16:46:36Z stefan $
6#
7# Author: Andreas Wachter    IBM      2006-04-14
8
9# This file defines the common autoconf macros for COIN
10#
11
12# Check requirements
13AC_PREREQ(2.59)
14
15###########################################################################
16#                           COIN_MAIN_SUBDIR                              #
17###########################################################################
18
19# This is the macro for AC_COIN_MAIN_SUBDIRS taking care of ONE (or two or three) argument(s)
20# It calles AC_COIN_HAS_PROJECT with the given argument(s) and adds $1 to the CONFIG_SUBDIRS, if
21# either argument $3 is given and the file $2/$1/$3 is available in $srcdir,
22# or $3 is not given and the file $2/$1/configure is available in $srcdir,
23# where $2 = . if not given
24AC_DEFUN([AC_COIN_MAIN_SUBDIR],
25[AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
26
27# AC_COIN_HAS_PROJECT also checks whether $3 is available in $2/$1, if not it sets coin_has... to notGiven
28AC_COIN_HAS_PROJECT($1,$2,$3)
29AC_MSG_CHECKING(whether project $1 need to be configured)
30if test "$m4_tolower(coin_has_$1)" != skipping &&
31   test "$m4_tolower(coin_has_$1)" != notGiven &&
32   test "$m4_tolower(coin_has_$1)" != installed; then
33
34  m4_ifvaln([$2], [projfulldir=$2/$1], [projfulldir=$1])
35  if test -r $srcdir/$projfulldir/configure; then
36    coin_subdirs="$coin_subdirs $projfulldir"
37    AC_MSG_RESULT(yes)
38    m4_ifvaln([$2], [AC_CONFIG_SUBDIRS($2/$1)], [AC_CONFIG_SUBDIRS($1)])
39  else
40    AC_MSG_RESULT(no)
41  fi
42else
43  AC_MSG_RESULT(no)
44fi
45])
46
47###########################################################################
48#                           COIN_MAIN_SUBDIRS                             #
49###########################################################################
50
51# This macro sets up the recursion into configure scripts into
52# subdirectories.  Each possible subdirectory should be provided as a
53# new argument to this macro.  The current limit is 10 subdirectories.
54# This automatically also checks for the Data subdirectory.
55
56AC_DEFUN([AC_COIN_MAIN_SUBDIRS],
57[m4_ifvaln([$1],[AC_COIN_MAIN_SUBDIR($1)])
58m4_ifvaln([$2],[AC_COIN_MAIN_SUBDIR($2)])
59m4_ifvaln([$3],[AC_COIN_MAIN_SUBDIR($3)])
60m4_ifvaln([$4],[AC_COIN_MAIN_SUBDIR($4)])
61m4_ifvaln([$5],[AC_COIN_MAIN_SUBDIR($5)])
62m4_ifvaln([$6],[AC_COIN_MAIN_SUBDIR($6)])
63m4_ifvaln([$7],[AC_COIN_MAIN_SUBDIR($7)])
64m4_ifvaln([$8],[AC_COIN_MAIN_SUBDIR($8)])
65m4_ifvaln([$9],[AC_COIN_MAIN_SUBDIR($9)])
66m4_ifvaln([$10],[AC_COIN_MAIN_SUBDIR($10)])
67
68]) # AC_COIN_MAIN_SUBDIRS
69
70###########################################################################
71#                            COIN_CHECK_FILE                              #
72###########################################################################
73
74# A simple replacement for AC_CHECK_FILE that works for cross compilation
75
76AC_DEFUN([AC_COIN_CHECK_FILE],
77[if test -r $1; then
78  $2
79  :
80else
81  $3
82  :
83fi
84])
85
86###########################################################################
87#                        COIN_THIRDPARTY_SUBDIRS                          #
88###########################################################################
89
90# This macro sets up the recursion into the configure script in a
91# subdirectory for compilation of third party code.  The first
92# argument is just the string that appears in the configure output.
93# The second argument is the directory with the configure script, and
94# the third one is a file that should exists in that directory.  If
95# this file does not exist, we assume that the user has not downloaded
96# the code, and we are not going to compile it
97
98AC_DEFUN([AC_COIN_THIRDPARTY_SUBDIRS],
99[AC_MSG_CHECKING(whether code for third party package $1 is available)
100coin_skip=no
101if test x"$COIN_SKIP_PROJECTS" != x; then
102  for dir in $COIN_SKIP_PROJECTS; do
103    if test $dir = $2; then
104      coin_skip=yes
105    fi
106  done
107fi
108if test $coin_skip = yes; then
109  AC_MSG_RESULT(skipping)
110else
111  coin_tmp=`echo $srcdir/$2/$3`
112  # There is probably a more elegant way to get the first thing out here...
113  for i in $coin_tmp; do
114    coin_tmp2=$i
115    #break 1
116  done
117  if test -r $coin_tmp2; then
118    coin_subdirs="$coin_subdirs $2"
119    AC_MSG_RESULT(yes)
120    AC_CONFIG_SUBDIRS($2)
121  else
122    AC_MSG_RESULT(no)
123  fi
124fi
125]) # AC_COIN_THIRDPARTY_SUBDIRS
126
127###########################################################################
128#                           COIN_CHECK_VPATH                              #
129###########################################################################
130
131# This macro sets the variable coin_vpath_config to true if this is a
132# VPATH configuration, otherwise it sets it to false.
133AC_DEFUN([AC_COIN_CHECK_VPATH],
134[AC_MSG_CHECKING(whether this is a VPATH configuration)
135if test `cd $srcdir; pwd` != `pwd`; then
136  coin_vpath_config=yes;
137else
138  coin_vpath_config=no;
139fi
140AC_MSG_RESULT($coin_vpath_config)
141]) # AC_COIN_CHECK_VPATH
142
143###########################################################################
144#                         COIN_PROJECTDIR_INIT                            #
145###########################################################################
146
147# This macro does everything that is required in the early part in the
148# configure script, such as defining a few variables.  This should only
149# be used in the main directory of a project directory (the one under
150# which src is)
151
152AC_DEFUN([AC_COIN_PROJECTDIR_INIT],
153[# Initialize the ADDLIBS variable
154ADDLIBS="-lm $LIBS"
155AC_SUBST(ADDLIBS)
156
157# Initialize the FADDLIBS variable (which is to be used with a fortran
158# compiler and will not include FLIBS)
159FADDLIBS="$LIBS"
160AC_SUBST(FADDLIBS)
161
162# A useful makefile conditional that is always false
163AM_CONDITIONAL(ALWAYS_FALSE, false)
164
165# We set the following variable so that we know later in AC_COIN_FINALIZE
166# that we are in a project main directory
167coin_projectdir=yes
168
169# Check if a library version is set for libtool
170m4_ifvaln([$1],[coin_libversion=$1],[])
171]) # AC_COIN_PROJECTDIR_INIT
172
173###########################################################################
174#                          COIN_DEBUG_COMPILE                             #
175###########################################################################
176
177# enable the configure flags --enable-debug and --enable-debug-prjct
178# (where prcjt is the name of the project in lower case) and set the
179# variable coin_debug_compile to true or false This is used by
180# COIN_PROG_CXX, COIN_PROG_CC and COIN_PROG_F77 to determine the
181# compilation flags.  This macro also makes the switches
182# --with-prjct-verbosity and --with-prjct-checklevel available, which
183# define the preprocessor macros COIN_PRJCT_VERBOSITY and
184# COIN_PRJCT_CHECKLEVEL to the specified value (default is 0).
185#
186# The project specific flags are only made available, if one gives the
187# name of the project as first argument to this macro.
188
189AC_DEFUN([AC_COIN_DEBUG_COMPILE],
190[AC_BEFORE([$0],[AC_COIN_PROG_CXX])dnl
191AC_BEFORE([$0],[AC_COIN_PROG_CC])dnl
192AC_BEFORE([$0],[AC_COIN_PROG_F77])dnl
193
194AC_MSG_CHECKING([whether we want to compile in debug mode])
195
196AC_ARG_ENABLE([debug],
197[AC_HELP_STRING([--enable-debug],
198                [compile all projects with debug options tests])],
199[case "${enableval}" in
200   yes) coin_debug_compile=true
201        if test "${enable_shared+set}" = set; then :; else
202          enable_shared=no
203        fi
204        ;;
205   no)  coin_debug_compile=false
206        ;;
207   *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug)
208        ;;
209esac],
210[coin_debug_compile=false])
211
212m4_ifvaln([$1],
213[AC_ARG_ENABLE(debug-m4_tolower($1),
214 [AC_HELP_STRING([--enable-debug-m4_tolower($1)],
215                 [compile this project ($1) with debug options])],
216 [case "${enableval}" in
217    yes) coin_debug_compile=true
218         enable_shared=no
219         ;;
220    no)  coin_debug_compile=false
221         ;;
222    *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug-m4_tolower($1))
223         ;;
224 esac],[:])
225]) # m4_ifvaln([$1],
226
227if test $coin_debug_compile = true; then
228  AC_MSG_RESULT([yes])
229else
230  AC_MSG_RESULT([no])
231fi
232
233m4_ifvaln([$1],
234[AC_ARG_WITH(m4_tolower($1)-verbosity,
235             AC_HELP_STRING([--with-m4_tolower($1)-verbosity],
236                            [specify the debug verbosity level for project $1]),
237             [if test "$withval" = yes; then
238                withval=1
239              fi
240              m4_tolower(coin_$1_verbosity)=$withval],
241             [m4_tolower(coin_$1_verbosity)=0])
242 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_VERBOSITY),
243                    m4_tolower($coin_$1_verbosity),
244                    [Define to the debug verbosity level (0 is no output)])
245
246 AC_ARG_WITH(m4_tolower($1)-checklevel,
247             AC_HELP_STRING([--with-m4_tolower($1)-checklevel],
248                            [specify the sanity check level for project $1]),
249             [if test "$withval" = yes; then
250                withval=1
251              fi
252              m4_tolower(coin_$1_checklevel)=$withval],
253             [m4_tolower(coin_$1_checklevel)=0])
254 AC_DEFINE_UNQUOTED(m4_toupper(COIN_$1_CHECKLEVEL),
255                    m4_tolower($coin_$1_checklevel),
256                    [Define to the debug sanity check level (0 is no test)])
257
258# We use the following variable to have a string with the upper case
259# version of the project name
260COIN_PRJCT=m4_toupper($1)
261
262]) # m4_ifvaln([$1],
263 
264]) # AC_COIN_DEBUG_COMPILE
265
266###########################################################################
267#                          COIN_MINGW_LD_FIX                              #
268###########################################################################
269
270# This macro is included by any PROG_compiler macro, to set the LD
271# environment variable on MinGW to the correct value (link). But note that
272# if we're building in cygwin with -mno-cygwin, we still want ld! If we're
273# building from cygwin with MSVC tools (cl/link), then we do want link and
274# you'd better have your PATH variable straight, else you'll be doing file
275# links instead of code links! Arguably, LDFLAGS should include -mno-cygwin
276# but in practice all linking seems to be handled through the compilers, so
277# CFLAGS and CXXFLAGS suffice.
278
279AC_DEFUN([AC_COIN_MINGW_LD_FIX],
280[case $build in
281  *-mingw*)
282    if test "${LD+set}" = set; then :; else
283      LD=link
284    fi
285    ;;
286 esac
287 case $enable_doscompile in
288   msvc)
289     if test "x${LD+set}" = xset; then :; else
290       LD=link
291     fi
292     ;;
293 esac
294])
295
296###########################################################################
297#                        COIN_ENABLE_DOSCOMPILE                           #
298###########################################################################
299
300# This macro is invoked by any PROG_compiler macro to establish the
301# --enable-doscompile option, used when one wants to compile an executable
302# under Cygwin which also runs directly under DOS (without requiring
303# Cygwin1.dll). The job of this macro is to make sure the option is correct and
304# to set enable_doscompile. Legal values are mingw, msvc, and no (disabled).
305# mingw: Fake mingw under cygwin, using GCC tools and -mno-cygwin. The most
306#        important thing here is that preprocess, compile, and link steps
307#        *all* see -mno-cygwin.
308# msvc:  Assume the presence of cl/link. It's the user's responsibility to
309#        make sure their PATH is correct. In particular, that MSVC link is
310#        found and not cygwin link (we want to do code linking, not file
311#        linking).
312# It's the responsibility of individual PROG_compiler macros to ensure that
313# they correctly set the compiler search list and preprocess, compile, and
314# link flags. This is tied to compiler setup because in practice invocations
315# of the preprocessor and linker are made through the compiler.
316
317AC_DEFUN([AC_COIN_ENABLE_DOSCOMPILE],
318[AC_REQUIRE([AC_CANONICAL_BUILD])
319 AC_ARG_ENABLE([doscompile],
320  [AC_HELP_STRING([--enable-doscompile],
321                  [Under Cygwin, compile so that executables run under DOS.
322                   Set to mingw to use gcc/g++/ld with -mno-cygwin.
323                   Set to msvc to use cl/link (or icl/link).
324                   Default when mentioned: mingw.
325                   Default when not mentioned: disabled.])],
326  [if test "$enable_doscompile" != no; then
327     case $build in
328       *-cygwin* | *-mingw*) ;;
329       *) AC_MSG_ERROR([--enable-doscompile option makes sense only under Cygwin or MinGW]) ;;
330     esac
331   fi],
332  [enable_doscompile=no])
333 case "$enable_doscompile" in
334   mingw)
335     case $build in
336       *-mingw*) enable_doscompile=no ;;
337     esac
338     ;;
339   msvc|no) ;;
340   yes) enable_doscompile=mingw ;;
341   *) AC_MSG_ERROR([Invalid value $enable_doscompile for --enable-doscompile.
342                    Try configure --help=recursive.])
343      ;;
344  esac
345  if test "$enable_doscompile" != no ; then
346    AC_MSG_NOTICE([DOS compile style is: $enable_doscompile])
347  fi
348])
349
350###########################################################################
351#                             COIN_PROG_CXX                               #
352###########################################################################
353
354# Find the compile command by running AC_PROG_CXX (with compiler names for
355# different operating systems) and put it into CXX (unless it was given by the
356# user). Then find an appropriate value for CXXFLAGS. If either of CXXFLAGS or
357# PRJCT_CXXFLAGS is defined, that value is used (replace PRJCT with the upper
358# case name of this project).  It is possible to provide additional -D flags
359# in the variable CXXDEFS, and additional compilation flags with ADD_CXXFLAGS.
360
361AC_DEFUN([AC_COIN_PROG_CXX],
362[AC_REQUIRE([AC_COIN_PROG_CC]) #Let's try if that overcomes configuration problem with VC++ 6.0
363AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
364AC_LANG_PUSH(C++)
365
366AC_ARG_VAR(CXXDEFS,[Additional -D flags to be used when compiling C++ code.])
367AC_ARG_VAR(ADD_CXXFLAGS,[Additional C++ compiler options])
368AC_ARG_VAR(DBG_CXXFLAGS,[Debug C++ compiler options])
369AC_ARG_VAR(OPT_CXXFLAGS,[Optimize C++ compiler options])
370
371coin_has_cxx=yes
372
373save_cxxflags="$CXXFLAGS"
374# For *-*-solaris*, promote Studio/Workshop compiler to front of list.
375case $build in
376  *-cygwin* | *-mingw*)
377             if test "$enable_doscompile" = msvc ; then
378               comps="icl cl"
379             else
380               comps="g++ cl"
381             fi ;;
382  *-*-solaris*)
383             comps="CC xlC_r aCC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
384  *-darwin*) comps="g++ c++ CC" ;;
385          *) comps="xlC_r aCC CC g++ c++ pgCC icpc gpp cxx cc++ cl FCC KCC RCC" ;;
386esac
387
388# We delete the cached value, since the test might not have been
389# performed with our choice of compilers earlier
390$as_unset ac_cv_prog_CXX || test "${ac_cv_prog_CXX+set}" != set || { ac_cv_prog_CXX=; export ac_cv_prog_CXX; }
391# AC_MSG_NOTICE([C++ compiler candidates: $comps])
392AC_PROG_CXX([$comps])
393
394#AC_PROG_CXX sets CXX to g++ if it cannot find a working C++ compiler
395#thus, we test here whether $CXX is actually working
396AC_LANG_PUSH(C++)
397AC_MSG_CHECKING([whether C++ compiler $CXX works]);
398AC_COMPILE_IFELSE(
399  [AC_LANG_PROGRAM(, [int i=0;])],
400  [AC_MSG_RESULT(yes)],
401  [AC_MSG_RESULT(no)
402   AC_MSG_ERROR(failed to find a C++ compiler or C++ compiler $CXX does not work)]
403)
404AC_LANG_POP(C++)
405
406# It seems that we need to cleanup something here for the Windows
407case "$CXX" in
408  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
409    sed -e 's/^void exit (int);//' confdefs.h >> confdefs.hh
410    mv confdefs.hh confdefs.h
411    ;;
412esac
413
414# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
415case "$CXX" in
416  cl* | */cl* | CL* | */CL* )
417    if test "$ac_cv_prog_cxx_g" = yes ; then
418      ac_cv_prog_cxx_g=no
419      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
420    fi ;;
421esac
422CXXFLAGS="$save_cxxflags"
423
424# Check if a project specific CXXFLAGS variable has been set
425if test x$COIN_PRJCT != x; then
426  eval coin_tmp=\${${COIN_PRJCT}_CXXFLAGS+set}
427  if test x$coin_tmp = xset; then
428    eval CXXFLAGS=\${${COIN_PRJCT}_CXXFLAGS}
429  fi
430fi
431
432if test x"$CXXFLAGS" = x; then
433
434# ToDo decide whether we want -DNDEBUG for optimization
435  coin_add_cxxflags=
436  coin_opt_cxxflags=
437  coin_dbg_cxxflags=
438  coin_warn_cxxflags=
439
440  if test "$GXX" = "yes"; then
441    case "$CXX" in
442      icpc* | */icpc*)
443        ;;
444      *)
445# ToDo decide about unroll-loops
446        coin_opt_cxxflags="-O3 -fomit-frame-pointer"
447        coin_add_cxxflags="-pipe"
448        coin_dbg_cxxflags="-g"
449        coin_warn_cxxflags="-Wimplicit -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas"
450        case $build in
451          *-darwin*)
452            ;;
453          *)
454            coin_warn_cxxflags="-pedantic-errors $coin_warn_cxxflags"
455            ;;
456        esac
457
458        case $enable_doscompile in
459          mingw)
460            CXXFLAGS="-mno-cygwin"
461            AC_TRY_LINK(,[int i=0; i++;],[coin_add_cxxflags="-mno-cygwin $coin_add_cxxflags"])
462            CXXFLAGS=
463          ;;
464        esac
465    esac
466  fi
467
468# Note that we do not need to cover GCC in the following tests.
469
470  if test -z "$coin_opt_cxxflags"; then
471    case $build in
472      *-cygwin* | *-mingw*)
473        case "$CXX" in
474          cl* | */cl* | CL* | */CL*)
475            # The MT and MTd options are mutually exclusive
476            coin_opt_cxxflags='-MT -O2'
477            coin_add_cxxflags='-nologo -EHsc -GR -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
478            coin_dbg_cxxflags='-MTd'
479            ;;
480          icl* | */icl* | ICL* | */ICL*)
481            # The MT and MTd options are mutually exclusive
482            coin_opt_cxxflags='-MT -Ox'
483            coin_add_cxxflags='-nologo -EHsc -GR -D_CRT_SECURE_NO_DEPRECATE'
484            coin_dbg_cxxflags='-MTd -debug'
485            ;;
486        esac
487        ;;
488      *-linux-*)
489        case "$CXX" in
490          icpc* | */icpc*)
491            coin_opt_cxxflags="-O3 -ip -mp1"
492            coin_add_cxxflags=""
493            coin_dbg_cxxflags="-g"
494            # Check if -i_dynamic is necessary (for new glibc library)
495            CXXFLAGS=
496            AC_TRY_LINK(,[int i=0; i++;],[],
497                        [coin_add_cxxflags="-i_dynamic $coin_add_cxxflags"])
498            ;;
499          pgCC* | */pgCC*)
500            coin_opt_cxxflags="-fast"
501            coin_add_cxxflags="-Kieee -pc 64"
502            coin_dbg_cxxflags="-g"
503            ;;
504        esac
505        ;;
506      *-ibm-*)
507        case "$CXX" in
508          xlC* | */xlC* | mpxlC* | */mpxlC*)
509            coin_opt_cxxflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
510            coin_add_cxxflags="-bmaxdata:0x80000000 -qrtti=dyna -qsuppress=1500-036 -qsuppress=1500-029 -qsourcetype=c++"
511            coin_dbg_cxxflags="-g"
512            ;;
513        esac
514        ;;
515      *-hp-*)
516        case "$CXX" in
517          aCC* | */aCC* )
518            coin_opt_cxxflags="-O"
519            coin_add_cxxflags="-AA"
520            coin_dbg_cxxflags="-g"
521            ;;
522        esac
523        ;;
524      *-*-solaris*)
525          coin_opt_cxxflags="-O4"
526          coin_dbg_cxxflags="-g"
527        ;;
528    esac
529  fi
530
531# Generic flag settings. If these don't work, add a case above.
532
533  if test "$ac_cv_prog_cxx_g" = yes && test -z "$coin_dbg_cxxflags" ; then
534    coin_dbg_cxxflags="-g"
535  fi
536
537  if test -z "$coin_opt_cxxflags"; then
538    # Try if -O option works if nothing else is set
539    CXXFLAGS=-O
540    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cxxflags="-O"])
541  fi
542
543  # if PM doesn't want the warning messages, take them out
544  if test x"$coin_skip_warn_cxxflags" = xyes; then
545    coin_warn_cxxflags=
546  fi
547
548# Do final setup of flags based on values determined above.
549
550  if test x${DBG_CXXFLAGS+set} != xset; then
551    DBG_CXXFLAGS="$coin_dbg_cxxflags $coin_add_cxxflags $coin_warn_cxxflags"
552  fi
553  if test x${OPT_CXXFLAGS+set} != xset; then
554    OPT_CXXFLAGS="$coin_opt_cxxflags $coin_add_cxxflags -DNDEBUG $coin_warn_cxxflags"
555  fi
556
557  DBG_CXXFLAGS="$DBG_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
558  OPT_CXXFLAGS="$OPT_CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
559
560  if test "$coin_debug_compile" = "true"; then
561    CXXFLAGS="$DBG_CXXFLAGS"
562  else
563    CXXFLAGS="$OPT_CXXFLAGS"
564  fi
565
566# Handle the case where CXXFLAGS was set externally.
567else
568  CXXFLAGS="$CXXFLAGS $ADD_CXXFLAGS $CXXDEFS"
569  if test x${DBG_CXXFLAGS+set} != xset; then
570    DBG_CXXFLAGS="$CXXFLAGS"
571  fi
572  if test x${OPT_CXXFLAGS+set} != xset; then
573    OPT_CXXFLAGS="$CXXFLAGS"
574  fi
575fi
576
577# If CXXFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
578
579case "$CXXFLAGS" in
580  *-mno-cygwin*)
581    if test x${CPPFLAGS+set} != xset ; then
582      CPPFLAGS="-mno-cygwin"
583    else
584      case "$CPPFLAGS" in
585        *-mno-cygwin*)
586          ;;
587        *)
588          CPPFLAGS="$CPPFLAGS -mno-cygwin"
589          ;;
590      esac
591    fi ;;
592esac
593
594# Try if CXXFLAGS works
595save_CXXFLAGS="$CXXFLAGS"
596AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
597if test -z "$CXXFLAGS"; then
598  AC_MSG_WARN([The flags CXXFLAGS="$save_CXXFLAGS" do not work.  I will now just try '-O', but you might want to set CXXFLAGS manually.])
599  CXXFLAGS='-O'
600  AC_TRY_LINK([],[int i=0; i++;],[],[CXXFLAGS=])
601  if test -z "$CXXFLAGS"; then
602    AC_MSG_WARN([This value for CXXFLAGS does not work.  I will continue with empty CXXFLAGS, but you might want to set CXXFLAGS manually.])
603  fi
604fi
605
606AC_MSG_NOTICE([C++ compiler options are: $CXXFLAGS])
607
608AC_ARG_VAR(MPICXX,[C++ MPI Compiler])
609if test x"$MPICXX" = x; then :; else
610  AC_MSG_NOTICE([Will use MPI C++ compiler $MPICXX])
611  CXX="$MPICXX"
612fi
613
614case "$CXX" in
615  cl* | */cl* | CL* | */CL* )
616    AC_COIN_MINGW_LD_FIX
617    ;;
618esac
619
620AC_LANG_POP(C++)
621]) # AC_COIN_PROG_CXX
622
623
624###########################################################################
625#                             COIN_CXXLIBS                                #
626###########################################################################
627
628# Determine the C++ runtime libraries required for linking a C++ library
629# with a Fortran or C compiler.  The result is available in CXXLIBS.
630
631AC_DEFUN([AC_COIN_CXXLIBS],
632[AC_REQUIRE([AC_PROG_CXX])dnl
633AC_LANG_PUSH(C++)
634AC_ARG_VAR(CXXLIBS,[Libraries necessary for linking C++ code with Fortran compiler])
635if test -z "$CXXLIBS"; then
636  if test "$GXX" = "yes"; then
637    case "$CXX" in
638      icpc* | */icpc*)
639        CXXLIBS="-lstdc++"
640        ;;
641      *)
642        CXXLIBS="-lstdc++ -lm" # -lgcc"
643        ;;
644    esac
645  else
646    case $build in
647     *-mingw32 | *-cygwin* )
648      case "$CXX" in
649      cl* | */cl* | CL* | */CL*)
650        CXXLIBS=nothing;;
651      esac;;
652     *-linux-*)
653      case "$CXX" in
654      icpc* | */icpc*)
655        CXXLIBS="-lstdc++"
656             ;;
657      pgCC* | */pgCC*)
658        CXXLIBS="-lstd -lC -lc"
659             ;;
660      esac;;
661    *-ibm-*)
662      CXXLIBS="-lC -lc"
663      ;;
664    *-hp-*)
665      CXXLIBS="-L/opt/aCC/lib -l++ -lstd_v2 -lCsup_v2 -lm -lcl -lc"
666      ;;
667    *-*-solaris*)
668      CXXLIBS="-lCstd -lCrun"
669    esac
670  fi
671fi
672if test -z "$CXXLIBS"; then
673  AC_MSG_WARN([Could not automatically determine CXXLIBS (C++ link libraries; necessary if main program is in Fortran or C).])
674else
675  AC_MSG_NOTICE([Assuming that CXXLIBS is \"$CXXLIBS\".])
676fi
677if test x"$CXXLIBS" = xnothing; then
678  CXXLIBS=
679fi
680AC_LANG_POP(C++)
681]) # AC_COIN_CXXLIBS
682
683###########################################################################
684#                           COIN_CHECK_HEADER                             #
685###########################################################################
686
687# This macro checks for a header file, but it does so without the
688# standard header.  This avoids warning messages like:
689#
690# configure: WARNING: dlfcn.h: present but cannot be compiled
691# configure: WARNING: dlfcn.h:     check for missing prerequisite headers?
692# configure: WARNING: dlfcn.h: see the Autoconf documentation
693# configure: WARNING: dlfcn.h:     section "Present But Cannot Be Compiled"
694# configure: WARNING: dlfcn.h: proceeding with the preprocessor's result
695# configure: WARNING: dlfcn.h: in the future, the compiler will take precedence
696
697# My guess that the problem lay with CPPFLAGS seems to be correct. With this
698# macro reduced to a direct call to AC_CHECK_HEADERS, there are no warnings
699# now that CPPFLAGS contains -mno-cygwin when it needs it. -- lh, 061214 --
700
701# AW 070609: I restored the previous version, since otherwise the warnings
702# still pop up for the cl compiler
703
704AC_DEFUN([AC_COIN_CHECK_HEADER],
705[#if test x"$4" = x; then
706#  hdr="#include <$1>"
707#else
708#  hdr="$4"
709#fi
710#AC_CHECK_HEADERS([$1],[$2],[$3],[$hdr])
711AC_CHECK_HEADERS([$1],[$2],[$3],[$4])
712]) # AC_COIN_CHECK_HEADER
713
714###########################################################################
715#                       COIN_CHECK_CXX_CHEADER                             #
716###########################################################################
717
718# This macro checks for C header files that are used from C++.  For a give
719# stub (e.g., math), it first checks if the C++ library (cmath) is available.
720# If it is, it defines HAVE_CMATH (or whatever the stub is).  If it is not
721# available, it checks for the old C head (math.h) and defines HAVE_MATH_H
722# if that one exists.
723
724AC_DEFUN([AC_COIN_CHECK_CXX_CHEADER],
725[AC_LANG_PUSH(C++)
726AC_COIN_CHECK_HEADER([c$1],[$2],[$3],[$4])
727if test "$ac_cv_header_c$1" != "yes"; then
728  AC_COIN_CHECK_HEADER([$1.h],[$2],[$3],[$4])
729fi
730AC_LANG_POP(C++)
731]) # AC_COIN_CHECK_CXX_CHEADER
732
733###########################################################################
734#                             COIN_PROG_CC                                #
735###########################################################################
736
737# Find the compile command by running AC_PROG_CC (with compiler names
738# for different operating systems) and put it into CC (unless it was
739# given my the user), and find an appropriate value for CFLAGS.  It is
740# possible to provide additional -D flags in the variable CDEFS.
741
742AC_DEFUN([AC_COIN_PROG_CC],
743[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
744AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
745AC_LANG_PUSH(C)
746
747# For consistency, we set the C compiler to the same value of the C++
748# compiler, if the C++ is set, but the C compiler isn't (only for CXX=cl)
749if test x"$CXX" != x; then
750  case "$CXX" in
751    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
752      if test x"$CC" = x; then
753        CC="$CXX"
754        AC_MSG_WARN([C++ compiler name provided as $CXX, but CC is unset. Setting CC to $CXX])
755      fi
756      ;;
757  esac
758fi
759
760AC_ARG_VAR(CDEFS,[Additional -D flags to be used when compiling C code.])
761AC_ARG_VAR(ADD_CFLAGS,[Additional C compiler options])
762AC_ARG_VAR(DBG_CFLAGS,[Debug C compiler options])
763AC_ARG_VAR(OPT_CFLAGS,[Optimize C compiler options])
764
765coin_has_cc=yes
766
767save_cflags="$CFLAGS"
768
769# For *-*-solaris*, promote Studio/Workshop cc compiler to front of list.
770# Depending on the user's PATH, when Studio/Workshop cc is not present we may
771# find /usr/ucb/cc, which is almost certainly not a good choice for the C
772# compiler. In this case, put cc after gcc.
773
774case $build in
775  *-cygwin* | *-mingw*)
776             if test "$enable_doscompile" = msvc ; then
777               comps="icl cl"
778             else
779               comps="gcc cl"
780             fi ;;
781  *-*-solaris*)
782             AC_CHECK_PROG(sol_cc_compiler,cc,cc,[],[],/usr/ucb/cc)
783             if test "$sol_cc_compiler" = "cc" ; then
784               comps="cc xlc gcc pgcc icc"
785             else
786               comps="xlc gcc pgcc icc cc"
787             fi
788             ;;
789  *-linux-*) comps="xlc gcc cc pgcc icc" ;;
790  *)         comps="xlc_r xlc cc gcc pgcc icc" ;;
791esac
792
793# We delete the cached value, since the test might not have been
794# performed with our choice of compilers earlier
795$as_unset ac_cv_prog_CC || test "${ac_cv_prog_CC+set}" != set || { ac_cv_prog_CC=; export ac_cv_prog_CC; }
796# AC_MSG_NOTICE([C compiler candidates: $comps])
797AC_PROG_CC([$comps])
798if test -z "$CC" ; then
799  AC_MSG_ERROR([Failed to find a C compiler!])
800fi
801# Autoconf incorrectly concludes that cl recognises -g. It doesn't.
802case "$CC" in
803  cl* | */cl* | CL* | */CL* )
804    if test "$ac_cv_prog_cc_g" = yes ; then
805      ac_cv_prog_cc_g=no
806      AC_MSG_NOTICE([Overruling autoconf; cl does not recognise -g.])
807    fi ;;
808esac
809CFLAGS="$save_cflags"
810
811# Check if a project specific CFLAGS variable has been set
812if test x$COIN_PRJCT != x; then
813  eval coin_tmp=\${${COIN_PRJCT}_CFLAGS+set}
814  if test x$coin_tmp = xset; then
815    eval CFLAGS=\${${COIN_PRJCT}_CFLAGS}
816  fi
817fi
818
819if test x"$CFLAGS" = x; then
820
821  coin_add_cflags=
822  coin_opt_cflags=
823  coin_dbg_cflags=
824  coin_warn_cflags=
825
826  if test "$GCC" = "yes"; then
827    case "$CC" in
828      icc* | */icc*)
829        ;;
830      *)
831        coin_opt_cflags="-O3 -fomit-frame-pointer"
832        coin_add_cflags="-pipe"
833        coin_dbg_cflags="-g"
834        coin_warn_cflags="-Wimplicit -Wparentheses -Wsequence-point -Wreturn-type -Wcast-qual -Wall -Wno-unknown-pragmas"
835        case $build in
836          *-darwin*)
837            ;;
838          *)
839            coin_warn_cflags="-pedantic-errors $coin_warn_cflags"
840            ;;
841        esac
842        case $enable_doscompile in
843          mingw)
844            CFLAGS="-mno-cygwin"
845            AC_TRY_LINK([],[int i=0; i++;],
846                        [coin_add_cflags="-mno-cygwin $coin_add_cflags"])
847            CFLAGS=
848          ;;
849        esac
850    esac
851  fi
852  if test -z "$coin_opt_cflags"; then
853    case $build in
854      *-cygwin* | *-mingw*)
855        case "$CC" in
856          cl* | */cl* | CL* | */CL*)
857            coin_opt_cflags='-MT -O2'
858            coin_add_cflags='-nologo -wd4996 -D_CRT_SECURE_NO_DEPRECATE'
859            coin_dbg_cflags='-MTd'
860            ;;
861          icl* | */icl* | ICL* | */ICL*)
862            coin_opt_cflags='-MT -Ox'
863            coin_add_cflags='-nologo -D_CRT_SECURE_NO_DEPRECATE'
864            coin_dbg_cflags='-MTd -debug'
865            ;;
866        esac
867        ;;
868      *-linux-*)
869        case "$CC" in
870          icc* | */icc*)
871            coin_opt_cflags="-O3 -ip -mp1"
872            coin_add_cflags=""
873            coin_dbg_cflags="-g"
874            # Check if -i_dynamic is necessary (for new glibc library)
875            CFLAGS=
876            AC_TRY_LINK([],[int i=0; i++;],[],
877                        [coin_add_cflags="-i_dynamic $coin_add_cflags"])
878            ;;
879          pgcc* | */pgcc*)
880            coin_opt_cflags="-fast"
881            coin_add_cflags="-Kieee -pc 64"
882            coin_dbg_cflags="-g"
883            ;;
884        esac
885        ;;
886      *-ibm-*)
887        case "$CC" in
888          xlc* | */xlc* | mpxlc* | */mpxlc*)
889            coin_opt_cflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
890            coin_add_cflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
891            coin_dbg_cflags="-g"
892          ;;
893        esac
894        ;;
895      *-hp-*)
896        coin_opt_cflags="-O"
897        coin_add_cflags="-Ae"
898        coin_dbg_cflags="-g"
899        ;;
900      *-*-solaris*)
901        coin_opt_cflags="-xO4"
902        coin_dbg_cflags="-g"
903        ;;
904      *-sgi-*)
905        coin_opt_cflags="-O -OPT:Olimit=0"
906        coin_dbg_cflags="-g"
907        ;;
908    esac
909  fi
910
911  if test "$ac_cv_prog_cc_g" = yes && test -z "$coin_dbg_cflags" ; then
912    coin_dbg_cflags="-g"
913  fi
914
915  if test -z "$coin_opt_cflags"; then
916    # Try if -O option works if nothing else is set
917    CFLAGS="-O"
918    AC_TRY_LINK([],[int i=0; i++;],[coin_opt_cflags="-O"])
919  fi
920
921  # if PM doesn't want the warning messages, take them out
922  if test x"$coin_skip_warn_cflags" = xyes; then
923    coin_warn_cflags=
924  fi
925
926  if test x${DBG_CFLAGS+set} != xset; then
927    DBG_CFLAGS="$coin_dbg_cflags $coin_add_cflags $coin_warn_cflags"
928  fi
929  if test x${OPT_CFLAGS+set} != xset; then
930    OPT_CFLAGS="$coin_opt_cflags $coin_add_cflags -DNDEBUG $coin_warn_cflags"
931  fi
932
933  DBG_CFLAGS="$DBG_CFLAGS $ADD_CFLAGS $CDEFS"
934  OPT_CFLAGS="$OPT_CFLAGS $ADD_CFLAGS $CDEFS"
935
936  if test "$coin_debug_compile" = "true"; then
937    CFLAGS="$DBG_CFLAGS"
938  else
939    CFLAGS="$OPT_CFLAGS"
940  fi
941else
942  CFLAGS="$CFLAGS $ADD_CFLAGS $CDEFS"
943  if test x${DBG_CFLAGS+set} != xset; then
944    DBG_CFLAGS="$CFLAGS"
945  fi
946  if test x${OPT_CFLAGS+set} != xset; then
947    OPT_CFLAGS="$CFLAGS"
948  fi
949fi
950
951# If CFLAGS contains -mno-cygwin, CPPFLAGS must also have it.
952
953case "$CFLAGS" in
954  *-mno-cygwin*)
955    if test x${CPPFLAGS+set} != xset ; then
956      CPPFLAGS="-mno-cygwin"
957    else
958      case "$CPPFLAGS" in
959        *-mno-cygwin*)
960          ;;
961        *)
962          CPPFLAGS="$CPPFLAGS -mno-cygwin"
963          ;;
964      esac
965    fi ;;
966esac
967
968# Try if CFLAGS works
969save_CFLAGS="$CFLAGS"
970AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
971if test -z "$CFLAGS"; then
972  AC_MSG_WARN([The value CFLAGS="$save_CFLAGS" do not work.  I will now just try '-O', but you might want to set CFLAGS manually.])
973  CFLAGS='-O'
974  AC_TRY_LINK([],[int i=0; i++;],[],[CFLAGS=])
975  if test -z "$CFLAGS"; then
976    AC_MSG_WARN([This value for CFLAGS does not work.  I will continue with empty CFLAGS, but you might want to set CFLAGS manually.])
977  fi
978fi
979
980AC_MSG_NOTICE([C compiler options are: $CFLAGS])
981
982AC_ARG_VAR(MPICC,[C MPI Compiler])
983if test x"$MPICC" = x; then :; else
984  AC_MSG_NOTICE([Will use MPI C compiler $MPICC])
985  CC="$MPICC"
986fi
987
988# Correct ADDLIBS initialization if we are using the MS compiler
989case "$CC" in
990  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
991    ADDLIBS=
992    AC_COIN_MINGW_LD_FIX
993    ;;
994esac
995
996AC_LANG_POP(C)
997]) # AC_COIN_PROG_CC
998
999###########################################################################
1000#                             COIN_PROG_F77                               #
1001###########################################################################
1002
1003# Find the compile command by running AC_PROG_F77 (with compiler names
1004# for different operating systems) and put it into F77 (unless it was
1005# given by the user), and find an appropriate value for FFLAGS
1006
1007AC_DEFUN([AC_COIN_PROG_F77],
1008[AC_REQUIRE([AC_COIN_MINGW_LD_FIX])
1009AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1010AC_REQUIRE([AC_COIN_PROG_CC])
1011AC_REQUIRE([AC_COIN_F77_COMPS])
1012AC_LANG_PUSH([Fortran 77])
1013
1014AC_ARG_VAR(ADD_FFLAGS,[Additional Fortran compiler options])
1015AC_ARG_VAR(DBG_FFLAGS,[Debug Fortran compiler options])
1016AC_ARG_VAR(OPT_FFLAGS,[Optimize Fortran compiler options])
1017
1018coin_has_f77=yes
1019
1020save_fflags="$FFLAGS"
1021
1022# We delete the cached value, since the test might not have been
1023# performed with our choice of compilers earlier
1024$as_unset ac_cv_prog_F77 || test "${ac_cv_prog_F77+set}" != set || { ac_cv_prog_F77=; export ac_cv_prog_F77; }
1025
1026# This is a real belt-and-suspenders approach. AC_COIN_FIND_F77 will use
1027# coin_f77_comps to see if there's a program that matches one of the names.
1028# If there's no such program, F77 = unavailable. If we match the name,
1029# feed AC_PROG_F77 the same search list, just to be sure it's a functioning
1030# compiler.
1031# AC_MSG_NOTICE([Fortran compiler candidates: $coin_f77_comps])
1032AC_COIN_FIND_F77
1033if test "$F77" != "unavailable" ; then
1034  AC_PROG_F77($coin_f77_comps)
1035else
1036  AC_MSG_WARN([Failed to find a Fortran compiler!])
1037fi
1038
1039FFLAGS="$save_fflags"
1040
1041# Check if a project specific FFLAGS variable has been set
1042if test x$COIN_PRJCT != x; then
1043  eval coin_tmp=\${${COIN_PRJCT}_FFLAGS+set}
1044  if test x$coin_tmp = xset; then
1045    eval FFLAGS=\${${COIN_PRJCT}_FFLAGS}
1046  fi
1047fi
1048
1049if test "$F77" != "unavailable" && test x"$FFLAGS" = x ; then
1050
1051  coin_add_fflags=
1052  coin_opt_fflags=
1053  coin_dbg_fflags=
1054  coin_warn_fflags=
1055
1056  if test "$G77" = "yes"; then
1057    coin_opt_fflags="-O3 -fomit-frame-pointer"
1058    coin_add_fflags="-pipe"
1059    coin_dbg_fflags="-g"
1060    case $enable_doscompile in
1061      mingw)
1062        FFLAGS="-mno-cygwin"
1063        AC_TRY_LINK(,[      write(*,*) 'Hello world'],
1064                    [coin_add_fflags="-mno-cygwin $coin_add_fflags"])
1065        FFLAGS=
1066      ;;
1067    esac
1068  else
1069    case $build in
1070      *-cygwin* | *-mingw*)
1071        case $F77 in
1072          ifort* | */ifort* | IFORT* | */IFORT* )
1073            coin_opt_fflags='-MT -O3'
1074            coin_add_fflags='-fpp -nologo'
1075            coin_dbg_fflags='-MTd -debug'
1076          ;;
1077          compile_f2c*)
1078            coin_opt_fflags='-MT -O2'
1079            coin_add_fflags='-nologo -wd4996'
1080            coin_dbg_fflags='-MTd'
1081          ;;
1082        esac
1083        ;;
1084      *-linux-*)
1085        case $F77 in
1086          ifc* | */ifc* | ifort* | */ifort*)
1087            coin_opt_fflags="-O3 -ip"
1088            coin_add_fflags="-cm -w90 -w95"
1089            coin_dbg_fflags="-g -CA -CB -CS"
1090            # Check if -i_dynamic is necessary (for new glibc library)
1091            FFLAGS=
1092            AC_TRY_LINK(,[      write(*,*) 'Hello world'],[],
1093                        [coin_add_fflags="-i_dynamic $coin_add_fflags"])
1094            ;;
1095          pgf77* | */pgf77* | pgf90* | */pgf90*)
1096            coin_opt_fflags="-fast"
1097            coin_add_fflags="-Kieee -pc 64"
1098            coin_dbg_fflags="-g"
1099          ;;
1100        esac
1101        ;;
1102      *-ibm-*)
1103        case "$F77" in
1104          xlf* | */xlf* | mpxlf* | */mpxlf* )
1105            coin_opt_fflags="-O -qarch=auto -qcache=auto -qtune=auto -qmaxmem=-1"
1106            coin_add_fflags="-bmaxdata:0x80000000 -qsuppress=1500-036 -qsuppress=1500-029"
1107            coin_dbg_fflags="-g -C"
1108            ;;
1109        esac
1110        ;;
1111      *-hp-*)
1112        coin_opt_fflags="+O3"
1113        coin_add_fflags="+U77"
1114        coin_dbg_fflags="-C -g"
1115        ;;
1116      *-*-solaris*)
1117        coin_opt_fflags="-O4"
1118        coin_dbg_fflags="-g"
1119        ;;
1120      *-sgi-*)
1121        coin_opt_fflags="-O5 -OPT:Olimit=0"
1122        coin_dbg_fflags="-g"
1123        ;;
1124    esac
1125  fi
1126
1127  if test "$ac_cv_prog_f77_g" = yes && test -z "$coin_dbg_fflags" ; then
1128    coin_dbg_fflags="-g"
1129  fi
1130
1131  if test -z "$coin_opt_fflags"; then
1132    # Try if -O option works if nothing else is set
1133    FFLAGS=-O
1134    AC_TRY_LINK(,[      integer i], [coin_opt_fflags="-O"])
1135  fi
1136
1137  # if PM doesn't want the warning messages, take them out
1138  if test x"$coin_skip_warn_fflags" = xyes; then
1139    coin_warn_fflags=
1140  fi
1141
1142  if test x${DBG_FFLAGS+set} != xset; then
1143    DBG_FFLAGS="$coin_dbg_fflags $coin_add_fflags $coin_warn_fflags"
1144  fi
1145  if test x${OPT_FFLAGS+set} != xset; then
1146    OPT_FFLAGS="$coin_opt_fflags $coin_add_fflags $coin_warn_fflags"
1147  fi
1148
1149  DBG_FFLAGS="$DBG_FFLAGS $ADD_FFLAGS"
1150  OPT_FFLAGS="$OPT_FFLAGS $ADD_FFLAGS"
1151
1152  if test "$coin_debug_compile" = "true"; then
1153    FFLAGS="$DBG_FFLAGS"
1154  else
1155    FFLAGS="$OPT_FFLAGS"
1156  fi
1157else
1158  FFLAGS="$FFLAGS $ADD_FFLAGS"
1159  if test x${DBG_FFLAGS+set} != xset; then
1160    DBG_FFLAGS="$FFLAGS"
1161  fi
1162  if test x${OPT_FFLAGS+set} != xset; then
1163    OPT_FFLAGS="$FFLAGS"
1164  fi
1165fi
1166
1167# If FFLAGS contains -mno-cygwin, CPPFLAGS must have it.
1168case "$FFLAGS" in
1169  *-mno-cygwin*)
1170    if test x${CPPFLAGS+set} != xset ; then
1171      CPPFLAGS="-mno-cygwin"
1172    else
1173      case "$CPPFLAGS" in
1174        *-mno-cygwin*)
1175          ;;
1176        *)
1177          CPPFLAGS="$CPPFLAGS -mno-cygwin"
1178          ;;
1179      esac
1180    fi ;;
1181esac
1182
1183# Try if FFLAGS works
1184if test "$F77" != "unavailable" ; then
1185  AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1186  if test -z "$FFLAGS"; then
1187    AC_MSG_WARN([The flags FFLAGS="$FFLAGS" do not work.  I will now just try '-O', but you might want to set FFLAGS manually.])
1188    FFLAGS='-O'
1189    AC_TRY_LINK(,[      integer i],[],[FFLAGS=])
1190    if test -z "$FFLAGS"; then
1191      AC_MSG_WARN([This value for FFLAGS does not work.  I will continue with empty FFLAGS, but you might want to set FFLAGS manually.])
1192    fi
1193  fi
1194fi
1195
1196AC_MSG_NOTICE([Fortran compiler options are: $FFLAGS])
1197
1198AC_ARG_VAR(MPIF77,[Fortran MPI Compiler])
1199if test x"$MPIF77" = x; then :; else
1200  AC_MSG_NOTICE([Will use MPI Fortran compiler $MPIF77])
1201  F77="$MPIF77"
1202fi
1203
1204case "$F77" in
1205  ifort* | */ifort* | IFORT* | */IFORT*)
1206    AC_COIN_MINGW_LD_FIX
1207    ;;
1208esac
1209
1210AC_LANG_POP([Fortran 77])
1211]) # AC_COIN_PROG_F77
1212
1213###########################################################################
1214#                           COIN_F77_WRAPPERS                             #
1215###########################################################################
1216
1217# Calls autoconfs AC_F77_WRAPPERS and does additional corrections to FLIBS
1218
1219AC_DEFUN([AC_COIN_F77_WRAPPERS],
1220[AC_BEFORE([AC_COIN_PROG_F77],[$0])dnl
1221AC_BEFORE([AC_PROG_F77],[$0])dnl
1222
1223AC_LANG_PUSH([Fortran 77])
1224
1225save_FLIBS="$FLIBS"
1226
1227AC_F77_WRAPPERS
1228
1229if test x"$save_FLIBS" != x; then
1230  FLIBS="$save_FLIBS"
1231else
1232  # This is to correct a missing exclusion in autoconf 2.59
1233  if test x"$FLIBS" != x; then
1234    my_flibs=
1235    for flag in $FLIBS; do
1236      case $flag in
1237        -lcrt*.o) ;;
1238               *) my_flibs="$my_flibs $flag" ;;
1239      esac
1240    done
1241    FLIBS="$my_flibs"
1242  fi
1243
1244  case $build in
1245  # The following is a fix to define FLIBS for ifort on Windows
1246  # In its original version, it linked in libifcorert.lib or libifcorertd.lib on Windows/ifort explicitly.
1247  # However, this seem to create a dependency on libifcorert.dll (or libifcorertd.dll) in the executables.
1248  # This is seem to be unnecessary, libifcorert(d).lib has been removed from the link line.
1249     *-cygwin* | *-mingw*)
1250       case "$F77" in
1251         ifort* | */ifort* | IFORT* | */IFORT*)
1252           FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib"
1253#           if "$coin_debug_compile" = true ; then
1254#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib"
1255#           else
1256#             FLIBS="-link $LIBS /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmtd.lib"
1257#           fi
1258           ;;
1259         compile_f2c*)
1260           FLIBS=`$F77 -FLIBS` ;;
1261       esac;;
1262     *-hp-*)
1263         FLIBS="$FLIBS -lm";;
1264     *-ibm-*)
1265         FLIBS=`echo $FLIBS | sed 's/-lc)/-lc/g'` ;;
1266     *-linux-*)
1267       case "$F77" in
1268         pgf77* | */pgf77* | pgf90* | */pgf90*)
1269# ask linker to go through the archives multiple times
1270# (the Fortran compiler seems to do that automatically...
1271           FLIBS="-Wl,--start-group $FLIBS -Wl,--end-group" ;;
1272       esac
1273  esac
1274  ac_cv_f77_libs="$FLIBS"
1275fi
1276
1277AC_LANG_POP([Fortran 77])
1278
1279]) # AC_COIN_F77_WRAPPERS
1280
1281###########################################################################
1282#                             COIN_FIND_F77                               #
1283###########################################################################
1284
1285# Attempt to preempt autoconf by locating an appropriate F77 program. This
1286# macro will not trigger a fatal error if a suitable compiler cannot be
1287# found. It should be called before COIN_PROG_F77 or COIN_TRY_FLINK.
1288
1289AC_DEFUN([AC_COIN_FIND_F77],
1290[AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
1291AC_REQUIRE([AC_COIN_F77_COMPS])
1292AC_MSG_NOTICE([Trying to determine Fortran compiler name])
1293AC_CHECK_PROGS([F77],[$coin_f77_comps],[unavailable])
1294])
1295
1296# Auxilliary macro to make sure both COIN_PROG_F77 and COIN_FIND_F77 use
1297# the same search lists for compiler names.
1298# For *-*-solaris*, promote Studio/Workshop compilers to front of list.
1299AC_DEFUN([AC_COIN_F77_COMPS],
1300[case $build in
1301  *-cygwin* | *-mingw*)
1302     if test "$enable_doscompile" = msvc ; then
1303       coin_f77_comps="ifort fl32 compile_f2c"
1304     else
1305       coin_f77_comps="gfortran g77 ifort fl32 compile_f2c"
1306     fi ;;
1307  *-*-solaris*)
1308     coin_f77_comps="f95 f90 f77 xlf_r fort77 gfortran g77 pgf90 pgf77 ifort ifc frt af77" ;;
1309  *) coin_f77_comps="xlf_r fort77 gfortran f77 g77 pgf90 pgf77 ifort ifc frt af77" ;;
1310 esac
1311])
1312
1313###########################################################################
1314#                          COIN_INIT_AUTOMAKE                             #
1315###########################################################################
1316
1317# This macro calls the regular INIT_AUTOMAKE and MAINTAINER_MODE
1318# macros, and defines additional variables and makefile conditionals,
1319# that are used in the maintainer parts of the makfile.  It also
1320# checks if the correct versions of the autotools are used.
1321#
1322# This also defines the AC_SUBST variables:
1323# abs_source_dir     absolute path to source code for this package
1324# abs_bin_dir        absolute path to the directory where binaries are
1325#                    going to be installed (prefix/bin)
1326# abs_lib_dir        absolute path to the directory where libraries are
1327#                    going to be installed (prefix/lib)
1328# abs_include_dir    absolute path to the directory where the header files
1329#                    are installed (prefix/include)
1330
1331AC_DEFUN([AC_COIN_INIT_AUTOMAKE],
1332[AC_REQUIRE([AC_PROG_EGREP])
1333
1334# AC_MSG_NOTICE([Beginning automake initialisation.])
1335# Stuff for automake
1336AM_INIT_AUTOMAKE
1337AM_MAINTAINER_MODE
1338
1339coin_have_externals=no
1340if test "$enable_maintainer_mode" = yes; then
1341
1342  # If maintainer mode is chosen, we make sure that the correct versions
1343  # of the tools are used, and that we know where libtool.m4 is (to
1344  # recreate acinclude.m4)
1345
1346  AC_SUBST(LIBTOOLM4)
1347  LIBTOOLM4=
1348  # Normally, $HOME
1349  AUTOTOOLS_DFLT=$HOME
1350
1351  AC_CACHE_CHECK([whether we are using the correct autotools],
1352                 [ac_cv_use_correct_autotools],
1353                 [ac_cv_use_correct_autotools=check])
1354
1355  if test $ac_cv_use_correct_autotools = check; then
1356    ac_cv_use_correct_autotools=yes
1357    # Check if we have autoconf
1358    AC_CHECK_PROG([have_autoconf],[autoconf],[yes],[no])
1359    if test $have_autoconf = no; then
1360      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find autoconf in your path.])
1361    fi
1362
1363    # Check whether autoconf is the correct version
1364    correct_version='2.59'
1365    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1366    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of autoconf])
1367    autoconf --version > confauto.out 2>&1
1368    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1369      AC_MSG_RESULT([yes])
1370    else
1371      rm -f confauto.out
1372      AC_MSG_RESULT([no])
1373      AC_MSG_ERROR([You don't have the correct version of autoconf as the first one in your path.])
1374    fi
1375    rm -f confauto.out
1376
1377    # Check if the executable autoconf is picked up from the correct location
1378    AC_MSG_CHECKING([whether autoconf is coming from the correct location])
1379    autoconf_dir=`which autoconf | sed -e 's=/autoconf=='`
1380    autoconf_dir=`cd $autoconf_dir; pwd`
1381    if test x$AUTOTOOLS_DIR = x; then
1382      want_dir=$AUTOTOOLS_DFLT/bin
1383    else
1384      want_dir=$AUTOTOOLS_DIR/bin
1385    fi
1386    if test $autoconf_dir = `cd $want_dir; pwd`; then
1387      AC_MSG_RESULT([yes])
1388    else
1389      rm -f confauto.out
1390      AC_MSG_RESULT([no])
1391      AC_MSG_ERROR([The autoconf executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1392    fi
1393
1394    # Check if we have automake
1395    AC_CHECK_PROG([have_automake],[automake],[yes],[no])
1396    if test $have_automake = no; then
1397      AC_MSG_ERROR([You specified you want to use maintainer mode, but I cannot find automake in your path.])
1398    fi
1399 
1400    # Check whether automake is the correct version
1401    correct_version='1.9.6'
1402    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1403    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of automake])
1404    automake --version > confauto.out 2>&1
1405    if $EGREP $grep_version confauto.out >/dev/null 2>&1; then
1406      AC_MSG_RESULT([yes])
1407    else
1408      rm -f confauto.out
1409      AC_MSG_RESULT([no])
1410      AC_MSG_ERROR([You don't have the correct version of automake as the first one in your path.])
1411    fi
1412    rm -f confauto.out
1413
1414    # Check if the executable automake is picked up from the correct location
1415    AC_MSG_CHECKING([whether automake is coming from the correct location])
1416    automake_dir=`which automake | sed -e 's=/automake=='`
1417    automake_dir=`cd $automake_dir; pwd`
1418    if test x$AUTOTOOLS_DIR = x; then
1419      want_dir=$AUTOTOOLS_DFLT/bin
1420    else
1421      want_dir=$AUTOTOOLS_DIR/bin
1422    fi
1423    if test $automake_dir = `cd $want_dir; pwd`; then
1424      AC_MSG_RESULT([yes])
1425    else
1426      rm -f confauto.out
1427      AC_MSG_RESULT([no])
1428      AC_MSG_ERROR([The automake executable should be picked up from \$AUTOTOOLS_DFLT/bin or \$AUTOTOOLS_DIR/bin.])
1429    fi
1430
1431    # Check if this is the correct version of libtool (with escaped dots)
1432    if test x$AUTOTOOLS_DIR = x; then
1433      want_dir=$AUTOTOOLS_DFLT/share
1434    else
1435      want_dir=$AUTOTOOLS_DIR/share
1436    fi
1437    correct_version='1.5.22'
1438    grep_version=`echo  $correct_version | sed -e 's/\\./\\\\\\./g'`
1439    AC_COIN_CHECK_FILE([$want_dir/libtool/ltmain.sh],
1440                       [have_ltmain=yes],
1441                       [have_ltmain=no])
1442    AC_MSG_CHECKING([whether we are using the correct version ($correct_version) of libtool.])
1443    if test $have_ltmain = yes; then
1444    if $EGREP $grep_version $want_dir/libtool/ltmain.sh >/dev/null 2>&1; then
1445        AC_MSG_RESULT([yes])
1446      else
1447        AC_MSG_RESULT([no])
1448        AC_MSG_ERROR([You don't have the correct version of libtool.])
1449      fi
1450    else
1451      AC_MSG_RESULT([no])
1452      AC_MSG_ERROR([I cannot find the ltmain.sh file.])
1453    fi
1454  fi
1455
1456  # Check if we can find the libtool file
1457  if test x$AUTOTOOLS_DIR = x; then
1458    want_dir=$AUTOTOOLS_DFLT/share
1459  else
1460    want_dir=$AUTOTOOLS_DIR/share
1461  fi
1462  AC_COIN_CHECK_FILE([$want_dir/aclocal/libtool.m4],
1463                     [LIBTOOLM4="$want_dir/aclocal/libtool.m4"],
1464                     [AC_MSG_ERROR([I cannot find the libtool.m4 file.])])
1465
1466  # Check if we have an Externals file
1467  if test -r $srcdir/Externals; then
1468    coin_have_externals=yes
1469  fi
1470  # Check if subversion is installed and understands https
1471  AC_CHECK_PROG([have_svn],[svn],[yes],[no])
1472  if test x$have_svn = xyes; then
1473    AC_CACHE_CHECK([whether svn understands https],
1474                   [ac_cv_svn_understands_https],
1475                   [svn --version > confauto.out 2>&1
1476                    if $EGREP https confauto.out >/dev/null 2>&1; then
1477                      ac_cv_svn_understands_https=yes
1478                    else
1479                      ac_cv_svn_understands_https=no
1480                      have_svn=no
1481                      ac_cv_prog_have_svn=no
1482                    fi
1483                    rm -f confauto.out])
1484  fi
1485
1486  # Find the location of the BuildTools directory
1487  BUILDTOOLSDIR=
1488  if test -r $srcdir/BuildTools/coin.m4; then
1489    BUILDTOOLSDIR=$srcdir/BuildTools
1490  else
1491    if test -r $srcdir/../BuildTools/coin.m4; then
1492      BUILDTOOLSDIR=$srcdir/../BuildTools
1493    else
1494      if test -r $srcdir/../../BuildTools/coin.m4; then
1495        BUILDTOOLSDIR=$srcdir/../../BuildTools
1496      else
1497        AC_MSG_ERROR(Cannot find the BuildTools directory)
1498      fi
1499    fi
1500  fi
1501  AC_SUBST(BUILDTOOLSDIR)
1502
1503  # The following variable is set to the name of the directory where
1504  # the autotool scripts are located
1505  AC_SUBST(AUX_DIR)
1506  AUX_DIR=$ac_aux_dir
1507fi
1508
1509# helpful variable for the base directory of this package
1510abs_source_dir=`cd $srcdir; pwd`
1511AC_SUBST(abs_source_dir)
1512
1513# Stuff for example Makefiles
1514if test x$prefix = xNONE; then
1515  full_prefix=$ac_default_prefix
1516else
1517  full_prefix=$prefix
1518fi
1519full_prefix=`cd $full_prefix ; pwd`
1520AC_SUBST(abs_lib_dir)
1521abs_lib_dir=$full_prefix/lib
1522AC_SUBST(abs_include_dir)
1523abs_include_dir=$full_prefix/include
1524AC_SUBST(abs_bin_dir)
1525abs_bin_dir=$full_prefix/bin
1526
1527AM_CONDITIONAL(HAVE_EXTERNALS,
1528               test $coin_have_externals = yes && test x$have_svn = xyes)
1529
1530# AC_MSG_NOTICE([End automake initialisation.])
1531
1532]) # AC_COIN_INIT_AUTOMAKE
1533
1534###########################################################################
1535#                          COIN_CREATE_LIBTOOL                            #
1536###########################################################################
1537
1538# This does all the tests necessary to create the libtool script in the
1539# package base directory.  If this is used, then the COIN_INIT_AUTO_TOOLS
1540# test in the subdirectories will be able to skip the libtool tests and
1541# just use the one in the package base directory.
1542
1543m4_define([AC_COIN_CREATE_LIBTOOL],
1544[AC_CANONICAL_BUILD
1545
1546# Check if user wants to produce debugging code
1547AC_COIN_DEBUG_COMPILE
1548
1549# Get the name of the C compiler and appropriate compiler options
1550AC_COIN_PROG_CC
1551
1552# Get the name of the C++ compiler and appropriate compiler options
1553AC_COIN_PROG_CXX
1554
1555# Get the name of the Fortran compiler and appropriate compiler options
1556AC_COIN_PROG_F77
1557
1558# Initialize automake and libtool
1559# AC_MSG_NOTICE([Calling INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1560AC_COIN_INIT_AUTO_TOOLS
1561# AC_MSG_NOTICE([Finished INIT_AUTO_TOOLS from CREATE_LIBTOOL.])
1562])
1563
1564###########################################################################
1565#                         COIN_INIT_AUTO_TOOLS                            #
1566###########################################################################
1567
1568# Initialize the auto tools automake and libtool, with all
1569# modifications we want for COIN packages.
1570#
1571# RPATH_FLAGS        link flags for hardcoding path to shared objects
1572
1573# This is a trick to have this code before AC_COIN_PROG_LIBTOOL
1574AC_DEFUN([AC_COIN_DISABLE_STATIC],
1575[
1576# Test if force_shared has been set
1577if test "x$1" = xforce_shared; then
1578  if test x$enable_shared = xno; then
1579    AC_MSG_ERROR([Shared libraries are disabled by user, but this is not feasible with the given options])
1580  fi
1581  enable_shared=yes;
1582else
1583  # On Cygwin and AIX, building DLLs doesn't work
1584  case $build in
1585    *-cygwin*)
1586      coin_disable_shared=yes
1587      platform=Cygwin
1588    ;;
1589    *-aix*)
1590      coin_disable_shared=yes
1591      platform=AIX
1592    ;;
1593    *-mingw*)
1594      coin_disable_shared=yes
1595      platform="Msys"
1596#      case "$CXX" in
1597#        cl*)
1598#          coin_disable_shared=yes
1599#          platform="Msys with cl"
1600#      ;;
1601#      esac
1602    ;;
1603  esac
1604fi
1605if test x"$coin_disable_shared" = xyes; then
1606  if test x"$enable_shared" = xyes; then
1607    AC_MSG_WARN([On $platform, shared objects are not supported. I'm disabling your choice.])
1608  fi
1609  enable_shared=no
1610fi
1611# By default, we only want the shared objects to be compiled
1612AC_DISABLE_STATIC
1613])
1614
1615m4_define([AC_COIN_INIT_AUTO_TOOLS],
1616[{AC_BEFORE([AC_COIN_PROG_CXX],[$0])
1617AC_BEFORE([AC_COIN_PROG_CC],[$0])
1618AC_BEFORE([AC_COIN_PROG_F77],[$0])
1619
1620# START
1621AC_COIN_DISABLE_STATIC([$1])
1622
1623# Initialize automake
1624AC_COIN_INIT_AUTOMAKE
1625
1626LIBTOOL=
1627if test -r ../libtool; then
1628  coin_config_dir=..
1629  LIBTOOL='$(SHELL) $(top_builddir)/../libtool'
1630fi
1631if test "x$LIBTOOL" = x; then
1632  if test -r ../../libtool; then
1633    coin_config_dir=../..
1634    LIBTOOL='$(SHELL) $(top_builddir)/../../libtool'
1635  fi
1636fi
1637
1638if test "x$LIBTOOL" = x; then
1639# AC_MSG_NOTICE([Creating libtool script (calling COIN_PROG_LIBTOOL).])
1640  # Stuff for libtool
1641  AC_COIN_PROG_LIBTOOL
1642# AC_MSG_NOTICE([Finished COIN_PROG_LIBTOOL.])
1643  # set RPATH_FLAGS to the compiler link flags required to hardcode location
1644  # of the shared objects
1645  AC_COIN_RPATH_FLAGS($abs_lib_dir)
1646
1647else
1648
1649  AC_MSG_NOTICE([Using libtool script in directory $coin_config_dir])
1650  # get all missing information from the config.log file
1651
1652  # output variables and defines
1653  as_save_IFS=$IFS
1654  IFS='
1655'
1656  for oneline in `cat $coin_config_dir/config.status`; do
1657    case "$oneline" in
1658         # First some automake conditionals
1659      s,@am__fastdep* | s,@AR@* | s,@CPP@*  | s,@CPPFLAGS@* | s,@CXXCPP@*  | \
1660      s,@RANLIB@* | s,@STRIP@* | s,@ac_ct_AR@* | s,@ac_ct_RANLIB@* | \
1661      s,@ac_ct_STRIP@* | s,@host* | s,@LN_S@* | s,@RPATH_FLAGS@* | \
1662      s,@ac_c_preproc_warn_flag@* |  s,@ac_cxx_preproc_warn_flag@* )
1663        command=`echo $oneline | sed -e 's/^s,@//' -e 's/@,/="/' -e 's/,;t t/"/'`
1664#        echo "$command"
1665        eval "$command"
1666        ;;
1667      s,@DEFS@* )
1668        command=`echo $oneline | sed -e 's/^s,@DEFS@,/defsline="/' -e 's/,;t t/"/'`
1669#        echo "$command"
1670        eval "$command"
1671        ;;
1672    esac
1673  done
1674  IFS=$as_save_IFS
1675
1676  # And some defines (assuming here that the packages base dir
1677  # doesn't have a config.h file
1678  for word in $defsline; do
1679#    echo word $word
1680    case $word in
1681      -DHAVE_@<:@A-Z_@:>@*_H=1 | -DSTDC_HEADERS=1 )
1682        i=`echo $word | sed -e 's/-D/#define /' -e 's/=/ /'`
1683#        echo dd $i
1684        echo $i >>confdefs.h
1685        ;;
1686    esac
1687  done
1688fi
1689
1690# AC_MSG_NOTICE([End of INIT_AUTO_TOOLS.])
1691
1692# ToDo
1693# For now, don't use the -no-undefined flag, since the Makefiles are
1694# not yet set up that way.  But we need to fix this, when we want
1695# to comile DLLs under Windows.
1696LT_LDFLAGS=
1697
1698# Check if we want to set the library version
1699AC_MSG_CHECKING([if library version is set])
1700if test x"$coin_libversion" != x; then
1701  LT_LDFLAGS="$LT_LDFLAGS -version-info $coin_libversion"
1702  AC_MSG_RESULT([$coin_libversion])
1703else
1704  AC_MSG_RESULT([no])
1705fi
1706
1707AC_SUBST(LT_LDFLAGS)
1708
1709#END
1710}])
1711
1712
1713###########################################################################
1714#                      COIN_PATCH_LIBTOOL_CYGWIN                          #
1715###########################################################################
1716
1717# Patches to libtool for cygwin. Lots for cl, a few for GCC.
1718# For cl:
1719# - cygpath is not correctly quoted in fix_srcfile_path
1720# - paths generated for .lib files is not run through cygpath -w
1721
1722
1723AC_DEFUN([AC_COIN_PATCH_LIBTOOL_CYGWIN],
1724[ case "$CXX" in
1725    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1726      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
1727      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1728          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1729          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1730          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
1731          -e 's%lib /OUT:%lib -OUT:%' \
1732          -e "s%cygpath -w%$CYGPATH_W%" \
1733          -e 's%$AR x \\$f_ex_an_ar_oldlib%bla=\\`lib -nologo -list \\$f_ex_an_ar_oldlib | xargs echo '"$mydos2unix"'\\`; echo \\$bla; for i in \\$bla; do lib -nologo -extract:\\$i \\$f_ex_an_ar_oldlib; done%' \
1734          -e 's/$AR t/lib -nologo -list/' \
1735          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
1736          -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
1737          -e 's%old_archive_cmds="lib -OUT:\\$oldlib\\$oldobjs\\$old_deplibs"%old_archive_cmds="if test -r \\$oldlib; then bla=\\"\\$oldlib\\"; else bla=; fi; lib -OUT:\\$oldlib \\\\\\$bla\\$oldobjs\\$old_deplibs"%' \
1738      libtool > conftest.bla
1739
1740      mv conftest.bla libtool
1741      chmod 755 libtool
1742      ;;
1743    *)
1744      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
1745      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
1746          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
1747          -e 's|libext="lib"|libext="a"|' \
1748      libtool > conftest.bla
1749
1750      mv conftest.bla libtool
1751      chmod 755 libtool
1752      ;;
1753  esac ]) # COIN_PATCH_LIBTOOL_CYGWIN
1754
1755###########################################################################
1756#                    COIN_PATCH_LIBTOOL_SOLARIS                           #
1757###########################################################################
1758# If we want to do a 64-bit build with GCC on Solaris, the system search
1759# libraries need to point to 64-bit subdirectories. If they do not already do
1760# that, fix them. This patch is evolving, as are GCC compilers.  GCC 4.2.1
1761# reports the correct search list, given the correct call. GCC 4.1.1 does not.
1762# `Correct call' means -m64 is specified. `Correct search list' seems to amount
1763# to prepending the list of 64-bit subdirectories to the 32-bit directories.
1764# Both SPARC and x86 have this issue, but a different hardware id string is
1765# required depending on the underlying CPU. The macro executes isainfo to get
1766# the string. This will fail, of course, if we're cross-compiling. The
1767# alternative is to fail on a regular basis each time a new CPU identifier is
1768# needed. This macro will also fail if the search list reported with
1769# -print-search-dirs differs between the C, C++, and Fortran compilers; each
1770# have their own setting in libtool.  If GCC reports the correct search list
1771# given the -m64 flag, the best solution is to define CC='gcc -m64', and
1772# similarly for CXX, F77, so that libtool will make the correct call.
1773###########################################################################
1774AC_DEFUN([AC_COIN_PATCH_LIBTOOL_SOLARIS],
1775[ if test "$GCC" = yes && \
1776     (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm64' >/dev/null 2>&1) ; then
1777    hdwisa=`isainfo | sed -e 's/\(@<:@^ @:>@*\) .*$/\1/'`
1778    if `$EGREP 'sys_lib_search_path_spec=' libtool | $EGREP -v $hdwisa >/dev/null 2>&1` ; then
1779      AC_MSG_NOTICE([Applying patches to libtool for 64-bit GCC compilation])
1780      fixlibtmp=`$CC -m64 -print-search-dirs | $EGREP '^libraries:'`
1781      fixlibtmp=`echo $fixlibtmp | sed -e 's/libraries: =//' -e 's/:/ /g'`
1782      if `echo "$fixlibtmp" | $EGREP -v $hdwisa  >/dev/null 2>&1` ; then
1783        # AC_MSG_NOTICE(Compensating for broken gcc)
1784        for lib in $fixlibtmp ; do
1785          if test -d "${lib}${hdwisa}" ; then
1786            syslibpath64="$syslibpath64 ${lib}${hdwisa}/"
1787          fi
1788        done
1789        syslibpath64="${syslibpath64} ${fixlibtmp}"
1790      else
1791        syslibpath64="$fixlibtmp"
1792      fi
1793      sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="'"$syslibpath64"'"|' libtool > conftest.bla
1794      mv conftest.bla libtool
1795      chmod 755 libtool 
1796    fi
1797    # AC_MSG_NOTICE(Result is )
1798    # $EGREP 'sys_lib_search_path_spec=' libtool
1799  fi ]) # COIN_PATCH_LIBTOOL_SOLARIS
1800
1801###########################################################################
1802#                           COIN_PROG_LIBTOOL                             #
1803###########################################################################
1804
1805# Setup the libtool stuff together with any modifications to make it
1806# work on additional platforms
1807
1808AC_DEFUN([AC_COIN_LIBTOOL_WRAPPER],
1809[AC_BEFORE([AC_COIN_BLA],[$0])
1810AC_PROG_LIBTOOL])
1811
1812AC_DEFUN([AC_COIN_BLA],[echo bla])
1813
1814AC_DEFUN([AC_COIN_PROG_LIBTOOL],
1815[# No longer needed now that CPPFLAGS is correctly set -- lh, 061214 --
1816 # AC_REQUIRE([AC_COIN_DLFCN_H])
1817
1818# NEW: If libtool exists in the directory higher up, we use that one
1819#      instead of creating a new one
1820
1821# It turns out that the code for AC_PROG_LIBTOOL is somehow AC_REQUIRED
1822# out in front of this macro body. You'll notice that LIBTOOL is already
1823# defined here.  We'll have to count on this macro not being called if libtool
1824# already exists, or at least move the libtool fixes outside the conditional.
1825# AC_MSG_NOTICE([Entering coin_prog_libtool, LIBTOOL = "$LIBTOOL".])
1826# This test is therefore removed.  -- lh, 061214 --
1827# if test "x$LIBTOOL" = x; then
1828
1829# AC_MSG_NOTICE([Calling PROG_LIBTOOL.])
1830  AC_PROG_LIBTOOL
1831# AC_MSG_NOTICE([Finished PROG_LIBTOOL.])
1832  AC_SUBST(ac_c_preproc_warn_flag)
1833  AC_SUBST(ac_cxx_preproc_warn_flag)
1834
1835  AC_MSG_NOTICE([Build is "$build".])
1836  mydos2unix='| dos2unix'
1837  case $build in
1838    *-mingw*)
1839      CYGPATH_W=echo
1840      mydos2unix=
1841      ;;
1842  esac
1843
1844  case $build in
1845    # Here we need to check if -m32 is specified.  If so, we need to correct
1846    # sys_lib_search_path_spec
1847    *x86_64-*)
1848      if test "$GCC" = yes && (echo $CXXFLAGS $CFLAGS $FFLAGS | $EGREP 'm32' >& /dev/null); then
1849        AC_MSG_NOTICE(Applying patches to libtool for 32bit compilation)
1850        sed -e 's|sys_lib_search_path_spec=".*"|sys_lib_search_path_spec="/lib /usr/lib"|' libtool > conftest.bla
1851        mv conftest.bla libtool
1852        chmod 755 libtool 
1853      fi
1854      ;;
1855
1856    *-solaris*)
1857      AC_COIN_PATCH_LIBTOOL_SOLARIS
1858      ;;
1859    # Cygwin. Ah, cygwin. Too big and ugly to inline; see the macro.
1860    *-cygwin* | *-mingw*)
1861      AC_COIN_PATCH_LIBTOOL_CYGWIN
1862      ;;
1863    *-darwin*)
1864      AC_MSG_NOTICE(Applying patches to libtool for Darwin)
1865      sed -e 's/verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"/verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"/' \
1866        -e 's/ -dynamiclib / -dynamiclib -single_module /g' \
1867      libtool > conftest.bla
1868
1869      mv conftest.bla libtool
1870      chmod 755 libtool
1871      ;;
1872  esac
1873# This fi matches the commented `if test "x$LIBTOOL" = x;' up at the head of
1874# the macro. -- lh, 061214 --
1875# fi
1876
1877# AC_MSG_NOTICE([End libtool initialisation.])
1878]) # AC_COIN_PROG_LIBTOOL
1879
1880# This is a trick to force the check for the dlfcn header to be done before
1881# the checks for libtool
1882# No longer needed now that CPPFLAGS is correctly set.  -- lh, 061214 --
1883# ACDEFUN([AC_COIN_DLFCN_H],
1884# [AC_LANG_PUSH(C)
1885# AC_COIN_CHECK_HEADER([dlfcn.h])
1886# AC_LANG_POP(C)
1887# ]) # AC_COIN_DLFCN_H
1888
1889###########################################################################
1890#                            COIN_RPATH_FLAGS                             #
1891###########################################################################
1892
1893# This macro, in case shared objects are used, defines a variable
1894# RPATH_FLAGS that can be used by the linker to hardwire the library
1895# search path for the given directories.  This is useful for example
1896# Makefiles
1897
1898AC_DEFUN([AC_COIN_RPATH_FLAGS],
1899[RPATH_FLAGS=
1900
1901if test $enable_shared = yes; then
1902  case $build in
1903    *-linux-*)
1904      if test "$GXX" = "yes"; then
1905        RPATH_FLAGS=
1906        for dir in $1; do
1907          RPATH_FLAGS="$RPATH_FLAGS -Wl,--rpath -Wl,$dir"
1908        done
1909      fi ;;
1910    *-darwin*)
1911        RPATH_FLAGS=nothing ;;
1912    *-ibm-*)
1913      case "$CXX" in
1914      xlC* | */xlC* | mpxlC* | */mpxlC*)
1915        RPATH_FLAGS=nothing ;;
1916      esac ;;
1917    *-hp-*)
1918        RPATH_FLAGS=nothing ;;
1919    *-mingw32)
1920        RPATH_FLAGS=nothing ;;
1921    *-*-solaris*)
1922        RPATH_FLAGS=
1923        for dir in $1; do
1924          RPATH_FLAGS="$RPATH_FLAGS -R$dir"
1925        done
1926  esac
1927
1928  if test "$RPATH_FLAGS" = ""; then
1929    AC_MSG_WARN([Could not automatically determine how to tell the linker about automatic inclusion of the path for shared libraries.  The test examples might not work if you link against shared objects.  You will need to set the LD_LIBRARY_PATH, DYLP_LIBRARY_PATH, or LIBDIR variable manually.])
1930  fi
1931  if test "$RPATH_FLAGS" = "nothing"; then
1932    RPATH_FLAGS=
1933  fi
1934fi
1935
1936AC_SUBST(RPATH_FLAGS)
1937]) # AC_COIN_RPATH_FLAGS
1938
1939###########################################################################
1940#                        COIN_LINK_INPUT_CMD                              #
1941###########################################################################
1942
1943# This macro determines which command should be used to "link" files
1944# that are input to the generated executables.  On Windows, the codes
1945# using the native Windows system libraries, cannot understand symbolic
1946# links, and a copy should be used instead of 'ln -s'.
1947# The result is stored in coin_link_input_cmd
1948
1949AC_DEFUN([AC_COIN_LINK_INPUT_CMD],
1950[AC_REQUIRE([AC_PROG_LN_S])
1951AC_BEFORE([AC_COIN_PROG_CC], [$0])
1952AC_BEFORE([AC_COIN_ENABLE_DOSCOMPILE], [$0])
1953
1954AC_MSG_CHECKING([which command should be used to link input files])
1955coin_link_input_cmd="$LN_S"
1956if test "$enable_doscompile" = mingw; then
1957  coin_link_input_cmd=cp
1958fi
1959case "$CC" in
1960  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1961    coin_link_input_cmd=cp ;;
1962esac
1963AC_MSG_RESULT($coin_link_input_cmd)
1964])
1965
1966###########################################################################
1967#                              COIN_FINALIZE                              #
1968###########################################################################
1969
1970# This macro should be called at the very end of the configure.ac file.
1971# It creates the output files (by using AC_OUTPUT), and might do some other
1972# things (such as generating links to data files in a VPATH configuration).
1973# It also prints the "success" message.
1974# Note: If the variable coin_skip_ac_output is set to yes, then no output
1975# files are written.
1976
1977AC_DEFUN([AC_COIN_FINALIZE],
1978[
1979AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
1980if test x$coin_skip_ac_output != xyes; then
1981
1982  FADDLIBS="$ADDLIBS"
1983  if test x"$coin_need_flibs" = xyes; then
1984    ADDLIBS="$ADDLIBS $FLIBS"
1985  fi
1986
1987  # library extension
1988  AC_SUBST(LIBEXT)
1989  case "$CC" in
1990    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
1991         LIBEXT=lib ;;
1992      *) LIBEXT=a ;;
1993  esac
1994
1995  # Define VPATH_DISTCLEANFILES to be everything that needs to be
1996  # cleaned for distclean in a vpath configuration
1997  AC_SUBST(VPATH_DISTCLEANFILES)
1998  VPATH_DISTCLEANFILES="$coin_vpath_link_files"
1999
2000  # Take out subdirectories if their configuration concluded that they
2001  # don't need to be compiled
2002  if test x"$coin_ac_skip_subdirs" != x; then
2003    new_subdirs=
2004    for i in $subdirs; do
2005      skipme=no
2006      for j in $coin_ac_skip_subdirs; do
2007        if test $i = $j; then
2008          skipme=yes;
2009        fi
2010      done
2011      if test $skipme = no; then
2012        new_subdirs="$new_subdirs $i"
2013      fi
2014    done
2015    subdirs="$new_subdirs"
2016  fi
2017
2018  AC_OUTPUT
2019
2020  if test x"$coin_vpath_link_files" = x; then : ; else
2021    lnkcmd="$coin_link_input_cmd"
2022    if test "$lnkcmd" = cp; then
2023      AC_MSG_NOTICE(Copying data files for VPATH configuration)
2024    else
2025      AC_MSG_NOTICE(Creating VPATH links for data files)
2026    fi
2027    for file in $coin_vpath_link_files; do
2028      dir=`AS_DIRNAME(["./$file"])`
2029      if test -d $dir; then : ; else
2030        AS_MKDIR_P($dir)
2031      fi
2032      rm -f $file
2033      $lnkcmd $abs_source_dir/$file $file
2034    done
2035  fi
2036
2037  if test x$coin_projectdir = xyes; then
2038    AC_MSG_NOTICE([Configuration of $PACKAGE_NAME successful])
2039  else
2040    AC_MSG_NOTICE([Main configuration of $PACKAGE_NAME successful])
2041  fi
2042else
2043  AC_MSG_NOTICE([No configuration of $PACKAGE_NAME necessary])
2044fi
2045
2046]) #AC_COIN_FINALIZE
2047
2048###########################################################################
2049#                             COIN_VPATH_LINK                             #
2050###########################################################################
2051
2052# This macro makes sure that a symbolic link is created to a file in
2053# the source code directory tree if we are in a VPATH compilation, and
2054# if this package is the main package to be installed
2055
2056AC_DEFUN([AC_COIN_VPATH_LINK],
2057[AC_REQUIRE([AC_COIN_CHECK_VPATH])
2058if test $coin_vpath_config = yes; then
2059  coin_vpath_link_files="$coin_vpath_link_files $1"
2060fi
2061]) #AC_COIN_VPATH_LINK
2062
2063###########################################################################
2064#                       COIN_ENABLE_GNU_PACKAGES                          #
2065###########################################################################
2066
2067# This macro defined the --enable-gnu-packages flag.  This can be used
2068# to check if a user wants to compile GNU packges (such as readline or
2069# zlib) into the executable.  By default, GNU packages are disabled.
2070# This also defines the automake conditional COIN_ENABLE_GNU_PACKAGES
2071
2072AC_DEFUN([AC_COIN_ENABLE_GNU_PACKAGES],
2073[AC_ARG_ENABLE([gnu-packages],
2074               [AC_HELP_STRING([--enable-gnu-packages],
2075                               [compile with GNU packages (disabled by default)])],
2076               [coin_enable_gnu=$enableval],
2077               [coin_enable_gnu=no])
2078]) # AC_COIN_ENABLE_GNU_PACKAGES
2079
2080###########################################################################
2081#                           COIN_CHECK_GNU_ZLIB                           #
2082###########################################################################
2083
2084# This macro checks for the libz library.
2085
2086AC_DEFUN([AC_COIN_CHECK_GNU_ZLIB],
2087[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2088AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2089AC_BEFORE([AC_COIN_PROG_CC],[$0])
2090AC_BEFORE([AC_COIN_PROG_F77],[$0])
2091AC_BEFORE([$0],[AC_COIN_FINALIZE])
2092
2093coin_has_zlib=no
2094if test $coin_enable_gnu = yes; then
2095  AC_COIN_CHECK_HEADER([zlib.h],[coin_has_zlib=yes])
2096
2097  if test $coin_has_zlib = yes; then
2098    AC_CHECK_LIB([z],[gzopen],
2099                 [ADDLIBS="-lz $ADDLIBS"],
2100                 [coin_has_zlib=no])
2101  fi
2102
2103  if test $coin_has_zlib = yes; then
2104    AC_DEFINE([COIN_HAS_ZLIB],[1],[Define to 1 if zlib is available])
2105  fi
2106fi
2107
2108AM_CONDITIONAL(COIN_HAS_ZLIB,test x$coin_has_zlib = xyes)
2109]) # AC_COIN_CHECK_GNU_ZLIB
2110
2111
2112###########################################################################
2113#                          COIN_CHECK_GNU_BZLIB                           #
2114###########################################################################
2115
2116# This macro checks for the libbz2 library.
2117
2118AC_DEFUN([AC_COIN_CHECK_GNU_BZLIB],
2119[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2120AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2121AC_BEFORE([AC_COIN_PROG_CC],[$0])
2122AC_BEFORE([AC_COIN_PROG_F77],[$0])
2123AC_BEFORE([$0],[AC_COIN_FINALIZE])
2124
2125coin_has_bzlib=no
2126if test $coin_enable_gnu = yes; then
2127  AC_COIN_CHECK_HEADER([bzlib.h],[coin_has_bzlib=yes])
2128
2129  if test $coin_has_bzlib = yes; then
2130    AC_CHECK_LIB([bz2],[BZ2_bzReadOpen],
2131                 [ADDLIBS="-lbz2 $ADDLIBS"],
2132                 [coin_has_bzlib=no])
2133  fi
2134
2135  if test $coin_has_bzlib = yes; then
2136    AC_DEFINE([COIN_HAS_BZLIB],[1],[Define to 1 if bzlib is available])
2137  fi
2138fi
2139]) # AC_COIN_CHECK_GNU_BZLIB
2140
2141
2142###########################################################################
2143#                         COIN_CHECK_GNU_READLINE                         #
2144###########################################################################
2145
2146# This macro checks for GNU's readline.  It verifies that the header
2147# readline/readline.h is available, and that the -lreadline library
2148# contains "readline".  It is assumed that #include <stdio.h> is included
2149# in the source file before the #include<readline/readline.h>
2150
2151AC_DEFUN([AC_COIN_CHECK_GNU_READLINE],
2152[AC_REQUIRE([AC_COIN_ENABLE_GNU_PACKAGES])
2153AC_BEFORE([AC_COIN_PROG_CXX],[$0])
2154AC_BEFORE([AC_COIN_PROG_CC],[$0])
2155AC_BEFORE([AC_COIN_PROG_F77],[$0])
2156AC_BEFORE([$0],[AC_COIN_FINALIZE])
2157
2158coin_has_readline=no
2159if test $coin_enable_gnu = yes; then
2160  AC_COIN_CHECK_HEADER([readline/readline.h],
2161                       [coin_has_readline=yes],[],
2162                       [#include <stdio.h>])
2163
2164  coin_save_LIBS="$LIBS"
2165  LIBS=
2166  # First we check if tputs and friends are available
2167  if test $coin_has_readline = yes; then
2168    AC_SEARCH_LIBS([tputs],[ncurses termcap curses],[],
2169                   [coin_has_readline=no])
2170  fi
2171
2172  # Now we check for readline
2173  if test $coin_has_readline = yes; then
2174    AC_CHECK_LIB([readline],[readline],
2175                 [ADDLIBS="-lreadline $LIBS $ADDLIBS"],
2176                 [coin_has_readline=no])
2177  fi
2178
2179  if test $coin_has_readline = yes; then
2180    AC_DEFINE([COIN_HAS_READLINE],[1],[Define to 1 if readline is available])
2181  fi
2182
2183  LIBS="$coin_save_LIBS"
2184fi
2185]) # AC_COIN_CHECK_GNU_READLINE
2186
2187###########################################################################
2188#                             COIN_DATA_PATH                              #
2189###########################################################################
2190
2191# This macro defines a preprocessor macro with the absolute path to a
2192# subdirectory of Data.  The argument of this macro is the name of the
2193# subdirectory (in correct case), and the name of the macro is
2194# COIN_DATA_DIR_PATH, where dir is replaced by the capitalized name of
2195# the directory.  The path ends with a separator ("/" for linux and
2196# '\\' for Windows).  The default value for this path can be
2197# overwritten with the input variable with the same name
2198# (COIN_DATA_DIR_PATH).  At this point we chech only for the
2199# $srcdir/../Data subdirectory.
2200
2201AC_DEFUN([AC_COIN_DATA_PATH],
2202[AC_MSG_CHECKING([absolute path to data directory $1])
2203
2204AC_ARG_VAR(m4_toupper(COIN_DATA_$1_PATH),[Set to absolute path to Data/$1 subdirectory])
2205
2206if test x"$m4_toupper(COIN_DATA_$1_PATH)" = x; then
2207  m4_toupper(COIN_DATA_$1_PATH)=`cd $srcdir/../Data/$1; pwd`
2208fi
2209
2210# Under Cygwin, use Windows path.  Add separator
2211case $build in
2212  *-cygwin*)
2213    m4_toupper(COIN_DATA_$1_PATH)=`cygwin -w $m4_toupper(COIN_DATA_$1_PATH)`\\
2214    ;;
2215  *)
2216    m4_toupper(COIN_DATA_$1_PATH)="$m4_toupper(COIN_DATA_$1_PATH)/"
2217    ;;
2218esac
2219
2220if test -r $m4_toupper(COIN_DATA_$1_PATH); then
2221  AC_DEFINE_UNQUOTED(m4_toupper(COIN_DATA_$1_PATH),["$m4_toupper(COIN_DATA_$1_PATH)"],
2222            [Define to absolute path for Data subdirectory $1])
2223  AC_MSG_RESULT($m4_toupper(COIN_DATA_$1_PATH))
2224else
2225  AC_MSG_ERROR(Directory $m4_toupper(COIN_DATA_$1_PATH) does not exist)
2226fi
2227]) # AC_COIN_HAS_DATA
2228
2229###########################################################################
2230#                       COIN_LINK_FROM_FILELIST                           #
2231###########################################################################
2232
2233# This macro creates links (or copies, if necessary) to files listed
2234# as content in a text file (second argument) into a target directory
2235# (first argument), which is created if it doesn't exist yet.  If s link
2236# already exists, nothing happens.
2237
2238AC_DEFUN([AC_COIN_LINKCOPY_FROM_FILELIST],
2239[cmd="$3"
2240if test -e $srcdir/$2 ; then
2241  my_target_dir="$1"
2242  my_link_files=`cat $srcdir/$2`
2243  my_dirname=`AS_DIRNAME($2)`
2244#  if test -e $my_target_dir; then : ; else
2245#    AS_MKDIR_P($my_target_dir)
2246#  fi
2247  for i in $my_link_files; do
2248    #rm -rf $my_target_dir/$i
2249    if test -e $my_target_dir/$i; then : ; else
2250      dirn2=`AS_DIRNAME($my_target_dir/$i)`
2251      if test -e $dirn2; then : ; else
2252        AS_MKDIR_P($dirn2)
2253      fi
2254      $cmd $abs_source_dir/$my_dirname/$i $my_target_dir/$i
2255    fi
2256  done
2257else
2258  AC_MSG_WARN([File list file $2 missing!])
2259fi
2260])
2261
2262AC_DEFUN([AC_COIN_LINK_FROM_FILELIST],
2263[
2264AC_REQUIRE([AC_COIN_LINK_INPUT_CMD])
2265echo Creating links in $1 ...
2266AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, $coin_link_input_cmd)
2267])
2268
2269###########################################################################
2270#                       COIN_COPY_FROM_FILELIST                           #
2271###########################################################################
2272
2273# Like COIN_LINK_FROM_FILELIST, but copies the files.
2274
2275AC_DEFUN([AC_COIN_COPY_FROM_FILELIST],
2276[
2277echo Creating copies in $1 ...
2278AC_COIN_LINKCOPY_FROM_FILELIST($1, $2, [cp])
2279])
2280
2281###########################################################################
2282#                          COIN_EXAMPLE_FILES                             #
2283###########################################################################
2284
2285# This macro determines the names of the example files (using the
2286# argument in an "ls" command) and sets up the variables EXAMPLE_FILES
2287# and EXAMPLE_CLEAN_FILES.  If this is a VPATH configuration, it also
2288# creates soft links to the example files.
2289
2290AC_DEFUN([AC_COIN_EXAMPLE_FILES],
2291[AC_REQUIRE([AC_COIN_CHECK_GNU_ZLIB])
2292AC_REQUIRE([AC_COIN_CHECK_VPATH])
2293AC_REQUIRE([AC_COIN_ENABLE_DOSCOMPILE])
2294AC_REQUIRE([AC_PROG_LN_S])
2295
2296files=`cd $srcdir; ls $1`
2297# We need to do the following loop to make sure that are no newlines
2298# in the variable
2299for file in $files; do
2300  EXAMPLE_FILES="$EXAMPLE_FILES $file"
2301done
2302if test $coin_vpath_config = yes; then
2303  lnkcmd=
2304  if test "$enable_doscompile" != no; then
2305    lnkcmd=cp
2306  fi
2307  case "$CC" in
2308    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2309      lnkcmd=cp ;;
2310  esac
2311  if test "x$lnkcmd" = xcp; then
2312    AC_MSG_NOTICE([Copying example files ($1)])
2313  else
2314    AC_MSG_NOTICE([Creating links to the example files ($1)])
2315    lnkcmd="$LN_S"
2316  fi
2317  for file in $EXAMPLE_FILES; do
2318    rm -f $file
2319    $lnkcmd $srcdir/$file $file
2320  done
2321  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES $1"
2322else
2323  EXAMPLE_CLEAN_FILES="$EXAMPLE_CLEAN_FILES"
2324fi
2325
2326# In case there are compressed files, we create a variable with the
2327# uncompressed names
2328EXAMPLE_UNCOMPRESSED_FILES=
2329for file in $EXAMPLE_FILES; do
2330  case $file in
2331    *.gz)
2332      EXAMPLE_UNCOMPRESSED_FILES="$EXAMPLE_UNCOMPRESSED_FILES `echo $file | sed -e s/.gz//`"
2333      ;;
2334  esac
2335done
2336
2337AC_SUBST(EXAMPLE_UNCOMPRESSED_FILES)
2338AC_SUBST(EXAMPLE_FILES)
2339AC_SUBST(EXAMPLE_CLEAN_FILES)
2340]) #AC_COIN_EXAMPLE_FILES
2341
2342###########################################################################
2343#                            COIN_HAS_PROJECT                             #
2344###########################################################################
2345
2346# This macro sets up usage of a Coin package.  It defines the
2347# PKGSRCDIR and PKGOBJDIR variables, refering to the main source and
2348# object directory of the package, respectively.  It also defines
2349# a COIN_HAS_PKG preprocessor macro and makefile conditional.  The
2350# argument should be the name (Pkg) of the project (in correct lower
2351# and upper case).
2352#
2353# It is also possible to specify a preinstalled version of this Coin
2354# package.  In this case, only PKGINSTDIR is set to the prefix of that
2355# installation.  If the user is providing such a preinstalled version,
2356# this macro checks for a header (second argument) and the existance
2357# of a library file (third argument - only the stub without extension
2358# is to be given, e.g., "libCoinUtils").
2359
2360AC_DEFUN([AC_COIN_HAS_PROJECT],
2361[AC_MSG_CHECKING([for COIN project $1 in $2])
2362# First check, if the sub-project is actually available (ToDo: allow
2363# other locations)
2364
2365#replace backslashes by underscore
2366#m4_define([escape], m4_bpatsubsts([$1],[/],[_]))
2367
2368m4_tolower(coin_has_$1)=notGiven
2369if test x"$COIN_SKIP_PROJECTS" != x; then
2370  for dir in $COIN_SKIP_PROJECTS; do
2371    if test $dir = $1; then
2372      m4_tolower(coin_has_$1)=skipping
2373    fi
2374  done
2375fi
2376
2377AC_SUBST(m4_toupper($1SRCDIR))
2378AC_SUBST(m4_toupper($1OBJDIR))
2379AC_SUBST(m4_toupper($1DOCDIR))
2380AC_SUBST(m4_toupper($1DATADIR))
2381AC_SUBST(m4_toupper($1INSTDIR))
2382m4_toupper($1SRCDIR)=This_Variable_Is_Not_Set
2383m4_toupper($1OBJDIR)=This_Variable_Is_Not_Set
2384m4_toupper($1DOCDIR)=This_Variable_Is_Not_Set
2385m4_toupper($1DATADIR)=This_Variable_Is_Not_Set
2386m4_toupper($1INSTDIR)=This_Variable_Is_Not_Set
2387
2388if test $m4_tolower(coin_has_$1) != skipping; then
2389  if test $PACKAGE_TARNAME = m4_tolower($1); then
2390    m4_tolower(coin_has_$1)=.
2391  else
2392    AC_ARG_WITH([m4_tolower($1)-instdir],
2393                AC_HELP_STRING([--with-m4_tolower($1)-instdir],
2394                               [prefix of installation directory for precompiled $1 package]),
2395                [m4_tolower(coin_has_$1)=installed
2396                 if test -d "$withval"; then : ; else
2397                   AC_MSG_ERROR([argument for --with-m4_tolower($1)-instdir not a directory])
2398                 fi
2399                 m4_toupper($1INSTDIR)=`cd $withval; pwd`], [])
2400
2401    AC_ARG_WITH([m4_tolower($1)-srcdir],
2402                AC_HELP_STRING([--with-m4_tolower($1)-srcdir],
2403                               [source directory for $1 package]),
2404                [if test "$m4_tolower(coin_has_$1)" = installed; then
2405                   AC_MSG_ERROR([--with-$m4_tolower($1)-srcdir cannot be given together with --with-m4_tolower($1)-instdir])
2406                 fi
2407                 if test -d "$withval"; then : ; else
2408                   AC_MSG_ERROR([argument for --with-m4_tolower($1)-srcdir not a directory])
2409                 fi
2410                 m4_tolower(coin_has_$1)=$withval
2411                 m4_toupper($1SRCDIR)=`cd $withval; pwd`], [])
2412
2413    AC_ARG_WITH([m4_tolower($1)-objdir],
2414                AC_HELP_STRING([--with-m4_tolower($1)-objdir],
2415                               [object directory for $1 package (if different from source directory in VPATH compilation)]),
2416                [if test "$m4_tolower(coin_has_$1)" = installed; then
2417                   AC_MSG_ERROR([--with-m4_tolower($1)-objdir cannot be given together with --with-m4_tolower($1)-instdir])
2418                 fi
2419                 if test "$m4_tolower(coin_has_$1)" = notGiven; then
2420                   AC_MSG_ERROR([--with-m4_tolower($1)-objdir must be accompanied by --with-m4_tolower($1)-srcdir])
2421                 fi
2422                 if test -d "$withval"; then : ; else
2423                   AC_MSG_ERROR([argument for --with-m4_tolower($1)-objdir not a directory])
2424                 fi
2425                 m4_toupper($1OBJDIR)=`cd $withval; pwd`], [m4_toupper($1OBJDIR)="$m4_toupper($1SRCDIR)"])
2426
2427    # if we still don't have a location, check for generic flag
2428    if test "$m4_tolower(coin_has_$1)" = notGiven; then
2429      AC_ARG_WITH([coin-instdir],
2430                  AC_HELP_STRING([--with-coin-instdir],
2431                                 [prefix of installation directory for precompiled COIN packages]),
2432                  [if test -d "$withval"; then : ; else
2433                     AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
2434                   fi
2435                   m4_ifvaln([$2],
2436                     [if test -r $withval/share/doc/coin/$2/$1/README;],
2437                     [if test -r $withval/share/doc/coin/$1/README;])
2438                   then
2439                     m4_tolower(coin_has_$1)=installed
2440                     m4_toupper($1INSTDIR)=`cd $withval; pwd`
2441                   fi],
2442                   [])
2443    fi
2444
2445    # check if project can be found in $2/$1
2446    # this is for the classic setup when this macro is called from AC_COIN_MAIN_SUBDIR
2447    m4_ifvaln([$2], [fulldir=$2/$1], [fulldir=$1])
2448    if test "$m4_tolower(coin_has_$1)" = notGiven; then
2449      if test -d $srcdir/$fulldir; then
2450        m4_ifvaln([$3],
2451          [for i in $srcdir/$fulldir/$3; do
2452             if test -r $i; then
2453               m4_tolower(coin_has_$1)=$fulldir
2454             fi
2455           done],
2456          [ m4_tolower(coin_has_$1)=$fulldir ]
2457        )
2458      fi
2459    fi
2460
2461    # check if project can be found in ../$2/$1
2462    # this is for the classic setup when this macro is called from the project main directory
2463    m4_ifvaln([$2], [fulldir=../$2/$1], [fulldir=../$1])
2464    if test "$m4_tolower(coin_has_$1)" = notGiven; then
2465      if test -d $srcdir/$fulldir; then
2466        m4_ifvaln([$3],
2467          [for i in $srcdir/$fulldir/$3; do
2468             if test -r $i; then
2469               m4_tolower(coin_has_$1)=$fulldir
2470             fi
2471           done],
2472          [ m4_tolower(coin_has_$1)=$fulldir ]
2473        )
2474      fi
2475    fi
2476  fi
2477fi
2478
2479if test $m4_tolower(coin_has_$1) != notGiven &&
2480   test $m4_tolower(coin_has_$1) != skipping; then
2481  # Set the #define if the component is available
2482  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
2483
2484  if test $m4_tolower(coin_has_$1) = installed; then
2485    m4_ifvaln([$2],
2486      [m4_toupper($1DOCDIR)=$m4_toupper($1INSTDIR)/share/doc/coin/$2/$1
2487       m4_toupper($1DATADIR)=$m4_toupper($1INSTDIR)/share/coin/$2/$1],
2488      [m4_toupper($1DOCDIR)=$m4_toupper($1INSTDIR)/share/doc/coin/$1
2489       m4_toupper($1DATADIR)=$m4_toupper($1INSTDIR)/share/coin/$1])
2490  else
2491    if test "$m4_toupper($1OBJDIR)" = This_Variable_Is_Not_Set; then
2492      # Set the variables for source and object code location
2493      m4_toupper($1SRCDIR)=`cd $srcdir/$m4_tolower(coin_has_$1); pwd`
2494      m4_toupper($1OBJDIR)=`pwd`/$m4_tolower(coin_has_$1)
2495      m4_ifvaln([$2],
2496        [m4_toupper($1DOCDIR)=$abs_lib_dir/../share/doc/coin/$2/$1],
2497        [m4_toupper($1DOCDIR)=$abs_lib_dir/../share/doc/coin/$1])
2498      m4_toupper($1DATADIR)=$m4_toupper($1OBJDIR)
2499    else
2500      # This is just a guess:
2501      m4_ifvaln([$2],
2502        [m4_toupper($1DOCDIR)=$m4_toupper($1OBJDIR)/../share/doc/coin/$2/$1
2503         m4_toupper($1DATADIR)=$m4_toupper($1OBJDIR)/../share/coin/$2/$1],
2504        [m4_toupper($1DOCDIR)=$m4_toupper($1OBJDIR)/../share/doc/coin/$1
2505         m4_toupper($1DATADIR)=$m4_toupper($1OBJDIR)/../share/coin/$1])
2506    fi
2507  fi
2508fi
2509
2510# Define the Makefile conditional
2511AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
2512               [test $m4_tolower(coin_has_$1) != notGiven &&
2513                test $m4_tolower(coin_has_$1) != skipping])
2514AM_CONDITIONAL(m4_toupper(COIN_HAS_$1_PREINSTALLED),
2515               [test $m4_tolower(coin_has_$1) = installed])
2516
2517if test $m4_tolower(coin_has_$1) = installed; then
2518  AC_MSG_RESULT([installed in $m4_toupper($1INSTDIR)])
2519  m4_ifvaln([$2],
2520    [AC_COIN_CHECK_FILE([$m4_toupper($1INSTDIR)/share/doc/coin/$2/$1/README],[],[AC_MSG_ERROR([$m4_toupper($1INSTDIR)/share/doc/coin/$2/$1/README should be available if $1 is installed])])],
2521    [AC_COIN_CHECK_FILE([$m4_toupper($1INSTDIR)/share/doc/coin/$1/README],[],[AC_MSG_ERROR([$m4_toupper($1INSTDIR)/share/doc/coin/$1/README should be available if $1 is installed])])]
2522  )
2523else
2524  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
2525  if test $m4_tolower(coin_has_$1) != notGiven &&
2526     test $m4_tolower(coin_has_$1) != skipping; then
2527    AC_MSG_CHECKING([for source code location of $1])
2528    AC_MSG_RESULT([$m4_toupper($1SRCDIR)])
2529    AC_MSG_CHECKING([for object code location of $1])
2530    AC_MSG_RESULT([$m4_toupper($1OBJDIR)])
2531  fi
2532fi
2533]) # AC_COIN_HAS_PROJECT
2534
2535###########################################################################
2536#                        COIN_HAS_USER_LIBRARY                            #
2537###########################################################################
2538# This macro sets up usage of a user library with header files. The assumption
2539# is that the header file(s) and library do not reside in standard system
2540# directories, hence both the include directory and link flags must be
2541# specified. There are two mandatory arguments and two optional arguments.
2542#
2543# The first argument (mandatory) should be a name (LibraryName) for the
2544# library.  The second argument (mandatory) should be an abbreviation in
2545# upper case letters (LBRY) for the library. Ultimately, the macro will
2546# specify two variables, LBRYINCDIR and LBRYLIB, to be substituted in files
2547# generated during configuration; a preprocessor symbol COIN_HAS_LBRY; and a
2548# matching automake conditional COIN_HAS_LBRY. LBRYINCDIR should specify the
2549# directory containing include files for the library. LBRYLIB should specify
2550# the flags necessary to link to the library. A variable coin_has_lbry will
2551# be set to true or false, as appropriate. A variable lbry_libcheck will be
2552# be set to yes or no; no indicates link checks should not be attempted.
2553#
2554# The macro defines three configure arguments, --with-libraryname-incdir,
2555# --with-libraryname-lib, and --disable-libraryname-libcheck, by converting
2556# LibraryName to lower case.
2557#
2558# LBRYINCDIR and LBRYLIB can be specified as environment variables or as
2559# part of the configure command using --with-libraryname-incdir and
2560# --with-libraryname-lib, respectively. Command line arguments override
2561# environment variables.
2562#
2563# If a third argument is given, it should specify a file in LBRYINCDIR.  The
2564# macro will check for the presence of the file. If a fourth argument is given,
2565# it should specify a function name, `fname'.  The macro will attempt to link a
2566# trivial program containing a parameterless call to the function, `fname()',
2567# using the LBRYLIB flags. The link check uses C as the language; this has been
2568# adequate to date but has limitations. It is possible to disable the link
2569# check by specifying --disable-libraryname-libcheck. This is a workaround for
2570# instances where the link check does not work properly, for whatever reason.
2571# If you're trying to link to a Fortran library, consider using F77_FUNC or
2572# FC_FUNC to obtain a mangled fname appropriate for use from C code. For a C++
2573# library, you're on your own unless the library declares some function with
2574# extern "C" linkage. Otherwise, you'll have to somehow find the mangled C++
2575# name.
2576
2577AC_DEFUN([AC_COIN_HAS_USER_LIBRARY],
2578[ AC_REQUIRE([AC_COIN_PROJECTDIR_INIT])
2579  AC_MSG_CHECKING(if user provides library for $1)
2580
2581# Check for header file directory
2582
2583  AC_ARG_WITH(m4_tolower($1)-incdir,
2584      AS_HELP_STRING([--with-m4_tolower($1)-incdir],
2585                     [specify the header file directory for library $1]),
2586      [$2INCDIR=`cd $withval; pwd`])
2587
2588# Check for library directory
2589
2590  AC_ARG_WITH(m4_tolower($1)-lib,
2591      AS_HELP_STRING([--with-m4_tolower($1)-lib],
2592                     [specify the flags used to link with the library $1]),
2593      [$2LIB=$withval])
2594
2595# Switch to disable library check if requested
2596
2597  AC_ARG_ENABLE(m4_tolower($1)-libcheck,
2598      AS_HELP_STRING([--enable-m4_tolower($1)-libcheck],
2599                     [use disable-m4_tolower($1)-libcheck to skip the link
2600                      check at configuration time]),
2601      [m4_tolower($1)_libcheck=$enableval],
2602      [m4_tolower($1)_libcheck=yes])
2603
2604# At this point, if we're going to use the library, both LBRYINCDIR and
2605# LBRYLIB must be defined and not empty.
2606
2607  if test x"$$2INCDIR" != x || test x"$$2LIB" != x; then
2608    if test x"$$2INCDIR" = x || test x"$$2LIB" = x; then
2609      AC_MSG_ERROR([You need to specify both an include directory and link flags to use library $1. Use --with-m4_tolower($1)-incdir of environment variable $$2INCDIR to specify the include directory. Use --with-m4_tolower($1)-lib or environment variable $$2LIB to specify link flags.])
2610    fi
2611    m4_tolower(coin_has_$2)=true
2612    AC_MSG_RESULT(yes)
2613  else
2614    m4_tolower(coin_has_$2)=false
2615    AC_MSG_RESULT(no)
2616  fi
2617
2618# If we have instructions for use, consider header and link checks.
2619
2620  if test $m4_tolower(coin_has_$2) = true; then
2621
2622# If argument 3 (file) is given, check for the file. Typically this will be a
2623# header file, but that's not assumed.
2624
2625    m4_ifval([$3],
2626        [AC_COIN_CHECK_FILE([$$2INCDIR/$3],[],
2627             [AC_MSG_ERROR([Cannot find file $3 in $$2INCDIR])])])
2628
2629# Now see if we can link the function. There are arguments for and against
2630# assuming argument 3 is a header file declaring the function. A correct
2631# function declaration is the main argument in favour. Having to cope with
2632# possible dependencies or other oddities are the main arguments against.
2633# Force the use of C as the best single choice amongst C++, C, and Fortran.
2634# Obviously, this has limits.
2635
2636    m4_ifvaln([$4],
2637        [if test x"$m4_tolower($1)_libcheck" != xno; then
2638           coin_save_LIBS="$LIBS"
2639           LIBS="$$2LIB $ADDLIBS"
2640           coin_$2_link=no
2641           AC_LANG_PUSH(C)
2642           for fnm in $4 ; do
2643             AC_MSG_CHECKING([whether symbol $fnm is available with $2])
2644             AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[$fnm()]])],
2645                 [AC_MSG_RESULT(yes)
2646                  coin_$2_link=yes
2647                  break],
2648                 [AC_MSG_RESULT(no)])
2649           done
2650           AC_LANG_POP(C)
2651           if test x"$coin_$2_link" = xyes ; then
2652             LIBS="$coin_save_LIBS"
2653           else
2654             AC_MSG_ERROR([Cannot find symbol(s) $4 with $2])
2655           fi
2656         fi])
2657
2658# If we make it this far, we've verified the file and linked the function. Add
2659# the necessary link flags to ADDLIBS and define the preprocessor symbol
2660# COIN_HAS_LBRY.
2661
2662    ADDLIBS="$$2LIB $ADDLIBS"
2663    AC_DEFINE(COIN_HAS_$2,[1],[Define to 1 if the $1 package is available])
2664  fi
2665
2666# Arrange for configure to substitute LBRYINCDIR and LBRYLIB and create the
2667# automake conditional. These actions must occur unconditionally.
2668
2669  AC_SUBST($2INCDIR)
2670  AC_SUBST($2LIB)
2671  AM_CONDITIONAL(COIN_HAS_$2, test $m4_tolower(coin_has_$2) = true)
2672]) #AC_COIN_HAS_USER_LIBRARY
2673
2674###########################################################################
2675#                               COIN_HAS_ASL                              #
2676###########################################################################
2677
2678# This macro checks if the user has provide arguments that say where
2679# the precompiled ASL files should be found (with the --with-asldir
2680# flag).  If this is not the case, we check if the ThirdParty/ASL
2681# directory has been configured, which indicates that the files will
2682# be in that directory and can be used.
2683
2684AC_DEFUN([AC_COIN_HAS_ASL],
2685[coin_aslobjdir=../ThirdParty/ASL
2686coin_aslsrcdir=$srcdir/$coin_aslobjdir
2687
2688# Determine the name of the ASL library
2689case "$CC" in
2690  cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2691    ampllib=amplsolv.lib ;;
2692  *)
2693    ampllib=amplsolver.a ;;
2694esac
2695
2696AC_ARG_WITH([asldir],
2697            AC_HELP_STRING([--with-asldir],
2698                           [specify path to AMPL solver directory (or BUILD for compilation, or "no" for disabling AMPL)]),
2699            [use_asldir=$withval], [use_asldir=])
2700
2701if test "$use_asldir" = BUILD; then
2702  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2703    # If we are configuring ThirdParty/ASL, don't check
2704    if test -r $coin_aslobjdir/.MakeOk; then :; else
2705      AC_MSG_ERROR([option \"BUILD\" specified for asldir, but directory is not configure (sources missing?)])
2706    fi
2707  fi
2708elif test -z "$use_asldir"; then
2709 # try to find sources - if not given don't compile
2710  if test "$PACKAGE_NAME" != ThirdPartyASL; then
2711    if test -r $coin_aslobjdir/.MakeOk; then
2712      use_asldir=BUILD
2713    else
2714      use_asldir=no
2715    fi
2716  else
2717    use_asldir=no
2718  fi
2719elif test "$use_asldir" != "no"; then
2720  AC_COIN_CHECK_FILE([$use_asldir/$ampllib],[],
2721                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but library missing])])
2722  AC_COIN_CHECK_FILE([$use_asldir/asl.h],[],
2723                     [AC_MSG_ERROR([ASL directory \"$use_asldir\" specified, but header files are missing])])
2724  use_asldir=`cd $use_asldir; pwd`
2725  case $build in
2726    *-cygwin*) use_asldir=`cygpath -w $use_asldir | sed -e sX\\\\\\\\X/Xg` ;;
2727  esac
2728fi
2729
2730# Variable containing ASL library (including full path)
2731AC_SUBST(ASLLIB)
2732# Variable containing flags for including ASL header files
2733AC_SUBST(ASL_CPPFLAGS)
2734
2735if test "$use_asldir" = BUILD; then
2736  coin_aslobjdir=`cd $coin_aslobjdir; pwd`
2737  ASLLIB=`$CYGPATH_W $coin_aslobjdir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2738  coin_aslsrcdir=`cd $coin_aslsrcdir; pwd`
2739  ASL_CPPFLAGS="-I"`$CYGPATH_W $coin_aslobjdir | sed -e sX\\\\\\\\X/Xg`" -I"`$CYGPATH_W $coin_aslsrcdir/solvers | sed -e sX\\\\\\\\X/Xg`
2740elif test "$use_asldir" != no; then
2741  ASLLIB=`$CYGPATH_W $use_asldir/$ampllib | sed -e sX\\\\\\\\X/Xg`
2742  ASL_CPPFLAGS="-I"`$CYGPATH_W $use_asldir | sed -e sX\\\\\\\\X/Xg`
2743fi
2744
2745if test "$use_asldir" != no; then
2746  AC_LANG_PUSH(C)
2747  AC_CHECK_LIB(dl,[dlopen],[ASLLIB="$ASLLIB -ldl"],[])
2748  coin_has_asl=yes
2749  AC_DEFINE([COIN_HAS_ASL],[1],
2750            [If defined, the Ampl Solver Library is available.])
2751  AC_LANG_POP(C)
2752else
2753  coin_has_asl=no
2754fi
2755AM_CONDITIONAL(COIN_HAS_ASL, test $coin_has_asl = yes)
2756]) # AC_COIN_HAS_ASL
2757
2758###########################################################################
2759#                            COIN_TRY_FLINK                               #
2760###########################################################################
2761
2762# Auxilliary macro to test if a Fortran function name can be linked,
2763# given the current settings of LIBS.  We determine from the context, what
2764# the currently active programming language is, and cast the name accordingly.
2765# The first argument is the name of the function/subroutine, in small letters,
2766# the second argument are the actions taken when the test works, and the
2767# third argument are the actions taken if the test fails.
2768
2769AC_DEFUN([AC_COIN_TRY_FLINK],
2770[case $ac_ext in
2771  f)
2772    AC_TRY_LINK(,[      call $1],[$2],[$3])
2773    ;;
2774  c)
2775    AC_F77_FUNC($1,cfunc$1)
2776    if test x"$coin_need_flibs" = xyes; then
2777      flink_try=no;
2778    else
2779      AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2780                  [flink_try=yes],[flink_try=no])
2781    fi
2782    if test $flink_try = yes; then
2783      $2
2784    else
2785      if test x"$FLIBS" != x; then
2786        flink_save_libs="$LIBS"
2787        LIBS="$LIBS $FLIBS"
2788        AC_TRY_LINK([void $cfunc$1();],[$cfunc$1()],
2789                    [LIBS="$flink_save_libs"
2790                     $2
2791                     coin_need_flibs=yes],
2792                    [LIBS="$flink_save_libs"
2793                     $3])
2794      else
2795        $3
2796      fi
2797    fi
2798    ;;
2799  cc|cpp)
2800    AC_F77_FUNC($1,cfunc$1)
2801    if test x"$coin_need_flibs" = xyes; then
2802      flink_try=no;
2803    else
2804      AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2805                  [flink_try=yes],[flink_try=no])
2806    fi
2807    if test $flink_try = yes; then
2808      $2
2809    else
2810      if test x"$FLIBS" != x; then
2811        flink_save_libs="$LIBS"
2812        LIBS="$LIBS $FLIBS"
2813        AC_TRY_LINK([extern "C" {void $cfunc$1();}],[$cfunc$1()],
2814                    [LIBS="$flink_save_libs"
2815                     $2
2816                     coin_need_flibs=yes],
2817                    [LIBS="$flink_save_libs"
2818                     $3])
2819      else
2820        $3
2821      fi
2822    fi
2823    ;;
2824esac
2825]) # AC_COIN_TRY_FLINK
2826
2827###########################################################################
2828#                             COIN_HAS_BLAS                               #
2829###########################################################################
2830
2831# This macro checks for a library containing the BLAS library.  It
2832# tries standard libraries, and if none is found to be working, it
2833# checks whether the BLAS ThirdParty/Blas directory has been configured.
2834# It adds to ADDLIBS any flags required to link with an externally provided
2835# BLAS.  It defines the makefile conditional and preprocessor macro
2836# COIN_HAS_BLAS, if blas is available, and it defines the makefile conditional
2837# COIN_BUILD_BLAS, if blas is compiled within COIN.
2838
2839AC_DEFUN([AC_COIN_HAS_BLAS],
2840[if test "$PACKAGE_NAME" = ThirdPartyBlas || test "$PACKAGE_NAME" = ThirdPartyLapack || test "$PACKAGE_NAME" = ThirdPartyMumps; then
2841  coin_blasobjdir=../Blas
2842else
2843  coin_blasobjdir=../ThirdParty/Blas
2844fi
2845coin_blassrcdir=$srcdir/$coin_blasobjdir
2846
2847AC_ARG_WITH([blas],
2848            AC_HELP_STRING([--with-blas],
2849                           [specify BLAS library (or BUILD for compilation)]),
2850            [use_blas=$withval], [use_blas=])
2851
2852MAKEOKFILE=.MakeOk
2853# Check if user supplied option makes sense
2854if test x"$use_blas" != x; then
2855  if test "$use_blas" = "BUILD"; then
2856    # Don't check for course code if this is executed in ThirdParty/Blas
2857    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2858      if test -r $coin_blasobjdir/.MakeOk; then :; else
2859        AC_MSG_ERROR([option \"BUILD\" specified for Blas, but $coin_blasobjdir directory is not properly configured])
2860      fi
2861    fi
2862  elif test "$use_blas" != no ; then
2863    AC_MSG_CHECKING([whether user supplied BLASLIB=\"$use_blas\" works])
2864    LIBS="$use_blas $LIBS"
2865    ADDLIBS="$use_blas $ADDLIBS"
2866    AC_COIN_TRY_FLINK([daxpy],
2867                      [AC_MSG_RESULT([yes])],
2868                      [AC_MSG_RESULT([no])
2869                       AC_MSG_ERROR([user supplied BLAS library \"$use_blas\" does not work])])
2870  fi
2871else
2872# Try to autodetect the library for blas based on build system
2873  #AC_MSG_CHECKING([default locations for BLAS])
2874  skip_lblas_check=no
2875  case $build in
2876    *-sgi-*)
2877      SAVE_LIBS="$LIBS"
2878      AC_MSG_CHECKING([whether -lcomplib.sgimath has BLAS])
2879      LIBS="-lcomplib.sgimath $LIBS"
2880      AC_COIN_TRY_FLINK([daxpy],
2881                        [AC_MSG_RESULT([yes])
2882                         use_blas=-lcomplib.sgimath;
2883                         ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
2884                        [AC_MSG_RESULT([no])
2885                         SAVE_LIBS="$LIBS"])
2886      ;;
2887
2888# Ideally, we'd use -library=sunperf, but it's an imperfect world. Studio
2889# cc doesn't recognise -library, it wants -xlic_lib. Studio 12 CC doesn't
2890# recognise -xlic_lib. Libtool doesn't like -xlic_lib anyway. Sun claims
2891# that CC and cc will understand -library in Studio 13. The main extra
2892# function of -xlic_lib and -library is to arrange for the Fortran run-time
2893# libraries to be linked for C++ and C. We can arrange that explicitly.
2894    *-*-solaris*)
2895      SAVE_LIBS="$LIBS"
2896      AC_MSG_CHECKING([for BLAS in libsunperf])
2897      LIBS="-lsunperf $FLIBS $LIBS"
2898      AC_COIN_TRY_FLINK([daxpy],
2899                        [AC_MSG_RESULT([yes])
2900                         use_blas='-lsunperf'
2901                         ADDLIBS="-lsunperf $ADDLIBS"
2902                         coin_need_flibs=yes],
2903                        [AC_MSG_RESULT([no])
2904                         LIBS="$SAVE_LIBS"])
2905      ;;
2906    *-cygwin* | *-mingw*)
2907# On cygwin, consider -lblas only if doscompile is disabled. The prebuilt
2908# library will want to link with cygwin, hence won't run standalone in DOS.
2909      if test "$enable_doscompile" = mingw; then
2910        skip_lblas_check=yes
2911      fi
2912      case "$CC" in
2913        cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
2914          SAVE_LIBS="$LIBS"
2915          AC_MSG_CHECKING([for BLAS in MKL])
2916          LIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $LIBS"
2917          AC_COIN_TRY_FLINK([daxpy],
2918                            [AC_MSG_RESULT([yes])
2919                             use_blas='mkl_intel_c.lib mkl_sequential.lib mkl_core.lib'
2920                             ADDLIBS="mkl_intel_c.lib mkl_sequential.lib mkl_core.lib $ADDLIBS"],
2921                            [AC_MSG_RESULT([no])
2922                             LIBS="$SAVE_LIBS"])
2923          ;;
2924      esac
2925      ;;
2926  esac
2927
2928  if test -z "$use_blas" && test $skip_lblas_check = no; then
2929    SAVE_LIBS="$LIBS"
2930    AC_MSG_CHECKING([whether -lblas has BLAS])
2931    LIBS="-lblas $LIBS"
2932    AC_COIN_TRY_FLINK([daxpy],
2933                      [AC_MSG_RESULT([yes])
2934                       ADDLIBS="-lblas $ADDLIBS"
2935                       use_blas='-lblas'],
2936                      [AC_MSG_RESULT([no])
2937                       LIBS="$SAVE_LIBS"])
2938  fi
2939
2940# If we have no other ideas, consider building BLAS.
2941  if test -z "$use_blas"; then
2942    if test "$PACKAGE_NAME" != ThirdPartyBlas; then
2943      if test -r $coin_blasobjdir/.MakeOk; then
2944        use_blas=BUILD
2945      fi
2946    fi
2947  fi
2948fi
2949
2950if test "$use_blas" = BUILD; then
2951  coin_need_flibs=yes
2952fi
2953
2954AM_CONDITIONAL([COIN_HAS_BLAS],[test x"$use_blas" != x])
2955AM_CONDITIONAL([COIN_BUILD_BLAS],[test "$use_blas" = BUILD])
2956
2957if test x"$use_blas" = x || test "$use_blas" = no; then
2958  coin_has_blas=no
2959else
2960  coin_has_blas=yes
2961  AC_DEFINE([COIN_HAS_BLAS],[1],
2962            [If defined, the BLAS Library is available.])
2963fi
2964]) # AC_COIN_HAS_BLAS
2965
2966###########################################################################
2967#                            COIN_HAS_LAPACK                              #
2968###########################################################################
2969
2970# This macro checks for a library containing the LAPACK library.  It
2971# tries standard libraries, and if none is found to be working, it
2972# checks whether the LAPACK ThirdParty/Lapack directory has been
2973# configured.  It adds to ADDLIBS any flags required to link with an
2974# externally provided LAPACK.  It defines the makefile conditional and
2975# preprocessor macro COIN_HAS_LAPACK, if lapack is available, and it
2976# defines the makefile conditional COIN_BUILD_LAPACK, if lapack is
2977# compiled within COIN.
2978
2979AC_DEFUN([AC_COIN_HAS_LAPACK],
2980[coin_lapackobjdir=../ThirdParty/Lapack
2981coin_lapacksrcdir=$srcdir/$coin_lapackobjdir
2982
2983AC_ARG_WITH([lapack],
2984            AC_HELP_STRING([--with-lapack],
2985                           [specify LAPACK library (or BUILD for compilation)]),
2986            [use_lapack=$withval], [use_lapack=])
2987
2988# Check if user supplied option makes sense
2989if test x"$use_lapack" != x; then
2990  if test "$use_lapack" = "BUILD"; then
2991    # Don't check for course code if this is executed in ThirdParty/Lapack
2992    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
2993      if test -r $coin_lapackobjdir/.MakeOk; then :; else
2994        AC_MSG_ERROR([option \"BUILD\" specified for LAPACK, but $coin_lapackobjdir directory is not configured])
2995      fi
2996    fi
2997  elif test "$use_lapack" != no; then
2998    AC_MSG_CHECKING([whether user supplied LAPACKLIB=\"$use_lapack\" works])
2999    LIBS="$use_lapack $LIBS"
3000    ADDLIBS="$use_lapack $ADDLIBS"
3001    AC_COIN_TRY_FLINK([dsyev],
3002                      [AC_MSG_RESULT([yes])],
3003                      [AC_MSG_RESULT([no])
3004                       AC_MSG_ERROR([user supplied LAPACK library \"$use_lapack\" does not work])])
3005  fi
3006else
3007  if test x$coin_has_blas = xyes; then
3008    # First try to see if LAPACK is already available with BLAS library
3009    AC_MSG_CHECKING([whether LAPACK is already available with BLAS library])
3010    AC_COIN_TRY_FLINK([dsyev],
3011                      [AC_MSG_RESULT([yes]); use_lapack=ok],
3012                      [AC_MSG_RESULT([no])])
3013  fi
3014  skip_llapack_check=no
3015  if test -z "$use_lapack"; then
3016    # Try to autodetect the library for lapack based on build system
3017    case $build in
3018      *-sgi-*)
3019        SAVE_LIBS="$LIBS"
3020        AC_MSG_CHECKING([whether -lcomplib.sgimath has LAPACK])
3021        LIBS="-lcomplib.sgimath $LIBS"
3022        AC_COIN_TRY_FLINK([dsyev],
3023                          [AC_MSG_RESULT([yes])
3024                           use_lapack=-lcomplib.sgimath;
3025                           ADDLIBS="-lcomplib.sgimath $ADDLIBS"],
3026                          [AC_MSG_RESULT([no])
3027                           SAVE_LIBS="$LIBS"])
3028        ;;
3029
3030# See comments in COIN_HAS_BLAS.
3031      *-*-solaris*)
3032      SAVE_LIBS="$LIBS"
3033      AC_MSG_CHECKING([for LAPACK in libsunperf])
3034      LIBS="-lsunperf $FLIBS $LIBS"
3035      AC_COIN_TRY_FLINK([dsyev],
3036                        [AC_MSG_RESULT([yes])
3037                         use_blas='-lsunperf'
3038                         ADDLIBS="-lsunperf $ADDLIBS"
3039                         coin_need_flibs=yes],
3040                        [AC_MSG_RESULT([no])
3041                         LIBS="$SAVE_LIBS"])
3042        ;;
3043# On cygwin, do this check only if doscompile is disabled. The prebuilt library
3044# will want to link with cygwin, hence won't run standalone in DOS.
3045      *-cygwin*)
3046        if test "$enable_doscompile" = mingw; then
3047          skip_llapack_check=yes
3048        fi
3049        ;;
3050    esac
3051  fi
3052
3053  if test -z "$use_lapack" && test $skip_llapack_check = no; then
3054    SAVE_LIBS="$LIBS"
3055    AC_MSG_CHECKING([whether -llapack has LAPACK])
3056    LIBS="-llapack $LIBS"
3057    AC_COIN_TRY_FLINK([dsyev],
3058                      [AC_MSG_RESULT([yes])
3059                       ADDLIBS="-llapack $ADDLIBS"
3060                       use_lapack='-llapack'],
3061                      [AC_MSG_RESULT([no])
3062                       LIBS="$SAVE_LIBS"])
3063  fi
3064
3065# If we have no other ideas, consider building LAPACK.
3066  if test -z "$use_lapack"; then
3067    if test "$PACKAGE_NAME" != ThirdPartyLapack; then
3068      if test -r $coin_lapackobjdir/.MakeOk; then
3069        use_lapack=BUILD
3070      fi
3071    fi
3072  fi
3073fi
3074
3075if test "$use_lapack" = BUILD; then
3076  coin_need_flibs=yes
3077fi
3078
3079AM_CONDITIONAL([COIN_HAS_LAPACK],[test x"$use_lapack" != x])
3080AM_CONDITIONAL([COIN_BUILD_LAPACK],[test "$use_lapack" = BUILD])
3081
3082if test x"$use_lapack" = x || test "$use_lapack" = no; then
3083  coin_has_lapack=no
3084else
3085  coin_has_lapack=yes
3086  AC_DEFINE([COIN_HAS_LAPACK],[1],
3087            [If defined, the LAPACK Library is available.])
3088fi
3089]) # AC_COIN_HAS_LAPACK
3090
3091###########################################################################
3092#                            COIN_HAS_MUMPS                               #
3093###########################################################################
3094
3095# This macro checks for a library containing the MUMPS library.  It
3096# checks if the user has provided an argument for the MUMPS library,
3097# and if not, it checks whether the MUMPS ThirdParty/Mumps directory has
3098# been configured.  It adds to ADDLIBS any flags required to link with
3099# an externally provided MUMPS.  It defines the makefile conditional
3100# and preprocessor macro COIN_HAS_MUMPS, if MUMPS is available, and it
3101# defines the makefile conditional COIN_BUILD_MUMPS, if MUMPS is
3102# compiled within COIN.
3103
3104AC_DEFUN([AC_COIN_HAS_MUMPS],
3105[
3106if test "$PACKAGE_NAME" = ThirdPartyMumps; then
3107  coin_mumpsobjdir=../Mumps
3108else
3109  coin_mumpsobjdir=../ThirdParty/Mumps
3110fi
3111coin_mumpssrcdir=$abs_source_dir/$coin_mumpsobjdir/MUMPS
3112
3113MAKEOKFILE=.MakeOk
3114
3115#check if user provides a MUMPS library (that works)
3116AC_LANG_PUSH(C)
3117SAVE_ADDLIBS="$ADDLIBS"
3118ADDLIBS="$ADDLIBS $FLIBS"
3119AC_COIN_HAS_USER_LIBRARY(mumps, MUMPS, dmumps_c.h, dmumps_c)
3120ADDLIBS="$SAVE_ADDLIBS"
3121AC_LANG_POP(C)
3122
3123if test "$coin_has_mumps" = "true"; then  # user provided mumps library
3124  use_mumps=yes
3125  coin_has_mumps=yes
3126
3127  MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $MUMPSINCDIR\`"
3128  ADDLIBS="$MUMPSLIB $ADDLIBS"
3129
3130else # no user provided library, so we try to build our own
3131  use_mumps=BUILD
3132
3133  # Check if the MUMPS' ThirdParty project has been configured
3134  if test "$PACKAGE_NAME" != ThirdPartyMumps; then
3135    if test -r $coin_mumpsobjdir/.MakeOk; then
3136      use_mumps=BUILD
3137      # Mumps needs pthreads
3138      AC_LANG_PUSH(C)
3139      save_LIBS="$LIBS"
3140      LIBS="$LIBS $FLIBS"
3141      AC_CHECK_LIB([pthread],[pthread_create],[LIBS="-lpthread $save_LIBS"; ADDLIBS="-lpthread $ADDLIBS"],[LIBS="save_LIBS"])
3142      AC_LANG_POP(C)
3143 
3144      MUMPS_INCFLAGS="-I\`\$(CYGPATH_W) $coin_mumpssrcdir/libseq\` -I\`\$(CYGPATH_W) $coin_mumpssrcdir/include\`"
3145    else
3146      use_mumps=
3147    fi
3148  fi
3149
3150  # if a user provided library is used, then COIN_HAS_USER_LIBRARY takes care of the COIN_HAS_MUMPS conditional and preprocessor symbol
3151  AM_CONDITIONAL([COIN_HAS_MUMPS],[test x"$use_mumps" != x])
3152  if test x"$use_mumps" != x; then
3153    AC_DEFINE([COIN_HAS_MUMPS],[1],[If defined, the MUMPS Library is available.])
3154    coin_has_mumps=yes
3155  else
3156    coin_has_mumps=no
3157  fi
3158  AC_MSG_CHECKING([whether MUMPS is available])
3159  AC_MSG_RESULT([$coin_has_mumps])
3160fi
3161
3162if test x"$use_mumps" != x; then
3163  # we need the Fortran runtime libraries if we want to link with C/C++
3164  coin_need_flibs=yes
3165
3166  AC_SUBST(MUMPS_INCFLAGS)
3167fi
3168
3169AM_CONDITIONAL([COIN_BUILD_MUMPS],[test "$use_mumps" = BUILD])
3170
3171]) # AC_COIN_HAS_MUMPS
3172
3173###########################################################################
3174#                            COIN_HAS_METIS                               #
3175###########################################################################
3176
3177# This macro checks for a library containing the METIS library.  It
3178# checks if the user has provided an argument for the METIS library,
3179# and if not, it checks whether the METIS ThirdParty/Metis directory has
3180# been configured.  It adds to ADDLIBS any flags required to link with
3181# an externally provided METIS.  It defines the makefile conditional
3182# and preprocessor macro COIN_HAS_METIS, if METIS is available, and it
3183# defines the makefile conditional COIN_BUILD_METIS, if METIS is
3184# compiled within COIN.
3185
3186AC_DEFUN([AC_COIN_HAS_METIS],
3187[
3188case "$PACKAGE_NAME" in
3189  ThirdParty*)
3190    coin_metisobjdir=../Metis
3191    ;;
3192  *)
3193    coin_metisobjdir=../ThirdParty/Metis
3194    ;;
3195esac
3196
3197MAKEOKFILE=.MakeOk
3198
3199#check if user provides a METIS library (that works)
3200AC_LANG_PUSH(C)
3201AC_ARG_WITH(metis,
3202   AS_HELP_STRING([--with-metis], [specify flags to link with METIS library]),
3203   [METISLIB="$withval"; coin_has_metis=true], [coin_has_metis=no])
3204
3205if test $coin_has_metis = true; then
3206  coin_save_LIBS="$LIBS"
3207  LIBS="$METISLIB $ADDLIBS"
3208  AC_MSG_CHECKING([whether symbol metis_nodend is available with ])
3209  AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[metis_nodend()]])],
3210     [AC_MSG_RESULT(yes)],
3211     [AC_MSG_RESULT(no)
3212      AC_MSG_ERROR([User-supplied METIS library does not work])])
3213  LIBS="$coin_save_LIBS"
3214fi
3215AC_LANG_POP(C)
3216
3217if test "$coin_has_metis" = "true"; then  # user provided metis library
3218  use_metis=yes
3219  coin_has_metis=yes
3220
3221  ADDLIBS="$METISLIB $ADDLIBS"
3222
3223else # no user provided library, so we try to build our own
3224  use_metis=BUILD
3225
3226  # Check if the METIS' ThirdParty project has been configured
3227  if test "$PACKAGE_NAME" != ThirdPartyMetis; then
3228    if test -r $coin_metisobjdir/.MakeOk; then
3229      use_metis=BUILD
3230    else
3231      use_metis=
3232    fi
3233  fi
3234
3235  if test x"$use_metis" != x; then
3236    coin_has_metis=yes
3237  else
3238    coin_has_metis=no
3239  fi
3240  AC_MSG_CHECKING([whether METIS is available])
3241  AC_MSG_RESULT([$coin_has_metis])
3242fi
3243
3244AM_CONDITIONAL([COIN_HAS_METIS],[test $coin_has_metis = yes])
3245if test $coin_has_metis = yes; then
3246  AC_DEFINE([COIN_HAS_METIS],[1],[If defined, the METIS library is available.])
3247fi
3248
3249]) # AC_COIN_HAS_METIS
3250
3251
3252###########################################################################
3253#                             COIN_HAS_GLPK                               #
3254###########################################################################
3255#
3256# This macro checks for the GLPK package. GLPK provides two capabilities,
3257# an LP and MIP solver (GLPK) and the GNU Mathprog modelling language (GMPL).
3258# The macro checks for either Glpk or Gmpl, according to the value specified as
3259# the parameter. Use one of Glpk or Gmpl. Use *exactly* these strings, eh?
3260#
3261#
3262# The macro first uses COIN_HAS_USER_LIBRARY to see if the user has specified
3263# a preexisting library (this allows the use of any glpk version, if the user
3264# is fussy). The macro then checks for ThirdParty/Glpk.
3265#
3266# This macro will define the following variables for Glpk:
3267#   coin_has_glpk       true or false
3268#   GLPKLIB             link flags for GLPK (if user supplied)
3269#   GLPKINCDIR          location of glpk include files
3270#   COIN_HAS_GLPK       Preprocessor symbol, defined to 1
3271#   COIN_HAS_GLPK       Automake conditional
3272#   COIN_BUILD_GLPK     Automake conditional, defined only if Glpk is to be
3273#                       built in ThirdParty/Glpk
3274#
3275# With the exception of COIN_BUILD_GLPK, an identical set of variables is
3276# defined for Gmpl.
3277
3278AC_DEFUN([AC_COIN_HAS_GLPK],
3279[
3280if test "$PACKAGE_NAME" = ThirdPartyGlpk; then
3281  coin_glpkobjdir=../Glpk
3282else
3283  coin_glpkobjdir=../ThirdParty/Glpk
3284fi
3285coin_glpksrcdir=$abs_source_dir/$coin_glpkobjdir
3286
3287use_thirdpartyglpk=no
3288
3289# Check for the requested component. If the user specified an external glpk
3290# library don't force a ThirdParty build, let the error propagate.
3291
3292m4_if([$1],[Glpk],
3293[AC_COIN_HAS_USER_LIBRARY([Glpk],[GLPK],[glpk.h],
3294    [_glp_lpx_simplex glp_lpx_simplex])
3295 if test x"$coin_has_glpk" = xfalse && test x"$GLPKLIB" = x ; then
3296   use_thirdpartyglpk=try
3297 fi])
3298m4_if([$1],[Gmpl],
3299[AC_COIN_HAS_USER_LIBRARY([Gmpl],[GMPL],[glpmpl.h],
3300    [_glp_mpl_initialize glp_mpl_initialize])
3301 if test x"$coin_has_gmpl" = xfalse && test x"$GMPLLIB" = x ; then
3302   use_thirdpartyglpk=try
3303 fi])
3304
3305# If the user has supplied an external library, use it. Otherwise, consider
3306# a build in ThirdParty/Glpk. If we build, assume we get both glpk and gmpl.
3307
3308if test x"$use_thirdpartyglpk" = xtry ; then
3309  MAKEOKFILE=.MakeOk
3310  # Check if the Glpk's ThirdParty project has been configured
3311  if test "$PACKAGE_NAME" != ThirdPartyGlpk; then
3312    if test -r $coin_glpkobjdir/.MakeOk; then
3313      use_thirdpartyglpk=build
3314    else
3315      use_thirdpartyglpk=no
3316    fi
3317  else
3318    use_thirdpartyglpk=build
3319  fi
3320
3321# If we're building, set the library and include directory variables, create a
3322# preprocessor symbol, define a variable that says we're using glpk/gmpl, and
3323# another to indicate a link check is a bad idea (hard to do before the library
3324# exists).
3325
3326  if test x"$use_thirdpartyglpk" = xbuild ; then
3327    m4_toupper($1INCDIR)="$coin_glpksrcdir/glpk/include"
3328    AC_SUBST(m4_toupper($1INCDIR))
3329    AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],
3330              [Define to 1 if $1 package is available])
3331    m4_tolower(coin_has_$1)=true
3332    m4_tolower($1_libcheck)=no
3333    AC_MSG_NOTICE([Using $1 in ThirdParty/Glpk])
3334  fi
3335fi
3336
3337# Define the necessary automake conditionals.
3338
3339AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3340               [test x"$m4_tolower(coin_has_$1)" = xtrue])
3341AM_CONDITIONAL([COIN_BUILD_GLPK],[test x"$use_thirdpartyglpk" = xbuild])
3342
3343]) # AC_COIN_HAS_GLPK
3344
3345###########################################################################
3346#                           COIN_HAS_PKGCONFIG                            #
3347###########################################################################
3348
3349# This macro checks whether a pkg-config tool with a minimal version number is available.
3350# If so, then the variable PKGCONFIG is set to its path.
3351# If not, PKGCONFIG is set to "".
3352# The minimal version number can be given as first parameter, by default it is 0.9.0.
3353# This macro is a modified version of PKG_PROG_PKG_CONFIG in pkg.m4
3354AC_DEFUN([AC_COIN_HAS_PKGCONFIG],
3355[AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
3356
3357if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
3358  AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
3359fi
3360if test -n "$PKG_CONFIG"; then
3361  _pkg_min_version=m4_default([$1], [0.9.0])
3362  AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
3363  if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
3364    AC_MSG_RESULT([yes])
3365  else
3366    AC_MSG_RESULT([no])
3367    PKG_CONFIG=""
3368  fi
3369fi
3370
3371# check if pkg-config supports the short-errors flag
3372if test -n "$PKG_CONFIG" && \
3373  $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
3374  pkg_short_errors=" --short-errors "
3375else
3376  pkg_short_errors=""
3377fi
3378
3379])
3380
3381###########################################################################
3382#                           COIN_PKG_CHECK_EXISTS (deprecated)            #
3383###########################################################################
3384
3385# COIN_PKG_CHECK_EXISTS(MODULE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3386#
3387# Check to see whether a particular module exists.  Similar
3388# to PKG_CHECK_MODULES(), but set only the variables $1_VERSION and $1_PKG_ERRORS variables
3389#
3390AC_DEFUN([AC_COIN_PKG_CHECK_EXISTS],
3391[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3392if test -n "$PKG_CONFIG" ; then
3393  if $PKG_CONFIG --exists "m4_tolower($1)"; then
3394    m4_toupper($1)[]_VERSION=`$PKG_CONFIG --modversion "m4_tolower($1)" 2>/dev/null`
3395    m4_ifval([$2], [$2], [:])
3396  else
3397    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors "m4_tolower($1)"`
3398    $3
3399  fi
3400else
3401  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
3402fi
3403])
3404
3405
3406###########################################################################
3407#                           COIN_PKG_CHECK_MODULE   (deprecated)          #
3408###########################################################################
3409
3410# COIN_PKG_CHECK_MODULE(MODULE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3411#
3412# Checks whether a pkg-config file for a given module is available.
3413# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
3414# If not, then ACTION-IF-NOT-FOUND is executed.
3415# A reason for not finding a package is stored in MODULE_PKG_ERRORS
3416#
3417# --------------------------------------------------------------
3418AC_DEFUN([AC_COIN_PKG_CHECK_MODULE],
3419[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3420
3421AC_COIN_PKG_CHECK_EXISTS([$1],
3422  [ m4_toupper($1)[]_CFLAGS=`$PKG_CONFIG --cflags "m4_tolower($1)" 2>/dev/null`
3423    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "m4_tolower($1)" 2>/dev/null`
3424    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "m4_tolower($1)" 2>/dev/null`
3425    $2
3426  ],
3427  [ $3 ])
3428
3429])# PKG_CHECK_MODULES
3430
3431###########################################################################
3432#                           COIN_PKG_CHECK_MODULE_EXISTS                  #
3433###########################################################################
3434
3435# COIN_PKG_CHECK_MODULES_EXISTS(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3436#
3437# Check to see whether a particular set of packages exists.
3438# Similar to PKG_CHECK_MODULES(), but set only the variable $1_VERSIONS and $1_PKG_ERRORS
3439#
3440AC_DEFUN([AC_COIN_PKG_CHECK_MODULE_EXISTS],
3441[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3442if test -n "$PKG_CONFIG" ; then
3443  if $PKG_CONFIG --exists "$2"; then
3444    m4_toupper($1)[]_VERSIONS="`$PKG_CONFIG --modversion $2 2>/dev/null`"
3445    m4_ifval([$3], [$3], [:])
3446  else
3447    m4_toupper($1)_PKG_ERRORS=`$PKG_CONFIG $pkg_short_errors --errors-to-stdout --print-errors $2`
3448    $4
3449  fi
3450else
3451  AC_MSG_ERROR("Cannot check for existance of module $1 without pkg-config")
3452fi
3453])
3454
3455###########################################################################
3456#                           COIN_PKG_HAS_MODULE                           #
3457###########################################################################
3458
3459# COIN_PKG_CHECK_MODULE(MODULE, PACKAGES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
3460#
3461# Checks whether pkg-config files for a given set of packages is available.
3462# If so, sets MODULE_CFLAGS, MODULE_LIBS, and MODULES_DATA and executes ACTION-IF-FOUND.
3463# If not, then ACTION-IF-NOT-FOUND is executed.
3464# A reason for not finding a package is stored in MODULE_PKG_ERRORS
3465#
3466# --------------------------------------------------------------
3467AC_DEFUN([AC_COIN_PKG_HAS_MODULE],
3468[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3469
3470AC_COIN_PKG_CHECK_MODULE_EXISTS([$1],[$2],
3471  [ m4_toupper($1)[]_CFLAGS=`$PKG_CONFIG --cflags "m4_tolower($1)" 2>/dev/null`
3472    m4_toupper($1)[]_LIBS=`$PKG_CONFIG --libs "m4_tolower($1)" 2>/dev/null`
3473    m4_toupper($1)[]_DATA=`$PKG_CONFIG --variable=datadir "m4_tolower($1)" 2>/dev/null`
3474    $3
3475  ],
3476  [ $4 ])
3477
3478])# PKG_CHECK_MODULES
3479
3480###########################################################################
3481#                           COIN_MAIN_SUBDIR2                             #
3482###########################################################################
3483
3484# This is the macro for AC_COIN_MAIN_SUBDIRS taking care of ONE (or two or three) argument(s)
3485# It calles AC_COIN_HAS_PROJECT with the given argument(s) and adds $1 to the CONFIG_SUBDIRS, if
3486# either argument $3 is given and the file $2/$1/$3 is available in $srcdir,
3487# or $3 is not given and the file $2/$1/configure is available in $srcdir,
3488# where $2 = . if not given
3489AC_DEFUN([AC_COIN_MAIN_SUBDIR2],
3490[AC_ARG_VAR([COIN_SKIP_PROJECTS],[Set to the subdirectories of projects that should be skipped in the configuration])
3491
3492AC_MSG_CHECKING([for project $1])
3493# First check, if the sub-project is actually available
3494
3495m4_tolower(coin_has_$1)=notGiven
3496
3497# check if user wants to skip project in any case
3498if test x"$COIN_SKIP_PROJECTS" != x; then
3499  for dir in $COIN_SKIP_PROJECTS; do
3500    if test $dir = "$1"; then
3501      m4_tolower(coin_has_$1)=skipping
3502    fi
3503    if test $dir = "$2/$1"; then
3504      m4_tolower(coin_has_$1)=skipping
3505    fi
3506  done
3507fi
3508
3509if test $m4_tolower(coin_has_$1) != skipping; then
3510  if test $PACKAGE_TARNAME = m4_tolower($1); then
3511    m4_tolower(coin_has_$1)=.
3512  fi
3513
3514  AC_ARG_WITH([m4_tolower($1)-lib],
3515    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3516                   [linker flags for using project $1]),
3517      [m4_tolower(coin_has_$1)=installed],
3518      [])
3519
3520  AC_ARG_WITH([m4_tolower($1)-incdir],
3521    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3522                   [directory with header files for using project $1]),
3523    [m4_tolower(coin_has_$1)=installed],
3524    [])
3525
3526  AC_ARG_WITH([m4_tolower($1)-datadir],
3527    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3528                   [directory with data files for using project $1]),
3529    [m4_tolower(coin_has_$1)=installed],
3530    [])
3531fi
3532
3533if test $m4_tolower(coin_has_$1) = notGiven; then
3534  #see if user gives directory where project might be installed: assemble search path for pkg-config
3535  coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3536  AC_ARG_WITH([coin-instdir],
3537    AC_HELP_STRING([--with-coin-instdir],
3538                   [prefix of installation directory for precompiled COIN packages]),
3539    [if test -d "$withval"; then : ; else
3540       AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
3541     fi
3542     PKG_CONFIG_PATH="$withval/lib/$2/pkgconfig:$PKG_CONFIG_PATH"
3543    ],[])
3544
3545#   AC_ARG_WITH([m4_tolower($1)],
3546#     AC_HELP_STRING([--with-m4_tolower($1)],
3547#                    [prefix of installation directory for precompiled $1 package]),
3548#     [if test -d "$withval"; then : ; else
3549#        AC_MSG_ERROR([argument for --with-m4_tolower($1) not a directory])
3550#      fi
3551#      # maybe the user points directly to the directory with the .pc file
3552#      PKG_CONFIG_PATH="$withval:$PKG_CONFIG_PATH"
3553#      # maybe the user points to a project main directory
3554#      if test -d "$withval/lib/$2/pkgconfig"; then
3555#        PKG_CONFIG_PATH="$withval/lib/$2/pkgconfig:$PKG_CONFIG_PATH"
3556#      fi
3557#     ],[])
3558
3559  # let pkgconfig check if the project is already installed somewhere
3560  # need to export variable to be sure that the following pkg-config call gets these values
3561  export PKG_CONFIG_PATH
3562  AC_COIN_PKG_CHECK_EXISTS([$1], [m4_tolower(coin_has_$1)="$m4_toupper($1)_VERSION"])
3563
3564  PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3565fi
3566
3567# if not found yet, check if project is available in present directory
3568if test "$m4_tolower(coin_has_$1)" = notGiven; then
3569  if test -d $srcdir/$2/$1; then
3570    coin_pkg_is_here=no
3571    m4_ifvaln([$3],
3572      [for i in $srcdir/$2/$1/$3; do
3573         if test -r $i; then
3574           coin_pkg_is_here=yes
3575         fi
3576       done],
3577      [ coin_pkg_is_here=yes ])
3578    if test $coin_pkg_is_here = yes; then
3579      m4_tolower(coin_has_$1)=$2/$1
3580    fi
3581  fi
3582fi
3583
3584AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3585
3586AC_MSG_CHECKING(whether project $1 need to be configured)
3587if test "$m4_tolower(coin_has_$1)" != skipping &&
3588   test "$m4_tolower(coin_has_$1)" != notGiven &&
3589   test "$m4_tolower(coin_has_$1)" != installed; then
3590
3591  if test -r $srcdir/$2/$1/configure; then
3592    coin_subdirs="$coin_subdirs m4_ifval($2,[$2/],)$1"
3593    AC_MSG_RESULT(yes)
3594    AC_CONFIG_SUBDIRS(m4_ifval($2,[$2/],)$1)
3595  else
3596    AC_MSG_RESULT(no)
3597  fi
3598else
3599  AC_MSG_RESULT(no)
3600fi
3601])
3602
3603###########################################################################
3604#                            COIN_HAS_PROJECT2                            #
3605###########################################################################
3606
3607# This macro sets up usage of a Coin package.  It defines the
3608# PKG_CFLAGS and PKG_LIBS variables, refering to the compiler and linker
3609# flags to use when linking against this package.
3610# It also defines a COIN_HAS_PKG preprocessor macro and makefile conditional.
3611# The argument should be the name (Pkg) of the project (in correct lower
3612# and upper case), optionally a directory where to look at it, and
3613# optionally a file that need to be present in the package directory.
3614#
3615# It is also possible to specify a preinstalled version of this Coin
3616# package or to specify only the linker and compiler flags.
3617
3618AC_DEFUN([AC_COIN_HAS_PROJECT2],
3619[AC_MSG_CHECKING([for COIN project $1])
3620
3621m4_tolower(coin_has_$1)=notGiven
3622
3623# check if user wants to skip project in any case
3624if test x"$COIN_SKIP_PROJECTS" != x; then
3625  for dir in $COIN_SKIP_PROJECTS; do
3626    if test $dir = "$1"; then
3627      m4_tolower(coin_has_$1)=skipping
3628    fi
3629    if test $dir = "$2/$1"; then
3630      m4_tolower(coin_has_$1)=skipping
3631    fi
3632  done
3633fi
3634
3635m4_toupper($1_LIBS)=
3636m4_toupper($1_CFLAGS)=
3637m4_toupper($1_DATA)=
3638AC_SUBST(m4_toupper($1_LIBS))
3639AC_SUBST(m4_toupper($1_CFLAGS))
3640AC_SUBST(m4_toupper($1_DATA))
3641
3642if test $m4_tolower(coin_has_$1) != skipping; then
3643  if test $PACKAGE_TARNAME = m4_tolower($1); then
3644    m4_tolower(coin_has_$1)=.
3645  fi
3646
3647  AC_ARG_WITH([m4_tolower($1)-lib],
3648    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3649                   [linker flags for using project $1]),
3650      [m4_tolower(coin_has_$1)=yes
3651       m4_toupper($1_LIBS)="$withval"],
3652      [])
3653
3654  AC_ARG_WITH([m4_tolower($1)-incdir],
3655    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3656                   [directory with header files for using project $1]),
3657    [m4_tolower(coin_has_$1)=yes
3658     m4_toupper($1_CFLAGS)="-I$withval"],
3659    [])
3660
3661  AC_ARG_WITH([m4_tolower($1)-datadir],
3662    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3663                   [directory with data files for using project $1]),
3664    [m4_tolower(coin_has_$1)=yes
3665     m4_toupper($1_DATA)="$withval"],
3666    [])
3667fi
3668
3669if test $m4_tolower(coin_has_$1) = notGiven; then
3670  #assemble search path for pkg-config
3671  coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3672
3673  AC_ARG_WITH([coin-instdir],
3674    AC_HELP_STRING([--with-coin-instdir],
3675                   [prefix of installation directory for precompiled COIN packages]),
3676    [if test -d "$withval"; then : ; else
3677       AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
3678     fi
3679     PKG_CONFIG_PATH="$withval/lib/$2/pkgconfig:$PKG_CONFIG_PATH",
3680    ],[])
3681
3682#   AC_ARG_WITH([m4_tolower($1)],
3683#     AC_HELP_STRING([--with-m4_tolower($1)],
3684#                    [prefix of installation directory for precompiled $1 package]),
3685#     [if test -d "$withval"; then : ; else
3686#        AC_MSG_ERROR([argument for --with-m4_tolower($1) not a directory])
3687#      fi
3688#      #if the user points directly to the directory with the .pc file
3689#      PKG_CONFIG_PATH="$withval:$PKG_CONFIG_PATH"
3690#      #if the user points to a project main directory
3691#      if test -d "$withval/lib/$2/pkgconfig"; then
3692#        PKG_CONFIG_PATH="$withval/lib/$2/pkgconfig:$PKG_CONFIG_PATH"
3693#      fi
3694#     ],[])
3695
3696  # check if uninstalled project can be found in ../$2/$1
3697  # this is for the classic setup when this macro is called from the project main directory
3698  if test -d $srcdir/../$2/$1; then
3699    coin_pkg_is_here=no
3700    m4_ifvaln([$3],
3701      [for i in $srcdir/../$2/$1/$3; do
3702         if test -r $i; then
3703           coin_pkg_is_here=yes
3704         fi
3705       done],
3706      [ coin_pkg_is_here=yes ])
3707    if test $coin_pkg_is_here = yes; then
3708      PKG_CONFIG_PATH="../$2/$1:$PKG_CONFIG_PATH"
3709    fi
3710  fi
3711
3712  # let pkg-config do it's magic
3713  # need to export variable to be sure that the following pkg-config gets these values
3714  export PKG_CONFIG_PATH
3715  AC_COIN_PKG_CHECK_MODULE([$1],
3716    [ m4_tolower(coin_has_$1)=$m4_toupper($1)_VERSION
3717      AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3718    ],
3719    [ m4_tolower(coin_has_$1)=notGiven
3720      AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
3721    ])
3722
3723  PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3724
3725else
3726  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3727fi
3728
3729if test $m4_tolower(coin_has_$1) != skipping &&
3730   test $m4_tolower(coin_has_$1) != notGiven ; then
3731  if test "x$m4_toupper($1)_CFLAGS" != x ; then
3732    AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3733  fi
3734  if test "x$m4_toupper($1)_LIBS" != x ; then
3735    AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
3736    ADDLIBS="$m4_toupper($1)_LIBS $ADDLIBS"
3737  fi
3738  if test "x$m4_toupper($1)_DATA" != x ; then
3739    AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
3740  fi
3741  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 package is used])
3742fi
3743
3744# Define the Makefile conditional
3745AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3746               [test $m4_tolower(coin_has_$1) != notGiven &&
3747                test $m4_tolower(coin_has_$1) != skipping])
3748
3749]) # AC_COIN_HAS_PROJECT2
3750
3751AC_DEFUN([AC_COIN_HAS_MODULE_HELPER],
3752[
3753module_content="$module_content m4_tolower($1)"
3754for i in $1 ; do
3755  # check if directory $srcdir/../$1 exists and add ../$1 to the PKG_CONFIG_PATH
3756  # this is for the classic setup where an uninstalled project can be found in ../$1
3757  if test -d $srcdir/../$1; then
3758#    coin_pkg_is_here=no
3759#    m4_ifvaln([$3],
3760#      [for i in $srcdir/../$2/$1/$3; do
3761#         if test -r $i; then
3762#           coin_pkg_is_here=yes
3763#         fi
3764#       done],
3765#      [ coin_pkg_is_here=yes ])
3766#    if test $coin_pkg_is_here = yes; then
3767      PKG_CONFIG_PATH="../$1:$PKG_CONFIG_PATH"
3768#    fi
3769  break;
3770  fi
3771done
3772]) # AC_COIN_HAS_MODULE_HELPER
3773
3774###########################################################################
3775#                            COIN_HAS_MODULE                              #
3776###########################################################################
3777
3778# This macro sets up a COIN-OR module.
3779# A module consists of one or more COIN-OR packages.
3780# It defines the MODULE_CFLAGS, MODULE_LIBS, and MODULE_DATA variables, refering to the compiler and linker
3781# flags to use when linking against this module and the directories where the module data resists.
3782# It also defines a COIN_HAS_MODULE preprocessor macro and makefile conditional.
3783# Further, tolower(coin_has_$1) is set to "yes" and the packages of the module are added to
3784# the REQUIREDPACKAGES variable, which can be used to setup a .pc file.
3785# The argument should be the name (MODULE) of the module (in correct lower
3786# and upper case), and a list of projects that belong to this module.
3787#
3788# It is also possible to specify a preinstalled version of this module
3789# or to specify only the linker and compiler flags and data directory.
3790
3791AC_DEFUN([AC_COIN_HAS_MODULE],
3792[AC_REQUIRE([AC_COIN_HAS_PKGCONFIG])
3793AC_MSG_CHECKING([for COIN module $1])
3794
3795m4_tolower(coin_has_$1)=notGiven
3796
3797# check if user wants to skip module in any case
3798if test x"$COIN_SKIP_PROJECTS" != x; then
3799  for dir in $COIN_SKIP_PROJECTS; do
3800    if test $dir = "$1"; then
3801      m4_tolower(coin_has_$1)=skipping
3802    fi
3803  done
3804fi
3805
3806m4_toupper($1_LIBS)=
3807m4_toupper($1_CFLAGS)=
3808m4_toupper($1_DATA)=
3809AC_SUBST(m4_toupper($1_LIBS))
3810AC_SUBST(m4_toupper($1_CFLAGS))
3811AC_SUBST(m4_toupper($1_DATA))
3812
3813#check if user provided LIBS, CFLAGS, and DATA for module
3814if test $m4_tolower(coin_has_$1) != skipping; then
3815
3816  AC_ARG_WITH([m4_tolower($1)-lib],
3817    AC_HELP_STRING([--with-m4_tolower($1)-lib],
3818                   [linker flags for using module $1]),
3819      [m4_tolower(coin_has_$1)=yes
3820       m4_toupper($1_LIBS)="$withval"],
3821      [])
3822
3823  AC_ARG_WITH([m4_tolower($1)-incdir],
3824    AC_HELP_STRING([--with-m4_tolower($1)-incdir],
3825                   [directory with header files for using module $1]),
3826    [m4_tolower(coin_has_$1)=yes
3827     m4_toupper($1_CFLAGS)="-I$withval"],
3828    [])
3829
3830  AC_ARG_WITH([m4_tolower($1)-datadir],
3831    AC_HELP_STRING([--with-m4_tolower($1)-datadir],
3832                   [directory with data files for using module $1]),
3833    [m4_tolower(coin_has_$1)=yes
3834     m4_toupper($1_DATA)="$withval"],
3835    [])
3836fi
3837
3838if test $m4_tolower(coin_has_$1) = notGiven; then
3839  #assemble search path for pkg-config
3840  if test -n "$PKG_CONFIG" ; then
3841    coin_save_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
3842
3843    AC_ARG_WITH([coin-instdir],
3844      AC_HELP_STRING([--with-coin-instdir],
3845                     [prefix of installation directory for precompiled COIN packages]),
3846      [if test -d "$withval"; then : ; else
3847         AC_MSG_ERROR([argument for --with-coin-instdir not a directory])
3848       fi
3849       PKG_CONFIG_PATH="$withval/lib/pkgconfig:$PKG_CONFIG_PATH",
3850      ],[])
3851
3852    # go through $2 to ... and assemble PKG_CONFIG_PATH with ../$2 and module search string
3853    module_content=""
3854    m4_ifvaln([$2], AC_COIN_HAS_MODULE_HELPER([$2]))
3855    m4_ifvaln([$3], AC_COIN_HAS_MODULE_HELPER([$3]))
3856    m4_ifvaln([$4], AC_COIN_HAS_MODULE_HELPER([$4]))
3857    m4_ifvaln([$5], AC_COIN_HAS_MODULE_HELPER([$5]))
3858    m4_ifvaln([$6], AC_COIN_HAS_MODULE_HELPER([$6]))
3859    m4_ifvaln([$7], AC_COIN_HAS_MODULE_HELPER([$7]))
3860    m4_ifvaln([$8], AC_COIN_HAS_MODULE_HELPER([$8]))
3861    m4_ifvaln([$9], AC_COIN_HAS_MODULE_HELPER([$9]))
3862
3863    # let pkg-config do it's magic
3864    # need to export variable to be sure that the following pkg-config gets these values
3865    export PKG_CONFIG_PATH
3866    AC_COIN_PKG_HAS_MODULE([$1],[$module_content],
3867      [ m4_tolower(coin_has_$1)=yes
3868        AC_MSG_RESULT([yes: $m4_toupper($1)_VERSIONS])
3869        REQUIREDPACKAGES="$REQUIREDPACKAGES $module_content"
3870        AC_SUBST(REQUIREDPACKAGES)
3871      ],
3872      [ m4_tolower(coin_has_$1)=notGiven
3873        AC_MSG_RESULT([not given: $m4_toupper($1)_PKG_ERRORS])
3874      ])
3875
3876    PKG_CONFIG_PATH="$coin_save_PKG_CONFIG_PATH"
3877  else
3878    AC_MSG_RESULT([skipped check via pkg-config])
3879  fi
3880
3881else
3882  AC_MSG_RESULT([$m4_tolower(coin_has_$1)])
3883fi
3884
3885if test $m4_tolower(coin_has_$1) != skipping &&
3886   test $m4_tolower(coin_has_$1) != notGiven ; then
3887  if test "x$m4_toupper($1)_CFLAGS" != x ; then
3888    AC_MSG_NOTICE([$1 CFLAGS are $m4_toupper($1)_CFLAGS])
3889  fi
3890  if test "x$m4_toupper($1)_LIBS" != x ; then
3891    AC_MSG_NOTICE([$1 LIBS   are $m4_toupper($1)_LIBS])
3892  fi
3893  if test "x$m4_toupper($1)_DATA" != x ; then
3894    AC_MSG_NOTICE([$1 DATA   is  $m4_toupper($1)_DATA])
3895  fi
3896  AC_DEFINE(m4_toupper(COIN_HAS_$1),[1],[Define to 1 if the $1 module is available])
3897fi
3898
3899# Define the Makefile conditional
3900AM_CONDITIONAL(m4_toupper(COIN_HAS_$1),
3901               [test $m4_tolower(coin_has_$1) != notGiven &&
3902                test $m4_tolower(coin_has_$1) != skipping])
3903
3904]) # AC_COIN_HAS_MODULE
3905
Note: See TracBrowser for help on using the repository browser.