source: trunk/configure.ac @ 316

Last change on this file since 316 was 316, checked in by kulshres, 8 years ago

tweaks in configure

to check for fmin/fmax and get rid of some redundancies

Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

  • Property svn:keywords set to Author Date Id Revision
File size: 17.3 KB
Line 
1##############################################################################
2# configure.ac -- Process this file with autoconf to produce configure
3# Revision: $Id: configure.ac 316 2012-04-10 14:36:09Z kulshres $
4#
5# Copyright (C) Andrea Walther, Andreas Kowarz
6#               
7# contains patches from the COIN OR libtool
8#
9##############################################################################
10define([ADOLC_VER], [2])
11define([ADOLC_SUB], [3])
12define([ADOLC_LVL], [0])
13
14AC_PREREQ(2.67)
15AC_INIT(adolc,
16        ADOLC_VER.ADOLC_SUB.ADOLC_LVL-trunk,
17        [adol-c@list.coin-or.org])
18AC_REVISION($Revision: 316 $)
19AC_CONFIG_SRCDIR([ADOL-C/src/adolc.h])
20AC_CONFIG_AUX_DIR(autoconf)
21AC_CONFIG_HEADERS([ADOL-C/src/config.h])
22AC_PREFIX_DEFAULT(${HOME}/adolc_base)
23AM_INIT_AUTOMAKE([1.11 dist-bzip2 foreign])
24AM_SILENT_RULES([yes])
25
26if test "x$CFLAGS" == x ; then
27    ac_shell_cflags="not_set"
28else
29    ac_shell_cflags="$CFLAGS"
30fi
31if test "x$CXXFLAGS" == x ; then
32    ac_shell_cxxflags="not_set"
33else
34    ac_shell_cxxflags="$CXXFLAGS"
35fi
36
37# checks for programs
38AC_PROG_CXX
39AC_PROG_CC
40AC_PROG_CPP
41AC_PROG_INSTALL
42AC_PROG_LN_S
43AC_PROG_MAKE_SET
44AC_LIBTOOL_WIN32_DLL
45AC_PROG_LIBTOOL
46
47AC_CHECK_SIZEOF([void *])
48if test "x$ac_cv_sizeof_void_p" = "x8" ; then
49   _lib=lib64
50else
51   _lib=lib
52fi
53libdir='${exec_prefix}/${_lib}'
54AC_SUBST(_lib)
55AC_SUBST(libdir)
56
57# checks for header files
58AC_HEADER_STDC
59AC_HEADER_TIME
60AC_HEADER_STDBOOL
61AC_CHECK_HEADERS([stddef.h stdlib.h stdio.h string.h unistd.h sys/timeb.h])
62
63# checks for types
64AC_C_CONST
65AC_C_INLINE
66AC_TYPE_SIZE_T
67AC_STRUCT_TM
68
69# Checks for library functions
70AC_FUNC_MALLOC
71AC_FUNC_REALLOC
72
73# Checks for libraries and fuctions
74AC_SEARCH_LIBS([pow], [m])
75AC_CHECK_FUNCS([floor fmax fmin ftime pow sqrt strchr strtol trunc])
76
77# substitutions
78AC_SUBST(ac_aux_dir)
79
80# ADOL-C configuration
81AC_DEFINE(ADOLC_VERSION,ADOLC_VER,[ADOL-C Version])
82AC_DEFINE(ADOLC_SUBVERSION,ADOLC_SUB,[ADOL-C Subversion])
83AC_DEFINE(ADOLC_PATCHLEVEL,ADOLC_LVL,[ADOL-C Patchlevel])
84ADOLC_VERSION=ADOLC_VER
85ADOLC_SUBVERSION=ADOLC_SUB
86ADOLC_PATCHLEVEL=ADOLC_LVL
87AC_SUBST(ADOLC_VERSION)
88AC_SUBST(ADOLC_SUBVERSION)
89AC_SUBST(ADOLC_PATCHLEVEL)
90
91AC_MSG_CHECKING(whether to use ADOL-C debug mode)
92AC_ARG_ENABLE(debug,
93              [
94AS_HELP_STRING([--enable-debug],[enable ADOL-C debug mode [default=no]])],
95  [AC_DEFINE(ADOLC_DEBUG,1,[ADOL-C debug mode])
96   AC_MSG_RESULT(yes)
97   adolc_debug="yes"],
98  [AC_MSG_RESULT(no)
99   adolc_debug="no"])
100
101AC_MSG_CHECKING(whether to use ADOL-C hard debug mode)
102AC_ARG_ENABLE(harddebug,
103              [
104AS_HELP_STRING([--enable-harddebug],[enable ADOL-C hard debug mode
105 [default=no]])],
106  [AC_DEFINE(ADOLC_HARDDEBUG,1,[ADOL-C hard debug mode])
107   AC_DEFINE(ADOLC_DEBUG,1,[ADOL-C debug mode])
108   AC_MSG_RESULT(yes)
109   adolc_harddebug="yes"],
110  [AC_MSG_RESULT(no)
111   adolc_harddebug="no"])
112
113AC_MSG_CHECKING(whether standard adouble constructor shall zero value)
114AC_ARG_ENABLE(stdczero,
115              [
116AS_HELP_STRING([--enable-stdczero],[adouble standard constructor zeros value
117(at the cost of performance) [default=no]])],
118  [AC_DEFINE(ADOLC_ADOUBLE_STDCZERO,1,[ADOL-C adouble zeroing mode])
119   AC_MSG_RESULT(yes)
120   adolc_stdczero="yes"],
121  [AC_MSG_RESULT(no)
122   adolc_stdczero="no"])
123
124AC_MSG_CHECKING(whether errno is thread save)
125AC_ARG_ENABLE(tserrno,
126              [
127AS_HELP_STRING([--enable-tserrno],[use errno as thread number cache [default=no]])],
128  [AC_DEFINE(ADOLC_THREADSAVE_ERRNO,1,[ADOL-C thread save errno mode])
129   AC_MSG_RESULT(yes)
130   adolc_tserrno="yes"],
131  [AC_MSG_RESULT(no)
132   adolc_tserrno="no"])
133
134AC_MSG_CHECKING(whether external function call forces backup of all adoubles)
135AC_ARG_ENABLE(safe_extern,
136              [
137AS_HELP_STRING([--enable-safe-extern],[backup all adoubles before calling an external function [default=no]])],
138  [AC_DEFINE(ADOLC_SAFE_EXTERN,1,[ADOL-C safe extern mode])
139   AC_MSG_RESULT(yes)
140   adolc_safe_extern="yes"],
141  [AC_MSG_RESULT(no)
142   adolc_safe_extern="no"])
143
144AC_MSG_CHECKING(which flag to use to enable OpenMP)
145AC_ARG_WITH(openmp-flag,
146            [AS_HELP_STRING([--with-openmp-flag=FLAG],
147                            [use FLAG to enable OpenMP at compile time [default=none]])],
148            [ac_adolc_openmpflag=$withval
149             msg_result=$withval
150             AC_MSG_RESULT($ac_adolc_openmpflag)],
151            [ac_adolc_openmpflag=""
152             msg_result="none"
153             AC_MSG_RESULT($ac_adolc_openmpflag)])
154
155
156# ADOL-C Sparse facility
157AC_MSG_CHECKING(whether to build sparse drivers)
158AC_ARG_ENABLE(sparse,
159            [
160AS_HELP_STRING([--enable-sparse],[build sparse drivers [default=disabled]])],
161            [sparse=$enableval
162             AC_MSG_RESULT(yes)],
163            [sparse="no"
164             AC_MSG_RESULT(no)])
165
166AC_ARG_WITH(colpack,
167        [
168AS_HELP_STRING([--with-colpack=DIR],[path to the colpack library and headers [default=${srcdir}/ThirdParty/ColPack]])],
169[
170colpack=$withval
171COLPACK_CFLAGS="$ac_adolc_openmpflag -I$colpack/include"
172COLPACK_LIBDIR="$colpack/${_lib}"
173COLPACK_LIBS="$ac_adolc_openmpflag -L$COLPACK_LIBDIR -lColPack"
174],
175[
176COLPACK_CFLAGS="$ac_adolc_openmpflag"
177COLPACK_LIBDIR=""
178COLPACK_LIBS="-lColPack"
179])
180
181AC_LANG_PUSH([C++])
182save_CPPFLAGS="$CPPFLAGS"
183save_LIBS="$LIBS"
184CPPFLAGS="$CPPFLAGS $COLPACK_CFLAGS"
185LIBS="$COLPACK_LIBS $LIBS"
186AC_MSG_CHECKING(for ColPack in $COLPACK_LIBDIR)
187AC_CHECK_HEADER([ColPack/ColPackHeaders.h],[have_colpackheaders=yes],[have_colpackheaders=no])
188if test x$have_colpackheaders = xyes ; then
189   AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <ColPack/ColPackHeaders.h>],
190                        [ColPack::GraphColoring g])],
191                       [have_colpack=yes
192                        AC_MSG_RESULT(linking with -lColPack succeeded)],
193                       [have_colpack=no,
194                        AC_MSG_RESULT(linking with -lColPack failed)])
195else
196    have_colpack=no
197fi
198CPPFLAGS="$save_CPPFLAGS"
199LIBS="$save_LIBS"
200AC_LANG_POP([C++])
201
202AM_CONDITIONAL(HAVE_LIBCOLPACK,[test x$have_colpack = xyes])
203if test x$have_colpack = xyes; then
204   sparse=yes
205   echo "will build sparse drivers as linking with -lColPack succeeded"
206fi
207AM_CONDITIONAL(SPARSE,[test x${sparse} = xyes])
208
209if test x$sparse = xyes && test x$have_colpack = xyes; then
210        AC_DEFINE(HAVE_LIBCOLPACK,[1],[Define 1 if ColPack is available])
211else
212        COLPACK_CFLAGS=""
213        COLPACK_LIBS=""
214fi
215AC_SUBST(COLPACK_CFLAGS)
216AC_SUBST(COLPACK_LIBS)
217
218# ADOL-C Examples
219AC_MSG_CHECKING(whether to build documented examples)
220AC_ARG_ENABLE(docexa,
221            [
222AS_HELP_STRING([--enable-docexa],[build documented examples [default=disabled]])],
223            [docexa=$enableval
224             AC_MSG_RESULT(yes)],
225            [docexa="no"
226             AC_MSG_RESULT(no)])
227AM_CONDITIONAL(DOCEXA,[test x${docexa} = xyes])
228
229AC_MSG_CHECKING(whether to build additional examples)
230AC_ARG_ENABLE(addexa,
231            [AS_HELP_STRING([--enable-addexa],
232                            [build additional examples [default=disabled]])],
233            [addexa=$enableval
234             AC_MSG_RESULT(yes)],
235            [addexa="no"
236             AC_MSG_RESULT(no)])
237AM_CONDITIONAL(ADDEXA,[test x${addexa} = xyes])
238
239AC_MSG_CHECKING(whether to build parallel example)
240AC_ARG_ENABLE(parexa,
241            [AS_HELP_STRING([--enable-parexa],
242                            [build parallel example [default=disabled], if enabled -with-openmp-flag=FLAG required])],
243            [parexa=$enableval
244             AC_MSG_RESULT(yes)],
245            [parexa="no"
246             AC_MSG_RESULT(no)])
247AM_CONDITIONAL(PAREXA,[test x${parexa} = xyes])
248
249# ADOL-C Compilation flags
250AC_MSG_CHECKING(which CFLAGS to use)
251AC_ARG_WITH(cflags,
252            [AS_HELP_STRING([--with-cflags=FLAGS],
253                            [use CFLAGS=FLAGS (default: -O2)])],
254            [ac_adolc_cflags="$withval"
255             if test x${adolc_debug} == xyes ||
256                test x${adolc_harddebug} == xyes ; then
257                ac_adolc_cflags="$ac_adolc_cflags -g -O0"
258             fi
259             ac_adolc_cflags="$ac_adolc_cflags $ac_adolc_openmpflag"
260             AC_SUBST(ac_adolc_cflags)
261             AC_MSG_RESULT($ac_adolc_cflags)],
262            [if test "$ac_shell_cflags" = "not_set"; then
263                ac_adolc_cflags="-O2"
264                if test x${adolc_debug} == xyes ||
265                   test x${adolc_harddebug} == xyes ; then
266                   ac_adolc_cflags="-g -O3 -Wall -ansi"
267                fi
268             else
269                ac_adolc_cflags="$CFLAGS"
270             fi
271             ac_adolc_cflags="$ac_adolc_cflags $ac_adolc_openmpflag"
272
273             AC_SUBST(ac_adolc_cflags)
274             AC_MSG_RESULT($ac_adolc_cflags)])
275
276AC_MSG_CHECKING(which CXXFLAGS to use)
277AC_ARG_WITH(cxxflags,
278            [AS_HELP_STRING([--with-cxxflags=FLAGS],
279                            [use CXXFLAGS=FLAGS (default: -O2)])],
280            [ac_adolc_cxxflags="$withval"
281             if test x${adolc_debug} == xyes ||
282                test x${adolc_harddebug} == xyes ; then
283                ac_adolc_cxxflags="$ac_adolc_cxxflags -g -O0"
284             fi
285             ac_adolc_cxxflags="$ac_adolc_cxxflags $ac_adolc_openmpflag"
286             AC_SUBST(ac_adolc_cxxflags)
287             AC_MSG_RESULT($ac_adolc_cxxflags)],
288            [if test "$ac_shell_cxxflags" = "not_set"; then
289                ac_adolc_cxxflags="-O2"
290                if test x${adolc_debug} == xyes ||
291                   test x${adolc_harddebug} == xyes ; then
292                   ac_adolc_cxxflags="-g -O0 -Wall"
293                fi
294             else
295                ac_adolc_cxxflags="$CXXFLAGS"
296             fi
297             ac_adolc_cxxflags="$ac_adolc_cxxflags $ac_adolc_openmpflag"
298            AC_SUBST(ac_adolc_cxxflags)
299             AC_MSG_RESULT($ac_adolc_cxxflags)])
300
301###########################################################################
302#                      COIN_PATCH_LIBTOOL_CYGWIN                          #
303###########################################################################
304
305# Patches to libtool for cygwin. Lots for cl, a few for GCC.
306# For cl:
307# - cygpath is not correctly quoted in fix_srcfile_path
308# - paths generated for .lib files is not run through cygpath -w
309
310#
311# REQUIRED FOR COMPILATION WITH CYGWIN !!!
312#
313 
314
315AC_DEFUN([AC_COIN_PATCH_LIBTOOL_CYGWIN],
316[ case "$CXX" in
317    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
318      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
319      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
320          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
321          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
322          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
323          -e 's%lib /OUT:%lib -OUT:%' \
324          -e "s%cygpath -w%$CYGPATH_W%" \
325          -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%' \
326          -e 's/$AR t/lib -nologo -list/' \
327          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
328          -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
329          -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"%' \
330      libtool > conftest.bla
331
332      mv conftest.bla libtool
333      chmod 755 libtool
334      ;;
335    *)
336      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
337      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
338          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
339          -e 's|libext="lib"|libext="a"|' \
340      libtool > conftest.bla
341
342      mv conftest.bla libtool
343      chmod 755 libtool
344      ;;
345  esac ]) # COIN_PATCH_LIBTOOL_CYGWIN
346 
347
348# output
349AC_CONFIG_FILES(Makefile
350                ADOL-C/Makefile
351                ADOL-C/src/Makefile
352                ADOL-C/src/drivers/Makefile
353                ADOL-C/src/sparse/Makefile
354                ADOL-C/src/tapedoc/Makefile
355                ADOL-C/doc/version.tex
356                ADOL-C/examples/Makefile
357                ADOL-C/examples/additional_examples/Makefile
358                ADOL-C/examples/additional_examples/clock/Makefile
359                ADOL-C/examples/additional_examples/checkpointing/Makefile
360                ADOL-C/examples/additional_examples/ext_diff_func/Makefile
361                ADOL-C/examples/additional_examples/fixpoint_exam/Makefile
362                ADOL-C/examples/additional_examples/hessmat/Makefile
363                ADOL-C/examples/additional_examples/lufact/Makefile
364                ADOL-C/examples/additional_examples/openmp_exam/Makefile
365                ADOL-C/examples/additional_examples/scal/Makefile
366                ADOL-C/examples/additional_examples/speelpenning/Makefile
367                ADOL-C/examples/additional_examples/taylor/Makefile
368                ADOL-C/examples/additional_examples/detexam/Makefile
369                ADOL-C/examples/additional_examples/helm/Makefile
370                ADOL-C/examples/additional_examples/lighthouse/Makefile
371                ADOL-C/examples/additional_examples/ode/Makefile
372                ADOL-C/examples/additional_examples/sparse/Makefile
373                ADOL-C/examples/additional_examples/tapesave/Makefile
374                ADOL-C/examples/additional_examples/pow/Makefile
375                ADOL-C/examples/additional_examples/timing/Makefile
376                ADOL-C/test/Makefile
377                MSVisualStudio/v10/sparse/config.h
378                MSVisualStudio/v10/nosparse/config.h
379                MSVisualStudio/v10/x64/sparse/config.h
380                MSVisualStudio/v10/x64/nosparse/config.h
381                adolc.spec
382)
383
384AC_OUTPUT
385
386#call libtool for cygwin
387AC_COIN_PATCH_LIBTOOL_CYGWIN
388warn=false
389# echo configuration
390echo \
391"
392-----------------------------------------------------------------------------
393Configuration:
394
395  C compiler:                       ${CC}
396  C++ compiler:                     ${CXX}
397  Linker:                           ${LD}
398  Source code location:             `pwd`
399  Install path:                     ${prefix}
400 
401  CFLAGS:                           ${ac_adolc_cflags}
402  CXXFLAGS:                         ${ac_adolc_cxxflags}
403
404  Use ADOL-C debug mode:            ${adolc_debug}
405  Use ADOL-C hard debug mode:       ${adolc_harddebug}
406  Use ADOL-C adouble zeroing mode:  ${adolc_stdczero}"
407
408if [[ "x${ac_adolc_openmpflag}" != "x" ]] ; then
409    echo \
410"  Access thread number via errno:   ${adolc_tserrno}"
411fi
412
413echo \
414"  Use ADOL-C safe extern mode:      ${adolc_safe_extern}
415
416  Build sparse drivers:             ${sparse}
417  Build with ColPack:               ${have_colpack}"
418if test x$sparse = xyes && test x$have_colpack = xno; then
419    echo -e \
420"  \033@<:@1;31mCompressed sparse structures will not be available
421  Only sparsity patterns can be computed\033@<:@0m"
422    warn=true
423fi
424echo
425
426echo \
427"  Build documented examples:        ${docexa}
428  Build additional examples:        ${addexa}
429
430  See ADOL-C/src/config.h for further configuration information.
431-----------------------------------------------------------------------------"
432
433# check for make install problems resulting from missing write permission
434pdir=${prefix}
435writable=true
436while test "x${pdir}" != "x/" ; do
437    if test -e ${pdir} && test ! -w ${pdir}; then
438        writable=false
439        break
440    elif test ! -e ${pdir} ; then
441        pdir=`dirname ${pdir}`
442    else
443        break
444    fi
445done
446if test "x${pdir}" == "x/" ; then
447    writable=false
448fi
449if ! ${writable} ; then
450    echo -e \
451"  \033@<:@1;31mPrefix ${prefix} not writable
452  please run ./configure --prefix=DIR
453  with a writable directory path otherwise administrator privilages
454  will be required to run \`make install'\033@<:@0m"
455    warn=true
456fi
457
458case ${prefix} in
459   ${HOME}|${HOME}/*)
460if $warn ; then
461    for (( i=5; i>0; i-- )); do
462        echo -ne "\rPlease read the above messages carefully, continuing in ${i} seconds"
463        sleep 1
464    done
465    echo -e "\rPlease read the above messages carefully                                 "
466fi
467echo \
468"
469*****************************************************************************
470
471  To successfully compile and run programs using the ADOL-C shared library do
472  the following things:
473     compiling:
474        * add \"-I${prefix}/include\" to your compiler call
475     linking:
476        * add \"-L${prefix}/${_lib} -ladolc\" to your linker call
477        * extend your linker call by \"-Wl,--rpath -Wl,${prefix}/${_lib}\"
478          (if you wish to skip the point \"executing\")
479     executing (do one of the following things):
480        * add ${prefix}/${_lib} to your LD_LIBRARY_PATH variable
481        * ask your system administrator for adding ${prefix}/${_lib} to
482          the global file containing library search paths (/etc/ld.so.conf)
483
484     (or use the static library by replacing
485        \"-L${prefix}/${_lib} -ladolc\" with
486        \"${prefix}/${_lib}/libadolc.a\" when linking)
487
488  See README for instructions on how to change to a nonlocal installation!
489
490*****************************************************************************
491"
492;;
493esac
Note: See TracBrowser for help on using the repository browser.