source: git/Singular/configure.in @ 7afec5

spielwiese
Last change on this file since 7afec5 was 7afec5, checked in by Hans Schönemann <hannes@…>, 16 years ago
*hannes: SI_CPU_* git-svn-id: file:///usr/local/Singular/svn/trunk@10753 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 25.4 KB
Line 
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(tesths.cc)
3AC_CONFIG_HEADER(mod2.h)
4AC_CONFIG_HEADER(../kernel/mod2.h)
5
6dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
7dnl determine singuname
8dnl
9
10AC_MSG_CHECKING(CPU for singular)
11ac_cv_singcpuname=`uname -p`
12AC_MSG_CHECKING(uname for singular)
13AC_CACHE_VAL(ac_cv_singuname,
14ac_cv_singuname="unknown"
15if test -r "singuname.sh"; then
16  if (/bin/sh singuname.sh >/dev/null 2>&1) then
17    ac_cv_singuname=`/bin/sh singuname.sh`
18  fi
19fi
20if test "$ac_cv_singuname" = unknown && test -r "../singuname.sh"; then
21  if (/bin/sh ../singuname.sh >/dev/null 2>&1) then
22    ac_cv_singuname=`/bin/sh ../singuname.sh`
23  fi
24fi
25)
26AC_MSG_RESULT($ac_cv_singuname)
27if test "$ac_cv_singuname" = unknown; then
28  AC_MSG_WARN(Unknown architecture: Check singuname.sh)
29  ac_cv_singuname="unknown"
30fi
31AC_DEFINE_UNQUOTED(S_UNAME, "$ac_cv_singuname")
32SINGUNAME=$ac_cv_singuname
33AC_SUBST(SINGUNAME)
34
35if test "$ac_cv_singuname" = ix86-Win; then
36  EXEC_EXT=".exe"
37  AC_DEFINE(SI_CPU_I386)
38fi
39AC_SUBST(EXEC_EXT)
40if test "$ac_cv_ac_cv_singcpuname" = sparc; then
41  AC_DEFINE(SI_CPU_SPARC)
42fi
43if test "$ac_cv_singuname" = x86_64-Linux; then
44  AC_DEFINE(SI_CPU_X86_64)
45fi
46if test "$ac_cv_singuname" = IA64-Linux; then
47  AC_DEFINE(SI_CPU_IA64)
48fi
49if test "$ac_cv_singuname" = ppc-Linux; then
50  AC_DEFINE(SI_CPU_PPC)
51fi
52if test "$ac_cv_singuname" = ppcMac-darwin; then
53  AC_DEFINE(SI_CPU_PPC)
54fi
55
56SING_UNAME=`echo $SINGUNAME | tr '-' '_' `
57AC_SUBST(SING_UNAME)
58
59# stupid Win programs do not like dots in their pathnames
60VERSION_SEP="-"
61
62dnl llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
63dnl version stuff -- should be set in ../configure.in
64dnl
65dnl here are some defaults
66
67SINGULAR_MAJOR_VERSION=${SINGULAR_MAJOR_VERSION:-3}
68SINGULAR_MINOR_VERSION=${SINGULAR_MINOR_VERSION:-0}
69SINGULAR_SUB_VERSION=${SINGULAR_SUB_VERSION:-4}
70SINGULAR_VERSION="${SINGULAR_VERSION:-$SINGULAR_MAJOR_VERSION${VERSION_SEP}$SINGULAR_MINOR_VERSION${VERSION_SEP}$SINGULAR_SUB_VERSION}"
71VERSION_DATE=${VERSION_DATE:-"Nov 2007"}
72
73dnl pass them on into the Makefiles
74AC_SUBST(SINGULAR_VERSION)
75AC_SUBST(VERSION_DATE)
76AC_SUBST(SINGULAR_MAJOR_VERSION)
77AC_SUBST(SINGULAR_MINOR_VERSION)
78AC_SUBST(SINGULAR_SUB_VERSION)
79AC_DEFINE_UNQUOTED(SINGULAR_MAJOR_VERSION, ${SINGULAR_MAJOR_VERSION})
80AC_DEFINE_UNQUOTED(SINGULAR_MINOR_VERSION, ${SINGULAR_MINOR_VERSION})
81AC_DEFINE_UNQUOTED(SINGULAR_SUB_VERSION, ${SINGULAR_SUB_VERSION})
82AC_DEFINE_UNQUOTED(S_VERSION1, "${SINGULAR_MAJOR_VERSION}${VERSION_SEP}${SINGULAR_MINOR_VERSION}${VERSION_SEP}${SINGULAR_SUB_VERSION}")
83AC_DEFINE_UNQUOTED(S_VERSION2, "${VERSION_DATE}")
84AC_DEFINE_UNQUOTED(SINGULAR_SUB_VERSION, ${SINGULAR_SUB_VERSION})
85
86
87dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
88dnl compiler stuff
89dnl is needed to check for libs and headers, later on
90dnl
91dnl we do not want to have "-g -O" for CFLAGS
92if test "${CXXFLAGS+set}" != set; then
93  ac_cxxflags_set=no
94  CXXFLAGS="-O"
95fi
96if test "${CFLAGS+set}" != set; then
97  CFLAGS="-O"
98  ac_cflags_set=no
99fi
100
101# check whether CXX was set by user as env variable
102if test "${CXX+set}" != set; then
103  ac_cxx_set=no
104else
105  ac_cxx_set=yes
106fi
107AC_PROG_CC
108AC_PROG_CPP
109AC_PROG_CXX
110AC_PROG_INSTALL
111AC_AIX
112
113# test for gcc-version: gcc2: prefer CC=gcc, CXX=gcc
114#                       gcc3:        CC=gcc  CXX=g++
115#                       other:       CC=cc   CXX=c++
116AC_MSG_CHECKING(gcc version)
117AC_CACHE_VAL(ac_cv_c_cpp,
118ac_cv_c_cp="unknown"
119if test -r "gccversion.sh"; then
120  ac_cv_c_cpp=`/bin/sh gccversion.sh`
121fi
122)
123AC_MSG_RESULT($ac_cv_c_cpp)
124
125# we prefer using gcc for compiling C++ files, provided the user did
126# not overwrite it explicitely
127if test "${GXX}" = yes && test "${ac_cxx_set}" = no; then
128  if test "${ac_cv_c_cpp}" = gcc2; then
129    CXX=g++
130  elif test "${ac_cv_c_cpp}" = gcc3; then
131    CXX=g++
132  fi
133  temp_flags="${CXXFLAGS}"
134  AC_LANG_SAVE
135  AC_LANG_CPLUSPLUS
136  # check whether gcc accepts --no-rtti
137  AC_MSG_CHECKING(whether gcc accepts --no-rtti)
138  CXXFLAGS="${CXXFLAGS} --no-rtti"
139  AC_CACHE_VAL(ac_cv_cxx_have_rtti,
140    AC_TRY_COMPILE(,,ac_cv_cxx_have_rtti=yes,ac_cv_cxx_have_rtti=no)
141  )
142  AC_MSG_RESULT(${ac_cv_cxx_have_rtti})
143  if test "${ac_cv_cxx_have_rtti}" != yes; then
144    CXXFLAGS="$temp_flags"
145  else
146    CXXFLAGS="${temp_flags} --no-rtti"
147    temp_flags="${CXXFLAGS}"
148  fi
149
150# check whether gcc accepts --no-exceptions
151  AC_MSG_CHECKING(whether gcc accepts --no-exceptions)
152  CXXFLAGS="${CXXFLAGS} --no-exceptions"
153  AC_CACHE_VAL(ac_cv_cxx_have_exceptions,
154    AC_TRY_LINK(,,ac_cv_cxx_have_exceptions=yes,ac_cv_cxx_have_exceptions=no)
155  )
156  AC_MSG_RESULT(${ac_cv_cxx_have_exceptions})
157  if test "${ac_cv_cxx_have_exceptions}" != yes; then
158    CXXFLAGS="$temp_flags"
159  else
160    CXXFLAGS="${temp_flags} --no-exceptions"
161    temp_flags="${CXXFLAGS}"
162  fi
163
164  AC_LANG_RESTORE
165  CXXFLAGS="$temp_flags"
166  #here is broking something
167  #uncommented breaks CXXFLAGS variable set
168  #only pipes would remain then in CXXFLAGS
169fi
170
171# check whether the compiler accepts -pipe
172if test x$ac_cv_c_cpp = xgcc2 -o  x$ac_cv_c_cpp = xgcc3
173then
174  AC_MSG_CHECKING(whether compiler accepts -pipe)
175  temp_cflags="${CFLAGS}"
176  CFLAGS="${CFLAGS} -pipe"
177  AC_CACHE_VAL(ac_cv_cxx_have_pipe,
178  AC_TRY_COMPILE(,,ac_cv_cxx_have_pipe=yes,ac_cv_cxx_have_pipe=no))
179  AC_MSG_RESULT(${ac_cv_cxx_have_pipe})
180  CFLAGS=${temp_cflags}
181else
182  ac_cv_cxx_have_pipe="no"
183fi
184
185if test "${ac_cv_cxx_have_pipe}" != yes; then
186  PIPE=
187else
188  PIPE="-pipe"
189fi
190AC_SUBST(PIPE)
191
192# Customize CFLAGS
193AC_MSG_CHECKING(whether _AIX is defined)
194AC_CACHE_VAL(ac_cv_is_aix,
195AC_EGREP_CPP(yes,
196[#ifdef _AIX
197    yes
198#endif
199], ac_cv_is_aix=yes, ac_cv_is_aix=no, 1))
200if test "$ac_cv_is_aix" = yes; then
201  AC_MSG_RESULT(yes)
202else
203  AC_MSG_RESULT(no)
204fi
205
206# we know best when compiling with gcc
207if test "${GXX}" = yes; then
208  if test "$ac_cxxflags_set" = no; then
209    CXXFLAGS="-O3 -w -fomit-frame-pointer"
210  fi
211  temp_flags="${CXXFLAGS}"
212  if test "${ac_cv_cxx_have_rtti}" = yes; then
213    CXXFLAGS="${temp_flags} --no-rtti"
214  fi
215  temp_flags="${CXXFLAGS}"
216  CXXTEMPLFLAGS="-fno-implicit-templates"
217  if test "${ac_cv_cxx_have_exceptions}" = yes; then
218    CXXTEMPLFLAGS="${CXXTEMPLFLAGS} --no-exceptions"
219  fi
220  if test "$ac_cv_is_aix" = yes; then
221    CXXNOOPTFLAGS="-w"
222  else
223    CXXNOOPTFLAGS=$CXXFLAGS
224  fi
225  STATIC_LDFLAGS="-static"
226else
227  CXXTEMPFLAGS=""
228  CXXNOOPTFLAGS=$CXXFLAGS
229  STATIC_LDFLAGS=""
230fi
231AC_SUBST(CXXTEMPLFLAGS)
232AC_SUBST(CXXNOOPTFLAGS)
233AC_SUBST(STATIC_LDFLAGS)
234
235if test "${GCC}" = yes && test "$ac_cflags_set" = no ; then
236  CFLAGS="-O3 -w -fomit-frame-pointer"
237fi
238
239AC_PROG_MAKE_SET
240
241dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
242dnl path stuff
243dnl
244AC_PREFIX_DEFAULT(`pwd`/..)
245
246dnl set exec_prefix, bindir, libdir, includedir to some sensible values
247dnl if they are not yet already set
248
249# expand prefix
250test "x$prefix" = xNONE && prefix=$ac_default_prefix
251if test "${with_rootdir+set}" != set; then
252  AC_DEFINE_UNQUOTED(S_ROOT_DIR, "${prefix}")
253else
254  AC_DEFINE_UNQUOTED(S_ROOT_DIR, "${with_rootdir}")
255fi
256
257# expand exec_prefixad
258if test "x$exec_prefix" = xNONE; then
259 exec_prefix=${prefix}/${ac_cv_singuname}
260fi
261
262# expand bindir
263test "x$bindir" = 'x${exec_prefix}/bin' && bindir="${exec_prefix}"
264SINGULAR=${SINGULAR:-$bindir/Singular-$SINGULAR_MAJOR_VERSION${VERSION_SEP}$SINGULAR_MINOR_VERSION${VERSION_SEP}$SINGULAR_SUB_VERSION}
265AC_SUBST(SINGULAR)
266AC_DEFINE_UNQUOTED(S_BIN_DIR, "${bindir}")
267
268# expand libdir
269test "x$libdir" = 'x${exec_prefix}/lib'&& libdir="${exec_prefix}/lib"
270
271# expand includedir
272test "x$includedir" = 'x${prefix}/include' && includedir="${exec_prefix}/include"
273
274# add to -I to CPPFLAGS and and -L to LDFLAGS, just to be sure
275if test "$ac_cv_c_cpp" = gcc3 ; then
276  LDFLAGS="-L${libdir} ${LDFLAGS}"
277  CPPFLAGS="-I${includedir} ${CPPFLAGS}"
278else
279  LDFLAGS="-L${libdir} ${LDFLAGS} -L/usr/local/lib"
280  CPPFLAGS="-I${includedir} ${CPPFLAGS} -I/usr/local/include"
281fi
282
283# this is a work-around to include the right term.h
284if test "$ac_cv_singuname" = SunOS-5; then
285CPPFLAGS="-I/usr/xpg4/include ${CPPFLAGS}"
286fi
287
288
289dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
290dnl Checks for programs.
291dnl
292
293# lex
294if test "${with_lex+set}" != set; then
295  AC_MSG_CHECKING(for flex)
296  changequote(<<,>>)dnl
297  cmd="egrep [2-9]\.[5-9]"
298  changequote([,])dnl
299  AC_CACHE_VAL(ac_cv_prog_flex,
300  if (flex --version >/dev/null 2>&1)
301    then
302    if (flex --version | $cmd >/dev/null 2>&1 )
303    then
304        ac_cv_prog_flex=flex
305    fi
306  fi
307  )
308  dnl changequote([,])dnl
309  if test "${ac_cv_prog_flex+set}" = set; then
310    AC_MSG_RESULT(flex)
311    LEX=flex
312    AC_SUBST(LEX)
313  else
314    AC_MSG_WARN(can not find flex with version 2.4.5-2.5.4)
315  fi
316elif test "${with_lex}" = no; then
317  AC_MSG_WARN(building without lex -- make might fail)
318else
319  unset LEX
320  unset ac_cv_prog_LEX
321  AC_CHECK_PROGS(LEX, ${with_lex})
322  if test "x${LEX}" = x; then
323    AC_MSG_WARN(building without lex -- make might fail)
324  fi
325fi
326
327# bison
328AC_CHECK_PROGS(BISON, bison)
329if test "${BISON+set}" != set; then
330  AC_MSG_WARN(did not find bison -- make might fail)
331fi
332
333# ln -s
334AC_PROG_LN_S
335
336AC_CHECK_PROGS(PERL, perl5 perl)
337
338dnl llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
339dnl check for general libraries, header files, typedefs, etc
340dnl
341# lib checks
342# under cygwin, we should not explicitly link with -lm, except for
343# it really is the last thing to link with
344if test "$ac_cv_singuname" != ix86-Win; then
345AC_CHECK_LIB(m, atof)
346fi
347AC_CHECK_LIB(nsl)
348AC_CHECK_LIB(socket)
349SAVE_LIBS=${LIBS}
350LIBS=
351
352dnl I'm not sure what they are for
353AC_CHECK_LIB(bsd, setenv)
354dnl i386-SunOS needs nsl and socket
355AC_CHECK_LIB(socket, listen)
356AC_CHECK_LIB(nsl, gethostbyname)
357dnl AC_CHECK_LIB(ucb, index)
358MP_LIBS=${LIBS}
359# check for dl lib
360case "$ac_cv_singuname" in
361        HPUX*)
362          AC_CHECK_LIB(dld, shl_load)
363          if test "$ac_cv_lib_dld_shl_load" = yes; then
364                LD_DYN_FLAGS="-ldld -Xlinker -E"
365                SFLAGS="-fpic -fPIC -DPIC"
366                SLDFLAGS="-fPIC -DPIC -shared"
367                LD=gcc
368                ac_lib_dl=yes
369          fi
370        ;;
371        *Linux*)
372          AC_CHECK_LIB(dl, dlopen)
373          if test "$ac_cv_lib_dl_dlopen" = yes; then
374                LD_DYN_FLAGS="-ldl -rdynamic"
375                SFLAGS="-fpic -DPIC"
376                SLDFLAGS=-shared
377                LD=ld
378                ac_lib_dl=yes
379          fi
380        ;;
381        IRIX-6)
382          LD_DYN_FLAGS="-lc"
383          SFLAGS="-fPIC -DPIC"
384          SLDFLAGS="-w -no_unresolved -_SYSTYPE_SVR4 -n32 -shared"
385          LD=ld
386          ac_lib_dl=yes
387        ;;
388        SunOS-5)
389          AC_CHECK_LIB(dl, dlopen)
390          if test "$ac_cv_lib_dl_dlopen" = yes; then
391                LD_DYN_FLAGS="-ldl"
392                SFLAGS="-fpic -DPIC"
393                SLDFLAGS=-shared
394                LD=$CC
395                ac_lib_dl=yes
396          fi
397        ;;
398        #use export MACOSX_DEPLOYMENT_TARGET=10.3
399        ppcMac-darwin)
400          AC_CHECK_LIB(dl, dlopen)
401          if test "$ac_cv_lib_dl_dlopen" = yes; then
402                LD_DYN_FLAGS="-ldl -dynamic"
403                SFLAGS="-fpic -DPIC"
404                SLDFLAGS="-dynamic -twolevel_namespace -weak_reference_mismatches weak -undefined dynamic_lookup"
405                LD=libtool
406                ac_lib_dl=yes
407          fi
408        ;;
409        ix86Mac-darwin)
410          AC_CHECK_LIB(dl, dlopen)
411          if test "$ac_cv_lib_dl_dlopen" = yes; then
412                LD_DYN_FLAGS="-ldl -dynamic"
413                SFLAGS="-fpic -DPIC"
414                SLDFLAGS="-dynamic -twolevel_namespace -weak_reference_mismatches weak -undefined dynamic_lookup"
415                LD=libtool
416                ac_lib_dl=yes
417          fi
418        ;;
419        ix86-freebsd)
420          AC_CHECK_LIB(c, dlopen)
421          if test "$ac_cv_lib_c_dlopen" = yes; then
422                LD_DYN_FLAGS="-Xlinker -E"
423                SFLAGS="-fpic -DPIC"
424                SLDFLAGS=-shared
425                LD=ld
426                ac_lib_dl=yes
427          fi
428        ;;
429esac
430AC_SUBST(LD_DYN_FLAGS)
431AC_SUBST(SFLAGS)
432AC_SUBST(SLDFLAGS)
433AC_SUBST(LD)
434LIBS=${SAVE_LIBS}
435
436
437# heder file checks
438AC_HEADER_STDC
439AC_CHECK_HEADERS(limits.h unistd.h,,
440  AC_MSG_ERROR(Can not compile without limits.h unistd.h))
441
442AC_CHECK_HEADERS(sys/file.h sys/ioctl.h sys/time.h sys/times.h sys/types.h \
443 sys/stat.h fcntl.h sys/param.h pwd.h asm/sigcontext.h pwd.h termcap.h \
444 termios.h term.h readline/readline.h)
445
446# typedefs, structures
447AC_C_CONST
448AC_C_INLINE
449AC_TYPE_SIZE_T
450AC_STRUCT_TM
451AC_HEADER_TIME
452
453# library functions.
454AC_FUNC_ALLOCA
455AC_PROG_GCC_TRADITIONAL
456AC_FUNC_MMAP
457AC_TYPE_SIGNAL
458AC_FUNC_VPRINTF
459AC_SEARCH_LIBS(setenv, bsd)
460AC_CHECK_FUNCS(gettimeofday atexit bcopy getcwd getwd vsnprintf readlink \
461 sleep usleep getpwnam popen setenv siginterrupt sysconf)
462
463
464dnl llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
465dnl Find out more about particularity of the system
466dnl
467
468# arithmetic shifts
469AC_MSG_CHECKING(whether your machine has correct arithmetic shifts)
470AC_CACHE_VAL(ac_cv_shift, AC_TRY_RUN(
471  [ int main() { if (-2 >> 1 == -1) return(0); else return(1); } ],
472   ac_cv_shift=yes,
473   ac_cv_shift=no,
474   if test "$ac_c_cross_dos" = yes; then
475     ac_cv_shift=yes;
476   else
477     AC_MSG_RESULT(no)
478     AC_MSG_ERROR(cross compilation without default value)
479   fi))
480
481if test "$ac_cv_shift" = yes; then
482  AC_MSG_RESULT(yes)
483else
484  AC_MSG_RESULT(no)
485  AC_MSG_ERROR(need  -2 >> 1 == -1)
486fi
487
488
489# check for a peculiar constructor initialization
490AC_MSG_CHECKING(whether explicit C++ constructor calls are allowed)
491AC_LANG_SAVE
492AC_LANG_CPLUSPLUS
493AC_CACHE_VAL(ac_cv_explicit_const,AC_TRY_COMPILE(,
494  class testclass
495  {
496  public:
497    int value;
498    testclass() : value(0) {}
499    testclass( int i ) : value(i) {}
500    ~testclass() { value = 0; }
501  };
502
503  testclass ptr;
504  ptr.testclass(1);
505, ac_cv_explicit_const=yes, ac_cv_explicit_const=no))
506AC_LANG_RESTORE
507AC_MSG_RESULT($ac_cv_explicit_const)
508if test "$ac_cv_explicit_const" = yes; then
509  AC_DEFINE(HAVE_EXPLICIT_CONSTR)
510fi
511
512# sprintf returns number of printed chars
513AC_MSG_CHECKING(whether vsprintf returns number of printed chars)
514AC_CACHE_VAL(ac_cv_returns_n_of_chars, AC_TRY_RUN(
515 [#include <stdio.h>
516 main() { char *str=(char*)malloc(20); if (((int) sprintf(str,"123456789")) == 9) exit(0); else exit(1); }],
517   ac_cv_returns_n_of_chars=yes,
518   ac_cv_returns_n_of_chars=no,
519   ac_cv_returns_n_of_chars=no))
520if test "$ac_cv_returns_n_of_chars" = yes; then
521  AC_MSG_RESULT(yes)
522else
523  AC_MSG_RESULT(no)
524  AC_DEFINE(BSD_SPRINTF)
525fi
526
527# determine ALIGN_8
528AC_CHECK_SIZEOF(char,1)
529AC_CHECK_SIZEOF(short,2)
530AC_CHECK_SIZEOF(int,4)
531AC_CHECK_SIZEOF(long,4)
532AC_CHECK_SIZEOF(void*,4)
533AC_CHECK_SIZEOF(double, 8)
534AC_C_BIGENDIAN
535if test "$ac_cv_sizeof_int" != 4; then
536  AC_MSG_ERROR(need int to be four bytes long)
537fi
538if test "$ac_cv_sizeof_long" != "$ac_cv_sizeof_voidp"; then
539  AC_MSG_ERROR(need equal sizes for long and void*)
540fi
541if test "$ac_cv_sizeof_double" != 8; then
542  AC_MSG_ERROR(need double to b 8 bytes long)
543fi
544if test "$ac_cv_sizeof_voidp" != 4 && test "$ac_cv_sizeof_voidp" != 8; then
545  AC_MSG_ERROR(need void* to be 4 or 8 bytes long)
546fi
547if test "$ac_cv_sizeof_voidp" != 4; then
548  DEFS="-UOM_NDEBUG"
549  AC_SUBST(DEFS)
550fi
551
552dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
553dnl help for configure
554dnl
555AC_ARG_WITH(
556  rootdir,
557  [  --with-rootdir=DIR      use DIR ass compiled-in root directory
558                             (default is PREFIX)])
559AC_ARG_WITH(
560  lex,
561  [  --with-lex=[LEX,no]     uses LEX as lex program, default is flex])
562AC_ARG_WITH(
563  readline,
564  [  --with-readline=[dynamic,static,no]
565                          do use dynamic/static/no readline for fancy display])
566AC_ARG_WITH(
567  Boost,
568  [  --without-Boost         do not use Boost ])
569AC_ARG_WITH(
570  stdvec,
571  [  --with-stdvec           use std::vector ])
572AC_ARG_WITH(
573  MP,
574  [  --without-MP            do not use MP (no MP links)])
575AC_ARG_WITH(
576  dbm,
577  [  --without-dbm           do not use dbm (no DBM links)])
578AC_ARG_WITH(
579  factory,
580  [  --without-factory       do not use factory (no poly factorization)])
581AC_ARG_WITH(
582  libfac,
583  [  --without-libfac        do not use libfac (no primary decompositions)])
584AC_ARG_WITH(
585  namespaces,
586  [  --with-namespaces       do compile namespace support])
587AC_ARG_WITH(
588  dl,
589  [  --without-dl            do not use dynamic linking, modules, and kernel])
590AC_ARG_WITH(
591  dynamic-modules,
592  [  --with-dynamic-modules  do compile with dynamic modules support])
593AC_ARG_WITH(
594  dynamic-kernel,
595  [  --without-dynamic-kernel
596                          do not compile with dynamic kernel parts])
597AC_ARG_WITH(apint,
598  [  --with-apint=PACKAGE    use PACKAGE for arbitary integer arithmetic])
599AC_ARG_WITH(svd,
600  [  --with-svd              use libsvd])
601AC_ARG_WITH(
602  Plural,
603  [  --without-Plural        do compile without Plural support])
604AC_ARG_WITH(
605  NTL,
606  [  --with-NTL              build for use with NTL.],
607  ,
608  with_NTL=yes)
609
610dnl llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
611dnl check for packages we need
612dnl for gmp, MP, factory and libfac, we built them in, even if the libs
613dnl and headers were not found under the condition that the respective
614dnl  --enable argument was given
615dnl
616
617
618AC_MSG_CHECKING(whether to use dynamic linking)
619if test "$with_dl" != no && test "$ac_lib_dl" = yes; then
620  AC_DEFINE(HAVE_DL)
621  ac_have_dl=yes
622  AC_MSG_RESULT(yes)
623else
624  AC_MSG_RESULT(no)
625fi
626
627AC_CHECK_LIB(ncurses,tgetent,,\
628 AC_CHECK_LIB(curses,tgetent,,\
629  AC_CHECK_LIB(termcap,tgetent)))
630
631# readline
632if test "$with_readline" = dynamic && test "$ac_have_dl" != yes; then
633  AC_MSG_WARN(can not build dynamic readline without dynamic linking)
634  with_readline=static
635fi
636
637
638if test "$with_readline" != dynamic && test "$with_readline" != no; then
639AC_LANG_SAVE
640AC_LANG_CPLUSPLUS
641   AC_CHECK_LIB(readline, rl_abort)
642   AC_CHECK_HEADERS(readline/readline.h readline/history.h)
643   if test "$ac_cv_lib_readline_rl_abort" = yes && \
644      test "$ac_cv_header_readline_readline_h" = yes; then
645     AC_MSG_CHECKING(whether readline.h is ok)
646     AC_CACHE_VAL(ac_cv_header_readline_readline_h_ok,
647     AC_TRY_LINK(
648#include<unistd.h>
649#include<stdio.h>
650#include<readline/readline.h>
651#ifdef HAVE_READLINE_HISTORY_H
652#include<readline/history.h>
653#endif
654,
655,
656ac_cv_header_readline_readline_h_ok="yes",
657ac_cv_header_readline_readline_h_ok="no",
658))
659    AC_MSG_RESULT($ac_cv_header_readline_readline_h_ok)
660    if test "$ac_cv_header_readline_readline_h_ok" != yes; then
661#not ok -- try once more with explicitly declaring everything
662      AC_MSG_CHECKING(whether or not we nevertheless can use readline)
663      AC_CACHE_VAL(ac_cv_have_readline,
664      AC_TRY_LINK(
665#include <stdio.h>
666extern "C"
667{
668extern char * rl_readline_name;
669extern char *rl_line_buffer;
670char *filename_completion_function();
671typedef char **CPPFunction ();
672extern char ** completion_matches ();
673extern CPPFunction * rl_attempted_completion_function;
674extern FILE * rl_outstream;
675char * readline ();
676void add_history ();
677int write_history ();
678int read_history();
679}
680#ifndef NULL
681#define NULL 0
682#endif
683,
684rl_readline_name=NULL;
685*rl_line_buffer=1;
686completion_matches(NULL, filename_completion_function);
687rl_attempted_completion_function = (CPPFunction *) NULL;
688rl_outstream=NULL;
689readline(NULL);
690add_history(NULL);
691read_history(NULL);
692write_history(NULL);
693,
694ac_cv_have_readline="yes"
695,
696ac_cv_have_readline="no"
697))
698      AC_MSG_RESULT($ac_cv_have_readline)
699    else
700      AC_DEFINE(READLINE_READLINE_H_OK)
701      ac_cv_have_readline="yes"
702    fi
703  fi
704  if test "$ac_cv_have_readline" = yes; then
705    AC_DEFINE(HAVE_READLINE)
706  fi
707AC_LANG_RESTORE
708fi
709
710AC_MSG_CHECKING(which readline to use)
711if test "$ac_cv_with_readline" = dynamic; then
712  AC_MSG_RESULT(dynamic)
713  AC_DEFINE(HAVE_DYN_RL)
714elif test "$ac_cv_have_readline" = yes; then
715  AC_MSG_RESULT(static)
716elif test "$ac_cv_singuname" = PowerMacintosh-darwin; then
717  AC_MSG_ERROR(building without readline impossible on PowerMacintosh-darwin)
718else
719  AC_MSG_RESULT(none)
720  AC_MSG_WARN(building without readline: disabling fancy display)
721fi
722
723NEED_LIBS=$LIBS
724
725# gmp, MP, MPT, factory, libfac
726AC_CHECK_LIB(gmp, main)
727SAVE_LIBS=$LIBS
728AC_CHECK_LIB(MP, IMP_PutGmpInt,,,$MP_LIBS)
729AC_CHECK_LIB(MPT, MPT_GetTree,,,$MP_LIBS)
730LIBS=$SAVE_LIBS
731AC_CHECK_LIB(singcf, atof)
732AC_CHECK_LIB(singfac, atof)
733AC_CHECK_LIB(omalloc, omTestAddr)
734AC_CHECK_LIB(omalloc_ndebug, main)
735AC_CHECK_LIB(ntl,main)
736
737AC_CHECK_HEADERS(gmp.h MP.h  MPT.h factory.h factor.h omalloc.h \
738 omalloc.c)
739
740AC_MSG_CHECKING(whether to use Boost)
741if test "$with_Boost" != no; then
742  AC_MSG_RESULT(yes)
743  AC_LANG_SAVE
744  AC_LANG_CPLUSPLUS
745  AC_CHECK_HEADERS(boost/dynamic_bitset.hpp)
746  AC_LANG_RESTORE
747else
748  AC_MSG_RESULT(no)
749  AC_MSG_CHECKING(whether to use std::vector)
750  if test "$with_stdvec" != yes; then
751    AC_MSG_RESULT(no)
752  else
753    AC_MSG_RESULT(yes)
754    AC_DEFINE(USE_STDVECBOOL)
755    USE_STDVECBOOL=1
756  fi
757fi
758AC_SUBST(USE_STDVECBOOL)
759
760if test "$ac_cv_lib_gmp_main" = yes && \
761 test "$ac_cv_header_gmp_h" = yes; then
762    ac_gmp_ok=yes
763fi
764
765if test "$ac_cv_lib_MP_IMP_PutGmpInt" = yes && \
766 test "$ac_cv_lib_MPT_MPT_GetTree" && \
767 test "$ac_cv_header_MP_h" = yes && \
768 test "$ac_cv_header_MPT_h" = yes; then
769  ac_MP_ok=yes
770fi
771
772if test "$ac_cv_lib_singcf_atof" = yes && \
773 test "$ac_cv_header_factory_h" = yes; then
774  ac_factory_ok=yes
775fi
776
777if test "$ac_cv_lib_singfac_atof" = yes && \
778 test "$ac_cv_header_factor_h" = yes; then
779  ac_libfac_ok=yes
780fi
781
782if test "$ac_cv_lib_omalloc_omTestAddr" = yes && \
783   test "$ac_cv_lib_omalloc_ndebug_main" = yes && \
784   test "$ac_cv_header_omalloc_c" = yes && \
785   test "$ac_cv_header_omalloc_h" = yes; then
786  ac_cv_omalloc_ok=yes
787fi
788
789if test "$ac_cv_lib_ntl_main" = yes; then
790  ac_cv_ntl_ok=yes
791fi
792
793SAVE_LIBS=$LIBS
794AC_CHECK_LIB(c_nonshared,__stack_chk_fail_local,GLIBC_DYN_FIX="-lc_nonshared",GLIBC_DYN_FIX="")
795LIBS=$SAVE_LIBS
796AC_SUBST(GLIBC_DYN_FIX)
797
798# evaluate results
799dnl llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
800dnl make sure that omalloc is there
801dnl
802if test "$ac_cv_omalloc_ok" != yes && test "$enable_omalloc" != yes; then
803  AC_MSG_ERROR(can not build without omalloc)
804fi
805
806AC_MSG_CHECKING(which apint package to use)
807if test "${with_apint}" != gmp; then
808  if test "$ac_gmp_ok" = yes || test "$enable_gmp" = yes; then
809    AC_MSG_RESULT(gmp)
810    will_have_gmp=yes
811    NEED_LIBS="-lgmp ${NEED_LIBS}"
812  else
813    AC_MSG_RESULT(none)
814    AC_MSG_ERROR(can not build without gmp)
815  fi
816else
817  if test "$ac_gmp_ok" = yes || test "$enable_gmp" = yes; then
818    AC_MSG_RESULT(gmp)
819    will_have_gmp=yes
820    NEED_LIBS="-lgmp ${NEED_LIBS}"
821  else
822    AC_MSG_RESULT(none)
823    AC_MSG_ERROR(can not build with gmp)
824  fi
825fi
826
827AC_MSG_CHECKING(whether to use libsvd)
828if test "$with_svd" = yes; then
829  AC_MSG_RESULT(yes)
830  AC_DEFINE(HAVE_SVD)
831  NEED_LIBS="-lsvd -lmpfr ${NEED_LIBS}"
832else
833  AC_MSG_RESULT(no)
834fi
835AC_SUBST(HAVE_SVD)
836
837#
838AC_MSG_CHECKING(whether to have MP)
839if test "${with_MP}" != yes && test "${with_MP}" != no; then
840  if (test "${will_have_gmp}" = yes) && \
841     (test "$ac_MP_ok" =  yes || test "$enable_MP" = yes); then
842    AC_MSG_RESULT(yes)
843    AC_DEFINE(HAVE_MPSR)
844    HAVE_MPSR=1
845    MP_LIBS="-lMPT -lMP ${MP_LIBS}"
846  else
847    AC_MSG_RESULT(no)
848  fi
849elif  test "${with_MP}" = yes; then
850  if (test "${will_have_gmp}" = yes) && \
851     (test "$ac_MP_ok" =  yes || test "$enable_MP" = yes); then
852    AC_MSG_RESULT(yes)
853    AC_DEFINE(HAVE_MPSR)
854    HAVE_MPSR=1
855    MP_LIBS="-lMPT -lMP ${MP_LIBS}"
856  else
857    AC_MSG_RESULT(no)
858    AC_MSG_ERROR(can not build with MP)
859  fi
860else
861  AC_MSG_RESULT(no)
862fi
863AC_SUBST(HAVE_MPSR)
864AC_SUBST(MP_LIBS)
865
866AC_MSG_CHECKING(whether to have NTL)
867if test "${with_NTL}" = yes ; then
868  AC_MSG_RESULT(yes)
869  NEED_LIBS="-lntl ${NEED_LIBS}"
870else
871  AC_MSG_RESULT(no)
872fi
873
874AC_MSG_CHECKING(whether to have factory)
875if test "${with_factory}" != yes && test "${with_factory}" != no; then
876  if test "$ac_factory_ok" =  yes || test "$enable_factory" = yes; then
877    AC_MSG_RESULT(yes)
878    AC_DEFINE(HAVE_FACTORY)
879    will_have_factory=yes
880    NEED_LIBS="-lsingcf ${NEED_LIBS}"
881  else
882    AC_MSG_RESULT(no)
883  fi
884elif  test "${with_factory}" = yes; then
885  if test "$ac_factory_ok" =  yes || test "$enable_factory" = yes; then
886    AC_MSG_RESULT(yes)
887    AC_DEFINE(HAVE_FACTORY)
888    will_have_factory=yes
889    NEED_LIBS="-lsingcf ${NEED_LIBS}"
890  else
891    AC_MSG_RESULT(no)
892    AC_MSG_ERROR(can not build with factory)
893  fi
894else
895  AC_MSG_RESULT(no)
896fi
897
898AC_MSG_CHECKING(whether to have libfac)
899if test "${with_libfac}" != yes && test "${with_libfac}" != no; then
900  if (test "${will_have_factory}" = yes) && \
901     (test "$ac_libfac_ok" =  yes || test "$enable_libfac" = yes); then
902    AC_MSG_RESULT(yes)
903    AC_DEFINE(HAVE_LIBFAC_P)
904    NEED_LIBS="-lsingfac ${NEED_LIBS}"
905  else
906    AC_MSG_RESULT(no)
907  fi
908elif  test "${with_libfac}" = yes; then
909  if (test "${will_have_factory}" = yes) && \
910     (test "$ac_libfac_ok" =  yes || test "$enable_libfac" = yes); then
911    AC_MSG_RESULT(yes)
912    AC_DEFINE(HAVE_LIBFAC_P)
913    NEED_LIBS="-lsingfac ${NEED_LIBS}"
914  else
915    AC_MSG_RESULT(no)
916    AC_MSG_ERROR(can not build with libfac)
917  fi
918else
919  AC_MSG_RESULT(no)
920fi
921
922NEED_LIBSG="${NEED_LIBS}"
923if test "$ac_cv_sizeof_voidp" != 4; then
924  NEED_LIBS="${NEED_LIBS} -lomalloc"
925else
926  NEED_LIBS="${NEED_LIBS} -lomalloc_ndebug"
927fi
928
929
930AC_SUBST(NEED_LIBS)
931AC_SUBST(NEED_LIBSG)
932
933AC_MSG_CHECKING(whether to have dbm links)
934if test "$with_dbm" != no; then
935  AC_DEFINE(HAVE_DBM)
936  AC_MSG_RESULT(yes)
937else
938  AC_MSG_RESULT(no)
939fi
940
941AC_MSG_CHECKING(whether to have namespaces)
942if test "$with_namespaces" != no; then
943  AC_MSG_RESULT(yes)
944  AC_DEFINE(HAVE_NS)
945else
946  AC_MSG_RESULT(no)
947fi
948
949AC_MSG_CHECKING(whether to have dynamic modules)
950if test "$with_dynamic_modules" = no || test "$ac_have_dl" != yes; then
951  AC_MSG_RESULT(no)
952else
953  AC_DEFINE(HAVE_DYNAMIC_LOADING)
954  AC_MSG_RESULT(yes)
955fi
956
957AC_MSG_CHECKING(whether to have dynamic kernel)
958if test "$with_dynamic_kernel" != no && test "$ac_lib_dl" = yes; then
959  DL_KERNEL=1
960  AC_SUBST(DL_KERNEL)
961  AC_MSG_RESULT(yes)
962else
963  AC_MSG_RESULT(no)
964fi
965
966AC_MSG_CHECKING(whether to have Plural)
967if test "$with_Plural" != no && test "$enable_Plural" != no; then
968  AC_DEFINE(HAVE_PLURAL)
969  AC_MSG_RESULT(yes)
970  PLURAL=1
971  AC_SUBST(PLURAL)
972else
973  AC_MSG_RESULT(no)
974fi
975
976
977OUTPUT_MAKEFILES="Makefile ../kernel/Makefile"
978
979if test "$ac_cv_singuname" = "ix86-Win"; then
980  OUTPUT_MAKEFILES="${OUTPUT_MAKEFILES} Singular.rc"
981fi
982
983AC_OUTPUT(${OUTPUT_MAKEFILES}, \
984 cp mod2.h ../kernel/mod2.h; \
985 if test "$CONFIG_HEADERS"; then echo timestamp > stamp-h; fi)
Note: See TracBrowser for help on using the repository browser.