source: stable/0.6/coin.m4 @ 1916

Last change on this file since 1916 was 1916, checked in by stefan, 11 years ago

sync stable/0.6 with trunk rev.1915

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