onl dnl Written by Olaf Bachmann (obachman@mathematik.uni-kl.de) dnl dnl configure.in for MP dnl Process this file with autoconf to produce a configure script. AC_INIT(MP/MP_Put.c) AC_CONFIG_HEADER(MP/MP_Config.h:MP/h/MP_Config.h.in) PRODUCT=MP VERSION=1.1.2.1 AC_SUBST(PRODUCT) AC_SUBST(VERSION) AC_DEFINE_UNQUOTED(MP_VERSION, "$VERSION") AC_CANONICAL_SYSTEM AC_PREFIX_DEFAULT(`pwd`) dnl The "philosophy" is this: dnl 1) by default the libraries are stored in ${prefix}/lib/${ARCH} dnl 2) the user can override this by setting either --exec-prefix dnl or --libdir dnl 3) If --libdir is given, then libraries are put exactly there dnl 4) If --libdir is not given, and --exec-dir is given, then dnl libraries are put into $exec_prefix/lib (as is standard) dnl 5) The same thing applies to bindir AC_MSG_CHECKING(for architecture identifier) AC_CACHE_VAL(ac_cv_arch,ac_cv_arch=`./pvmgetarch`) AC_MSG_RESULT($ac_cv_arch) if test "$libdir" = '${exec_prefix}/lib' && test "$exec_prefix" = "NONE"; then libdir='${prefix}/lib/'$ac_cv_arch fi if test "$bindir" = '${exec_prefix}/bin' && test "$exec_prefix" = "NONE"; then bindir='${prefix}/bin/'$ac_cv_arch fi dnl Check for programs AC_PROG_RANLIB AC_CHECK_PROG(AR, ar, ar, :) if test "$ac_cv_prog_AR" != ar; then AC_MSG_ERROR(*** ar program not found) fi dnl compiler stuff dnl we do not want to have "-g -O" for CFLAGS if test "$with_debug" = yes; then if test "${CFLAGS+set}" != set; then CFLAGS="-g" ac_cv_cflags_not_set=yes fi AC_DEFINE(MPT_DEBUG) else if test "${CFLAGS+set}" != set; then CFLAGS="-O" ac_cv_cflags_not_set=yes fi AC_DEFINE(NO_LOGGING) fi AC_PROG_CC AC_PROG_CPP AC_PROG_CXX AC_AIX dnl compiler/system specific options if test "${GCC}" != yes; then echo not using gcc, so checking for special flags and defines case "$target" in hppa1*) if test "$ac_cv_prog_CC" = cc; then echo Using HPUX native compiler with -Aa and -D_HPUX_SOURCE CFLAGS="$CFLAGS -Aa " AC_DEFUN(_HPUX_SOURCE) fi esac fi dnl add to CPPFLAGS and LDFLAGS so that ${includedir} and ${libdir} dnl are in there if test "$libdir" = '${exec_prefix}/lib'; then if test "x$exec_prefix" = xNONE; then if test "x$prefix" = xNONE; then LDFLAGS="-L${ac_default_prefix}/lib ${LDFLAGS}" else LDFLAGS="-L${prefix}/lib ${LDFLAGS}" fi else LDFLAGS="-L${exec_prefix}/lib ${LDFLAGS}" fi elif test "$libdir" = '${prefix}/lib/'$ac_cv_arch ; then if test "x$prefix" = xNONE; then LDFLAGS="-L${ac_default_prefix}/lib/$ac_cv_arch ${LDFLAGS}" else LDFLAGS="-L${prefix}/lib/$ac_cv_arch ${LDFLAGS}" fi else LDFLAGS="-L${libdir} ${LDFLAGS}" fi if test "$includedir" = '${prefix}/include'; then if test "x$prefix" = xNONE; then CPPFLAGS="-I${ac_default_prefix}/include ${CPPFLAGS}" else CPPFLAGS="-I${prefix}/include ${CPPFLAGS}" fi else CPPFLAGS="-I${includedir} ${CPPFLAGS}" fi dnl add to CPPFLAGS and LDFLAGS if PVM_ROOT and PVM_ARCH are set if test "${PVM_ROOT+set}" = set; then if test "$enable_mppvm" = yes || test "$with_pvm" = yes; then CPPFLAGS="${CPPFLAGS} -I${PVM_ROOT}/include" if test "${PVM_ARCH+set}" = set; then LDFLAGS="${LDFLAGS} -L{PVM_ROOT}/lib/${PVM_ARCH}" fi fi fi AC_SET_MAKE AC_FUNC_VFORK dnl dnl Lib checks --depend on enable/disable options dnl AC_ARG_ENABLE(MPT, \ [ --disable-MPT disable building of MPT library]) AC_ARG_ENABLE(gmp, \ [ --disable-gmp configure and build without gmp library]) AC_ARG_ENABLE(tests, \ [ --enable-example enable building of example programs]) AC_ARG_ENABLE(mpviewer, \ [ --enable-mpviewer enable building of mpviewer program]) AC_ARG_ENABLE(mppvm, \ [ --enable-mppvm enable building of mppvm routines]) if test "$enable_gmp" != no && test -d gmp; then CONFIG_SUBDIRS="gmp" enable_gmp=yes fi BUILD_SUBDIRS="$CONFIG_SUBDIRS MP" if test "$enable_MPT" != no && test -d MPT; then BUILD_SUBDIRS="${BUILD_SUBDIRS} MPT" fi if test "$enable_examples" = yes && test -d examples; then BUILD_SUBDIRS="${BUILD_SUBDIRS} examples" ac_check_prog=yes fi if test "$enable_mpviewer" = yes && test -d mpviewer; then BUILD_SUBDIRS="${BUILD_SUBDIRS} mpviewer" ac_check_prog=yes fi if test "$enable_mppvm" = yes && test -d mp-pvm3; then BUILD_SUBDIRS="${BUILD_SUBDIRS} mp-pvm3" ac_check_prog=yes with_pvm=yes fi AC_SUBST(BUILD_SUBDIRS) AC_SUBST(CONFIG_SUBDIRS) AC_CHECK_FUNCS(gethostbyname) if test "$ac_check_prog" = yes; then AC_CHECK_LIB(m, atof) AC_CHECK_LIB(bsd, socket) AC_CHECK_LIB(gmp, mpz_init) if test "$ac_cv_lib_gmp_mpz_init" != yes || "$enable_gmp" != no; then AC_MSG_WARN(Did not find gmp library: Linking programs with MP will fail) NEED_LIBS=$LIBS else NEED_LIBS="-lgmp $LIBS" fi AC_CHECK_FUNCS(select socket gethostname gethostbyname strtol strstr) if test "$ac_cv_func_select" != yes; then AC_MSG_WARN(Did not find library containing function select) AC_MSG_WARN(Linking programs with MP might fail) fi if test "$ac_cv_func_gethostname" != yes; then AC_MSG_WARN(Did not find library containing gethostname) AC_MSG_WARN(Linking programs with MP might fail) fi if test "$ac_cv_func_gethostbyname" != yes; then AC_CHECK_LIB(nsl, gethostbyname) if test "$ac_cv_lib_nsl_gethostbyname" != yes; then AC_MSG_WARN(Did not find library containing gethostbyname) AC_MSG_WARN(Linking programs with MP might fail) fi fi if test "$ac_cv_func_socket" != yes; then AC_CHECK_LIB(socket, socket) if test "$ac_cv_lib_socket_socket" != yes; then AC_MSG_WARN(Did not find library containing socket) AC_MSG_WARN(Linking programs with MP might fail) fi fi fi AC_SUBST(NEED_LIBS) dnl Do the header checks now AC_HEADER_STDC AC_HEADER_CHECK(arpa/inet.h,:, echo "*** no arpa/inet.h";exit) AC_HEADER_CHECK(assert.h,:, echo "*** no assert.h";exit) AC_HEADER_CHECK(ctype.h,:, echo "*** no ctype.h";exit) AC_HEADER_CHECK(errno.h,:, echo "*** no errno.h";exit) AC_HEADER_CHECK(netdb.h,:, echo "*** no netdb.h";exit) AC_HEADER_CHECK(netinet/in.h,:, echo "*** no netinet/in.h";exit) AC_HEADER_CHECK(netinet/tcp.h,:, echo "*** no netinet/tcp.h";exit) AC_HEADER_CHECK(signal.h,:, echo "*** no sihnal.h";exit) AC_HEADER_CHECK(stdarg.h,:, echo "*** no stdarg.h";exit) AC_HEADER_CHECK(stdio.h,:, echo "*** no stdio.h";exit) AC_HEADER_CHECK(stdlib.h,:, echo "*** no stdlib.h";exit) AC_HEADER_CHECK(string.h,:, echo "*** no string.h";exit) AC_HEADER_CHECK(stddef.h,:, echo "*** no stddef.h";exit) dnl Wrong preprocessor statement in /usr/include/values.h causes dnl problems on FreeBSD AC_HEADER_CHECK(values.h, freebsd_problem=no no_values_h=no, AC_CHECK_FILE(/usr/include/values.h, freebsd_problem=yes no_values_h=no, no_values_h=yes freebsd_problem=no)) if test "${freebsd_problem}" != no; then grep -v "#warning" /usr/include/values.h > ./MP/h/values.h elif test "${no_values_h}" != no; then cp ./values.h.subst ./MP/h/values.h CPPFLAGS="-I. ${CPPFLAGS}" fi AC_HEADER_CHECK(fcntl.h,:, echo "*** no fcntl.h";exit) AC_HEADER_CHECK(sys/ioctl.h,:, echo "*** no sys/ioctl.h";exit) AC_HEADER_CHECK(sys/param.h,:, echo "*** no sys/param.h";exit) AC_HEADER_CHECK(sys/socket.h,:, echo "*** no sys/socket.h";exit) AC_HEADER_CHECK(sys/stat.h,:, echo "*** no sys/stat.h";exit) AC_HEADER_CHECK(sys/time.h,:, echo "*** no sys/time.h";exit) AC_HEADER_CHECK(sys/types.h,:, echo "*** no sys/types.h";exit) AC_HEADER_CHECK(sys/uio.h,:, echo "*** no sys/uio.h";exit) AC_HEADER_CHECK(sys/un.h,:, echo "*** no sys/un.h";exit) AC_HEADER_CHECK(unistd.h,:, echo "*** no unistd.h";exit) AC_HEADER_CHECK(math.h,:, echo "*** no math.h";exit) AC_CHECK_HEADERS(sys/select.h gmp.h genpari.h saclib.h) dnl Check whether mpz_ptr is defined (is not defined in earlier gmp versions) if test "$ac_cv_header_gmp_h" = yes; then AC_EGREP_HEADER(mpz_ptr, gmp.h, MPZ_PTR=mpz_ptr) if test ! "$MPZ_PTR" = mpz_ptr; then AC_EGREP_HEADER(MP_INT, gmp.h, MPZ_PTR="MP_INT*") AC_DEFINE_UNQUOTED(mpz_ptr, MP_INT*) AC_DEFINE_UNQUOTED(_mp_alloc,alloc) AC_DEFINE_UNQUOTED(_mp_size,size) AC_DEFINE_UNQUOTED(_mp_d,d) fi AC_EGREP_HEADER(mpf_ptr, gmp.h, MPF_PTR=mpf_ptr) fi dnl dnl deal with Ap Number configuration dnl AC_ARG_WITH(apint, \ [ --with-default_apint=PACKAGE use PACKAGE as MP's default ApInt format where PACKAGE can be: gmp (default), pari, saclib, none]) AC_ARG_WITH(apreal, \ [ --with-default_apreal=PACKAGE use PACKAGE as MP's default ApReal format where PACKAGE can be: gmp (default), none]) AC_ARG_WITH(gmp, \ [ --without-gmp build without gmp ApNumber routines]) AC_ARG_WITH(pari, \ [ --with-pari build with pari ApInt routines]) AC_ARG_WITH(saclib, \ [ --with-saclib build with saclib ApInt routines]) AC_ARG_WITH(tb, \ [ --with-tb build with Toolbus device interface]) AC_ARG_WITH(pvm, \ [ --with-pvm build with Pvm saclib device interface]) AC_ARG_WITH(debug, \ [ --with-debug build with debug options and logging]) AC_ARG_WITH(extra_cflags, \ [ --with-extra_cflags=cflags build with 'cflags' appended to CFLAGS given to the compiler]) AC_ARG_WITH(rsh, \ [ --with-rsh=command use 'command' as remote shell command]) dnl evaluate specifications AC_DEFINE(MP_DUMMY, 0) AC_DEFINE(MP_GMP, 1) AC_DEFINE(MP_PARI, 2) AC_DEFINE(MP_SAC, 3) if test "$with_default_apint" = none; then AC_DEFINE(MP_DEFAULT_APINT, MP_DUMMY) elif test "$with_default_apint" = pari; then if test "$ac_cv_header_genpari_h" != yes; then AC_MSG_WARN(Need genpari.h to use pari as default ApInt format) AC_MSG_WARN(Use dummy as default MP ApInt format) AC_DEFINE(MP_DEFAULT_APINT_FORMAT, MP_DUMMY) else AC_DEFINE(MP_DEFAULT_APINT_FORMAT, MP_PARI) AC_DEFINE(MP_HAVE_PARI) fi elif test "$with_default_apint" = saclib; then if test "$ac_cv_header_saclib_h" != yes; then AC_MSG_WARN(Need saclib.h to use saclib as default ApInt format) AC_MSG_WARN(Use dummy as default MP ApInt format) AC_DEFINE(MP_DEFAULT_APINTFORMAT, MP_DUMMY) else AC_DEFINE(MP_DEFAULT_APINT_FORMAT, MP_SAC) AC_DEFINE(MP_HAVE_SACLIB) fi else if test "$ac_cv_header_gmp_h" != yes && test "$enable_gmp" != yes; then AC_MSG_WARN(Need gmp.h to use gmp as default ApInt format) AC_MSG_WARN(Use dummy as default MP ApInt format) AC_DEFINE(MP_DEFAULT_APINTFORMAT, MP_DUMMY) elif test -z "$MPZ_PTR" && test "$enable_gmp" != yes; then AC_MSG_WARN(Need gmp.h containing typedef of 'mpz_ptr' or 'MP_INT') AC_MSG_WARN(Use dummy as default MP ApInt format) AC_DEFINE(MP_DEFAULT_APINTFORMAT, MP_DUMMY) else AC_DEFINE(MP_DEFAULT_APINT_FORMAT, MP_GMP) AC_DEFINE(MP_HAVE_GMP_APINT) if test "$ac_cv_header_gmp_h" != yes; then AC_MSG_WARN(Need gmp.h to use gmp as default ApInt format) AC_MSG_WARN(Install gmp.h before making MP) fi fi fi if test "$with_default_apreal" = none; then AC_DEFINE(MP_DEFAULT_APREAL, MP_DUMMY) else if test "$ac_cv_header_gmp_h" != yes && test "$enable_gmp" != yes; then AC_MSG_WARN(Need gmp.h to use gmp as default ApReal format) AC_MSG_WARN(Use dummy as default MP ApReal format) AC_DEFINE(MP_DEFAULT_APREALFORMAT, MP_DUMMY) elif test -z "$MPF_PTR" && test "$enable_gmp" != yes; then AC_MSG_WARN(Need gmp.h containing tyedef of 'mpf_ptr') AC_MSG_WARN(Use dummy as default MP ApReal format) AC_DEFINE(MP_DEFAULT_APREALFORMAT, MP_DUMMY) else AC_DEFINE(MP_DEFAULT_APREAL_FORMAT, MP_GMP) AC_DEFINE(MP_HAVE_GMP_APREAL) if test "$ac_cv_header_gmp_h" != yes ; then AC_MSG_WARN(Need gmp.h to use gmp as default ApReal format) AC_MSG_WARN(Install gmp.h before making MP) fi fi fi if test "$with_gmp" != no; then if test "$ac_cv_header_gmp_h" != yes && test "$enable_gmp" != yes; then AC_MSG_WARN(Can not build MP with gmp ApInt routines: Need gmp.h) else AC_DEFINE(MP_HAVE_GMP) if test "$ac_cv_header_gmp_h" != yes; then AC_MSG_WARN(Need gmp.h to build MP with gmp ApInt routines) AC_MSG_WARN(Install gmp.h before making MP) fi fi fi if test "$with_saclib" = yes; then if test "$ac_cv_header_saclib_h" != yes; then AC_MSG_WARN(Can not build MP with saclib ApInt routines: Need saclib.h) else AC_DEFINE(MP_HAVE_SAC) fi fi if test "$with_pari" = yes; then if test "$ac_cv_header_genpari_h" != yes; then AC_MSG_WARN(Can not build MP with pari ApInt routines: Need genpari.h) else AC_DEFINE(MP_HAVE_PARI) AC_DEFINE(LONG_IS_32BIT) AC_CHECK_TYPE(ulong, no) if test "$ac_cv_type_ulong" = no; then AC_DEFINE(ULONG_NOT_DEFINED) fi fi fi if test "$with_tb" = yes; then AC_CHECK_HEADER(TB.h) if test "$ac_cv_header_TB_h" != yes; then AC_MSG_WARN(Can not build with Toolbus: Need TB.h) else AC_DEFINE(MP_HAVE_TB) fi fi if test "$with_pvm" = yes; then AC_CHECK_HEADER(pvm3.h) if test "$ac_cv_header_pvm3_h" != yes; then AC_MSG_WARN(Can not build with Pvm: Need pvm3.h) else AC_DEFINE(MP_HAVE_PVM) fi fi if test "${with_extra_cflags+set}" = set; then CFLAGS="$CFLAGS ${with_extra_cflags}" fi if test "${with_rsh+set}" = set; then AC_CHECK_PROG(with_rsh, ${with_rsh}, ${with_rsh}) if test "$ac_cv_prog_with_rsh" = $with_rsh; then mp_rsh_cmdline=${with_rsh} else mp_rsh_cmdline=no fi else mp_rsh_cmdline=no fi if test "$mp_rsh_cmdline" = no; then AC_CHECK_PROG(mp_ssh, ssh, ssh, no) AC_CHECK_PROG(mp_remsh, remsh, remsh, no) AC_CHECK_PROG(mp_rsh, rsh, rsh, no) if test "$ac_cv_prog_mp_ssh" = ssh; then mp_rsh_found=ssh elif test "$ac_cv_prog_mp_remsh" = remsh; then mp_rsh_found=remsh elif test "$ac_cv_prog_mp_rsh" = rsh; then mp_rsh_found=rsh else mp_rsh_found=no fi else mp_rsh_found=${mp_rsh_cmdline} fi AC_MSG_CHECKING(which remote shell command to use) AC_MSG_RESULT(${mp_rsh_found}) if test "$mp_rsh_found" = no; then AC_MSG_WARN("No remote shell command found") else AC_DEFINE_UNQUOTED(MP_RSH_COMMAND, "$mp_rsh_found") # check whether it also works with localhost, instead of hostname #if $mp_rsh localhost -n uname > /dev/null 2>&1; then # AC_DEFINE(RSH_CAN_LOCALHOST) #fi fi dnl Check for external memory managements AC_ARG_WITH(malloc_h, \ [ --with-malloc_h=HEADER use external malloc routines declared in HEADER]) if test "${with_malloc_h+set}" = set; then AC_CHECK_HEADER(${with_malloc_h},,with_malloc=) fi AC_MSG_CHECKING(where malloc rotuines come from) if test "${with_malloc_h+set}" = set; then AC_MSG_RESULT(${with_malloc_h}) AC_DEFINE(WITH_EXTERNAL_MALLOC) AC_DEFINE_UNQUOTED(EXTERNAL_MALLOC_H, "${with_malloc_h}") else AC_MSG_RESULT(stdlib.h) fi dnl Checks for typedefs, structures, and compiler characteristics. AC_C_BIGENDIAN AC_C_CONST AC_TYPE_SIZE_T AC_HEADER_TIME dnl miscellanous stuff dnl check for sizeof(long) AC_CHECK_SIZEOF(long, 4) if test "$ac_cv_sizeof_long" != 4; then AC_MSG_ERROR(Need sizeof long to equal 4) fi dnl add some defines for if pari is used CLEAN="rm -f *~ a.out core *.o .log" AC_SUBST(CLEAN) dnl if we use GCC, then we know CFLAGS best and do not let user overwrite it if test "${GCC}" = yes && test "$ac_cv_cflags_not_set" = yes; then if test "$with_debug" = yes; then CFLAGS="-g -Wall -Wno-unused ${with_extra_cflags}" else CFLAGS="-O3 -w -fomit-frame-pointer ${with_extra_cflags}" fi fi dnl check for args to pass to subconfigure if test "$prefix" = NONE; then ac_configure_args="$ac_configure_args --prefix=$ac_default_prefix" fi AC_CONFIG_SUBDIRS($CONFIG_SUBDIRS) AC_OUTPUT(Makefile MP/Makefile MPT/Makefile mpviewer/Makefile \ mp-pvm3/Makefile examples/Makefile, \ if test "$CONFIG_HEADERS"; then echo timestamp > MP/stamp-h; fi)