source: git/factory/configure.ac @ 7d160bb

spielwiese
Last change on this file since 7d160bb was 7d160bb, checked in by Oleksandr Motsak <motsak@…>, 10 years ago
Better compiler flags handling by BS fix: empty default compiler flags add: use optimization flags by default (incompatible with debug, see --disable-optimizationflags) add: check multiple compiler flags (debug/optimization) NOTE: some optimization flags lead to GCC crashes. NOTE: no implicit templates cannot be used due to some templated code (tgb*) :(
  • Property mode set to 100644
File size: 12.8 KB
Line 
1
2dnl # emacs edit mode for this file is -*- sh -*-
3
4dnl #
5dnl # configure.in - process this file with `autoconf' to generate
6dnl #   a `configure' script.
7dnl #
8dnl # See the `INSTALL' file for information on how the `configure'
9dnl # script works.
10dnl #
11
12#
13# - initialisation.
14#
15AC_INIT([factory], [3.1.3])
16AC_CONFIG_SRCDIR(canonicalform.cc)
17AC_CONFIG_MACRO_DIR([../m4])
18AC_CONFIG_AUX_DIR([.])
19AC_CONFIG_HEADER(config.h)
20
21AM_MAINTAINER_MODE
22AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # -Wno-extra-portability -Werror silent-rules
23m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
24m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
25
26# Add pre'prefixed config
27AX_PREFIX_CONFIG_H([config.h],[],[config.h])
28
29dnl #
30dnl # Change version here, do not believe the comment in the
31dnl # preceding lines.
32dnl #
33factory_version="3.1.3"
34factory_configuration="'$ac_configure_args' in `pwd`"
35
36#
37# - check for CC and CXX but be careful about CFLAGS.
38#
39SING_RESET_FLAGS()
40SING_CHECK_SET_ARGS()
41
42AC_PROG_CC
43AC_PROG_CXX
44#
45# - check for some other programs.
46#
47AC_PROG_CPP
48AC_PROG_CXXCPP
49AC_PROG_LN_S
50AC_PROG_INSTALL
51AC_DISABLE_STATIC
52AC_PROG_YACC
53LT_INIT
54AC_PROG_MAKE_SET
55AC_CHECK_PROG(AR, ar, ar, where-is-your-ar)
56AC_CHECK_PROG(M4, m4, m4, where-is-your-m4)
57AC_CHECK_PROG(BISON, bison, bison, where-is-your-bison)
58AC_CHECK_SIZEOF(long,4)
59AC_C_CONST
60AC_C_INLINE
61
62
63#
64# - check withs and enables.
65#
66AC_ARG_WITH(
67  Singular,
68  [AS_HELP_STRING([--without-Singular],[build NOT for the use with CAS Singular.])],
69  ,
70  [with_Singular=yes])
71
72AC_ARG_ENABLE(omalloc, AS_HELP_STRING([--enable-omalloc],[build for use with omalloc]),
73[if test "x$enableval" = "xyes"; then
74  ENABLE_OMALLOC=yes
75fi], ENABLE_OMALLOC=no)
76
77AC_ARG_ENABLE(omalloc_trust, AS_HELP_STRING([--enable-omalloc-trust],[do not check the omalloc header]),
78[if test "x$enableval" = "xyes"; then
79  omalloc_trust=yes
80fi], omalloc_trust=no)
81
82AC_ARG_WITH(omalloc_dir,[AS_HELP_STRING([--with-omalloc-dir=PTH],[location of omalloc])], with_omalloc_dir="$withval", with_omalloc_dir="")
83AC_ARG_WITH(omalloc_extra_dir,[AS_HELP_STRING([--with-omalloc-extra-dir=PTH],[optional extra location of omalloc])], with_omalloc_extra_dir="$withval", with_omalloc_extra_dir="")
84
85AC_ARG_ENABLE(
86  cf-inline,
87  [AS_HELP_STRING([--enable-cf-inline],[build Factory with \"configurable inline methods\" enabled.])],
88  [enable_cf_inline=$enableval],
89  [enable_cf_inline=no])
90
91AC_ARG_ENABLE(
92  streamio,
93  [AS_HELP_STRING([--enable-streamio],[build Factory with stream IO])],
94  ,
95  [enable_streamio=no])
96
97AC_ARG_ENABLE(
98  assertions,
99  [AS_HELP_STRING([--disable-assertions],[build Factory with no assertions])],
100  ,
101  enable_assertions=yes)
102
103AC_ARG_ENABLE(
104  timing,
105  [AS_HELP_STRING([--enable-timing],[build Factory so it will print timing information])],
106  ,
107  enable_timing=no)
108
109AC_ARG_ENABLE(
110  debugoutput,
111  [AS_HELP_STRING([--enable-debugoutput],[build Factory so it will print debugging information])],
112  ,
113  enable_debugoutput=no)
114
115AH_TEMPLATE([INT64], [Defenition for INT64])
116# Always long long int???!
117AC_DEFINE([INT64], [long long int]) 
118
119DX_INIT_DOXYGEN($PACKAGE_NAME, MYDOXYGENCONFIG)
120
121# do not use `MKINSTALLDIRS' and `MAKEHEADER' since there may be
122# name clashes with other peoples configure scripts via
123# `config.cache'.  Furthermore, we do not use cache at all to
124# avoid some nasty problems with our own development environment.
125unset ac_cv_path_FACTORY_MKINSTALLDIRS
126unset ac_cv_path_FACTORY_MAKEHEADER
127save_path="$PATH"
128PATH="$PATH:$srcdir/bin"
129AC_PATH_PROG(FACTORY_MKINSTALLDIRS, mkinstalldirs, -mkdir)
130PATH="$srcdir/bin:$save_path"
131AC_PATH_PROG(FACTORY_MAKEHEADER, makeheader)
132PATH="$save_path"
133
134#
135# - expand paths.
136#
137
138AC_MSG_CHECKING(and generating explicit install paths)
139
140# generate Makefile
141save_prefix="$prefix"
142save_exec_prefix="$exec_prefix"
143test "x$prefix" = xNONE && prefix=$ac_default_prefix
144test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
145for dir in prefix exec_prefix bindir sbindir libexecdir \
146           datadir sysconfdir sharedstatedir localstatedir libdir \
147           includedir oldincludedir infodir mandir; do
148  eval "dir_value=\$$dir"
149  cat >> ./conftest.mk << EXPLPATHEOT
150$dir=$dir_value
151explicit_$dir:
152        @ echo \$($dir)
153        @ if echo \$($dir) | grep '^/'; \\
154        then echo \$($dir) > ./conftest.dir; \\
155        else echo \`pwd\`/\$($dir) > ./conftest.dir; fi
156EXPLPATHEOT
157done
158prefix="$save_prefix"
159exec_prefix="$save_exec_prefix"
160
161# generate the explicit paths
162make >&5 2>&1 -f ./conftest.mk explicit_datadir
163explicit_datadir=`cat ./conftest.dir`
164make >&5 2>&1 -f ./conftest.mk explicit_libdir
165explicit_libdir=`cat ./conftest.dir`
166make >&5 2>&1 -f ./conftest.mk explicit_includedir
167explicit_includedir=`cat ./conftest.dir`
168
169# clean up
170rm -f ./conftest.mk ./conftest.dir
171
172AC_MSG_RESULT(done)
173
174#
175# - check for libraries.
176#
177AC_CHECK_LIB(m, atof, , [ AC_MSG_ERROR(libm.a not found) ])
178
179LB_CHECK_GMP(3.1.1,,AC_MSG_ERROR([Unable to find GMP on your machine: please use --with-gmp=PATH_TO_DIR_CONTAINING_LIB_AND_INCLUDE (see also ./configure --help if you do not understand what we are talking about)]))
180
181LB_CHECK_NTL(5.0,,AC_MSG_WARN([Unable to find NTL (which is strongly recommended) on your machine: please use --with-ntl=PATH_TO_DIR_CONTAINING_LIB_AND_INCLUDE (see also ./configure --help if you do not understand what we are talking about)]))
182
183LB_CHECK_FLINT(2.3,,AC_MSG_WARN([Unable to find FLINT (which is strongly recommended) on your machine: please use --with-flint=PATH_TO_DIR_CONTAINING_LIB_AND_INCLUDE (see also ./configure --help if you do not understand what we are talking about)]))
184
185# arithmetic shift
186#AC_MSG_CHECKING(whether your compiler does arithmetic shifts)
187#AC_CACHE_VAL(ac_cv_shift,
188#  [ LDFLAGS="-L$explicit_libdir $LDFLAGS"
189#       AC_TRY_RUN(
190#      [ int main() { if (-2 >> 1 == -1) return(0); else return(1); } ],
191#      ac_cv_shift=yes, ac_cv_shift=no, ac_cv_shift=yes) ])
192#if test "x$ac_cv_shift" = xyes; then   
193#  AC_MSG_RESULT(yes)
194#else
195#  AC_MSG_RESULT(no)
196#fi
197
198#
199# - check for header files.
200#
201AC_LANG_CPLUSPLUS
202
203AC_CHECK_HEADERS(stdio.h stdlib.h string.h time.h math.h, ,
204  [ AC_MSG_ERROR(C header files not found) ])
205AC_CHECK_HEADERS(cstdio)
206
207if test "x$enable_streamio" != xno; then
208  AC_CHECK_HEADERS(iostream.h strstream.h fstream.h iostream string fstream)
209  AC_CHECK_HEADERS(ctype.h, , [ AC_MSG_ERROR(standard C header files not found) ])
210
211  # since the FTE will compile only with stream IO enabled we will not
212  # check for the necessary header files if stream IO is disabled
213  AC_CHECK_HEADERS(stdarg.h signal.h errno.h unistd.h, ,
214    [ AC_MSG_WARN(C/C++ header files not found.
215                    You will not be able to build the Factory Test Environment
216                    (though Factory itself should compile)) ])
217fi
218
219if test "x$enable_timing" != xno; then
220  AC_CHECK_HEADERS(sys/param.h sys/times.h, ,
221    [ AC_MSG_ERROR(\`sys/times.h' or \`sys/param.h' not found.  Try
222                  \`configure --disable-timing') ])
223fi
224
225# font-lock-trick: '
226
227#
228# - check for compiler characteristics.
229#
230
231# use C to check compiler characteristics instead of C++.  On
232# nextstep, checking with C++ may fail.
233AC_LANG_C
234
235# cross-compiling ?!
236#AC_C_CROSS
237#if test "x$cross_compiling" = xyes; then
238#  AC_MSG_WARN([you better specify a cache file to get the values for
239#                    cross-compiling right (e.g., call \`configure
240#                    --cache-file=yourTarget.cache').  In particular, you
241#                    should make sure that your target machine supports
242#                    arithmetic shift.])
243#fi
244
245# font-lock-trick: '
246
247#
248# - paths.
249#
250
251# note that Singular has its own mechanism to search the tables,
252# hence we do not need to mind it here
253gftabledir='${datadir}/factory/gftables'
254explicit_gftabledir="$explicit_datadir/gftables"
255
256# for installation of the templates
257templatedir='${includedir}/templates'
258
259#
260# - the name of the game and the targets to create.
261#
262if test "x$with_Singular" = xyes; then
263  libfactory=libfactory.a
264
265  factorysrc='$(basefactorysrc) $(singfactorysrc)'
266  factoryincl='$(basefactoryincl) $(singfactoryincl)'
267
268  alltargets=cf
269  installtargets=installcf
270  uninstalltargets=uninstallcf
271else
272  libfactory=libcf.a
273
274  factorysrc='$(basefactorysrc)'
275  factoryincl='$(basefactoryincl)'
276
277  alltargets=cf
278  installtargets=installcf
279  uninstalltargets=uninstallcf
280fi
281
282#
283# - set defines and variables according to our tests.
284#
285
286# CFLAGS
287if test "x$GCC" = xyes && test "x$cflags_expl_set" = xno; then
288  CFLAGS=""
289fi
290
291# CXXFLAGS
292if test "x$GXX" = xyes && test "x$cxxflags_expl_set" = xno; then
293  CXXFLAGS=""
294
295AC_LANG_SAVE
296AC_LANG_CPLUSPLUS
297# check whether CXX accepts -fno-rtti
298AC_MSG_CHECKING(whether gcc accepts -fno-rtti)
299tmp_flags=${CXXFLAGS}
300CXXFLAGS="${CXXFLAGS}"
301AC_CACHE_VAL(ac_cv_cxx_have_rtti,
302AC_TRY_COMPILE(,,ac_cv_cxx_have_rtti=yes,ac_cv_cxx_have_rtti=no)
303)
304AC_MSG_RESULT(${ac_cv_cxx_have_rtti})
305CXXFLAGS=$tmp_flags
306if test "${ac_cv_cxx_have_rtti}" = yes; then
307CXXFLAGS="$CXXFLAGS"
308fi
309
310AC_MSG_CHECKING(whether gcc accepts -fno-exceptions)
311tmp_flags=${CXXFLAGS}
312CXXFLAGS="${CXXFLAGS} -fno-exceptions"
313AC_CACHE_VAL(ac_cv_cxx_have_exceptions,
314AC_TRY_LINK(,,ac_cv_cxx_have_exceptions=yes,ac_cv_cxx_have_exceptions=no)
315)
316AC_MSG_RESULT(${ac_cv_cxx_have_exceptions})
317CXXFLAGS=$tmp_flags
318if test "${ac_cv_cxx_have_exceptions}" = yes; then
319CXXFLAGS="$CXXFLAGS -fno-exceptions"
320fi
321AC_LANG_RESTORE
322
323fi
324
325# ARFLAGS
326test "${ARFLAGS+set}" = set || ARFLAGS=cr
327
328# M4FLAGS
329test "${M4FLAGS+set}" = set || M4FLAGS=
330
331AH_TEMPLATE([SINGULAR], [define if linked to Singular])
332AH_TEMPLATE([DISABLE_GMP_CPP],[DISABLE_GMP_CPP])
333AH_TEMPLATE([NOSTREAMIO],[DISABLE_GMP_CPP])
334
335# Singular
336if test "x$with_Singular" = xyes; then
337  AC_DEFINE([SINGULAR],[1]) 
338  AC_DEFINE([DISABLE_GMP_CPP],[1])
339  AC_DEFINE([NOSTREAMIO],[1])
340fi
341
342# arithmetic shift
343#if test "x$ac_cv_shift" = xyes; then   
344#  AC_DEFINE([HAS_ARITHMETIC_SHIFT],[1],[HAS_ARITHMETIC_SHIFT])
345#fi
346
347AH_TEMPLATE([HAVE_OMALLOC], [define if build with OMALLOC])
348
349if test "x$with_Singular" = xyes; then
350
351AC_MSG_CHECKING([whether to use omalloc/omalloc.h])
352if test "x$ENABLE_OMALLOC" = xyes; then
353  AC_MSG_RESULT(yes)
354 
355  if test "x$with_omalloc_dir" != "x"; then
356    OMALLOC_CFLAGS="-I${with_omalloc_dir}"
357  fi
358  if test "x$with_omalloc_extra_dir" != "x"; then
359    OMALLOC_CFLAGS="$OMALLOC_CFLAGS -I${with_omalloc_extra_dir}"
360    OMALLOC_LDFLAGS="$OMALLOC_LDFLAGS -L${with_omalloc_extra_dir}/omalloc -L${with_omalloc_extra_dir}/resources"
361  fi
362 
363  CPPFLAGS_save="$CPPFLAGS"
364  # adding $with_omalloc_dir and $with_omalloc_extra_dir to header search path
365  CPPFLAGS="$CPPFLAGS ${OMALLOC_CFLAGS}"
366  if test "x$omalloc_trust" = xno; then
367    AC_CHECK_HEADERS([omalloc/omalloc.h],,AC_MSG_ERROR([You asked for omalloc but it cannot be found with your default header search path]))
368  else
369    AC_CHECK_HEADERS([omalloc/omalloc.h],,AC_MSG_WARN([trusting the omalloc locations given: ${OMALLOC_CFLAGS}]))
370  fi
371  CPPFLAGS="$CPPFLAGS_save"
372
373  OMALLOC_G_LDADD="-lresources_g -lomalloc_g"
374  OMALLOC_R_LDADD="-lresources -lomalloc"
375 
376  AC_DEFINE(HAVE_OMALLOC, 1, [omalloc support])
377 
378  AC_SUBST(OMALLOC_CFLAGS)
379  AC_SUBST(OMALLOC_LDFLAGS)
380
381  AC_SUBST(OMALLOC_G_LDADD)
382  AC_SUBST(OMALLOC_R_LDADD)
383else
384  AC_MSG_RESULT(no)
385fi
386
387fi
388
389AM_CONDITIONAL([ENABLE_OMALLOC],[test "x$ENABLE_OMALLOC" = xyes])
390
391
392AH_TEMPLATE([CF_USE_INLINE], [define to use "configurable inline methods" (see cf_inline.cc)])
393# "configurable inline methods"
394if test "x$enable_cf_inline" != xno; then
395  AC_DEFINE([CF_USE_INLINE],[1])
396fi
397
398AH_TEMPLATE([NOSTREAMIO], [define to build factory without stream IO])
399# iostream
400if test "x$enable_streamio" = xno; then
401  AC_DEFINE([NOSTREAMIO],[1])
402else
403  factorysrc="$factorysrc \$(useiofactorysrc)"
404  factoryincl="$factoryincl \$(useiofactoryincl)"
405fi
406
407AH_TEMPLATE([NOASSERT], [define if you do not want to activate assertions])
408# assertions
409if test "x$enable_assertions" = xno; then
410  AC_DEFINE([NOASSERT],[1])
411fi
412
413AH_TEMPLATE([TIMING], [define if you want to activate the timing stuff])
414# timing
415if test "x$enable_timing" != xno; then
416  AC_DEFINE([TIMING],[1])
417fi
418
419# debugoutput
420AH_TEMPLATE([DEBUGOUTPUT], [define if you want to have debugging output])
421if test "x$enable_debugoutput" != xno; then
422  AC_DEFINE([DEBUGOUTPUT],[1]) 
423fi
424
425#
426# - complete and substitute variables, defines.
427#
428AC_SUBST(gftabledir)
429AC_SUBST(templatedir)
430
431AC_SUBST(factory_version)
432
433AC_SUBST(libfactory)
434
435AC_SUBST(ARFLAGS)
436AC_SUBST(M4FLAGS)
437AC_SUBST(MAKEHEADERFLAGS)
438
439AC_SUBST(factorysrc)
440AC_SUBST(factoryincl)
441
442AC_SUBST(alltargets)
443AC_SUBST(installtargets)
444AC_SUBST(uninstalltargets)
445
446AH_TEMPLATE([FACTORYVERSION], [factory version])
447AC_DEFINE_UNQUOTED([FACTORYVERSION], "$factory_version")
448
449AH_TEMPLATE([HAVE_LIBFAC], [have libfac])
450AC_DEFINE_UNQUOTED([HAVE_LIBFAC], 1)
451
452AH_TEMPLATE([FACTORYCONFIGURATION], [factory configuration])
453AC_DEFINE_UNQUOTED([FACTORYCONFIGURATION], "$factory_configuration")
454
455AH_TEMPLATE([GFTABLEDIR], [where the gftables live])
456AC_DEFINE_UNQUOTED([GFTABLEDIR], "$explicit_gftabledir")
457
458AM_CONDITIONAL(
459    [WITH_PARSER_FOR_CANONICAL_FORM],
460    [test x$with_Singular != xyes && test x$enable_streamio != xno])
461
462AC_CONFIG_FILES([Makefile include/factory/Makefile libfac/Makefile]) #  ftest/GNUmakefile
463AC_OUTPUT
464
Note: See TracBrowser for help on using the repository browser.