source: git/MP/configure.in @ def863

spielwiese
Last change on this file since def863 was 8fac88, checked in by Hans Schönemann <hannes@…>, 19 years ago
*hannes: values.h git-svn-id: file:///usr/local/Singular/svn/trunk@7686 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 15.7 KB
Line 
1onl
2dnl Written by Olaf Bachmann (obachman@mathematik.uni-kl.de)
3dnl
4dnl configure.in for MP
5dnl Process this file with autoconf to produce a configure script.
6AC_INIT(MP/MP_Put.c)
7AC_CONFIG_HEADER(MP/MP_Config.h:MP/h/MP_Config.h.in)
8
9PRODUCT=MP
10VERSION=1.1.2.1
11AC_SUBST(PRODUCT)
12AC_SUBST(VERSION)
13AC_DEFINE_UNQUOTED(MP_VERSION, "$VERSION")
14AC_CANONICAL_SYSTEM
15
16AC_PREFIX_DEFAULT(`pwd`)
17
18dnl The "philosophy" is this: 
19dnl 1) by default the libraries are stored in ${prefix}/lib/${ARCH}
20dnl 2) the user can override this by setting either --exec-prefix
21dnl    or --libdir
22dnl 3) If --libdir is given, then libraries are put exactly there
23dnl 4) If --libdir is not given, and --exec-dir is given, then
24dnl    libraries are put into $exec_prefix/lib (as is standard)
25dnl 5) The same thing applies to bindir
26
27AC_MSG_CHECKING(for architecture identifier) 
28AC_CACHE_VAL(ac_cv_arch,ac_cv_arch=`./pvmgetarch`)
29AC_MSG_RESULT($ac_cv_arch)
30
31if test "$libdir" = '${exec_prefix}/lib' && test "$exec_prefix" = "NONE"; then
32  libdir='${prefix}/lib/'$ac_cv_arch
33fi
34
35if test "$bindir" = '${exec_prefix}/bin' && test "$exec_prefix" = "NONE"; then
36  bindir='${prefix}/bin/'$ac_cv_arch
37fi
38
39dnl Check for programs
40AC_PROG_RANLIB
41AC_CHECK_PROG(AR, ar, ar, :)
42if test "$ac_cv_prog_AR" != ar; then
43  AC_MSG_ERROR(*** ar program not found)
44fi
45
46dnl compiler stuff
47dnl we do not want to have "-g -O" for CFLAGS
48
49if test "$with_debug" = yes; then
50  if test "${CFLAGS+set}" != set; then 
51    CFLAGS="-g"
52    ac_cv_cflags_not_set=yes
53  fi
54  AC_DEFINE(MPT_DEBUG)
55else
56  if test "${CFLAGS+set}" != set; then
57    CFLAGS="-O"
58    ac_cv_cflags_not_set=yes
59  fi
60  AC_DEFINE(NO_LOGGING)
61fi
62
63AC_PROG_CC
64AC_PROG_CPP
65AC_PROG_CXX
66AC_AIX
67
68dnl compiler/system specific options
69if test "${GCC}" != yes; then
70  echo not using gcc, so checking for special flags and defines
71  case "$target" in
72    hppa1*)
73      if test "$ac_cv_prog_CC" = cc; then
74         echo Using HPUX native compiler with -Aa and -D_HPUX_SOURCE
75         CFLAGS="$CFLAGS -Aa "
76         AC_DEFUN(_HPUX_SOURCE)
77      fi
78  esac
79fi
80
81dnl add to CPPFLAGS and LDFLAGS so that ${includedir} and ${libdir}
82dnl are in there
83if test "$libdir" = '${exec_prefix}/lib'; then
84  if test "x$exec_prefix" = xNONE; then
85    if test "x$prefix" = xNONE; then
86      LDFLAGS="-L${ac_default_prefix}/lib ${LDFLAGS}"
87    else
88      LDFLAGS="-L${prefix}/lib ${LDFLAGS}"
89    fi
90  else
91    LDFLAGS="-L${exec_prefix}/lib ${LDFLAGS}"
92  fi
93elif test "$libdir" = '${prefix}/lib/'$ac_cv_arch ; then
94  if test "x$prefix" = xNONE; then
95    LDFLAGS="-L${ac_default_prefix}/lib/$ac_cv_arch  ${LDFLAGS}"
96  else
97    LDFLAGS="-L${prefix}/lib/$ac_cv_arch ${LDFLAGS}"
98  fi
99else
100  LDFLAGS="-L${libdir} ${LDFLAGS}"
101fi
102
103if test "$includedir" = '${prefix}/include'; then
104  if test "x$prefix" = xNONE; then
105    CPPFLAGS="-I${ac_default_prefix}/include ${CPPFLAGS}"
106  else
107    CPPFLAGS="-I${prefix}/include ${CPPFLAGS}"
108  fi
109else
110  CPPFLAGS="-I${includedir} ${CPPFLAGS}"
111fi
112
113dnl add to  CPPFLAGS and LDFLAGS if PVM_ROOT and PVM_ARCH are set
114if test "${PVM_ROOT+set}" = set; then
115  if test "$enable_mppvm" = yes || test "$with_pvm" = yes; then
116    CPPFLAGS="${CPPFLAGS} -I${PVM_ROOT}/include"
117    if test "${PVM_ARCH+set}" = set; then
118      LDFLAGS="${LDFLAGS} -L{PVM_ROOT}/lib/${PVM_ARCH}"
119    fi
120  fi
121fi
122
123AC_SET_MAKE
124AC_FUNC_VFORK
125
126dnl
127dnl Lib checks --depend on enable/disable options
128dnl
129AC_ARG_ENABLE(MPT, \
130 [  --disable-MPT           disable building of MPT library])
131
132AC_ARG_ENABLE(gmp, \
133 [  --disable-gmp           configure and build without gmp library])
134
135AC_ARG_ENABLE(tests, \
136 [  --enable-example        enable building of example programs])
137
138AC_ARG_ENABLE(mpviewer, \
139 [  --enable-mpviewer       enable building of mpviewer program])
140
141AC_ARG_ENABLE(mppvm, \
142 [  --enable-mppvm          enable building of mppvm routines])
143
144
145if test "$enable_gmp" != no && test -d gmp; then
146  CONFIG_SUBDIRS="gmp"
147  enable_gmp=yes
148fi
149BUILD_SUBDIRS="$CONFIG_SUBDIRS MP"
150
151if test "$enable_MPT" != no && test -d MPT; then
152    BUILD_SUBDIRS="${BUILD_SUBDIRS} MPT"
153fi
154
155if test "$enable_examples" = yes && test -d examples; then
156  BUILD_SUBDIRS="${BUILD_SUBDIRS} examples"
157  ac_check_prog=yes
158fi
159
160if test "$enable_mpviewer" = yes && test -d mpviewer; then
161  BUILD_SUBDIRS="${BUILD_SUBDIRS} mpviewer"
162  ac_check_prog=yes
163fi
164
165if test "$enable_mppvm" = yes && test -d mp-pvm3; then
166  BUILD_SUBDIRS="${BUILD_SUBDIRS} mp-pvm3"
167  ac_check_prog=yes
168  with_pvm=yes
169fi
170
171AC_SUBST(BUILD_SUBDIRS)
172AC_SUBST(CONFIG_SUBDIRS)
173AC_CHECK_FUNCS(gethostbyname)
174
175if test "$ac_check_prog" = yes; then
176  AC_CHECK_LIB(m, atof)
177  AC_CHECK_LIB(bsd, socket)
178  AC_CHECK_LIB(gmp, mpz_init)
179
180  if test "$ac_cv_lib_gmp_mpz_init" != yes || "$enable_gmp" != no; then
181    AC_MSG_WARN(Did not find gmp library: Linking programs with MP will fail)
182    NEED_LIBS=$LIBS
183  else
184    NEED_LIBS="-lgmp $LIBS"
185  fi
186 
187  AC_CHECK_FUNCS(select socket gethostname gethostbyname strtol strstr)
188  if test "$ac_cv_func_select" != yes; then
189    AC_MSG_WARN(Did not find library containing function select)
190    AC_MSG_WARN(Linking programs with MP might fail)
191  fi
192  if test "$ac_cv_func_gethostname" != yes; then
193    AC_MSG_WARN(Did not find library containing gethostname)
194    AC_MSG_WARN(Linking programs with MP might fail)
195  fi
196
197  if test "$ac_cv_func_gethostbyname" != yes; then
198    AC_CHECK_LIB(nsl, gethostbyname)
199    if test "$ac_cv_lib_nsl_gethostbyname" != yes; then
200      AC_MSG_WARN(Did not find library containing gethostbyname)
201      AC_MSG_WARN(Linking programs with MP might fail)
202    fi
203  fi
204
205  if test "$ac_cv_func_socket" != yes; then
206    AC_CHECK_LIB(socket, socket)
207    if test "$ac_cv_lib_socket_socket" != yes; then
208      AC_MSG_WARN(Did not find library containing socket)
209      AC_MSG_WARN(Linking programs with MP might fail)
210    fi
211  fi
212fi
213AC_SUBST(NEED_LIBS)
214
215dnl Do the header checks now
216AC_HEADER_STDC
217AC_HEADER_CHECK(arpa/inet.h,:, echo "*** no arpa/inet.h";exit)
218AC_HEADER_CHECK(assert.h,:, echo "*** no assert.h";exit)
219AC_HEADER_CHECK(ctype.h,:, echo "*** no ctype.h";exit)
220AC_HEADER_CHECK(errno.h,:, echo "*** no errno.h";exit)
221AC_HEADER_CHECK(netdb.h,:, echo "*** no netdb.h";exit)
222AC_HEADER_CHECK(netinet/in.h,:, echo "*** no netinet/in.h";exit)
223AC_HEADER_CHECK(netinet/tcp.h,:, echo "*** no netinet/tcp.h";exit)
224AC_HEADER_CHECK(signal.h,:, echo "*** no sihnal.h";exit)
225AC_HEADER_CHECK(stdarg.h,:, echo "*** no stdarg.h";exit)
226AC_HEADER_CHECK(stdio.h,:, echo "*** no stdio.h";exit)
227AC_HEADER_CHECK(stdlib.h,:, echo "*** no stdlib.h";exit)
228AC_HEADER_CHECK(string.h,:, echo "*** no string.h";exit)
229AC_HEADER_CHECK(stddef.h,:, echo "*** no stddef.h";exit)
230
231dnl Wrong preprocessor statement in /usr/include/values.h causes
232dnl problems on FreeBSD
233AC_HEADER_CHECK(values.h, freebsd_problem=no
234                          no_values_h=no,
235                AC_CHECK_FILE(/usr/include/values.h,
236                              freebsd_problem=yes
237                              no_values_h=no,
238                              no_values_h=yes
239                              freebsd_problem=no))
240if test "${freebsd_problem}" != no; then
241  grep -v "#warning" /usr/include/values.h > ./MP/h/values.h
242elif test "${no_values_h}" != no; then
243  cp ./values.h.subst ./MP/h/values.h
244  CPPFLAGS="-I. ${CPPFLAGS}"
245fi
246
247AC_HEADER_CHECK(fcntl.h,:, echo "*** no fcntl.h";exit)
248AC_HEADER_CHECK(sys/ioctl.h,:, echo "*** no sys/ioctl.h";exit)
249AC_HEADER_CHECK(sys/param.h,:, echo "*** no sys/param.h";exit)
250AC_HEADER_CHECK(sys/socket.h,:, echo "*** no sys/socket.h";exit)
251AC_HEADER_CHECK(sys/stat.h,:, echo "*** no sys/stat.h";exit)
252AC_HEADER_CHECK(sys/time.h,:, echo "*** no sys/time.h";exit)
253AC_HEADER_CHECK(sys/types.h,:, echo "*** no sys/types.h";exit)
254AC_HEADER_CHECK(sys/uio.h,:, echo "*** no sys/uio.h";exit)
255AC_HEADER_CHECK(sys/un.h,:, echo "*** no sys/un.h";exit)
256AC_HEADER_CHECK(unistd.h,:, echo "*** no unistd.h";exit)
257AC_HEADER_CHECK(math.h,:, echo "*** no math.h";exit)
258
259
260AC_CHECK_HEADERS(sys/select.h gmp.h genpari.h saclib.h)
261
262dnl Check whether mpz_ptr is defined (is not defined in earlier gmp versions)
263if test "$ac_cv_header_gmp_h" = yes; then
264  AC_EGREP_HEADER(mpz_ptr, gmp.h, MPZ_PTR=mpz_ptr)
265  if test ! "$MPZ_PTR" = mpz_ptr; then
266    AC_EGREP_HEADER(MP_INT, gmp.h, MPZ_PTR="MP_INT*")
267    AC_DEFINE_UNQUOTED(mpz_ptr, MP_INT*)
268    AC_DEFINE_UNQUOTED(_mp_alloc,alloc)
269    AC_DEFINE_UNQUOTED(_mp_size,size)
270    AC_DEFINE_UNQUOTED(_mp_d,d)
271  fi
272  AC_EGREP_HEADER(mpf_ptr, gmp.h, MPF_PTR=mpf_ptr)
273fi
274
275dnl
276dnl deal with Ap Number configuration
277dnl
278AC_ARG_WITH(apint, \
279 [  --with-default_apint=PACKAGE    use PACKAGE as MP's default ApInt format
280                           where PACKAGE can be: gmp (default), pari,
281                           saclib, none])
282AC_ARG_WITH(apreal, \
283 [  --with-default_apreal=PACKAGE   use PACKAGE as MP's default ApReal format
284                           where PACKAGE can be: gmp (default), none])
285AC_ARG_WITH(gmp, \
286 [  --without-gmp           build without gmp ApNumber routines])
287
288AC_ARG_WITH(pari, \
289 [  --with-pari             build with pari ApInt routines])
290
291AC_ARG_WITH(saclib, \
292 [  --with-saclib           build with saclib ApInt routines])
293
294AC_ARG_WITH(tb, \
295 [  --with-tb               build with Toolbus device interface])
296
297AC_ARG_WITH(pvm, \
298 [  --with-pvm              build with Pvm saclib device interface])
299
300AC_ARG_WITH(debug, \
301 [  --with-debug            build with debug options and logging])
302
303AC_ARG_WITH(extra_cflags, \
304 [  --with-extra_cflags=cflags   build with 'cflags' appended to
305                                 CFLAGS given to the compiler])
306
307AC_ARG_WITH(rsh, \
308 [ --with-rsh=command      use 'command' as remote shell command])
309
310dnl evaluate specifications
311AC_DEFINE(MP_DUMMY, 0)
312AC_DEFINE(MP_GMP, 1)
313AC_DEFINE(MP_PARI, 2)
314AC_DEFINE(MP_SAC, 3)
315
316if test "$with_default_apint" = none; then
317  AC_DEFINE(MP_DEFAULT_APINT, MP_DUMMY)
318elif test "$with_default_apint" = pari; then
319  if test "$ac_cv_header_genpari_h" != yes; then
320    AC_MSG_WARN(Need genpari.h to use pari as default ApInt format)
321    AC_MSG_WARN(Use dummy as default MP ApInt format)
322    AC_DEFINE(MP_DEFAULT_APINT_FORMAT, MP_DUMMY) 
323  else
324    AC_DEFINE(MP_DEFAULT_APINT_FORMAT, MP_PARI)
325    AC_DEFINE(MP_HAVE_PARI)
326  fi
327elif test "$with_default_apint" = saclib; then
328  if test "$ac_cv_header_saclib_h" != yes; then
329    AC_MSG_WARN(Need saclib.h to use saclib as default ApInt format)
330    AC_MSG_WARN(Use dummy as default MP ApInt format)
331    AC_DEFINE(MP_DEFAULT_APINTFORMAT, MP_DUMMY) 
332  else
333    AC_DEFINE(MP_DEFAULT_APINT_FORMAT, MP_SAC)
334    AC_DEFINE(MP_HAVE_SACLIB)
335  fi
336else
337  if test "$ac_cv_header_gmp_h" != yes && test "$enable_gmp" != yes; then
338    AC_MSG_WARN(Need gmp.h to use gmp as default ApInt format)
339    AC_MSG_WARN(Use dummy as default MP ApInt format)
340    AC_DEFINE(MP_DEFAULT_APINTFORMAT, MP_DUMMY) 
341  elif test -z "$MPZ_PTR" && test "$enable_gmp" != yes; then
342    AC_MSG_WARN(Need gmp.h containing typedef of 'mpz_ptr' or 'MP_INT')
343    AC_MSG_WARN(Use dummy as default MP ApInt format)
344    AC_DEFINE(MP_DEFAULT_APINTFORMAT, MP_DUMMY)
345  else
346    AC_DEFINE(MP_DEFAULT_APINT_FORMAT, MP_GMP)
347    AC_DEFINE(MP_HAVE_GMP_APINT)
348    if test "$ac_cv_header_gmp_h" != yes; then
349      AC_MSG_WARN(Need gmp.h to use gmp as default ApInt format)
350      AC_MSG_WARN(Install gmp.h before making MP)
351    fi
352  fi
353fi
354
355if test "$with_default_apreal" = none; then
356  AC_DEFINE(MP_DEFAULT_APREAL, MP_DUMMY)
357else
358  if test "$ac_cv_header_gmp_h" != yes && test "$enable_gmp" != yes; then
359    AC_MSG_WARN(Need gmp.h to use gmp as default ApReal format)
360    AC_MSG_WARN(Use dummy as default MP ApReal format)
361    AC_DEFINE(MP_DEFAULT_APREALFORMAT, MP_DUMMY) 
362  elif test -z "$MPF_PTR" && test "$enable_gmp" != yes; then
363    AC_MSG_WARN(Need gmp.h containing tyedef of 'mpf_ptr')
364    AC_MSG_WARN(Use dummy as default MP ApReal format)
365    AC_DEFINE(MP_DEFAULT_APREALFORMAT, MP_DUMMY) 
366  else
367    AC_DEFINE(MP_DEFAULT_APREAL_FORMAT, MP_GMP)
368    AC_DEFINE(MP_HAVE_GMP_APREAL)
369    if test "$ac_cv_header_gmp_h" != yes ; then
370      AC_MSG_WARN(Need gmp.h to use gmp as default ApReal format)
371      AC_MSG_WARN(Install gmp.h before making MP)
372    fi
373  fi
374fi
375
376if test "$with_gmp" != no; then
377  if test "$ac_cv_header_gmp_h" != yes && test "$enable_gmp" != yes; then
378    AC_MSG_WARN(Can not build MP with gmp ApInt routines: Need gmp.h)
379  else
380    AC_DEFINE(MP_HAVE_GMP)
381    if test "$ac_cv_header_gmp_h" != yes; then
382      AC_MSG_WARN(Need gmp.h to build MP with gmp ApInt routines)
383      AC_MSG_WARN(Install gmp.h before making MP)
384    fi
385  fi
386fi
387
388if test "$with_saclib" = yes; then
389  if test "$ac_cv_header_saclib_h" != yes; then
390    AC_MSG_WARN(Can not build MP with saclib ApInt routines: Need saclib.h)
391  else
392    AC_DEFINE(MP_HAVE_SAC)
393  fi
394fi
395
396if test "$with_pari" = yes; then
397  if test "$ac_cv_header_genpari_h" != yes; then
398    AC_MSG_WARN(Can not build MP with pari ApInt routines: Need genpari.h)
399  else
400    AC_DEFINE(MP_HAVE_PARI)
401    AC_DEFINE(LONG_IS_32BIT)
402    AC_CHECK_TYPE(ulong, no)
403    if test "$ac_cv_type_ulong" = no; then
404        AC_DEFINE(ULONG_NOT_DEFINED)
405    fi
406  fi
407fi
408
409   
410
411if test "$with_tb" = yes; then
412  AC_CHECK_HEADER(TB.h)
413  if test "$ac_cv_header_TB_h" != yes; then
414    AC_MSG_WARN(Can not build with Toolbus: Need TB.h)
415  else
416    AC_DEFINE(MP_HAVE_TB)
417  fi
418fi
419
420if test "$with_pvm" = yes; then
421 AC_CHECK_HEADER(pvm3.h)
422 if test "$ac_cv_header_pvm3_h" != yes; then
423    AC_MSG_WARN(Can not build with Pvm: Need pvm3.h)
424  else
425    AC_DEFINE(MP_HAVE_PVM)
426  fi
427fi
428
429if test "${with_extra_cflags+set}" = set; then
430  CFLAGS="$CFLAGS ${with_extra_cflags}"
431fi
432
433if test "${with_rsh+set}" = set; then
434  AC_CHECK_PROG(with_rsh, ${with_rsh}, ${with_rsh})
435  if test "$ac_cv_prog_with_rsh" = $with_rsh; then
436    mp_rsh_cmdline=${with_rsh}
437  else
438    mp_rsh_cmdline=no
439  fi
440else
441  mp_rsh_cmdline=no
442fi
443
444if test "$mp_rsh_cmdline" = no; then
445  AC_CHECK_PROG(mp_ssh, ssh, ssh, no)
446  AC_CHECK_PROG(mp_remsh, remsh, remsh, no)
447  AC_CHECK_PROG(mp_rsh, rsh, rsh, no)
448  if test "$ac_cv_prog_mp_ssh" = ssh; then
449     mp_rsh_found=ssh
450  elif test "$ac_cv_prog_mp_remsh" = remsh; then
451     mp_rsh_found=remsh
452  elif test "$ac_cv_prog_mp_rsh" = rsh; then
453     mp_rsh_found=rsh
454  else
455     mp_rsh_found=no
456  fi
457else
458  mp_rsh_found=${mp_rsh_cmdline}
459fi
460
461AC_MSG_CHECKING(which remote shell command to use)
462AC_MSG_RESULT(${mp_rsh_found})
463
464if test "$mp_rsh_found" = no; then
465   AC_MSG_WARN("No remote shell command found")
466else
467  AC_DEFINE_UNQUOTED(MP_RSH_COMMAND, "$mp_rsh_found")
468   # check whether it also works with localhost, instead of hostname
469   #if $mp_rsh localhost -n uname  > /dev/null 2>&1; then
470   #  AC_DEFINE(RSH_CAN_LOCALHOST)
471   #fi
472fi
473
474
475
476dnl Check for external memory managements
477AC_ARG_WITH(malloc_h, \
478 [ --with-malloc_h=HEADER     use external malloc routines declared in HEADER])
479
480if test "${with_malloc_h+set}" = set; then
481  AC_CHECK_HEADER(${with_malloc_h},,with_malloc=)
482fi
483AC_MSG_CHECKING(where malloc rotuines come from)
484if test "${with_malloc_h+set}" = set; then
485  AC_MSG_RESULT(${with_malloc_h})
486  AC_DEFINE(WITH_EXTERNAL_MALLOC)
487  AC_DEFINE_UNQUOTED(EXTERNAL_MALLOC_H, "${with_malloc_h}")
488else
489  AC_MSG_RESULT(stdlib.h)
490fi
491
492
493dnl Checks for typedefs, structures, and compiler characteristics.
494AC_C_BIGENDIAN
495AC_C_CONST
496AC_TYPE_SIZE_T
497AC_HEADER_TIME
498
499dnl miscellanous stuff
500dnl check for sizeof(long)
501AC_CHECK_SIZEOF(long, 4)
502if test "$ac_cv_sizeof_long" != 4; then
503  AC_MSG_ERROR(Need sizeof long to equal 4)
504fi
505
506dnl add some defines for if pari is used
507
508CLEAN="rm -f *~ a.out core *.o .log"
509AC_SUBST(CLEAN)
510
511dnl if we use GCC, then we know CFLAGS best and do not let user overwrite it
512if test "${GCC}" = yes && test "$ac_cv_cflags_not_set" = yes; then
513  if test "$with_debug" = yes; then
514    CFLAGS="-g -Wall -Wno-unused ${with_extra_cflags}"
515  else
516    CFLAGS="-O3 -w -fomit-frame-pointer ${with_extra_cflags}"
517  fi
518fi
519
520dnl check for args to pass to subconfigure
521if test "$prefix" = NONE; then
522  ac_configure_args="$ac_configure_args --prefix=$ac_default_prefix"
523fi
524   
525AC_CONFIG_SUBDIRS($CONFIG_SUBDIRS)
526
527AC_OUTPUT(Makefile MP/Makefile MPT/Makefile mpviewer/Makefile \
528        mp-pvm3/Makefile examples/Makefile, \
529        if test "$CONFIG_HEADERS"; then echo timestamp > MP/stamp-h; fi)
Note: See TracBrowser for help on using the repository browser.