source: trunk/configure.ac @ 355

Last change on this file since 355 was 354, checked in by kulshres, 7 years ago

Move all external headers into a separate directory

This let's us get rid of the symlink adolc that was previously required
for building and created problems sometimes
This also adjusts all Makefiles for examples to make external builds
possible.

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

  • Property svn:keywords set to Author Date Id Revision
File size: 17.7 KB
Line 
1##############################################################################
2# configure.ac -- Process this file with autoconf to produce configure
3# Revision: $Id: configure.ac 354 2012-10-01 11:32:26Z 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: 354 $)
19AC_CONFIG_SRCDIR([ADOL-C/src/adouble.cpp])
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  [
96  adolc_debug=$enableval
97   AC_MSG_RESULT($adolc_debug)
98   ],
99  [
100   adolc_debug=no
101   AC_MSG_RESULT(no)
102   ])
103
104AC_MSG_CHECKING(whether to use ADOL-C hard debug mode)
105AC_ARG_ENABLE(harddebug,
106              [
107AS_HELP_STRING([--enable-harddebug],[enable ADOL-C hard debug mode
108 [default=no]])],
109  [
110   adolc_harddebug=$enableval
111   AC_MSG_RESULT($adolc_harddebug)
112   ],
113  [
114   adolc_harddebug=no
115   AC_MSG_RESULT(no)
116   ])
117
118if test x$adolc_harddebug == xyes ; then
119adolc_debug=yes
120AC_DEFINE(ADOLC_HARDDEBUG,1,[ADOL-C hard debug mode])
121fi
122
123if test x$adolc_debug == xyes ; then
124AC_DEFINE(ADOLC_DEBUG,1,[ADOL-C debug mode])
125fi
126
127AC_MSG_CHECKING(whether standard adouble constructor shall zero value)
128AC_ARG_ENABLE(stdczero,
129              [
130AS_HELP_STRING([--enable-stdczero],[adouble standard constructor zeros value
131(at the cost of performance) [default=no]])],
132  [
133  adolc_stdczero=$enableval
134  AC_MSG_RESULT($adolc_stdczero)
135  ],
136  [
137  adolc_stdczero=no
138  AC_MSG_RESULT(no)
139  ])
140
141if test x$adolc_stdczero == xyes ; then
142AC_DEFINE(ADOLC_ADOUBLE_STDCZERO,1,[ADOL-C adouble zeroing mode])
143fi
144
145AC_MSG_CHECKING(whether errno is thread save)
146AC_ARG_ENABLE(tserrno,
147              [
148AS_HELP_STRING([--enable-tserrno],[use errno as thread number cache [default=no]])],
149  [
150  adolc_tserrno=$enableval
151  AC_MSG_RESULT($adolc_tserrno)
152   ],
153  [
154  adolc_tserrno=no
155  AC_MSG_RESULT(no)
156  ])
157
158if test x$adolc_tserrno == xyes ; then
159AC_DEFINE(ADOLC_THREADSAVE_ERRNO,1,[ADOL-C thread save errno mode])
160fi
161
162AC_MSG_CHECKING(whether external function call forces backup of all adoubles)
163AC_ARG_ENABLE(safe_extern,
164              [
165AS_HELP_STRING([--enable-safe-extern],[backup all adoubles before calling an external function [default=no]])],
166  [
167  adolc_safe_extern=$enableval
168  AC_MSG_RESULT($adolc_safe_extern)
169  ],
170  [
171  adolc_safe_extern=no
172  AC_MSG_RESULT(no)
173  ])
174
175if test x$adolc_safe_extern == xyes ; then
176AC_DEFINE(ADOLC_SAFE_EXTERN,1,[ADOL-C safe extern mode])
177fi
178
179AC_MSG_CHECKING(which flag to use to enable OpenMP)
180AC_ARG_WITH(openmp-flag,
181            [AS_HELP_STRING([--with-openmp-flag=FLAG],
182                            [use FLAG to enable OpenMP at compile time [default=none]])],
183            [ac_adolc_openmpflag=$withval
184             AC_MSG_RESULT($ac_adolc_openmpflag)],
185            [ac_adolc_openmpflag=""
186             AC_MSG_RESULT(none)])
187
188
189# ADOL-C Sparse facility
190AC_MSG_CHECKING(whether to build sparse drivers)
191AC_ARG_ENABLE(sparse,
192            [
193AS_HELP_STRING([--enable-sparse],[build sparse drivers [default=disabled]])],
194            [sparse=$enableval
195             AC_MSG_RESULT($sparse)],
196            [sparse="no"
197             AC_MSG_RESULT(no)])
198
199AC_ARG_WITH(colpack,
200        [
201AS_HELP_STRING([--with-colpack=DIR],[path to the colpack library and headers [default=system libraries]])],
202[
203colpack=$withval
204COLPACK_CFLAGS="$ac_adolc_openmpflag -I$colpack/include"
205COLPACK_LIBDIR="$colpack/${_lib}"
206COLPACK_LIBS="$ac_adolc_openmpflag -L$COLPACK_LIBDIR -lColPack"
207],
208[
209COLPACK_CFLAGS="$ac_adolc_openmpflag"
210COLPACK_LIBDIR=""
211COLPACK_LIBS="-lColPack"
212])
213
214AC_LANG_PUSH([C++])
215save_CPPFLAGS="$CPPFLAGS"
216save_LIBS="$LIBS"
217CPPFLAGS="$CPPFLAGS $COLPACK_CFLAGS"
218LIBS="$COLPACK_LIBS $LIBS"
219AC_MSG_CHECKING(for ColPack in $COLPACK_LIBDIR)
220AC_CHECK_HEADER([ColPack/ColPackHeaders.h],[have_colpackheaders=yes],[have_colpackheaders=no])
221if test x$have_colpackheaders = xyes ; then
222   AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <ColPack/ColPackHeaders.h>],
223                        [ColPack::GraphColoring g])],
224                       [have_colpack=yes
225                        AC_MSG_RESULT(linking with -lColPack succeeded)],
226                       [have_colpack=no,
227                        AC_MSG_RESULT(linking with -lColPack failed)])
228else
229    have_colpack=no
230fi
231CPPFLAGS="$save_CPPFLAGS"
232LIBS="$save_LIBS"
233AC_LANG_POP([C++])
234
235AM_CONDITIONAL(HAVE_LIBCOLPACK,[test x$have_colpack = xyes])
236if test x$have_colpack = xyes; then
237   sparse=yes
238   echo "will build sparse drivers as linking with -lColPack succeeded"
239fi
240AM_CONDITIONAL(SPARSE,[test x${sparse} = xyes])
241
242if test x$sparse = xyes && test x$have_colpack = xyes; then
243        AC_DEFINE(HAVE_LIBCOLPACK,[1],[Define 1 if ColPack is available])
244else
245        COLPACK_CFLAGS=""
246        COLPACK_LIBS=""
247fi
248AC_SUBST(COLPACK_CFLAGS)
249AC_SUBST(COLPACK_LIBS)
250
251# ADOL-C Examples
252AC_MSG_CHECKING(whether to build documented examples)
253AC_ARG_ENABLE(docexa,
254            [
255AS_HELP_STRING([--enable-docexa],[build documented examples [default=disabled]])],
256            [docexa=$enableval
257             AC_MSG_RESULT(yes)],
258            [docexa="no"
259             AC_MSG_RESULT(no)])
260AM_CONDITIONAL(DOCEXA,[test x${docexa} = xyes])
261
262AC_MSG_CHECKING(whether to build additional examples)
263AC_ARG_ENABLE(addexa,
264            [AS_HELP_STRING([--enable-addexa],
265                            [build additional examples [default=disabled]])],
266            [addexa=$enableval
267             AC_MSG_RESULT(yes)],
268            [addexa="no"
269             AC_MSG_RESULT(no)])
270AM_CONDITIONAL(ADDEXA,[test x${addexa} = xyes])
271
272AC_MSG_CHECKING(whether to build parallel example)
273AC_ARG_ENABLE(parexa,
274            [AS_HELP_STRING([--enable-parexa],
275                            [build parallel example [default=disabled], if enabled -with-openmp-flag=FLAG required])],
276            [parexa=$enableval
277             AC_MSG_RESULT(yes)],
278            [parexa="no"
279             AC_MSG_RESULT(no)])
280AM_CONDITIONAL(PAREXA,[test x${parexa} = xyes])
281
282# ADOL-C Compilation flags
283AC_MSG_CHECKING(which CFLAGS to use)
284AC_ARG_WITH(cflags,
285            [AS_HELP_STRING([--with-cflags=FLAGS],
286                            [use CFLAGS=FLAGS (default: -O2)])],
287            [ac_adolc_cflags="$withval"
288             if test x${adolc_debug} == xyes ||
289                test x${adolc_harddebug} == xyes ; then
290                ac_adolc_cflags="$ac_adolc_cflags -g -O0"
291             fi
292             ac_adolc_cflags="$ac_adolc_cflags $ac_adolc_openmpflag"
293             AC_SUBST(ac_adolc_cflags)
294             AC_MSG_RESULT($ac_adolc_cflags)],
295            [if test "$ac_shell_cflags" = "not_set"; then
296                ac_adolc_cflags="-O2"
297                if test x${adolc_debug} == xyes ||
298                   test x${adolc_harddebug} == xyes ; then
299                   ac_adolc_cflags="-g -O3 -Wall -ansi"
300                fi
301             else
302                ac_adolc_cflags="$CFLAGS"
303             fi
304             ac_adolc_cflags="$ac_adolc_cflags $ac_adolc_openmpflag"
305
306             AC_SUBST(ac_adolc_cflags)
307             AC_MSG_RESULT($ac_adolc_cflags)])
308
309AC_MSG_CHECKING(which CXXFLAGS to use)
310AC_ARG_WITH(cxxflags,
311            [AS_HELP_STRING([--with-cxxflags=FLAGS],
312                            [use CXXFLAGS=FLAGS (default: -O2)])],
313            [ac_adolc_cxxflags="$withval"
314             if test x${adolc_debug} == xyes ||
315                test x${adolc_harddebug} == xyes ; then
316                ac_adolc_cxxflags="$ac_adolc_cxxflags -g -O0"
317             fi
318             ac_adolc_cxxflags="$ac_adolc_cxxflags $ac_adolc_openmpflag"
319             AC_SUBST(ac_adolc_cxxflags)
320             AC_MSG_RESULT($ac_adolc_cxxflags)],
321            [if test "$ac_shell_cxxflags" = "not_set"; then
322                ac_adolc_cxxflags="-O2"
323                if test x${adolc_debug} == xyes ||
324                   test x${adolc_harddebug} == xyes ; then
325                   ac_adolc_cxxflags="-g -O0 -Wall"
326                fi
327             else
328                ac_adolc_cxxflags="$CXXFLAGS"
329             fi
330             ac_adolc_cxxflags="$ac_adolc_cxxflags $ac_adolc_openmpflag"
331            AC_SUBST(ac_adolc_cxxflags)
332             AC_MSG_RESULT($ac_adolc_cxxflags)])
333
334###########################################################################
335#                      COIN_PATCH_LIBTOOL_CYGWIN                          #
336###########################################################################
337
338# Patches to libtool for cygwin. Lots for cl, a few for GCC.
339# For cl:
340# - cygpath is not correctly quoted in fix_srcfile_path
341# - paths generated for .lib files is not run through cygpath -w
342
343#
344# REQUIRED FOR COMPILATION WITH CYGWIN !!!
345#
346 
347
348AC_DEFUN([AC_COIN_PATCH_LIBTOOL_CYGWIN],
349[ case "$CXX" in
350    cl* | */cl* | CL* | */CL* | icl* | */icl* | ICL* | */ICL*)
351      AC_MSG_NOTICE(Applying patches to libtool for cl compiler)
352      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
353          -e 's|fix_srcfile_path=\"\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
354          -e 's%compile_deplibs=\"\$dir/\$old_library \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$old_library | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
355          -e 's%compile_deplibs=\"\$dir/\$linklib \$compile_deplibs\"%compile_deplibs="'\`"$CYGPATH_W"' \$dir/\$linklib | sed -e '"'"'sY\\\\\\\\Y/Yg'"'"\`' \$compile_deplibs\"'% \
356          -e 's%lib /OUT:%lib -OUT:%' \
357          -e "s%cygpath -w%$CYGPATH_W%" \
358          -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%' \
359          -e 's/$AR t/lib -nologo -list/' \
360          -e 's%f_ex_an_ar_oldlib="\($?*1*\)"%f_ex_an_ar_oldlib='\`"$CYGPATH_W"' \1`%' \
361          -e 's%^archive_cmds=.*%archive_cmds="\\$CC -o \\$lib \\$libobjs \\$compiler_flags \\\\\\`echo \\\\\\"\\$deplibs\\\\\\" | \\$SED -e '"\'"'s/ -lc\\$//'"\'"'\\\\\\` -link -dll~linknames="%' \
362          -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"%' \
363      libtool > conftest.bla
364
365      mv conftest.bla libtool
366      chmod 755 libtool
367      ;;
368    *)
369      AC_MSG_NOTICE(Applying patches to libtool for GNU compiler)
370      sed -e 's|fix_srcfile_path=\"`cygpath -w \"\$srcfile\"`\"|fix_srcfile_path=\"\\\`'"$CYGPATH_W"' \\\"\\$srcfile\\\"\\\`\"|' \
371          -e 's|"lib /OUT:\\$oldlib\\$oldobjs\\$old_deplibs"|"\\$AR \\$AR_FLAGS \\$oldlib\\$oldobjs\\$old_deplibs~\\$RANLIB \\$oldlib"|' \
372          -e 's|libext="lib"|libext="a"|' \
373      libtool > conftest.bla
374
375      mv conftest.bla libtool
376      chmod 755 libtool
377      ;;
378  esac ]) # COIN_PATCH_LIBTOOL_CYGWIN
379 
380
381# output
382AC_CONFIG_FILES(Makefile
383                ADOL-C/Makefile
384                ADOL-C/include/Makefile
385                ADOL-C/include/adolc/Makefile
386                ADOL-C/include/adolc/drivers/Makefile
387                ADOL-C/include/adolc/sparse/Makefile
388                ADOL-C/include/adolc/tapedoc/Makefile
389                ADOL-C/src/Makefile
390                ADOL-C/src/drivers/Makefile
391                ADOL-C/src/sparse/Makefile
392                ADOL-C/src/tapedoc/Makefile
393                ADOL-C/doc/version.tex
394                ADOL-C/examples/Makefile
395                ADOL-C/examples/additional_examples/Makefile
396                ADOL-C/examples/additional_examples/clock/Makefile
397                ADOL-C/examples/additional_examples/checkpointing/Makefile
398                ADOL-C/examples/additional_examples/ext_diff_func/Makefile
399                ADOL-C/examples/additional_examples/fixpoint_exam/Makefile
400                ADOL-C/examples/additional_examples/hessmat/Makefile
401                ADOL-C/examples/additional_examples/lufact/Makefile
402                ADOL-C/examples/additional_examples/openmp_exam/Makefile
403                ADOL-C/examples/additional_examples/scal/Makefile
404                ADOL-C/examples/additional_examples/speelpenning/Makefile
405                ADOL-C/examples/additional_examples/taylor/Makefile
406                ADOL-C/examples/additional_examples/detexam/Makefile
407                ADOL-C/examples/additional_examples/helm/Makefile
408                ADOL-C/examples/additional_examples/lighthouse/Makefile
409                ADOL-C/examples/additional_examples/ode/Makefile
410                ADOL-C/examples/additional_examples/sparse/Makefile
411                ADOL-C/examples/additional_examples/tapesave/Makefile
412                ADOL-C/examples/additional_examples/pow/Makefile
413                ADOL-C/examples/additional_examples/timing/Makefile
414                ADOL-C/test/Makefile
415                MSVisualStudio/v10/sparse/config.h
416                MSVisualStudio/v10/nosparse/config.h
417                MSVisualStudio/v10/x64/sparse/config.h
418                MSVisualStudio/v10/x64/nosparse/config.h
419                adolc.spec
420)
421
422AC_OUTPUT
423
424#call libtool for cygwin
425AC_COIN_PATCH_LIBTOOL_CYGWIN
426warn=false
427# echo configuration
428echo \
429"
430-----------------------------------------------------------------------------
431Configuration:
432
433  C compiler:                       ${CC}
434  C++ compiler:                     ${CXX}
435  Linker:                           ${LD}
436  Source code location:             `pwd`
437  Install path:                     ${prefix}
438 
439  CFLAGS:                           ${ac_adolc_cflags}
440  CXXFLAGS:                         ${ac_adolc_cxxflags}
441
442  Use ADOL-C debug mode:            ${adolc_debug}
443  Use ADOL-C hard debug mode:       ${adolc_harddebug}
444  Use ADOL-C adouble zeroing mode:  ${adolc_stdczero}"
445
446if [[ "x${ac_adolc_openmpflag}" != "x" ]] ; then
447    echo \
448"  Access thread number via errno:   ${adolc_tserrno}"
449fi
450
451echo \
452"  Use ADOL-C safe extern mode:      ${adolc_safe_extern}
453
454  Build sparse drivers:             ${sparse}
455  Build with ColPack:               ${have_colpack}"
456if test x$sparse = xyes && test x$have_colpack = xno; then
457    echo -e \
458"  \033@<:@1;31mCompressed sparse structures will not be available
459  Only sparsity patterns can be computed\033@<:@0m"
460    warn=true
461fi
462echo
463
464echo \
465"  Build documented examples:        ${docexa}
466  Build additional examples:        ${addexa}
467
468  See ADOL-C/src/config.h for further configuration information.
469-----------------------------------------------------------------------------"
470
471# check for make install problems resulting from missing write permission
472pdir=${prefix}
473writable=true
474while test "x${pdir}" != "x/" ; do
475    if test -e ${pdir} && test ! -w ${pdir}; then
476        writable=false
477        break
478    elif test ! -e ${pdir} ; then
479        pdir=`dirname ${pdir}`
480    else
481        break
482    fi
483done
484if test "x${pdir}" == "x/" ; then
485    writable=false
486fi
487if ! ${writable} ; then
488    echo -e \
489"  \033@<:@1;31mPrefix ${prefix} not writable
490  please run ./configure --prefix=DIR
491  with a writable directory path otherwise administrator privilages
492  will be required to run \`make install'\033@<:@0m"
493    warn=true
494fi
495
496case ${prefix} in
497   ${HOME}|${HOME}/*)
498if $warn ; then
499    for (( i=5; i>0; i-- )); do
500        echo -ne "\rPlease read the above messages carefully, continuing in ${i} seconds"
501        sleep 1
502    done
503    echo -e "\rPlease read the above messages carefully                                 "
504fi
505echo \
506"
507*****************************************************************************
508
509  To successfully compile and run programs using the ADOL-C shared library do
510  the following things:
511     compiling:
512        * add \"-I${prefix}/include\" to your compiler call
513     linking:
514        * add \"-L${prefix}/${_lib} -ladolc\" to your linker call
515        * extend your linker call by \"-Wl,--rpath -Wl,${prefix}/${_lib}\"
516          (if you wish to skip the point \"executing\")
517     executing (do one of the following things):
518        * add ${prefix}/${_lib} to your LD_LIBRARY_PATH variable
519        * ask your system administrator for adding ${prefix}/${_lib} to
520          the global file containing library search paths (/etc/ld.so.conf)
521
522     (or use the static library by replacing
523        \"-L${prefix}/${_lib} -ladolc\" with
524        \"${prefix}/${_lib}/libadolc.a\" when linking)
525
526  See README for instructions on how to change to a nonlocal installation!
527
528*****************************************************************************
529"
530;;
531esac
Note: See TracBrowser for help on using the repository browser.