source: trunk/configure.ac @ 296

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

Follow the latest changes in ColPack? version 1.0.6

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 296 2012-03-21 15:16:59Z 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: 296 $)
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='${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
72AC_CHECK_FUNCS([floor ftime pow sqrt strchr strtol])
73
74# substitutions
75AC_SUBST(ac_aux_dir)
76
77# Checks for libraries
78AC_CHECK_LIB([m], [pow])
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
166test "x${ac_pwd}" = x && ac_pwd=`pwd`
167abs_srcdir=`readlink -f ${ac_pwd}/${srcdir}`
168AC_ARG_WITH(colpack,
169        [
170AS_HELP_STRING([--with-colpack=DIR],[path to the colpack library and headers [default=${srcdir}/ThirdParty/ColPack]])],
171                [
172colpack=$withval
173COLPACK_CFLAGS="$ac_adolc_openmpflag -I$colpack/include"
174COLPACK_LIBDIR="$colpack/${_lib}"
175COLPACK_LIBS="$ac_adolc_openmpflag -L$COLPACK_LIBDIR -lColPack"
176],
177[
178COLPACK_CFLAGS="$ac_adolc_openmpflag"
179COLPACK_LIBDIR=""
180COLPACK_LIBS="-lColPack"
181])
182
183AC_LANG_PUSH([C++])
184save_CPPFLAGS="$CPPFLAGS"
185save_LIBS="$LIBS"
186CPPFLAGS="$CPPFLAGS $COLPACK_CFLAGS"
187LIBS="$COLPACK_LIBS $LIBS"
188AC_MSG_CHECKING(for ColPack in $COLPACK_LIBDIR)
189AC_CHECK_HEADER([ColPack/ColPackHeaders.h],[have_colpackheaders=yes],[have_colpackheaders=no])
190if test x$have_colpackheaders = xyes ; then
191   AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <ColPack/ColPackHeaders.h>],
192                        [ColPack::GraphColoring g])],
193                       [have_colpack=yes
194                        AC_MSG_RESULT(linking with -lColPack succeeded)],
195                       [have_colpack=no,
196                        AC_MSG_RESULT(linking with -lColPack failed)])
197else
198    have_colpack=no
199fi
200CPPFLAGS="$save_CPPFLAGS"
201LIBS="$save_LIBS"
202AC_LANG_POP([C++])
203
204AM_CONDITIONAL(HAVE_LIBCOLPACK,[test x$have_colpack = xyes])
205if test x$have_colpack = xyes; then
206   sparse=yes
207   echo "will build sparse drivers as linking with -lColPack succeeded"
208fi
209AM_CONDITIONAL(SPARSE,[test x${sparse} = xyes])
210
211if test x$sparse = xyes && test x$have_colpack = xyes; then
212        AC_DEFINE(HAVE_LIBCOLPACK,[1],[Define 1 if ColPack is available])
213else
214        COLPACK_CFLAGS=""
215        COLPACK_LIBS=""
216fi
217AC_SUBST(COLPACK_CFLAGS)
218AC_SUBST(COLPACK_LIBS)
219
220# ADOL-C Examples
221AC_MSG_CHECKING(whether to build documented examples)
222AC_ARG_ENABLE(docexa,
223            [
224AS_HELP_STRING([--enable-docexa],[build documented examples [default=disabled]])],
225            [docexa=$enableval
226             AC_MSG_RESULT(yes)],
227            [docexa="no"
228             AC_MSG_RESULT(no)])
229AM_CONDITIONAL(DOCEXA,[test x${docexa} = xyes])
230
231AC_MSG_CHECKING(whether to build additional examples)
232AC_ARG_ENABLE(addexa,
233            [AS_HELP_STRING([--enable-addexa],
234                            [build additional examples [default=disabled]])],
235            [addexa=$enableval
236             AC_MSG_RESULT(yes)],
237            [addexa="no"
238             AC_MSG_RESULT(no)])
239AM_CONDITIONAL(ADDEXA,[test x${addexa} = xyes])
240
241AC_MSG_CHECKING(whether to build parallel example)
242AC_ARG_ENABLE(parexa,
243            [AS_HELP_STRING([--enable-parexa],
244                            [build parallel example [default=disabled], if enabled -with-openmp-flag=FLAG required])],
245            [parexa=$enableval
246             AC_MSG_RESULT(yes)],
247            [parexa="no"
248             AC_MSG_RESULT(no)])
249AM_CONDITIONAL(PAREXA,[test x${parexa} = xyes])
250
251# ADOL-C Compilation flags
252AC_MSG_CHECKING(which CFLAGS to use)
253AC_ARG_WITH(cflags,
254            [AS_HELP_STRING([--with-cflags=FLAGS],
255                            [use CFLAGS=FLAGS (default: -O2)])],
256            [ac_adolc_cflags="$withval"
257             if test x${adolc_debug} == xyes ||
258                test x${adolc_harddebug} == xyes ; then
259                ac_adolc_cflags="$ac_adolc_cflags -g -O0"
260             fi
261             ac_adolc_cflags="$ac_adolc_cflags $ac_adolc_openmpflag"
262             AC_SUBST(ac_adolc_cflags)
263             AC_MSG_RESULT($ac_adolc_cflags)],
264            [if test "$ac_shell_cflags" = "not_set"; then
265                ac_adolc_cflags="-O2"
266                if test x${adolc_debug} == xyes ||
267                   test x${adolc_harddebug} == xyes ; then
268                   ac_adolc_cflags="-g -O3 -Wall -ansi"
269                fi
270             else
271                ac_adolc_cflags="$CFLAGS"
272             fi
273             ac_adolc_cflags="$ac_adolc_cflags $ac_adolc_openmpflag"
274
275             AC_SUBST(ac_adolc_cflags)
276             AC_MSG_RESULT($ac_adolc_cflags)])
277
278AC_MSG_CHECKING(which CXXFLAGS to use)
279AC_ARG_WITH(cxxflags,
280            [AS_HELP_STRING([--with-cxxflags=FLAGS],
281                            [use CXXFLAGS=FLAGS (default: -O2)])],
282            [ac_adolc_cxxflags="$withval"
283             if test x${adolc_debug} == xyes ||
284                test x${adolc_harddebug} == xyes ; then
285                ac_adolc_cxxflags="$ac_adolc_cxxflags -g -O0"
286             fi
287             ac_adolc_cxxflags="$ac_adolc_cxxflags $ac_adolc_openmpflag"
288             AC_SUBST(ac_adolc_cxxflags)
289             AC_MSG_RESULT($ac_adolc_cxxflags)],
290            [if test "$ac_shell_cxxflags" = "not_set"; then
291                ac_adolc_cxxflags="-O2"
292                if test x${adolc_debug} == xyes ||
293                   test x${adolc_harddebug} == xyes ; then
294                   ac_adolc_cxxflags="-g -O0 -Wall"
295                fi
296             else
297                ac_adolc_cxxflags="$CXXFLAGS"
298             fi
299             ac_adolc_cxxflags="$ac_adolc_cxxflags $ac_adolc_openmpflag"
300            AC_SUBST(ac_adolc_cxxflags)
301             AC_MSG_RESULT($ac_adolc_cxxflags)])
302
303###########################################################################
304#                      COIN_PATCH_LIBTOOL_CYGWIN                          #
305###########################################################################
306
307# Patches to libtool for cygwin. Lots for cl, a few for GCC.
308# For cl:
309# - cygpath is not correctly quoted in fix_srcfile_path
310# - paths generated for .lib files is not run through cygpath -w
311
312#
313# REQUIRED FOR COMPILATION WITH CYGWIN !!!
314#
315 
316
317AC_DEFUN([AC_COIN_PATCH_LIBTOOL_CYGWIN],
318[ case "$CXX" in
319    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
320      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
321      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
322          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
323          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
324          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
325          -e 's%lib /OUT:%lib -OUT:%' \
326          -e "s%cygpath -w%$CYGPATH_W%" \
327          -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%' \
328          -e 's/$AR t/lib -nologo -list/' \
329          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
330          -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
331          -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"%' \
332      libtool > conftest.bla
333
334      mv conftest.bla libtool
335      chmod 755 libtool
336      ;;
337    *)
338      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
339      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
340          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
341          -e 's|libext="lib"|libext="a"|' \
342      libtool > conftest.bla
343
344      mv conftest.bla libtool
345      chmod 755 libtool
346      ;;
347  esac ]) # COIN_PATCH_LIBTOOL_CYGWIN
348 
349
350# output
351AC_CONFIG_FILES(Makefile
352                ADOL-C/Makefile
353                ADOL-C/src/Makefile
354                ADOL-C/src/drivers/Makefile
355                ADOL-C/src/sparse/Makefile
356                ADOL-C/src/tapedoc/Makefile
357                ADOL-C/doc/version.tex
358                ADOL-C/examples/Makefile
359                ADOL-C/examples/additional_examples/Makefile
360                ADOL-C/examples/additional_examples/clock/Makefile
361                ADOL-C/examples/additional_examples/checkpointing/Makefile
362                ADOL-C/examples/additional_examples/ext_diff_func/Makefile
363                ADOL-C/examples/additional_examples/fixpoint_exam/Makefile
364                ADOL-C/examples/additional_examples/hessmat/Makefile
365                ADOL-C/examples/additional_examples/lufact/Makefile
366                ADOL-C/examples/additional_examples/openmp_exam/Makefile
367                ADOL-C/examples/additional_examples/scal/Makefile
368                ADOL-C/examples/additional_examples/speelpenning/Makefile
369                ADOL-C/examples/additional_examples/taylor/Makefile
370                ADOL-C/examples/additional_examples/detexam/Makefile
371                ADOL-C/examples/additional_examples/helm/Makefile
372                ADOL-C/examples/additional_examples/lighthouse/Makefile
373                ADOL-C/examples/additional_examples/ode/Makefile
374                ADOL-C/examples/additional_examples/sparse/Makefile
375                ADOL-C/examples/additional_examples/tapesave/Makefile
376                ADOL-C/examples/additional_examples/pow/Makefile
377                ADOL-C/examples/additional_examples/timing/Makefile
378                ADOL-C/test/Makefile
379                MSVisualStudio/v10/sparse/config.h
380                MSVisualStudio/v10/nosparse/config.h
381                MSVisualStudio/v10/x64/sparse/config.h
382                MSVisualStudio/v10/x64/nosparse/config.h
383                adolc.spec
384)
385
386AC_OUTPUT
387
388#call libtool for cygwin
389AC_COIN_PATCH_LIBTOOL_CYGWIN
390warn=false
391# echo configuration
392echo \
393"
394-----------------------------------------------------------------------------
395Configuration:
396
397  C compiler:                       ${CC}
398  C++ compiler:                     ${CXX}
399  Linker:                           ${LD}
400  Source code location:             `pwd`
401  Install path:                     ${prefix}
402 
403  CFLAGS:                           ${ac_adolc_cflags}
404  CXXFLAGS:                         ${ac_adolc_cxxflags}
405
406  Use ADOL-C debug mode:            ${adolc_debug}
407  Use ADOL-C hard debug mode:       ${adolc_harddebug}
408  Use ADOL-C adouble zeroing mode:  ${adolc_stdczero}"
409
410if [[ "x${ac_adolc_openmpflag}" != "x" ]] ; then
411    echo \
412"  Access thread number via errno:   ${adolc_tserrno}"
413fi
414
415echo \
416"  Use ADOL-C safe extern mode:      ${adolc_safe_extern}
417
418  Build sparse drivers:             ${sparse}
419  Build with ColPack:               ${have_colpack}"
420if test x$sparse = xyes && test x$have_colpack = xno; then
421    echo -e \
422"  \033@<:@1;31mCompressed sparse structures will not be available
423  Only sparsity patterns can be computed\033@<:@0m"
424    warn=true
425fi
426echo
427
428echo \
429"  Build documented examples:        ${docexa}
430  Build additional examples:        ${addexa}
431
432  See ADOL-C/src/config.h for further configuration information.
433-----------------------------------------------------------------------------"
434
435# check for make install problems resulting from missing write permission
436pdir=${prefix}
437writable=true
438while test "x${pdir}" != "x/" ; do
439    if test -e ${pdir} && test ! -w ${pdir}; then
440        writable=false
441        break
442    elif test ! -e ${pdir} ; then
443        pdir=`dirname ${pdir}`
444    else
445        break
446    fi
447done
448if test "x${pdir}" == "x/" ; then
449    writable=false
450fi
451if ! ${writable} ; then
452    echo -e \
453"  \033@<:@1;31mPrefix ${prefix} not writable
454  please run ./configure --prefix=DIR
455  with a writable directory path otherwise administrator privilages
456  will be required to run \`make install'\033@<:@0m"
457    warn=true
458fi
459
460case ${prefix} in
461   ${HOME}|${HOME}/*)
462if $warn ; then
463    for (( i=5; i>0; i-- )); do
464        echo -ne "\rPlease read the above messages carefully, continuing in ${i} seconds"
465        sleep 1
466    done
467    echo -e "\rPlease read the above messages carefully                                 "
468fi
469echo \
470"
471*****************************************************************************
472
473  To successfully compile and run programs using the ADOL-C shared library do
474  the following things:
475     compiling:
476        * add \"-I${prefix}/include\" to your compiler call
477     linking:
478        * add \"-L${prefix}/${_lib} -ladolc\" to your linker call
479        * extend your linker call by \"-Wl,--rpath -Wl,${prefix}/${_lib}\"
480          (if you wish to skip the point \"executing\")
481     executing (do one of the following things):
482        * add ${prefix}/${_lib} to your LD_LIBRARY_PATH variable
483        * ask your system administrator for adding ${prefix}/${_lib} to
484          the global file containing library search paths (/etc/ld.so.conf)
485
486     (or use the static library by replacing
487        \"-L${prefix}/${_lib} -ladolc\" with
488        \"${prefix}/${_lib}/libadolc.a\" when linking)
489
490  See README for instructions on how to change to a nonlocal installation!
491
492*****************************************************************************
493"
494;;
495esac
Note: See TracBrowser for help on using the repository browser.