#-----------------------------------------------------------------------------# # Copyright (C) 1995-2006 The University of Melbourne. # This file may only be copied under the terms of the GNU General # Public Licence - see the file COPYING in the Mercury distribution. #-----------------------------------------------------------------------------# # # configure.in: autoconf source code for `configure' script. # # This file is automatically processed by `autoconf' to produce the # `configure' script. # #-----------------------------------------------------------------------------# # # Define a macro MERCURY_MSG, similar to AC_MSG_RESULT, for displaying output. # dnl MERCURY_MSG(MESSAGE) define(MERCURY_MSG, [echo $1 1>&AC_FD_MSG]) #-----------------------------------------------------------------------------# AC_INIT(scripts/mmc.in) TMPDIR=${TMPDIR=/tmp} # AC_CHECK_TYPES does not exist in versions of autoconf before 2.50. # AC_CHECK_TYPE is broken in versions of autoconf before 2.50. AC_PREREQ(2.50) #-----------------------------------------------------------------------------# # # Ensure that all messages are saved to a file `configure.log' by # invoking ourself recursively without output piped into `tee configure.log'. # The environment variable `SUPPRESS_LOG_FILE_RECURSION' is used to prevent # infinite recursion. # if test "$SUPPRESS_LOG_FILE_RECURSION" != "yes"; then SUPPRESS_LOG_FILE_RECURSION=yes export SUPPRESS_LOG_FILE_RECURSION trap 0 1 2 3 13 15 rm -f configure.exit_status { case $# in 0) ${CONFIG_SHELL-/bin/sh} "$0" ;; *) ${CONFIG_SHELL-/bin/sh} "$0" "$@" ;; esac; echo $? > configure.exit_status; } | exec tee configure.log status=`cat configure.exit_status` rm -f configure.exit_status exit $status fi #-----------------------------------------------------------------------------# # Work out the default arguments to configure when reconfiguring, # for example when installing a binary distribution. # Strip out --no-create and --no-recursion added by config.status. # Remove any --prefix and --enable-reconfigure arguments passed by # mercury_config. # Also quote any args containing shell metacharacters. # # NOTE: Some macros, e.g. AC_CHECK_PROG, overwrite the argument list, # so this must come before any uses of those macros. prefix_arg=false RECONFIGURE_ARGS= for arg do if test $prefix_arg = true then prefix_arg=false else case "$arg" in --no-create | --no-recursion) ;; --prefix) prefix_arg=true ;; --prefix=*) ;; --enable-reconfigure=*) ;; *" "*|*" "*|*[[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]]*) # The argument needs to be quoted. RECONFIGURE_ARGS="$RECONFIGURE_ARGS '$arg'" ;; *) RECONFIGURE_ARGS="$RECONFIGURE_ARGS $arg" ;; esac fi done AC_SUBST(RECONFIGURE_ARGS) #-----------------------------------------------------------------------------# remake_dependencies=false AC_CONFIG_HEADER(runtime/mercury_conf.h) AC_PREFIX_DEFAULT(/usr/local/mercury-`. ./VERSION; echo $VERSION`) AC_CANONICAL_HOST FULLARCH="$host" AC_SUBST(FULLARCH) AC_DEFINE_UNQUOTED(MR_FULLARCH, "$FULLARCH") . ./VERSION AC_DEFINE_UNQUOTED(MR_VERSION, "$VERSION") if test "$prefix" = "NONE"; then PREFIX="$ac_default_prefix" if test -d $PREFIX then INSTALLABLE_PREFIX=yes else INSTALLABLE_PREFIX=no fi else PREFIX="$prefix" # the directory may be created later INSTALLABLE_PREFIX=yes fi AC_SUBST(INSTALLABLE_PREFIX) case "$PREFIX" in *\ *) AC_MSG_ERROR( [cannot install into a directory with a name containing spaces: \`$PREFIX.']) exit 1 ;; esac # Using `cygpath -m' gives a path that works under both # Cygwin and native Windows, without causing quoting # problems in shell scripts. (`cygpath -m' converts the # path to Windows format, with '/' as the directory # separator). AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo) AC_CHECK_PROG(CYGPATHU, cygpath, cygpath -u, echo) AC_SUBST(CYGPATHU) PREFIX="`$CYGPATH $PREFIX`" LIBDIR="`$CYGPATH $PREFIX/lib/mercury`" NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=$PREFIX/lib/nonshared} AC_SUBST(VERSION) AC_SUBST(PREFIX) AC_SUBST(NONSHARED_LIB_DIR) AC_SUBST(LIBDIR) DEFAULT_MERCURY_DEBUGGER_INIT_DIR=$LIBDIR/mdb AC_SUBST(DEFAULT_MERCURY_DEBUGGER_INIT_DIR) #-----------------------------------------------------------------------------# case "$host" in mips-sgi-irix5.*) AC_MSG_WARN(*** Read README.IRIX-5 before proceeding!) ;; *-*-bsdi*) AC_MSG_WARN(*** Read README.BSDI before proceeding!) ;; esac #-----------------------------------------------------------------------------# # MMC_INVOKE_CMD is the the command used to invoke mercury_compile in # scripts/mmc. # On MSYS (MinGW) we cannot use exec, since exec will not find the file because # it will expect a path relative to the MSYS home directory and will not work # with a full Windows path. A full Windows path, however must be used for the # prefix so that mercury_compile will find the standard library. # case "$host" in *mingw*) MMC_INVOKE_CMD= ;; *) MMC_INVOKE_CMD=exec ;; esac AC_SUBST(MMC_INVOKE_CMD) #-----------------------------------------------------------------------------# # Don't document this -- it's only used by the mercury_config script # to generate a new configuration for an already installed system. # CONFIG_PREFIX is the PREFIX for a partial installation generated # by mercury_config containing only the scripts and the configuration # files, which uses the libraries and executables from a previous # installation. AC_ARG_ENABLE(reconfigure, [], [reconfiguring=yes CONFIG_PREFIX="$enableval" CONFIG_LIBDIR="$CONFIG_PREFIX/lib/mercury"], [reconfiguring=no CONFIG_PREFIX="$PREFIX" CONFIG_LIBDIR="$LIBDIR"] ) case "$CONFIG_PREFIX" in yes) AC_MSG_ERROR(missing argument to --enable-reconfigure=... option) exit 1 ;; no) AC_MSG_ERROR(invalid option --no-enable-reconfigure) exit 1 ;; esac CONFIG_PREFIX="`$CYGPATH $CONFIG_PREFIX`" CONFIG_LIBDIR="`$CYGPATH $CONFIG_LIBDIR`" AC_SUBST(CONFIG_PREFIX) AC_SUBST(CONFIG_LIBDIR) #-----------------------------------------------------------------------------# case "$host" in i386-pc-solaris2.8) link_static_opt= ;; *powerpc*apple*darwin*) link_static_opt= ;; *) link_static_opt="--linkage static" ;; esac MERCURY_MSG("looking for an already installed Mercury compiler to bootstrap with...") AC_PATH_PROG(BOOTSTRAP_MC,mmc) if test "$BOOTSTRAP_MC" != ""; then AC_MSG_CHECKING(whether the above mmc works and is sufficiently recent) cat > conftest.m << EOF % this module contains features which didn't work in % previous versions of the Mercury compiler % We may also test to see if the installed compiler is % recent enough by checking what flags mmc takes. % Use [[ ]] for lists. :- module conftest. :- interface. :- import_module io. :- pred main(io__state::di, io__state::uo) is det. :- implementation. :- import_module bool, int, list, univ. :- mutable(global_var, int, 561, ground, [[untrailed, thread_safe, attach_to_io_state]] ). main(!IO) :- return_rtti_version(Version), p(T), q(T, _), get_global_var(Global, !IO), ( Version >= 8, ac(2) ^ elem(3, 5) = 17, (1 .. 2) = [[1, 2]], Global = 561 -> io.print("Hello, world\n", !IO) ; io.print("Nope.\n", !IO) ). :- type t ---> a ; b ; c(int). :- pred p(t::out) is det. p(b). :- pred q(t::in, int::out) is det. q(T, N) :- ( T = a : t, N = 0 : int ; ( T = b ; T = c(_) ), N = 1 ). :- type a ---> ac(int). :- func a ^ elem(int, int) = int. :- mode in ^ elem(in, in ) = out is det. ac(T) ^ elem(I, J) = T + I * J. :- pred return_rtti_version(int::out) is det. :- pragma foreign_decl("C", local, ""). :- type x ---> x. :- pragma foreign_type("C", x, "MR_Integer", [[can_pass_as_mercury_type, stable]]). :- pragma foreign_proc("C", return_rtti_version(Version::out), [[may_call_mercury, promise_pure, terminates, ordinary_despite_detism, will_not_modify_trail]], " Version = MR_RTTI_VERSION; "). % The code below is the hard_coded/disjs_in_switch test case. % The compiler now depends on the installed compiler handling % code like this test case correctly. :- type tp ---> f(int) ; g(int, int) ; h(float) ; i(string). :- pred p(tp::in, string::out) is det. p(T, U) :- ( ( T = f(_) ; T = g(_, _) ), U = "f or g" ; ( T = h(_) ; T = i(_) ), U = "h or i" ). EOF if # Test for the `--force-disable-tracing' option echo $BOOTSTRAP_MC conftest >&AC_FD_CC 2>&1 && $BOOTSTRAP_MC \ --verbose \ --force-disable-tracing \ --halt-at-warn $link_static_opt conftest \ &AC_FD_CC 2>&1 && test "`./conftest 2>&1 | tr -d '\015'`" = "Hello, world" && # Test for the --record-term-sizes-as-words option. # Note that we need to set --grade to an LLDS grade # when doing this test because term size profiling # requires an LLDS grade. # This also tests for the --shlib-linker-intall-name-flag # and --warn-known-bad-format-calls options. $BOOTSTRAP_MC \ --grade none.gc \ --warn-known-bad-format-calls \ --record-term-sizes-as-words \ --output-grade-string \ --shlib-linker-install-name-flag "-dummy_flag" \ &AC_FD_CC 2>&1 then AC_MSG_RESULT(yes) else BOOTSTRAP_MC= AC_MSG_RESULT(no) # This will only work if the user is working with a source # distribution which includes the pre-generated .C files. # So do a quick check now to ensure that we fail early with a # reasonable error message if they are not present. if test -f compiler/top_level.c || test -f compiler/Mercury/cs/top_level.c then true elif test -f $PREFIX/bin/mercury_compile || test -f $PREFIX/bin/mercury_compile.exe then AC_MSG_WARN( [using $PREFIX/bin/mercury_compile to bootstrap]) else AC_MSG_ERROR( [You need a working Mercury compiler to bootstrap with]) fi fi rm -f conftest* fi #-----------------------------------------------------------------------------# # Let the user specify which C compiler to use. AC_ARG_WITH(cc, [ --with-cc= Specify which C compiler to use.], mercury_cv_with_cc="$withval", mercury_cv_with_cc="") case "$mercury_cv_with_cc" in yes) AC_MSG_ERROR(missing argument to --with-cc=... option) exit 1 ;; no) AC_MSG_ERROR(invalid option --without-cc) exit 1 ;; "") ;; *) CC="$mercury_cv_with_cc" ;; esac #-----------------------------------------------------------------------------# # # Determine whether to define LARGE_CONFIG when compiling boehm_gc. # AC_ARG_ENABLE(gc-large-config, [ --disable-gc-large-config disable large heaps when using conservative GC], enable_gc_large_config="$enableval",enable_gc_large_config=yes) AC_MSG_CHECKING(whether to enable large heaps when using conservative GC) case $enable_gc_large_config in yes) AC_MSG_RESULT(yes) ENABLE_BOEHM_LARGE_CONFIG=-DLARGE_CONFIG ;; no) AC_MSG_RESULT(no) ENABLE_BOEHM_LARGE_CONFIG= ;; *) AC_MSG_RESULT(yes) AC_MSG_WARN([unexpected argument to --enable-gc-large-config]) ENABLE_BOEHM_LARGE_CONFIG=-DLARGE_CONFIG ;; esac AC_SUBST(ENABLE_BOEHM_LARGE_CONFIG) #-----------------------------------------------------------------------------# # # Find the GCC source code # and determine whether or not to enable the GCC back-end interface. # AC_ARG_ENABLE(gcc-back-end, [ --enable-gcc-back-end enable the Mercury compiler's GCC back-end interface], enable_gcc_back_end="$enableval",enable_gcc_back_end=default) AC_MSG_CHECKING(for GCC source directory) gcc_src_dir=not_found case $enable_gcc_back_end in yes|no|default) # Search for the gcc source code; # first try in a subdirectory of this directory, # then one parallel to this directory, # and finally try one level up. for dir in gcc ../gcc ..; do if test -f $dir/gcc/tree.c; then gcc_src_dir="$dir" break fi done ;; *) # The user has specified the gcc source directory via # `--enable-gcc-back-end='. Check that # they specified it correctly. gcc_src_dir="$enable_gcc_back_end" if test -f "$gcc_src_dir"/gcc/tree.c; then enable_gcc_back_end=yes else AC_MSG_RESULT($gcc_src_dir) AC_MSG_ERROR( [--enable-gcc-back-end=$gcc_src_dir specified, but GCC source code not found in $gcc_src_dir]) fi ;; esac AC_MSG_RESULT($gcc_src_dir) AC_MSG_CHECKING(whether to enable the GCC back-end interface) case $enable_gcc_back_end in yes|default) if test "$gcc_src_dir" = not_found; then case $enable_gcc_back_end in yes) AC_MSG_RESULT(yes) AC_MSG_ERROR( [--enable-gcc-back-end specified, but gcc source code not found]) ;; default) enable_gcc_back_end=no ;; esac else enable_gcc_back_end=yes fi ;; no) ;; esac case $enable_gcc_back_end in yes) if test "$BOOTSTRAP_MC" = ""; then AC_MSG_RESULT(yes) AC_MSG_ERROR( [--enable-gcc-back-end requires an already installed Mercury compiler]) else # This will regenerate compiler/maybe_mlds_to_gcc.m. remake_dependencies=true fi ;; esac AC_MSG_RESULT($enable_gcc_back_end) ENABLE_GCC_BACK_END=$enable_gcc_back_end GCC_SRC_DIR=$gcc_src_dir AC_SUBST(ENABLE_GCC_BACK_END) AC_SUBST(GCC_SRC_DIR) #-----------------------------------------------------------------------------# MERCURY_MSG("looking for GNU Make...") AC_PROGRAMS_CHECK(GNU_MAKE,gmake make) if test "$GNU_MAKE" != ""; then case "`$GNU_MAKE -v bogus &1`" in "GNU Make"*) ;; *) GNU_MAKE= esac fi if test "$GNU_MAKE" = ""; then AC_MSG_ERROR(cannot find GNU Make) exit 1 else MERCURY_MSG("found GNU Make: $GNU_MAKE") fi AC_SUBST(GNU_MAKE) #-----------------------------------------------------------------------------# MERCURY_MSG("looking for a way to create named pipes...") save_PATH="$PATH" PATH="$PATH:/etc:/usr/etc:/sbin" AC_PATH_PROG(MKFIFO,mkfifo) if test "$MKFIFO" != ""; then # check that it really works tmp=$TMPDIR/fifo$$ trap "rm -f $tmp" 1 2 3 13 15 if $MKFIFO $tmp && test -p $tmp; then true else MKFIFO="" fi rm -f $tmp fi if test "$MKFIFO" = ""; then AC_PATH_PROG(MKNOD,mknod) if test "$MKNOD" != ""; then # check that it really works tmp=$TMPDIR/fifo$$ trap "rm -f $tmp" 1 2 3 13 15 if $MKNOD $tmp p && test -p $tmp; then MKFIFO=mkfifo_using_mknod else MKNOD= fi fi fi if test "$MKFIFO" = ""; then AC_MSG_WARN(cannot find a working \`mkfifo' or \`mknod') MKFIFO=none AC_DEFINE_UNQUOTED(MR_MKFIFO, "") else AC_DEFINE_UNQUOTED(MR_MKFIFO, "$MKFIFO") fi AC_SUBST(MKFIFO) test "$MKNOD" = "" && MKNOD=mknod AC_SUBST(MKNOD) PATH="$save_PATH" #-----------------------------------------------------------------------------# MERCURY_MSG("looking for a way to create temporary files...") AC_PATH_PROG(MKTEMP,mktemp) if test "$MKTEMP" != ""; then # check that it really works TMPFILE="`mktemp $TMPDIR/configure.XXXXXX < /dev/null`" case "$TMPFILE" in $TMPDIR/configure.*) rm -f $TMPFILE ;; *) MKTEMP="" ;; esac fi if test "$MKTEMP" = ""; then AC_MSG_WARN(cannot find a working \`mktemp', using \`mkdir || exit') MKTEMP="" fi AC_SUBST(MKTEMP) #-----------------------------------------------------------------------------# AC_PATH_PROG(INSTALL_INFO,install-info) AC_SUBST(INSTALL_INFO) #-----------------------------------------------------------------------------# # texi2dvi is currently broken on cygwin and mingw case "$host" in *-cygwin*) TEXI2DVI="" ;; *mingw*) TEXI2DVI="" ;; *) AC_PATH_PROG(TEXI2DVI,texi2dvi) ;; esac AC_SUBST(TEXI2DVI) #-----------------------------------------------------------------------------# AC_PATH_PROG(PDFTEX, pdftex) AC_SUBST(PDFTEX) #-----------------------------------------------------------------------------# AC_PATH_PROG(LYNX,lynx) AC_SUBST(LYNX) #-----------------------------------------------------------------------------# AC_PATH_PROG(DVIPS,dvips) AC_SUBST(DVIPS) #-----------------------------------------------------------------------------# AC_PATH_PROG(MAKEINFO,makeinfo) AC_SUBST(MAKEINFO) #-----------------------------------------------------------------------------# AC_PATH_PROG(INFO,info) AC_SUBST(INFO) #-----------------------------------------------------------------------------# AC_PATH_PROG(PERL,perl) AC_SUBST(PERL) #-----------------------------------------------------------------------------# AC_PATH_PROG(HOSTNAMECMD,hostname uname) case "$HOSTNAMECMD" in *hostname) # OS X uses BSD's hostname command which outputs # the fully qualified domain name by default. It # doesn't have a `-f' flag. # XXX We should probably check that the user isn't # using GNU's hostname on OS X instead. case "$host" in powerpc*apple*darwin*) HOSTNAMECMD="$HOSTNAMECMD" ;; *) HOSTNAMECMD="$HOSTNAMECMD -f" ;; esac ;; esac AC_DEFINE_UNQUOTED(MR_HOSTNAMECMD, "$HOSTNAMECMD") #-----------------------------------------------------------------------------# AC_PROG_CC MERCURY_CHECK_CC_NEEDS_TRAD_CPP AC_SUBST(CC) # AC_PROG_CC sets GCC to yes if $CC is GNU C. if test "$GCC" = "yes"; then GCC_PROG=$CC else AC_PATH_PROG(GCC_PROG,gcc) fi AC_EXEEXT AC_SUBST(EXEEXT) # We need to ensure that CFLAGS does not contain `-g', because # on some (broken) distributions of Linux (specifically Debian 0.93R6), # the `-lc' and `-lg' libraries have different contents; specifically, # only the latter contains memalign(). We need to make sure that the # test for memalign() doesn't use `-g', since `ml' doesn't use `-g'. CFLAGS="-O" # we also need to add the appropriate `-I' options so that the test programs # can #include various Mercury runtime headers. case "$MERCURY_CONF_RECONFIGURE" in "") CPPFLAGS="-Iruntime -Iruntime/machdeps -Itrace $CPPFLAGS" ;; *) # We're generating a new configuration for # an existing installation. CPPFLAGS="-I$PREFIX/lib/mercury/inc $CPPFLAGS" ;; esac #-----------------------------------------------------------------------------# cat > conftest.c << EOF struct MR_TypeInfo_Almost_Struct { int MR_almost; }; struct MR_TypeCtorInfo_Struct { int MR_tci1; int MR_tci2; }; typedef struct MR_TypeCtorInfo_Struct *MR_TypeCtorInfo; typedef const struct MR_TypeInfo_Almost_Struct *MR_TypeInfo; struct MR_FA_TypeInfo_Struct1 { MR_TypeCtorInfo MR_ti_type_ctor_info; MR_TypeInfo MR_ti_fixed_arity_arg_typeinfos[1]; }; extern const struct MR_FA_TypeInfo_Struct1 ML_type_ctor_info; MR_TypeInfo f(void) { MR_TypeInfo x; x = (MR_TypeInfo) &ML_type_ctor_info; return x; } EOF AC_MSG_CHECKING(whether we can use -fno-strict-aliasing) if $CC -O2 -Wall -fno-strict-aliasing -c conftest.c \ &AC_FD_CC 2>&1 then AC_MSG_RESULT(yes) AC_MSG_CHECKING(whether we need to use -fno-strict-aliasing) $CC -O2 -Wall -fno-strict-aliasing -c conftest.c \ conftest1.out 2>&1 $CC -O2 -Wall -c conftest.c \ conftest2.out 2>&1 # get the lines that exist only in conftest2.out comm -13 conftest1.out conftest2.out > conftest.2only if test -s conftest.2only then AC_MSG_RESULT(yes) CFLAGS_FOR_NO_STRICT_ALIASING="-fno-strict-aliasing" else AC_MSG_RESULT(no) CFLAGS_FOR_NO_STRICT_ALIASING="" fi else AC_MSG_RESULT(no) CFLAGS_FOR_NO_STRICT_ALIASING= fi AC_SUBST(CFLAGS_FOR_NO_STRICT_ALIASING) rm -f conftest* #-----------------------------------------------------------------------------# # Make sure we search /usr/local/include and /usr/local/lib for # header files and libraries. GNU C normally searches /usr/local/include # by default, but (inconsistently) on some systems, such as Solaris, # it does _not_ search /usr/local/lib. # The user might also be using a different C compiler that # doesn't search either of those by default. MERCURY_CHECK_LOCAL_C_INCL_DIRS CPPFLAGS="$ALL_LOCAL_C_INCL_DIRS $CPPFLAGS" MERCURY_CHECK_LOCAL_C_LIB_DIRS for dir in $ALL_LOCAL_C_LIB_DIRS kludge_for_broken_shells do if test "$dir" != "kludge_for_broken_shells"; then LIBS="-L$dir $LIBS" fi done AC_PROG_CPP #-----------------------------------------------------------------------------# AC_MSG_CHECKING(for use of a Microsoft C compiler) AC_EGREP_CPP(yes, [ #ifdef _MSC_VER yes #endif ], [ac_microsoft=yes ] AC_MSG_RESULT(yes), [ac_microsoft=no ] AC_MSG_RESULT(no)) LDFLAGS_FOR_TRACE= LD_LIBFLAGS_FOR_TRACE= if test "$ac_microsoft" = "yes" ; then # Use MS-style file names and command-line options OBJ_SUFFIX="obj" LIB_SUFFIX="lib" LIB_PREFIX="lib" LIB_LIBPATH="/LIBPATH:" LINK_LIB="" LINK_LIB_SUFFIX=".lib" LINK_OPT_SEP="/link" OBJFILE_OPT="/Fo" AR="lib" ARFLAGS="" AR_LIBFILE_OPT="/OUT:" LDFLAGS_FOR_DEBUG="/DEBUG" LD_LIBFLAGS_FOR_DEBUG="/DEBUG" LD_STRIP_FLAG= USING_MICROSOFT_CL_COMPILER="yes" case "$CYGPATH" in "echo") AC_MSG_WARN(cygpath required with Microsoft Visual C++) ;; esac FIX_PATH_FOR_CC="$CYGPATH" # MS doesn't use a ranlib. RANLIB="echo" AC_SUBST(RANLIB) else # Use Unix-style file names and command-line options OBJ_SUFFIX="o" LIB_SUFFIX="a" LIB_PREFIX="" LIB_LIBPATH="-L" LINK_LIB="-l" LINK_LIB_SUFFIX="" LINK_OPT_SEP="" OBJFILE_OPT="-o " AR="ar" ARFLAGS="cr" AR_LIBFILE_OPT="" LD_STRIP_FLAG="-s" LDFLAGS_FOR_DEBUG="-g" LD_LIBFLAGS_FOR_DEBUG="-g" # # On Linux ELF, the linker option `-export-dynamic' is needed to make # symbols exported for use in code linked in with dlopen(), # which is used for interactive queries in the # Mercury debugger. For gcc, this linker option can be enabled by # passing either `-rdynamic' or `-Wl,-export-dynamic' to gcc; # we use the former. For lcc 4.2, we need to use `-Wl-export-dynamic'. # case $FULLARCH in *-linux*aout) ;; # no special options needed *-linux*) case "$CC" in lcc*) LDFLAGS_FOR_TRACE="-Wl-export-dynamic" ;; *) LDFLAGS_FOR_TRACE="-rdynamic" ;; esac ;; esac USING_MICROSOFT_CL_COMPILER="no" FIX_PATH_FOR_CC=echo AC_PROG_RANLIB # On MacOS 10.1 (and other MacOS systems?), # we need to pass the `-c' option to ranlib. # Otherwise, "common" symbols, i.e. "int foo;" without an initializer, # do not get included in the archive table of contents, and so # don't get found during linking. Whose !@#$ing idea was it to make # that brain-damaged and non-standard-conforming mode the default? case "$host" in *-apple-darwin*) RANLIB="$RANLIB -c" AC_SUBST(RANLIB) ;; esac fi AC_SUBST(OBJFILE_OPT) AC_SUBST(AR) AC_SUBST(ARFLAGS) AC_SUBST(AR_LIBFILE_OPT) AC_SUBST(LDFLAGS_FOR_DEBUG) AC_SUBST(LD_LIBFLAGS_FOR_DEBUG) AC_SUBST(LD_STRIP_FLAG) AC_SUBST(LDFLAGS_FOR_TRACE) AC_SUBST(LD_LIBFLAGS_FOR_TRACE) AC_SUBST(USING_MICROSOFT_CL_COMPILER) AC_SUBST(OBJ_SUFFIX) AC_SUBST(LIB_SUFFIX) AC_SUBST(LIB_PREFIX) AC_SUBST(LIB_LIBPATH) AC_SUBST(LINK_LIB) AC_SUBST(LINK_LIB_SUFFIX) AC_SUBST(LINK_OPT_SEP) AC_SUBST(FIX_PATH_FOR_CC) AC_SUBST(CYGPATH) #-----------------------------------------------------------------------------# # Check for `-lm': some systems, e.g. MacOS X (Darwin), don't have it. # The result of this check may be overridden below. AC_CHECK_LIB(m, sin, [MATH_LIB=-lm], [MATH_LIB=]) #-----------------------------------------------------------------------------# enable_symlinks_opt=no AC_ARG_ENABLE(symlinks, [ --enable-symlinks enable symbolic links. This is the default on all systems except Windows. On Windows you can force symbolic links to be used by giving this option. Note that symbolic links will only work on Windows if you are using the Cygwin version of GCC.], [ enable_symlinks_opt=yes ]) # If we're compiling the compiler on Windows, # don't use symlinks when installing unless the --enable-symlinks option # is given. # # When cross-compiling from Cygwin to Mingw (and perhaps also on # native Mingw?), `-lm' exists, but it is not needed and in fact we must # not use it, because if we do then it causes cygwin1.dll to be linked in. MMC_USE_SYMLINKS_OPT= LN_S="ln -s" case "$host" in *cygwin*) MATH_LIB= if test "$enable_symlinks_opt" != "yes"; then MMC_USE_SYMLINKS_OPT=--no-use-symlinks LN_S=false fi ;; *mingw*) MATH_LIB= if test "$enable_symlinks_opt" != "yes"; then MMC_USE_SYMLINKS_OPT=--no-use-symlinks LN_S=false fi ;; esac AC_SUBST(LN_S) AC_SUBST(MMC_USE_SYMLINKS_OPT) AC_SUBST(MATH_LIB) #-----------------------------------------------------------------------------# # Microsoft.NET configuration # MERCURY_CHECK_DOTNET #-----------------------------------------------------------------------------# # Java configuration # MERCURY_CHECK_JAVA #-----------------------------------------------------------------------------# mercury_check_for_functions () { for mercury_cv_func in "$@" do mercury_cv_func_define="MR_HAVE_`echo $mercury_cv_func | \ tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`" AC_CHECK_FUNC($mercury_cv_func, [ AC_DEFINE_UNQUOTED($mercury_cv_func_define) ]) done } # Don't try to use mprotect() on gnu-win32, since it is broken # (at least for version b18, anyway) and trying it can crash Win95. case "$host" in *-cygwin*) ac_cv_func_mprotect=no ;; *mingw*) ac_cv_func_mprotect=no ;; esac mercury_check_for_functions \ sysconf getpagesize gethostname \ mprotect memalign posix_memalign memmove \ sigaction siginterrupt setitimer \ snprintf _snprintf vsnprintf _vsnprintf strerror \ open close dup dup2 fdopen fileno fstat stat lstat isatty \ getpid setpgid fork execlp wait kill \ grantpt unlockpt ptsname tcgetattr tcsetattr ioctl \ access sleep opendir readdir closedir mkdir symlink readlink #-----------------------------------------------------------------------------# MERCURY_CHECK_FOR_HEADERS( \ unistd.h sys/wait.h sys/siginfo.h sys/signal.h ucontext.h \ asm/sigcontext.h sys/param.h sys/time.h sys/times.h \ sys/types.h sys/stat.h fcntl.h termios.h sys/ioctl.h \ sys/stropts.h windows.h dirent.h getopt.h malloc.h) if test "$MR_HAVE_GETOPT_H" = 1; then GETOPT_H_AVAILABLE=yes else GETOPT_H_AVAILABLE=no fi AC_SUBST(GETOPT_H_AVAILABLE) if test "$MR_HAVE_UCONTEXT_H" != 1; then MERCURY_CHECK_FOR_HEADERS(sys/ucontext.h) fi #-----------------------------------------------------------------------------# # # check the basics of sigaction # if test "$ac_cv_func_sigaction" = yes; then AC_MSG_CHECKING(for \`sigaction' field name) AC_CACHE_VAL(mercury_cv_sigaction_field, AC_TRY_RUN([ #include #include #define FAULT_ADDRESS ((int *)112) extern void handler(int signum, siginfo_t *info, void *context); int main() { struct sigaction act; act.sa_flags = SA_SIGINFO; act.sa_sigaction = handler; if (sigemptyset(&act.sa_mask) != 0) exit(1); if (sigaction(SIGSEGV, &act, NULL) != 0) exit(1); /* provoke a SIGSEGV */ (*FAULT_ADDRESS)++; exit(1); } void handler(int signum, siginfo_t *info, void *context) { if (signum == SIGSEGV && info->si_signo == SIGSEGV && info->si_code > 0 && (int *)info->si_addr == FAULT_ADDRESS) { exit(0); } else { exit(1); } }], [mercury_cv_sigaction_field=sa_sigaction], [mercury_cv_sigaction_field=sa_handler], [mercury_cv_sigaction_field=sa_handler])) AC_MSG_RESULT($mercury_cv_sigaction_field) AC_DEFINE_UNQUOTED(MR_SIGACTION_FIELD,$mercury_cv_sigaction_field) if test $mercury_cv_sigaction_field = sa_sigaction; then AC_DEFINE(MR_HAVE_SIGINFO) fi fi # # check the basics of sigcontext_struct # AC_MSG_CHECKING(for working \`sigcontext_struct' in second arg) AC_CACHE_VAL(mercury_cv_sigcontext_struct_2arg, mercury_cv_sigcontext_struct_2arg=no AC_TRY_RUN([ /* see runtime/mercury_signal.h for documentation of this code */ #define sigcontext_struct sigcontext #define __KERNEL__ #include #undef __KERNEL__ #ifdef MR_HAVE_ASM_SIGCONTEXT_H #include #endif #include "mercury_faultaddr.h" #include extern void handler(int signum, struct sigcontext_struct info); #define FAULT_ADDRESS ((int *)112) int main() { signal(SIGSEGV, (void (*)(int))handler); /* provoke a SIGSEGV */ (*FAULT_ADDRESS)++; exit(1); } void handler(int signum, struct sigcontext_struct context) { int *addr; addr = (int *) MR_GET_FAULT_ADDR(context); if (signum == SIGSEGV && addr == FAULT_ADDRESS) { exit(0); } else { exit(1); } }], [mercury_cv_sigcontext_struct_2arg=yes], [true], [true])) AC_MSG_RESULT($mercury_cv_sigcontext_struct_2arg) if test $mercury_cv_sigcontext_struct_2arg = no; then # # check for a sigcontext_struct in the third argument of # the signal handler (Linux-68k has this). # AC_MSG_CHECKING(for working \`sigcontext_struct' in third arg) AC_CACHE_VAL(mercury_cv_sigcontext_struct_3arg, mercury_cv_sigcontext_struct_3arg=no AC_TRY_RUN([ /* see runtime/mercury_signal.h for documentation of this code */ #define sigcontext_struct sigcontext #define __KERNEL__ #include #undef __KERNEL__ #ifdef MR_HAVE_ASM_SIGCONTEXT_H #include #endif #include "mercury_faultaddr.h" #include extern void handler(int signum, int code, struct sigcontext_struct info); #define FAULT_ADDRESS ((int *)112) int main() { signal(SIGSEGV, (void (*)(int))handler); /* provoke a SIGSEGV */ (*FAULT_ADDRESS)++; exit(1); } void handler(int signum, int code, struct sigcontext_struct context) { int *addr; addr = (int *) MR_GET_FAULT_ADDR(context); if (signum == SIGSEGV && addr == FAULT_ADDRESS) { exit(0); } else { exit(1); } }], [mercury_cv_sigcontext_struct_3arg=yes], [true], [true])) AC_MSG_RESULT($mercury_cv_sigcontext_struct_3arg) else mercury_cv_sigcontext_struct_3arg=no fi mercury_cv_sigcontext_struct=no if test $mercury_cv_sigcontext_struct_2arg = yes; then mercury_cv_sigcontext_struct=yes AC_DEFINE(MR_HAVE_SIGCONTEXT_STRUCT_2ARG) fi if test $mercury_cv_sigcontext_struct_3arg = yes; then mercury_cv_sigcontext_struct=yes AC_DEFINE(MR_HAVE_SIGCONTEXT_STRUCT_3ARG) fi if test $mercury_cv_sigcontext_struct = yes; then AC_DEFINE(MR_HAVE_SIGCONTEXT_STRUCT) AC_DEFINE(MR_HAVE_SIGINFO) # # check for sigcontext_struct.eip # AC_MSG_CHECKING(for \`sigcontext_struct' pc access at signals) AC_CACHE_VAL(mercury_cv_pc_access, mercury_cv_pc_access=no AC_TRY_RUN([ /* see runtime/mercury_signal.h for documentation of this code */ #define sigcontext_struct sigcontext #define __KERNEL__ #include #undef __KERNEL__ #ifdef MR_HAVE_ASM_SIGCONTEXT_H #include #endif #include "mercury_faultaddr.h" #include #if MR_HAVE_SIGCONTEXT_STRUCT_3ARG extern void handler(int signum, int code, struct sigcontext_struct context); #else extern void handler(int signum, struct sigcontext_struct context); #endif #define FAULT_ADDRESS ((int *)112) int main() { signal(SIGSEGV, (void (*)(int))handler); /* provoke a SIGSEGV */ (*FAULT_ADDRESS)++; exit(1); } #if MR_HAVE_SIGCONTEXT_STRUCT_3ARG void handler(int signum, int code, struct sigcontext_struct context) { #else void handler(int signum, struct sigcontext_struct context) { #endif int *addr; long pc; addr = (int *) MR_GET_FAULT_ADDR(context); pc = (long) context.eip; if (signum == SIGSEGV && addr == FAULT_ADDRESS && pc != 0) { exit(0); } else { exit(1); } }], [mercury_cv_pc_access=eip], [true], [true])) AC_MSG_RESULT($mercury_cv_pc_access) if test $mercury_cv_pc_access != no; then AC_DEFINE_UNQUOTED(MR_PC_ACCESS,$mercury_cv_pc_access) fi else AC_MSG_CHECKING(for \`siginfo_t') AC_CACHE_VAL(mercury_cv_siginfo_t, mercury_cv_siginfo_t=no AC_TRY_RUN([ #include #include #ifdef MR_HAVE_SYS_SIGINFO_H #include #endif #ifdef MR_HAVE_SYS_SIGNAL_H #include #endif #ifdef MR_HAVE_UCONTEXT_H #include #endif #ifdef MR_HAVE_SYS_UCONTEXT_H #include #endif int save_signum = 0; int save_cause; int save_pc; extern void handler(int signum, siginfo_t *info, void *context); int main() { struct sigaction act; act.sa_flags = SA_SIGINFO; act.$mercury_cv_sigaction_field = handler; if (sigemptyset(&act.sa_mask) != 0) exit(1); if (sigaction(SIGSEGV, &act, NULL) != 0) exit(1); if (kill(getpid(), SIGSEGV) != 0) exit(1); if (save_signum == 0) exit(1); exit(0); } void handler(int signum, siginfo_t *info, void *context) { save_signum = signum; save_cause = info->si_code; }], [mercury_cv_siginfo_t=yes], [true], [true])) AC_MSG_RESULT($mercury_cv_siginfo_t) if test $mercury_cv_siginfo_t = yes; then AC_DEFINE(MR_HAVE_SIGINFO_T) AC_DEFINE(MR_HAVE_SIGINFO) AC_MSG_CHECKING(for \`siginfo' pc access at signals) AC_CACHE_VAL(mercury_cv_pc_access, mercury_cv_pc_access=no AC_TRY_RUN([ #include #include #include #ifdef MR_HAVE_UCONTEXT_H #include #else #include #endif int save_signum = 0; int save_cause; int save_pc; extern void handler(int signum, siginfo_t *info, void *context); int main() { struct sigaction act; act.sa_flags = SA_SIGINFO; act.$mercury_cv_sigaction_field = handler; if (sigemptyset(&act.sa_mask) != 0) exit(1); if (sigaction(SIGSEGV, &act, NULL) != 0) exit(1); if (kill(getpid(), SIGSEGV) != 0) exit(1); if (save_signum == 0) exit(1); exit(0); } void handler(int signum, siginfo_t *info, void *context) { save_signum = signum; save_cause = info->si_code; /* Don't use array indexing - the square brackets are autoconf quote characters */ save_pc = *(((ucontext_t *) context)->uc_mcontext.gregs + REG_PC); }], [mercury_cv_pc_access=REG_PC;mercury_cv_pc_access_greg=yes], [true], [true]) AC_TRY_RUN([ #include #include #include #ifdef MR_HAVE_UCONTEXT_H #include #else #include #endif int save_signum = 0; int save_cause; int save_pc; extern void handler(int signum, siginfo_t *info, void *context); int main() { struct sigaction act; act.sa_flags = SA_SIGINFO; act.$mercury_cv_sigaction_field = handler; if (sigemptyset(&act.sa_mask) != 0) exit(1); if (sigaction(SIGSEGV, &act, NULL) != 0) exit(1); if (kill(getpid(), SIGSEGV) != 0) exit(1); if (save_signum == 0) exit(1); exit(0); } void handler(int signum, siginfo_t *info, void *context) { save_signum = signum; save_cause = info->si_code; save_pc = *(((ucontext_t *) context)->uc_mcontext.gregs + CTX_EPC); }], [mercury_cv_pc_access=CTX_EPC;mercury_cv_pc_access_greg=yes], [true], [true]) AC_TRY_RUN([ #include #include #include #ifdef MR_HAVE_UCONTEXT_H #include #else #include #endif int save_signum = 0; int save_cause; int save_pc; extern void handler(int signum, siginfo_t *info, void *context); int main() { struct sigaction act; act.sa_flags = SA_SIGINFO; act.$mercury_cv_sigaction_field = handler; if (sigemptyset(&act.sa_mask) != 0) exit(1); if (sigaction(SIGSEGV, &act, NULL) != 0) exit(1); if (kill(getpid(), SIGSEGV) != 0) exit(1); if (save_signum == 0) exit(1); exit(0); } void handler(int signum, siginfo_t *info, void *context) { save_signum = signum; save_cause = info->si_code; save_pc = ((ucontext_t *) context)->uc_mcontext.sc_pc; }], [mercury_cv_pc_access=sc_pc;mercury_cv_pc_access_greg=no], [true], [true]) ) AC_MSG_RESULT($mercury_cv_pc_access) if test $mercury_cv_pc_access != no; then AC_DEFINE_UNQUOTED(MR_PC_ACCESS,$mercury_cv_pc_access) if test $mercury_cv_pc_access_greg != no; then AC_DEFINE(MR_PC_ACCESS_GREG) fi fi fi fi #-----------------------------------------------------------------------------# AC_MSG_CHECKING(for an integer type with the same size as a pointer) AC_CACHE_VAL(mercury_cv_word_type, AC_TRY_RUN([ #include int main() { FILE *fp; fp = fopen("conftest.tags", "w"); if (fp == NULL) exit(1); if (sizeof(int) == sizeof(void *)) { fprintf(fp, "int\n"); exit(0); } if (sizeof(long) == sizeof(void *)) { fprintf(fp, "long\n"); exit(0); } fprintf(fp, "unknown\n"); exit(1); }], [mercury_cv_word_type=`cat conftest.tags`], [mercury_cv_word_type=unknown], [mercury_cv_word_type=unknown]) ) if test "$mercury_cv_word_type" = unknown; then AC_TRY_RUN([ #include int main() { FILE *fp; fp = fopen("conftest.tags", "w"); if (fp == NULL) exit(1); if (sizeof(long long) == sizeof(void *)) { fprintf(fp, "long long\n"); exit(0); } fprintf(fp, "unknown\n"); exit(1); }], [mercury_cv_word_type=`cat conftest.tags`], [mercury_cv_word_type=unknown], [mercury_cv_word_type=unknown]) fi AC_MSG_RESULT($mercury_cv_word_type) AC_DEFINE_UNQUOTED(MR_WORD_TYPE, $mercury_cv_word_type) MR_WORD_TYPE=$mercury_cv_word_type AC_SUBST(MR_WORD_TYPE) if test "$mercury_cv_word_type" = int; then AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "") elif test "$mercury_cv_word_type" = long; then AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "l") elif test "$mercury_cv_word_type" = "long long"; then AC_DEFINE_UNQUOTED(MR_INTEGER_LENGTH_MODIFIER, "ll") else AC_MSG_ERROR(Cannot determine the length modifier for the MR_Integer type.) fi AC_SUBST(MR_INTEGER_LENGTH_MODIFIER) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(for an integer type of at least 64 bits) AC_CACHE_VAL(mercury_cv_int_least64_type, AC_TRY_RUN([ #include #include int main() { FILE *fp; fp = fopen("conftest.tags", "w"); if (fp == NULL) exit(1); if (sizeof(int) * CHAR_BIT >= 64) { fprintf(fp, "int\n"); exit(0); } if (sizeof(long) * CHAR_BIT >= 64) { fprintf(fp, "long\n"); exit(0); } fprintf(fp, "unknown\n"); exit(1); }], [mercury_cv_int_least64_type=`cat conftest.tags`], [mercury_cv_int_least64_type=unknown], [mercury_cv_int_least64_type=unknown]) ) if test "$mercury_cv_int_least64_type" = unknown; then AC_TRY_RUN([ #include #include int main() { FILE *fp; fp = fopen("conftest.tags", "w"); if (fp == NULL) exit(1); if (sizeof(long long) * CHAR_BIT >= 64) { fprintf(fp, "long long\n"); exit(0); } fprintf(fp, "unknown\n"); exit(1); }], [mercury_cv_int_least64_type=`cat conftest.tags`], [mercury_cv_int_least64_type=unknown], [mercury_cv_int_least64_type=unknown]) fi # Uncomment the following line to test how the system behaves # in the absence of a 64-bit integer type. # mercury_cv_int_least64_type=unknown AC_MSG_RESULT($mercury_cv_int_least64_type) if test "$mercury_cv_int_least64_type" != unknown; then AC_DEFINE_UNQUOTED(MR_INT_LEAST64_TYPE, $mercury_cv_int_least64_type) MR_INT_LEAST64_TYPE=$mercury_cv_int_least64_type AC_SUBST(MR_INT_LEAST64_TYPE) fi #-----------------------------------------------------------------------------# AC_MSG_CHECKING(for an integer type of at least 32 bits) AC_CACHE_VAL(mercury_cv_int_least32_type, AC_TRY_RUN([ #include #include int main() { FILE *fp; fp = fopen("conftest.tags", "w"); if (fp == NULL) exit(1); if (sizeof(int) * CHAR_BIT >= 32) { fprintf(fp, "int\n"); exit(0); } if (sizeof(long) * CHAR_BIT >= 32) { fprintf(fp, "long\n"); exit(0); } fprintf(fp, "unknown\n"); exit(1); }], [mercury_cv_int_least32_type=`cat conftest.tags`], [mercury_cv_int_least32_type=unknown], [mercury_cv_int_least32_type=unknown]) ) AC_MSG_RESULT($mercury_cv_int_least32_type) AC_DEFINE_UNQUOTED(MR_INT_LEAST32_TYPE, $mercury_cv_int_least32_type) MR_INT_LEAST32_TYPE=$mercury_cv_int_least32_type AC_SUBST(MR_INT_LEAST32_TYPE) if test "$mercury_cv_int_least32_type" = int; then AC_DEFINE_UNQUOTED(MR_INT_LEAST32_MAX, INT_MAX) AC_DEFINE_UNQUOTED(MR_UINT_LEAST32_MAX, UINT_MAX) elif test "$mercury_cv_int_least32_type" = long; then AC_DEFINE_UNQUOTED(MR_INT_LEAST32_MAX, LONG_MAX) AC_DEFINE_UNQUOTED(MR_UINT_LEAST32_MAX, ULONG_MAX) else AC_MSG_ERROR( [Cannot find the name of the max values for MR_INT_LEAST32_TYPE.]) fi AC_SUBST(MR_INT_LEAST32_MAX) AC_SUBST(MR_UINT_LEAST32_MAX) #-----------------------------------------------------------------------------# AC_TYPE_PID_T AC_CHECK_TYPES([dev_t, ino_t]) case "$ac_cv_type_dev_t" in yes) AC_DEFINE_UNQUOTED(MR_HAVE_DEV_T) ;; esac case "$ac_cv_type_ino_t" in yes) AC_DEFINE_UNQUOTED(MR_HAVE_INO_T) ;; esac #-----------------------------------------------------------------------------# AC_MSG_CHECKING(for an integer type of at least 16 bits) AC_CACHE_VAL(mercury_cv_int_least16_type, AC_TRY_RUN([ #include #include int main() { FILE *fp; fp = fopen("conftest.tags", "w"); if (fp == NULL) exit(1); if (sizeof(short) * CHAR_BIT >= 16) { fprintf(fp, "short\n"); exit(0); } if (sizeof(int) * CHAR_BIT >= 16) { fprintf(fp, "int\n"); exit(0); } fprintf(fp, "unknown\n"); exit(1); }], [mercury_cv_int_least16_type=`cat conftest.tags`], [mercury_cv_int_least16_type=unknown], [mercury_cv_int_least16_type=unknown]) ) AC_MSG_RESULT($mercury_cv_int_least16_type) AC_DEFINE_UNQUOTED(MR_INT_LEAST16_TYPE, $mercury_cv_int_least16_type) MR_INT_LEAST16_TYPE=$mercury_cv_int_least16_type AC_SUBST(MR_INT_LEAST16_TYPE) if test "$mercury_cv_int_least16_type" = short; then AC_DEFINE_UNQUOTED(MR_INT_LEAST16_MAX, SHRT_MAX) AC_DEFINE_UNQUOTED(MR_UINT_LEAST16_MAX, USHRT_MAX) elif test "$mercury_cv_int_least16_type" = int; then AC_DEFINE_UNQUOTED(MR_INT_LEAST16_MAX, INT_MAX) AC_DEFINE_UNQUOTED(MR_UINT_LEAST16_MAX, UINT_MAX) else AC_MSG_ERROR(Cannot find the name of the max value for MR_INT_LEAST16_TYPE.) fi AC_SUBST(MR_INT_LEAST16_MAX) AC_SUBST(MR_UINT_LEAST16_MAX) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(the number of low tag bits available) AC_CACHE_VAL(mercury_cv_low_tag_bits, AC_TRY_RUN([ #include #include int main() { FILE *fp; fp = fopen("conftest.tags", "w"); if (fp == NULL) exit(1); if (sizeof(void *) == 4) { fprintf(fp, "2\n"); exit(0); } if (sizeof(void *) == 8) { fprintf(fp, "3\n"); exit(0); } if (sizeof(void *) == 16) { fprintf(fp, "4\n"); exit(0); } fprintf(fp, "0\n"); exit(1); }], [mercury_cv_low_tag_bits=`cat conftest.tags`], [mercury_cv_low_tag_bits=0], [mercury_cv_low_tag_bits=0]) ) AC_MSG_RESULT($mercury_cv_low_tag_bits) if test "$mercury_cv_low_tag_bits" -lt 2; then if test "$BOOTSTRAP_MC" = ""; then AC_MSG_ERROR(cannot bootstrap: low tag bits less than 2) exit 1 fi fi if test "$mercury_cv_low_tag_bits" -gt 2; then if test "$BOOTSTRAP_MC" = ""; then AC_MSG_WARN(bootstrapping using only 2 low tag bits) mercury_cv_low_tag_bits=2 fi fi AC_DEFINE_UNQUOTED(MR_LOW_TAG_BITS, $mercury_cv_low_tag_bits) LOW_TAG_BITS=$mercury_cv_low_tag_bits AC_SUBST(LOW_TAG_BITS) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(the number of bytes per word) AC_CACHE_VAL(mercury_cv_bytes_per_word, AC_TRY_RUN([ #include #include int main() { FILE *fp; fp = fopen("conftest.wordbytes", "w"); if (fp == NULL) exit(1); fprintf(fp, "%d\n", sizeof(void *)); exit(0); }], [mercury_cv_bytes_per_word=`cat conftest.wordbytes`], [mercury_cv_bytes_per_word=0], [mercury_cv_bytes_per_word=0]) ) AC_MSG_RESULT($mercury_cv_bytes_per_word) AC_DEFINE_UNQUOTED(MR_BYTES_PER_WORD, $mercury_cv_bytes_per_word) BYTES_PER_WORD=$mercury_cv_bytes_per_word AC_SUBST(BYTES_PER_WORD) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(the number of words in a synchronization term) AC_CACHE_VAL(mercury_cv_sync_term_size, AC_TRY_RUN([ #include #include #include int main() { struct { pthread_mutex_t lock; int count; void *parent; } x; FILE *fp; fp = fopen("conftest.syncsize", "w"); if (fp == NULL) exit(1); fprintf(fp, "%d\n", (sizeof(void *) - 1 + sizeof(x))/ sizeof(void *)); exit(0); }], [mercury_cv_sync_term_size=`cat conftest.syncsize`], [mercury_cv_sync_term_size=0], [mercury_cv_sync_term_size=0]) ) AC_MSG_RESULT($mercury_cv_sync_term_size) AC_DEFINE_UNQUOTED(MR_SYNC_TERM_SIZE, $mercury_cv_sync_term_size) SYNC_TERM_SIZE=$mercury_cv_sync_term_size AC_SUBST(SYNC_TERM_SIZE) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(the number of bits per word) AC_CACHE_VAL(mercury_cv_bits_per_word, AC_TRY_RUN([ #include #include #include int main() { FILE *fp; fp = fopen("conftest.wordbits", "w"); if (fp == NULL) exit(1); fprintf(fp, "%d\n", CHAR_BIT * sizeof(void *)); exit(0); }], [mercury_cv_bits_per_word=`cat conftest.wordbits`], [mercury_cv_bits_per_word=0], [mercury_cv_bits_per_word=0]) ) AC_MSG_RESULT($mercury_cv_bits_per_word) AC_DEFINE_UNQUOTED(MR_BITS_PER_WORD, $mercury_cv_bits_per_word) BITS_PER_WORD=$mercury_cv_bits_per_word AC_SUBST(BITS_PER_WORD) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether we can use unboxed floats) AC_CACHE_VAL(mercury_cv_unboxed_floats, AC_TRY_RUN([ int main() { if (sizeof(double) == sizeof(void *)) exit(0); else exit(1); }], [mercury_cv_unboxed_floats=yes], [mercury_cv_unboxed_floats=no], [mercury_cv_unboxed_floats=no]) ) AC_MSG_RESULT($mercury_cv_unboxed_floats) if test "$mercury_cv_unboxed_floats" = yes; then if test "$BOOTSTRAP_MC" = ""; then AC_MSG_WARN( [Mercury compiler not yet installed - **** cannot use unboxed floats, bootstrapping using boxed floats **** after installation is complete you may want to reinstall **** from scratch so you can use unboxed floats, which are more **** efficient.]) mercury_cv_unboxed_floats=no fi fi if test "$mercury_cv_unboxed_floats" = yes; then HAVE_BOXED_FLOATS="--unboxed-float" else AC_DEFINE(MR_BOXED_FLOAT) HAVE_BOXED_FLOATS="--no-unboxed-float" fi AC_SUBST(HAVE_BOXED_FLOATS) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether float is 64-bit) AC_CACHE_VAL(mercury_cv_float_is_64_bit, AC_TRY_RUN([ #include int main() { if (sizeof(float) * CHAR_BIT == 64) exit(0); else exit(1); }], [mercury_cv_float_is_64_bit=yes], [mercury_cv_float_is_64_bit=no], [mercury_cv_float_is_64_bit=no]) ) AC_MSG_RESULT($mercury_cv_float_is_64_bit) if test "$mercury_cv_float_is_64_bit" = yes; then AC_DEFINE(MR_FLOAT_IS_64_BIT) fi AC_SUBST(MR_FLOAT_IS_64_BIT) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether double is 64-bit) AC_CACHE_VAL(mercury_cv_double_is_64_bit, AC_TRY_RUN([ #include int main() { if (sizeof(double) * CHAR_BIT == 64) exit(0); else exit(1); }], [mercury_cv_double_is_64_bit=yes], [mercury_cv_double_is_64_bit=no], [mercury_cv_double_is_64_bit=no]) ) AC_MSG_RESULT($mercury_cv_double_is_64_bit) if test "$mercury_cv_double_is_64_bit" = yes; then AC_DEFINE(MR_DOUBLE_IS_64_BIT) fi AC_SUBST(MR_DOUBLE_IS_64_BIT) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether long double is 64-bit) AC_CACHE_VAL(mercury_cv_long_double_is_64_bit, AC_TRY_RUN([ #include int main() { if (sizeof(long double) * CHAR_BIT == 64) exit(0); else exit(1); }], [mercury_cv_long_double_is_64_bit=yes], [mercury_cv_long_double_is_64_bit=no], [mercury_cv_long_double_is_64_bit=no]) ) AC_MSG_RESULT($mercury_cv_long_double_is_64_bit) if test "$mercury_cv_long_double_is_64_bit" = yes; then AC_DEFINE(MR_LONG_DOUBLE_IS_64_BIT) fi AC_SUBST(MR_LONG_DOUBLE_IS_64_BIT) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether architecture is big-endian) AC_CACHE_VAL(mercury_cv_is_bigender, AC_TRY_RUN([ int main() { int x = 1; unsigned char *x_p; x_p = (unsigned char*) &x; if (*x_p == 0) exit(0); else exit(1); }], [mercury_cv_is_bigender=yes], [mercury_cv_is_bigender=no], [mercury_cv_is_bigender=no]) ) AC_MSG_RESULT($mercury_cv_is_bigender) if test "$mercury_cv_is_bigender" = yes; then AC_DEFINE(MR_BIG_ENDIAN) fi AC_SUBST(MR_BIG_ENDIAN) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether architecture is little-endian) AC_CACHE_VAL(mercury_cv_is_littleender, AC_TRY_RUN([ int main() { int x = 1; unsigned char *x_p; x_p = (unsigned char*) &x; if (*x_p == 1) exit(0); else exit(1); }], [mercury_cv_is_littleender=yes], [mercury_cv_is_littleender=no], [mercury_cv_is_littleender=no]) ) AC_MSG_RESULT($mercury_cv_is_littleender) if test "$mercury_cv_is_littleender" = yes; then AC_DEFINE(MR_LITTLE_ENDIAN) fi AC_SUBST(MR_LITTLE_ENDIAN) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether we can use files as locks) AC_CACHE_VAL(mercury_cv_have_ocreat_oexcl, AC_TRY_COMPILE([ #ifdef MR_HAVE_SYS_TYPES_H #include #endif #ifdef MR_HAVE_SYS_STAT_H #include #endif #ifdef MR_HAVE_FCNTL_H #include #endif ], [ #if defined(O_CREAT) && defined(O_EXCL) #else /* ** As these macros are not defined the compilation must fail. ** Unmatched brackets should do that for us. */ } #endif ], [mercury_cv_have_ocreat_oexcl=yes], [mercury_cv_have_ocreat_oexcl=no]) ) AC_MSG_RESULT($mercury_cv_have_ocreat_oexcl) if test "$mercury_cv_have_ocreat_oexcl" = yes; then AC_DEFINE(MR_HAVE_OCREAT_OEXCL) fi #-----------------------------------------------------------------------------# AC_MSG_CHECKING(return values of system) AC_CACHE_VAL(mercury_cv_normal_system_retval, AC_TRY_RUN([ #include #ifdef MR_HAVE_SYS_WAIT_H #include #endif int main() { #if defined (WIFEXITED) && defined (WEXITSTATUS) && \ defined (WIFSIGNALED) && defined (WTERMSIG) /* ** All the necessary macros for handling the return values of ** system() are defined, so we do not need to test the return ** value of system() */ exit(0); #else /* ** Normal return values from system() are considered to be ** when high 8 bits of the return value give the exit ** status, and the low 8 bits give the signal number which ** killed the process. */ if( system("exit 0") == 0 && system("exit 42") == 42 << 8 ) { /* && system("kill -9 $$") == 9 */ exit(0); } else { exit(1); } #endif }], [mercury_cv_normal_system_retval=yes], [mercury_cv_normal_system_retval=no], AC_TRY_COMPILE([#include ], [ #if defined (WIFEXITED) && defined (WEXITSTATUS) && \ defined (WIFSIGNALED) && defined (WTERMSIG) #else /* ** As these macros are not defined the compilation must fail. ** Unmatched brackets should do that for us. */ } #endif ], [mercury_cv_normal_system_retval=yes], [mercury_cv_normal_system_retval=no])) ) AC_MSG_RESULT($mercury_cv_normal_system_retval) if test "$mercury_cv_normal_system_retval" = no; then # Warn since VC++6 compiler fails this test AC_MSG_WARN(Unable to interpret return values from system) fi #-----------------------------------------------------------------------------# AC_MSG_CHECKING(to see if we can handle contexts blocking on IO) AC_CACHE_VAL(mercury_cv_can_do_pending_io, AC_TRY_RUN([ #include #include int main() { fd_set f; struct timeval zero; int err; FD_ZERO(&f); zero.tv_sec = 0; zero.tv_usec = 0; err = select(1, &f, &f, &f, &zero); exit(err != 0); }], [mercury_cv_can_do_pending_io=yes], [mercury_cv_can_do_pending_io=no], [mercury_cv_can_do_pending_io=no]) ) AC_MSG_RESULT($mercury_cv_can_do_pending_io) if test "$mercury_cv_can_do_pending_io" = yes; then AC_DEFINE(MR_CAN_DO_PENDING_IO) fi AC_SUBST(MR_CAN_DO_PENDING_IO) #-----------------------------------------------------------------------------# # There is a problem on some BSD based systems that FD_ZERO is defined # defined in terms of bzero() but the appropriate header file for bzero() # is not automatically included. The following deals with this situation # on MacOS 10.3. (It appears to be fixed in MacOS 10.4.) AC_MSG_CHECKING(to see if strings.h is needed for bzero) AC_CACHE_VAL(mercury_cv_bzero_needs_strings_header, [ save_CC="$CC" case $CC in *gcc*) CC="$CC -Wall -Werror" ;; esac cat > conftest.c << EOF #ifdef MR_BZERO_NEEDS_STRINGS_HEADER #include #endif #include #include #include void MR_fd_zero(fd_set *fdset); void MR_fd_zero(fd_set *fdset) { FD_ZERO(fdset); } EOF if $CC -c conftest.c < /dev/null >&AC_FD_CC 2>&1 then mercury_cv_bzero_needs_strings_header=no else if $CC -DMR_BZERO_NEEDS_STRINGS_HEADER -c conftest.c \ < /dev/null >&AC_FD_CC 2>&1 then mercury_cv_bzero_needs_strings_header=yes else mercury_cv_bzero_needs_strings_header=no fi fi rm -f conftest* CC="$save_CC" ]) AC_MSG_RESULT($mercury_cv_bzero_needs_strings_header) if test "$mercury_cv_bzero_needs_strings_header" = yes; then AC_DEFINE(MR_BZERO_NEEDS_STRINGS_HEADER) fi AC_SUBST(MR_BZERO_NEEDS_STRINGS_HEADER) #-----------------------------------------------------------------------------# # # On sparc, x86, and probably on other architectures, # if we're using non-local gotos, then for egcs 1.1, we need # `-fno-gcse -fno-function-cse', and for gcc 2.8 we need `-fno-function-cse'. # Otherwise gcc generates code which initializes registers in the function # prologue and expects them to be valid later on, which doesn't work with # non-local gotos, since we jump directly into the middle of a function. # (Actually I don't know if `-fno-functions-cse' is really needed. # Maybe you can get away without it. But better to err on the safe side...) # # For alpha, mips, and ARM, and probably on other architectures, when using # non-local gotos we need -fomit-frame-pointer, otherwise when compiling # with --no-c-optimize we run into a problem similar to the one above: # Gcc generates code which initializes the frame pointer in the # function prologue, and then expects it to be valid later on, which # doesn't work with non-local gotos, since we jump directly into the # middle of a function. # # For Irix 5, gcc labels don't work with shared libraries, # so if we're using gcc labels, we need to use non-shared libraries, # which means passing -non_shared and -mno-abicalls and also setting # LIBRARY_PATH. # # For x86, gcc global registers only work with -fno-builtin # and -fno-omit-frame-pointer. # # NB. Any changes here may also require changes to scripts/mgnuc.in. # CFLAGS_FOR_REGS= CFLAGS_FOR_GOTOS= LIBRARY_PATH_FOR_GOTOS= case $ac_cv_prog_gcc in yes) case "`$CC --version < /dev/null`" in 2.8*) CFLAGS_FOR_GOTOS="-fno-defer-pop -fno-function-cse" ;; *) CFLAGS_FOR_GOTOS="-fno-defer-pop -fno-function-cse -fno-gcse" ;; esac case "$host" in mips-sgi-irix5.*) # Non-local gotos don't work with shared libraries on Irix 5, # which causes lots of complications. # Now that we have the hlc back-end, it's not worth # supporting them. MERCURY_MSG("Mercury no longer supports gcc non-local on Irix 5") mercury_cv_asm_labels=no mercury_cv_gcc_labels=no CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -non_shared -mno-abicalls" LIBRARY_PATH_FOR_GOTOS="$NONSHARED_LIB_DIR:/usr/lib/nonshared" ;; esac case "$host" in mips-*) CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer" ;; i*86-*) CFLAGS_FOR_REGS="-fno-builtin -fno-omit-frame-pointer" ;; # We need a special-case hack here, because the auto-config # gets it wrong on the Alpha: the little example program # works fine in fast.gc mode, but big programs don't, # due to problems with the `gp' register. Ideally we # ought to write a big enough example program to trigger # the problem, but that would be too much work. alpha*-dec-*) MERCURY_MSG( "asm labels work on the Alpha but plain gcc labels do not") mercury_cv_asm_labels=yes mercury_cv_gcc_labels=no CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer" ;; # Similarly for rs6000 rs6000-*) MERCURY_MSG("gcc labels do not work on the RS/6000") mercury_cv_asm_labels=no mercury_cv_gcc_labels=no ;; arm*-*) CFLAGS_FOR_GOTOS="$CFLAGS_FOR_GOTOS -fomit-frame-pointer" ;; # On hppa64, ia64 and powerpc64 the test programs appear to work, but # larger programs die with an Illegal Instruction fault. hppa64-*) MERCURY_MSG("gcc labels do not work on HPPA64") mercury_cv_asm_labels=no mercury_cv_gcc_labels=no ;; ia64-*) MERCURY_MSG("gcc labels do not work on IA64") mercury_cv_asm_labels=no mercury_cv_gcc_labels=no ;; powerpc64-*) MERCURY_MSG("gcc labels do not work on PPC64") mercury_cv_asm_labels=no mercury_cv_gcc_labels=no ;; # On s390 the configure test goes into an infinite loop, so we need # to avoid running it. # # s390 systems can report themselves as s390-ibm-linux-gnu # or s390x-ibm-linux-gnu (and possibly others). s390*) MERCURY_MSG("gcc labels do not work on S/390") mercury_cv_asm_labels=no mercury_cv_gcc_labels=no ;; sparc*) case "`$CC --version < /dev/null`" in 2.8*) AC_MSG_WARN( [Mercury might not work with gcc 2.8 on sparc! **** We advise using gcc 2.95.x.]) ;; esac ;; esac ;; esac AC_SUBST(CFLAGS_FOR_REGS) AC_SUBST(CFLAGS_FOR_GOTOS) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether we can use gcc labels) # Set env vars for compiling with gcc non-local gotos save_CC="$CC" save_LIBRARY_PATH="$LIBRARY_PATH" CC="$CC $CFLAGS_FOR_GOTOS" if test "$LIBRARY_PATH_FOR_GOTOS" != ""; then LIBRARY_PATH="$LIBRARY_PATH_FOR_GOTOS:$LIBRARY_PATH" export LIBRARY_PATH fi AC_CACHE_VAL(mercury_cv_gcc_labels, AC_TRY_RUN([ void *entry_foo_1; void *entry_bar_1; void *succip; int global; void *dummy_identity_function(void *); foo() { entry_foo_1 = && foo_1; goto *dummy_identity_function(&&return_label); return_label: return; foo_1: if (global != 42) exit(1); goto *entry_bar_1; } bar() { entry_bar_1 = && bar_1; goto *dummy_identity_function(&&return_label); return_label: return; bar_1: if (global != 42) exit(1); goto *succip; } main() { global = 42; foo(); bar(); succip = &&last; goto *dummy_identity_function(&&return_label); return_label: goto *entry_foo_1; exit(1); last: if (global != 42) exit(1); exit(0); } void *dummy_identity_function(void *p) { return p; } ], [mercury_cv_gcc_labels=yes], [mercury_cv_gcc_labels=no], [mercury_cv_gcc_labels=no]) ) AC_MSG_RESULT($mercury_cv_gcc_labels) if test "$mercury_cv_gcc_labels" = yes; then AC_DEFINE(MR_HAVE_GCC_LABELS) fi if test $mercury_cv_gcc_labels = yes; then AC_MSG_CHECKING(whether we can use asm labels) AC_CACHE_VAL(mercury_cv_asm_labels, AC_TRY_RUN([ void *volatile volatile_global_pointer; extern void mercury__label1 (void) __asm__("entry_" "mercury__label1" ); main() { void *addr; volatile_global_pointer = &&mercury__label1; addr = &mercury__label1; goto *addr; exit(1); mercury__label1: __asm__(".globl entry_" "mercury__label1" "\n" "entry_" "mercury__label1" ":\n" "/* this is a comment */"); exit(0); }], [mercury_cv_asm_labels=yes], [mercury_cv_asm_labels=no], [mercury_cv_asm_labels=no]) ) AC_MSG_RESULT($mercury_cv_asm_labels) else mercury_cv_asm_labels=${mercury_cv_asm_labels-no} fi HAVE_ASM_LABELS=$mercury_cv_asm_labels AC_SUBST(HAVE_ASM_LABELS) if test $HAVE_ASM_LABELS = 1; then AC_DEFINE(MR_HAVE_ASM_LABELS) fi # Restore env vars modified above CC="$save_CC" LIBRARY_PATH="$save_LIBRARY_PATH" #-----------------------------------------------------------------------------# # We need to ensure that runtime/mercury_conf.h exists, since some of the # programs we attempt to compile below indirectly include it. test -f runtime/mercury_conf.h || { cat > runtime/mercury_conf.h <>) MercuryEngine MR_engine_base; changequote([,]) main() { MR_mr0 = 20; MR_mr7 = 22; if (MR_mr0 + MR_mr7 != 42) exit(1); exit(0); }], [mercury_cv_gcc_model_fast=yes], [mercury_cv_gcc_model_fast=no], [mercury_cv_gcc_model_fast=no]) ) AC_MSG_RESULT($mercury_cv_gcc_model_fast) # Restore env vars modified above CC="$save_CC" LIBRARY_PATH="$save_LIBRARY_PATH" else mercury_cv_gcc_model_fast=no fi #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether we can use global registers without gcc labels) # Set env vars for compiling with gcc registers save_CC="$CC" CC="$CC $CFLAGS_FOR_REGS" AC_CACHE_VAL(mercury_cv_gcc_model_reg, AC_TRY_RUN([ #define MR_USE_GCC_GLOBAL_REGISTERS #include "mercury_engine.h" changequote(<<,>>) MercuryEngine MR_engine_base; changequote([,]) main() { MR_mr0 = 20; MR_mr7 = 22; if (MR_mr0 + MR_mr7 != 42) exit(1); exit(0); }], [mercury_cv_gcc_model_reg=yes], [mercury_cv_gcc_model_reg=no], [mercury_cv_gcc_model_reg=no]) ) AC_MSG_RESULT($mercury_cv_gcc_model_reg) # Restore env vars modified above CC="$save_CC" #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether we can support profiling on this system) AC_CACHE_VAL(mercury_cv_profiling, AC_TRY_CPP([ /* The following code comes from runtime/prof.c */ #include #include #include #include #ifdef MR_HAVE_SYS_PARAM_H #include #endif #ifdef MR_HAVE_SYS_TIME_H #include #endif /* ** if HZ is not defined, we may be able to use sysconf(_SC_CLK_TCK) instead */ #if !defined(HZ) && defined(MR_HAVE_SYSCONF) && defined(_SC_CLK_TCK) #define HZ ((int)sysconf(_SC_CLK_TCK)) #endif #if !defined(HZ) || !defined(SIGPROF) || !defined(MR_HAVE_SETITIMER) #error "Time profiling not supported on this system" #endif ], [mercury_cv_profiling=yes], [mercury_cv_profiling=no])) AC_MSG_RESULT($mercury_cv_profiling) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(if C compiler is egcs) case "`$CC --version < /dev/null 2>&1`" in egcs-*) mercury_cv_egcs=yes ;; *) mercury_cv_egcs=no ;; esac AC_MSG_RESULT($mercury_cv_egcs) #-----------------------------------------------------------------------------# # # Add an option that disables the deep profiler. # AC_ARG_ENABLE(deep-profiler, [ --enable-deep-profiler= install deep profiler CGI script in ], enable_deep_profiler="$enableval",enable_deep_profiler=default) AC_MSG_CHECKING(whether to enable the deep profiler) # We test for all the features needed by the deep profiler. if test "$MR_HAVE_SYS_TYPES_H" = 1 && \ test "$MR_HAVE_SYS_STAT_H" = 1 && \ test "$MR_HAVE_FCNTL_H" = 1 && \ test "$MR_HAVE_UNISTD_H" = 1 && \ test "$MR_HAVE_DIRENT_H" = 1 && \ test "$ac_cv_func_getpid" = yes && \ test "$ac_cv_func_fork" = yes && \ test "$ac_cv_func_opendir" = yes && \ test "$ac_cv_func_readdir" = yes && \ test "$ac_cv_func_closedir" = yes && \ test "$mercury_cv_have_ocreat_oexcl" = yes then mercury_cv_can_enable_deep_profiler=yes AC_DEFINE(MR_DEEP_PROFILER_ENABLED) else mercury_cv_can_enable_deep_profiler=no fi # on x86, gcc version egcs-1.1.2 has a bug which causes it to get # an internal compiler error when compiling library/random.c # (when that file was build with mmc --intermodule-optimization -O4) # So if we're using an egcs version of gcc, disable deep profiling. case "$host" in i*86-*-*) case "$mercury_cv_egcs" in yes) mercury_cv_can_enable_deep_profiler=no ;; esac ;; esac case "$host" in powerpc*apple*darwin*) mercury_cv_default_cgi_dir=/Library/WebServer/CGI-Executables ;; *) mercury_cv_default_cgi_dir=/usr/lib/cgi-bin ;; esac case $enable_deep_profiler in default) if test -d $mercury_cv_default_cgi_dir; then mercury_cv_enable_deep_profiler=$mercury_cv_can_enable_deep_profiler mercury_cv_cgi_dir=$mercury_cv_default_cgi_dir else mercury_cv_enable_deep_profiler=no fi ;; no) mercury_cv_enable_deep_profiler=no ;; *) if test $enable_deep_profiler = yes; then mercury_cv_cgi_dir=$mercury_cv_default_cgi_dir else mercury_cv_cgi_dir=$enable_deep_profiler fi if test $mercury_cv_can_enable_deep_profiler = no; then AC_MSG_RESULT($enable_deep_profiler) AC_MSG_ERROR( [--enable-deep-profiler specified but system does not support it]) fi mercury_cv_enable_deep_profiler=yes ;; esac if test $mercury_cv_enable_deep_profiler = yes; then if test -d $mercury_cv_cgi_dir; then true else AC_MSG_RESULT($enable_deep_profiler) AC_MSG_ERROR(CGI script directory $mercury_cv_cgi_dir does not exist) fi fi AC_MSG_RESULT($mercury_cv_enable_deep_profiler) ENABLE_DEEP_PROFILER=$mercury_cv_enable_deep_profiler AC_SUBST(ENABLE_DEEP_PROFILER) CGIDIR=$mercury_cv_cgi_dir AC_SUBST(CGIDIR) #-----------------------------------------------------------------------------# # Figure out which flavour of pthreads to use, since none of the # implementations seem to be exactly the same case $host in alpha*-dec-osf*) mercury_cv_use_digital_unix_threads=yes ;; *) mercury_cv_use_digital_unix_threads=no ;; esac if test $mercury_cv_use_digital_unix_threads = yes; then AC_DEFINE(MR_DIGITAL_UNIX_PTHREADS) fi # Figure out what options we need to pass to the C compiler # for multithreading. We may need to pass different # options to tell (a) the Mercury runtime & library # (b) the boehm collector and (c) the C library # that they need to be thread-safe. # # For Linux, Irix, Solaris, and HPUX, # the thread-enabled version of the Boehm # collector contains a reference to dlopen(), so # if threads are enabled, we need to link with the # appropriate extra library for that (-ldl on Linux # and Solaris, -lrt on HPUX, and nothing on Irix). # XXX That should only be done if conservative GC # is enabled. # # Note that changes here may require changes in scripts/ml.in. LDFLAGS_FOR_THREADS= LD_LIBFLAGS_FOR_THREADS= ENABLE_BOEHM_THREAD_LOCAL_ALLOC= case "$host" in *solaris*) CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DSOLARIS_THREADS \ -D_SOLARIS_PTHREADS -DGC_SOLARIS_PTHREADS -D_REENTRANT" THREAD_LIBS="-lpthread -ldl" ;; *linux*) # Note that for old versions of Linux / glibc, # you may also need to make sure that you don't # pass -ansi to gcc. CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DLINUX_THREADS \ -D_THREAD_SAFE -D_REENTRANT -DGC_REDIRECT_TO_LOCAL" THREAD_LIBS="-lpthread -ldl" ENABLE_BOEHM_THREAD_LOCAL_ALLOC="-DTHREAD_LOCAL_ALLOC" ;; *cygwin*) THREAD_LIBS="" case "$CC" in *cl* | *CL*) # cl is the Microsoft C compiler CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DWIN32_THREADS /MD" LDFLAGS_FOR_THREADS="/MD" LD_LIBFLAGS_FOR_THREADS="/MD" ;; *) CFLAGS_FOR_THREADS="-DGC_WIN32_THREADS -DMR_THREAD_SAFE" ;; esac ;; *mingw*) THREAD_LIBS="" case "$CC" in *cl* | *CL*) # cl is the Microsoft C compiler CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DWIN32_THREADS /MD" LDFLAGS_FOR_THREADS="/MD" LD_LIBFLAGS_FOR_THREADS="/MD" ;; *) CFLAGS_FOR_THREADS="-DGC_WIN32_THREADS -DMR_THREAD_SAFE" ;; esac ;; # Theoretically we should change this check to *apple*darwin*) # as darwin should be the same whether or not we are on a powerpc or # an i386, but since we don't have access to an i386 with darwin # installed to test this, we currently restrict ourselves to the # powerpc architecture. *powerpc*apple*darwin*) CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DGC_DARWIN_THREADS" THREAD_LIBS="" ;; ### # The threads stuff on Digital Unix (OSF) is not yet enabled because ### # the Boehm garbage collector doesn't support threads on that platform ### # XXX probably we should enable it but report an error if you try to ### # use an *.par.gc* grade ### # XXX is this fixed in the Boehm collector now? ### *-osf*) ### CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE" ### THREAD_LIBS="-lpthreads -lmach -lc_r" ### ;; ### # The threads stuff on HPUX is not yet enabled because ### # we don't have an HPUX box to test it on. ### *hpux*) ### CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE" # XXX incomplete ### THREAD_LIBS="-lpthread -lrt" ;; ### # The threads stuff on IRIX is not yet enabled because ### # we don't have an IRIX box to test it on. ### # (XXX perhaps we should enable it anyway, so it is easier to test?) ### *irix*) ### CFLAGS_FOR_THREADS="-DMR_THREAD_SAFE -DIRIX_THREADS" ### THREAD_LIBS="-lpthread" ### ;; *) # Multithreading not (yet) supported on other architectures. # For multithreading, we need (1) Posix threads and # (2) a port of the Boehm gc for that architecture # that works with threads. CFLAGS_FOR_THREADS="" ;; esac AC_SUBST(CFLAGS_FOR_THREADS) AC_SUBST(THREAD_LIBS) AC_SUBST(LDFLAGS_FOR_THREADS) AC_SUBST(LD_LIBFLAGS_FOR_THREADS) AC_SUBST(ENABLE_BOEHM_THREAD_LOCAL_ALLOC) #-----------------------------------------------------------------------------# # # Figure out which is the best grade to use for various different purposes. # In particular, choose the default grade for compiling applications. # # BEST_LLDS_BASE_GRADE is the most efficient of the LLDS->C base grades. if test $mercury_cv_asm_labels = yes; then if test $mercury_cv_gcc_model_fast = yes; then BEST_LLDS_BASE_GRADE=asm_fast else BEST_LLDS_BASE_GRADE=asm_jump fi elif test $mercury_cv_gcc_labels = yes; then if test $mercury_cv_gcc_model_fast = yes; then BEST_LLDS_BASE_GRADE=fast else BEST_LLDS_BASE_GRADE=jump fi else if test $mercury_cv_gcc_model_reg = yes; then BEST_LLDS_BASE_GRADE=reg else BEST_LLDS_BASE_GRADE=none fi fi # BEST_DEBUG_BASE_GRADE is the most efficient base grade that supports # debugging (`--trace deep'). BEST_DEBUG_BASE_GRADE=$BEST_LLDS_BASE_GRADE # DEFAULT_BASE_GRADE is the best overall base grade; it should be reasonably # efficient, and it should support debugging unless that would compromise # efficiency too much. case $BEST_LLDS_BASE_GRADE in none|fast|jump) DEFAULT_BASE_GRADE=hlc ;; asm_fast|asm_jump|reg) DEFAULT_BASE_GRADE=$BEST_LLDS_BASE_GRADE ;; *) AC_MSG_ERROR(invalid BEST_LLDS_BASE_GRADE $BEST_LLDS_BASE_GRADE) ;; esac # DEFAULT_GRADE is the default grade used to compile applications. # This is the same as DEFAULT_BASE_GRADE except that we also want to # enable conservative garbage collection by default. # We also allow users to override the default grade by setting # "DEFAULT_GRADE" in the environment before invoking configure. AC_ARG_WITH(default-grade, AC_HELP_STRING([--with-default-grade=GRADE], [Have the built compiler default to using GRADE]), [case "$withval" in # Handle `--with-default-grade' (no `=GRADE') and # `--without-default-grade' flags. yes|no) AC_MSG_ERROR([Must supply a valid grade if using --with-default-grade.]) ;; *) # Perhaps do better checking on the supplied value here. DEFAULT_GRADE="$withval" export DEFAULT_GRADE ;; esac], []) if test "$DEFAULT_GRADE" = ""; then DEFAULT_GRADE=$DEFAULT_BASE_GRADE.gc fi MERCURY_MSG("using grade \`$DEFAULT_GRADE' as the default grade for applications") AC_SUBST(DEFAULT_GRADE) #-----------------------------------------------------------------------------# # # Choose which grade to use for the compiler. # # BEST_GRADE_FOR_COMPILER is the best grade for compiling # the Mercury compiler, if there is already an installed Mercury compiler. case $BEST_LLDS_BASE_GRADE in asm_fast) BEST_GRADE_FOR_COMPILER=asm_fast.gc ;; *) BEST_GRADE_FOR_COMPILER=hlc.gc ;; esac # BOOTSTRAP_GRADE is the most efficient grade which we can use to bootstrap # the compiler from the source distribution, if there is no installed Mercury # compiler. This grade needs to be one for which the C files are # compatible with the C files that we ship in the source distribution, # which are generated with grade asm_fast.gc. # In order to be compatible with grade asm_fast.gc, it needs to be an LLDS # grade. We generate the same C code for the base LLDS grades, except that a # couple of them (fast and jump) don't support code addresses in static # initializers. case $BEST_LLDS_BASE_GRADE in jump|fast) if test $mercury_cv_gcc_model_reg = yes; then BOOTSTRAP_GRADE=reg.gc else BOOTSTRAP_GRADE=none.gc fi ;; *) BOOTSTRAP_GRADE=$BEST_LLDS_BASE_GRADE.gc ;; esac # Choose whether to use $BOOTSTRAP_GRADE or $BEST_GRADE_FOR_COMPILER, # and if necessary remove the previously built C files. if test "$BEST_GRADE_FOR_COMPILER" != "$BOOTSTRAP_GRADE"; then if test "$BOOTSTRAP_MC" = ""; then GRADE="$BOOTSTRAP_GRADE" AC_MSG_WARN( [Mercury compiler not yet installed **** cannot use grade \`$BEST_GRADE_FOR_COMPILER' **** using grade \`$GRADE' to compile the compiler **** after installation is complete you should reinstall **** from scratch so you can use the more efficient **** grade \`$BEST_GRADE_FOR_COMPILER'.]) else GRADE=$BEST_GRADE_FOR_COMPILER MERCURY_MSG( "using grade \`$GRADE' to compile the compiler compiler and library will be rebuilt with new grade installation may take a long time") find library compiler browser mdbcomp analysis \ profiler deep_profiler \ -name \*.c -o -name \*.c_date | \ xargs rm > /dev/null 2>&1 fi else GRADE=$BEST_GRADE_FOR_COMPILER MERCURY_MSG("using grade \`$GRADE' to compile the compiler") fi AC_SUBST(GRADE) #-----------------------------------------------------------------------------# # # Define options for selecting which grades of the library to install # AC_ARG_ENABLE(inefficient-grades, [ --enable-inefficient-grades install inefficient versions of the library], enable_inefficient_grades="$enableval",enable_inefficient_grades=no) AC_ARG_ENABLE(most-grades, [ --disable-most-grades install only the essential versions of the library], enable_most_grades="$enableval",enable_most_grades=yes) AC_ARG_ENABLE(nogc-grades, [ --enable-nogc-grades install no-gc versions of the library], enable_nogc_grades="$enableval",enable_nogc_grades=no) AC_ARG_ENABLE(agc-grades, [ --enable-agc-grades install accurate GC versions of the library], enable_agc_grades="$enableval",enable_agc_grades=no) AC_ARG_ENABLE(debug-grades, [ --disable-debug-grades do not install the debugging versions of the library], enable_debug_grades="enableval",enable_debug_grades=yes) AC_ARG_ENABLE(decl-debug-grades, [ --disable-decl-debug-grades do not install the declarative debugging versions of the library], enable_decl_debug_grades="enableval",enable_decl_debug_grades=yes) AC_ARG_ENABLE(prof-grades, [ --disable-prof-grades do not install profiling versions of the library], enable_prof_grades="$enableval",enable_prof_grades=yes) AC_ARG_ENABLE(trail-grades, [ --disable-trail-grades do not install trailing versions of the library], enable_trail_grades="$enableval",enable_trail_grades=yes) AC_ARG_ENABLE(par-grades, [ --disable-par-grades do not install thread-safe versions of the library], enable_par_grades="$enableval",enable_par_grades=yes) AC_ARG_ENABLE(mm-grades, [ --enable-mm-grades install minimal model versions of the library], enable_mm_grades="$enableval",enable_mm_grades=no) AC_ARG_ENABLE(dmm-grades, [ --enable-dmm-grades install minimal model debug versions of the library], enable_dmm_grades="$enableval",enable_dmm_grades=no) AC_ARG_ENABLE(hlc-prof-grades, [ --enable-hlc-prof-grades install profiling versions of the high level C grade], enable_hlc_prof_grades="$enableval",enable_hlc_prof_grades=no) # We don't enable the .NET grades by default because that may lead to # installation process breaking on Linux systems that have DotGNU or Mono # installed. # AC_ARG_ENABLE(dotnet-grades, [ --enable-dotnet-grades install the .NET grades], enable_dotnet_grades="$enableval",enable_dotnet_grades=no) # XXX The java backend is currently broken, so we don't # enable the java grade by default. AC_ARG_ENABLE(java-grade, [ --enable-java-grade install the Java grade], enable_java_grade="$enableval",enable_java_grade=no) AC_ARG_ENABLE(libgrades, [ --enable-libgrades=... install exactly the given versions of the library. The versions are specified using a comma-separated list.], enable_libgrades_given=yes;enable_libgrades="$enableval",enable_libgrades_given=no) if test "$enable_most_grades" = no; then enable_inefficient_grades=no enable_nogc_grades=no enable_agc_grades=no enable_prof_grades=no enable_trail_grades=no enable_mm_grades=no enable_dmm_grades=no enable_hlc_prof_grades=no enable_par_grades=no enable_dotnet_grades=no enable_java_grade=no fi #-----------------------------------------------------------------------------# # # Choose which grades of the library to install # # Compute all the LLDS base grades. ALL_LLDS_BASE_GRADES="none" if test $mercury_cv_gcc_model_reg = yes; then ALL_LLDS_BASE_GRADES="$ALL_LLDS_BASE_GRADES reg" fi if test $mercury_cv_gcc_labels = yes; then ALL_LLDS_BASE_GRADES="$ALL_LLDS_BASE_GRADES jump" if test $mercury_cv_gcc_model_fast = yes; then ALL_LLDS_BASE_GRADES="$ALL_LLDS_BASE_GRADES fast" fi fi if test $mercury_cv_asm_labels = yes; then if test $mercury_cv_gcc_labels = yes; then ALL_LLDS_BASE_GRADES="$ALL_LLDS_BASE_GRADES asm_jump" fi if test $mercury_cv_gcc_model_fast = yes; then ALL_LLDS_BASE_GRADES="$ALL_LLDS_BASE_GRADES asm_fast" fi fi # Start with the selected LLDS base grades: # normally just the best LLDS base grade, # unless --enable-inefficient-grades was selected, # in which case we use all the LLDS grades. if test "$enable_inefficient_grades" = yes; then BASE_LIBGRADES="$ALL_LLDS_BASE_GRADES" else BASE_LIBGRADES="$BEST_LLDS_BASE_GRADE" fi # Find all the corresponding `.gc' (--conservative-gc) grades. # Use both `.gc' and non-`.gc' versions, unless --disable-nogc-grades was set, # in which case use only the `.gc' versions. GC_LIBGRADES="" for grade in $BASE_LIBGRADES; do GC_LIBGRADES="$GC_LIBGRADES $grade.gc" done if test "$enable_nogc_grades" = yes; then LIBGRADES="$BASE_LIBGRADES $GC_LIBGRADES" else LIBGRADES="$GC_LIBGRADES" fi # Add `hlc' (--high-level-code, i.e. MLDS back-end) grades LIBGRADES="$LIBGRADES hlc.gc" if test "$enable_inefficient_grades" = yes -a "$GCC" = yes ; then LIBGRADES="$LIBGRADES hlc_nest.gc" fi # Add `.agc' (--gc accurate) grades # Currently only hlc.agc is supported. if test "$enable_agc_grades" = yes; then LIBGRADES="$LIBGRADES hlc.agc" fi # Add grades for profiling. if test "$enable_prof_grades" = yes; then # Add `.prof' (--profiling) grades, if time profiling is supported. # We want to allow profiling of any installed grade which is likely # to be the most efficient grade for some application. # This means we want to support time profiling for # - both GC and non-GC grades # since non-GC grades might be best for some applications. # - both LLDS and hlc grades # It's also convenient if we support a time profiling variant of # the default grade, if this is not the same as the most efficient # grade. if test $mercury_cv_profiling = yes; then # Start with profiling versions of the default grade LIBGRADES="$LIBGRADES $DEFAULT_BASE_GRADE.gc.prof" if test "$enable_nogc_grades" = yes; then LIBGRADES="$LIBGRADES $DEFAULT_BASE_GRADE.prof" fi # Add profiling versions of the best LLDS grade, # if this is different than the default grade if test $BEST_LLDS_BASE_GRADE != $DEFAULT_BASE_GRADE; then LIBGRADES="$LIBGRADES $BEST_LLDS_BASE_GRADE.gc.prof" if test "$enable_nogc_grades" = yes; then LIBGRADES="$LIBGRADES $BEST_LLDS_BASE_GRADE.prof" fi fi # Add profiling versions of the hlc grade, # if this is different than the ones added above. if test $enable_hlc_prof_grades = "yes" && test hlc != $DEFAULT_BASE_GRADE && test hlc != $BEST_LLDS_BASE_GRADE then LIBGRADES="$LIBGRADES hlc.gc.prof" if test "$enable_nogc_grades" = yes; then LIBGRADES="$LIBGRADES hlc.prof" fi fi fi # Add a `.memprof' (--memory-profiling) grade. # Hopefully memory allocation should be pretty much # independent of the grade, so we don't need to support # both GC and non-GC versions, or both LLDS and MLDS versions. LIBGRADES="$LIBGRADES $DEFAULT_BASE_GRADE.gc.memprof" # Add a `.profdeep' (--deep-profiling) grade, # if deep profiling is enabled. if test $mercury_cv_enable_deep_profiler = yes; then LIBGRADES="$LIBGRADES $BEST_LLDS_BASE_GRADE.gc.profdeep" fi fi if test "$enable_trail_grades" = yes; then # add `.tr' (--trailing) grades LIBGRADES="$LIBGRADES $DEFAULT_BASE_GRADE.gc.tr" if test "$enable_inefficient_grades" = yes; then if test "$enable_nogc_grades" = yes; then LIBGRADES="$LIBGRADES $DEFAULT_BASE_GRADE.tr" else LIBGRADES="$LIBGRADES" fi if test $mercury_cv_profiling = yes && test "$enable_prof_grades" = yes then LIBGRADES="$LIBGRADES $DEFAULT_BASE_GRADE.gc.prof.tr" fi fi fi # add `.mm' (--minimal-model) grades if test "$enable_mm_grades" = yes; then LIBGRADES="$LIBGRADES $BEST_LLDS_BASE_GRADE.gc.mmsc \ $BEST_LLDS_BASE_GRADE.gc.mmsc.debug" if test "$enable_dmm_grades" = yes; then LIBGRADES="$LIBGRADES $BEST_LLDS_BASE_GRADE.gc.dmmsc \ $BEST_LLDS_BASE_GRADE.gc.dmmsc.debug" fi fi # add `.debug' (--debug) and `.decldebug' (--decl-debug) grades if test "$enable_debug_grades" = yes; then LIBGRADES="$LIBGRADES $BEST_DEBUG_BASE_GRADE.gc.tr.debug" if test "$enable_decl_debug_grades" = yes; then LIBGRADES="$LIBGRADES $BEST_DEBUG_BASE_GRADE.gc.decldebug" fi fi # Add the .par (thread-safe) grade, if it is supported for this system if test "$enable_par_grades" = yes -a "$CFLAGS_FOR_THREADS" != ""; then LIBGRADES="$LIBGRADES hlc.par.gc" fi # add .NET back-end grades if test $mercury_cv_microsoft_dotnet = yes -a "$enable_dotnet_grades" = yes then LIBGRADES="$LIBGRADES il" fi # add Java back-end grade, if Java is installed if test $mercury_cv_java = yes -a "$enable_java_grade" = yes then LIBGRADES="$LIBGRADES java" fi # Allow the user to override the default list of library grades if test "$enable_libgrades_given" = no -a -f .enable_lib_grades ; then MERCURY_MSG("using .enable_libgrades as the source for the set of grades to install") enable_libgrades=`cat .enable_lib_grades` enable_libgrades_given=yes fi if test "$enable_libgrades_given" = yes; then if test "$enable_libgrades" = no; then AC_MSG_ERROR( [--enable-libgrades requires a comma-separated list of grades as argument]) elif test "$enable_libgrades" = yes; then AC_MSG_ERROR( [--enable-libgrades requires a comma-separated list of grades as argument]) else # Generate only the grades specified by the user. raw_grades=`echo $enable_libgrades | sed 's/,/ /g'` canonical_grades="" grade_error=false for raw_grade in $raw_grades do if ! test -x scripts/canonical_grade then canonical_grades="$canonical_grades $raw_grade" elif scripts/canonical_grade --grade $raw_grade > .confgrade then canonical_grades="$canonical_grades `cat .confgrade`" else MERCURY_MSG("--enable-libgrades: $raw_grade is not a grade") grade_error=true fi done rm -f .confgrade > /dev/null 2>&1 if $grade_error then AC_MSG_ERROR( [invalid grade(s) specified for --enable-libgrades]) fi LIBGRADES=$canonical_grades fi fi # The echo deletes the initial space character. LIBGRADES=`echo $LIBGRADES` MERCURY_MSG("using \`$LIBGRADES' as the set of library grades to install") LIBGRADE_OPTS= for libgrade in $LIBGRADES do LIBGRADE_OPTS="$LIBGRADE_OPTS --libgrade $libgrade" done AC_SUBST(LIBGRADES) AC_SUBST(LIBGRADE_OPTS) #-----------------------------------------------------------------------------# # Determine how many of the r registers (r1, r2, ...) are real registers. # Determine how many temporaries may be allocated real registers. # Find out whether branch instructions have a delay slot. case "$host" in i*86-*) # NUM_REAL_REGS=3 # but succip and sp are real regs, so subtract 2 NUM_REAL_R_REGS=1 NUM_REAL_R_TEMPS=0 HAVE_DELAY_SLOT= ;; alpha*-*) # NUM_REAL_REGS=7 # but succip, sp, and hp are real regs, so subtract 3 NUM_REAL_R_REGS=4 NUM_REAL_R_TEMPS=6 HAVE_DELAY_SLOT= ;; mips-*) # NUM_REAL_REGS=8 # but succip, sp, and hp are real regs, so subtract 3 NUM_REAL_R_REGS=5 NUM_REAL_R_TEMPS=6 HAVE_DELAY_SLOT=--have-delay-slot ;; rs6000-*|powerpc-*) # NUM_REAL_REGS=10 # but succip, sp, hp, maxfr, and curfr are real regs, # so subtract 5 NUM_REAL_R_REGS=5 NUM_REAL_R_TEMPS=6 HAVE_DELAY_SLOT= ;; sparc-*) # NUM_REAL_REGS=10 # but succip, sp, hp, maxfr, and curfr are real regs, # so subtract 5 NUM_REAL_R_REGS=5 NUM_REAL_R_TEMPS=6 HAVE_DELAY_SLOT=--have-delay-slot ;; hppa-*) # NUM_REAL_REGS=8 # but succip, sp, and hp are real regs, so subtract 3 NUM_REAL_R_REGS=5 NUM_REAL_R_TEMPS=6 HAVE_DELAY_SLOT= ;; arm*-*) # NUM_REAL_REGS=4 # but succip and sp are real regs, so subtract 2 NUM_REAL_R_REGS=2 NUM_REAL_R_TEMPS=0 HAVE_DELAY_SLOT= ;; *) NUM_REAL_R_REGS=0 NUM_REAL_R_TEMPS=6 HAVE_DELAY_SLOT= ;; esac AC_SUBST(NUM_REAL_R_REGS) AC_SUBST(NUM_REAL_R_TEMPS) AC_SUBST(HAVE_DELAY_SLOT) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether the assembler handles .type) AC_CACHE_VAL(mercury_cv_cannot_grok_asm_type_directive, [ case "$host" in *-sunos4.*) mercury_cv_cannot_grok_asm_type_directive=yes can_grok_type_directive=no ;; *) mercury_cv_cannot_grok_asm_type_directive=no can_grok_type_directive=yes ;; esac ]) AC_MSG_RESULT($can_grok_type_directive) if test $mercury_cv_cannot_grok_asm_type_directive = "yes"; then AC_DEFINE(MR_CANNOT_GROK_ASM_TYPE_DIRECTIVE) fi #-----------------------------------------------------------------------------# AC_PATH_PROG(AS,as) AC_MSG_CHECKING(whether the assembler does full preprocessing) AC_CACHE_VAL(mercury_cv_asm_does_full_preprocessing, [ if test "$AS" != ""; then # check that it really works cat > conftest.s << EOF # define foo(x) \ /* foo */ foo(x) EOF if echo $AS conftest.s >&AC_FD_CC 2>&1 && $AS conftest.s &AC_FD_CC 2>&1 then mercury_cv_asm_does_full_preprocessing="yes" else mercury_cv_asm_does_full_preprocessing="no" fi rm -f conftest* else mercury_cv_asm_does_full_preprocessing="no" fi ]) AC_MSG_RESULT($mercury_cv_asm_does_full_preprocessing) if test $mercury_cv_asm_does_full_preprocessing = "no"; then AS="$GCC_PROG -c -x assembler-with-cpp" fi AC_SUBST(AS) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether structure assignment conflicts with global registers) AC_CACHE_VAL(mercury_cv_cannot_use_structure_assignment, AC_TRY_RUN([ changequote(<<,>>) /* MR_USE_GCC_GLOBAL_REGISTERS are essential to the purpose of the test. */ /* We define MR_USE_GCC_NONLOCAL_GOTOS because some platforms (e.g. SPARCs) */ /* cannot have MR_USE_GCC_GLOBAL_REGISTERS without it. */ #define MR_USE_GCC_GLOBAL_REGISTERS #define MR_USE_GCC_NONLOCAL_GOTOS #include "mercury_imp.h" #include "mercury_trace_spy.h" MR_Spy_Point spied_procs[2]; int main() { spied_procs[1] = spied_procs[0]; #if __GNUC__ >= 3 /* gcc 3.1 seems to have problems with structure assignment and global registers, but which this simple test case doesn't trigger. So just force the test to fail for gcc 3.x. */ exit(1); #else exit(0); #endif changequote([,]) }], [mercury_cv_cannot_use_structure_assignment=no], [mercury_cv_cannot_use_structure_assignment=yes], [mercury_cv_cannot_use_structure_assignment=yes])) AC_MSG_RESULT($mercury_cv_cannot_use_structure_assignment) if test $mercury_cv_cannot_use_structure_assignment = "yes"; then AC_DEFINE(MR_CANNOT_USE_STRUCTURE_ASSIGNMENT) fi #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether Mercury supports shared libraries on this system) # We ought to use $target here rather than $host - but we don't # support cross-compilation at the moment anyhow. # set up some default values that should work on most systems # see Mmake.common.in for documentation on the meaning of these variables LINK_EXE=$CC LINK_SHARED_OBJ="$CC -shared" LINK_SHARED_OBJ_SH="$CC -shared" if test "$GCC" = "yes"; then SHARED_LIBS="\`$CC -print-libgcc-file-name\` \$(MATH_LIB) -lc" SHARED_LIBS_SH="\`$CC -print-libgcc-file-name\` \$MATH_LIB -lc" else SHARED_LIBS='$(MATH_LIB) -lc' SHARED_LIBS_SH='$MATH_LIB -lc' fi EXE_RPATH_OPT="-Wl,-rpath," EXE_RPATH_SEP=" -Wl,-rpath," SHLIB_RPATH_OPT="-Wl,-rpath," SHLIB_RPATH_SEP=" -Wl,-rpath," SHLIB_USE_INSTALL_NAME="" SHLIB_INSTALL_NAME_FLAG="-install_name " CFLAGS_FOR_PIC="-fpic -DMR_PIC" EXT_FOR_PIC_OBJECTS=pic_o # Object files with extension $EXT_FOR_LINK_WITH_PIC_OBJECTS are used # in executables which are linked with shared Mercury libraries. # EXT_FOR_LINK_WITH_PIC_OBJECTS should be `lpic_o' if `-DMR_PIC_REG' # has any effect (currently only on x86), or `o' otherwise. EXT_FOR_LINK_WITH_PIC_OBJECTS=lpic_o EXT_FOR_SHARED_LIB=$LIB_SUFFIX USE_DLLS=no # The following variables specify options to $LINK_SHARED_OBJ to # allow/disallow unresolved symbols when building shared libraries. ALLOW_UNDEFINED="" ERROR_UNDEFINED="" DEFAULT_LINKAGE="shared" case "$host" in i*86-*-linux|i*86-*-linux-gnu) case $ac_cv_prog_gcc in yes) AC_MSG_RESULT(yes) EXT_FOR_SHARED_LIB=so AC_MSG_CHECKING(if linker supports --no-undefined) rm -f conftest* echo "int main(void) { return 0; }" > conftest.c $CC -Wl,--no-undefined -o conftest conftest.c if test -f conftest; then AC_MSG_RESULT(yes) ERROR_UNDEFINED="-Wl,--no-undefined" AC_MSG_CHECKING(for ld-linux.so) rm -f conftest* echo "int main(void) { return 0; }" > conftest.c $CC -o conftest conftest.c ld_linux=`ldd ./conftest | \ awk '/ld-linux/{print $1;}'` case $ld_linux in /lib/ld-linux.so*) AC_MSG_RESULT($ld_linux) SHARED_LIBS="$SHARED_LIBS $ld_linux" SHARED_LIBS_SH="$SHARED_LIBS_SH $ld_linux" ;; *) AC_MSG_RESULT(no) ;; esac else AC_MSG_RESULT(no) fi rm -f conftest* ;; *) case "$CC" in lcc*) AC_MSG_RESULT(yes) EXT_FOR_SHARED_LIB=so EXE_RPATH_OPT="-Wl-rpath -Wl" EXE_RPATH_SEP=" -Wl-rpath -Wl" SHLIB_RPATH_OPT="-Wl-rpath -Wl" SHLIB_RPATH_SEP=" -Wl-rpath -Wl" ;; *) AC_MSG_RESULT(no) ;; esac esac # Shared libraries are not the default on x86 systems that # use ELF -- see README.Linux DEFAULT_LINKAGE=static ;; m68*-linux|m68*-linux-gnu) AC_MSG_RESULT(yes) EXT_FOR_SHARED_LIB=so EXT_FOR_LINK_WITH_PIC_OBJECTS=o ;; i*86-*-freebsd*) # From Cornelis van der Laan AC_MSG_RESULT(yes) LINK_SHARED_OBJ="ld -Bshareable" LINK_SHARED_OBJ_SH="ld -Bshareable" EXT_FOR_SHARED_LIB=so # From Kevet Duncombe tested on FreeBSD 2.2.5 EXE_RPATH_OPT="-R" EXE_RPATH_SEP=" -R" SHLIB_RPATH_OPT="-R" SHLIB_RPATH_SEP=" -R" DEFAULT_LINKAGE=static ;; i*86-*-solaris2.*) AC_MSG_RESULT(yes) # XXX For Solaris/SPARC, we don't link in libgcc.a. # Why not? Do we need to do the same thing for Solaris/x86? #SHARED_LIBS="$(MATH_LIB) -lc" # don't link in libgcc.a #SHARED_LIBS_SH="$MATH_LIB -lc" # don't link in libgcc.a # XXX We need -mimpure-text because libraries such as # libreadline.a might be installed with only the .a rather # than the .so, and not compiled with -fpic, # and we need to link against them when creating shared libs. LINK_SHARED_OBJ="$CC -shared -mimpure-text" LINK_SHARED_OBJ_SH="$CC -shared -mimpure-text" # XXX We should use the following. # However, this causes problems on mundroo.cs.mu.oz.au, # due to the readline library being installed only as # libreadline.a, with no corresponding libreadline.so. #ERROR_UNDEFINED="-Wl,-z,defs" EXE_RPATH_OPT="-R" EXE_RPATH_SEP=" -R" SHLIB_RPATH_OPT="-R" SHLIB_RPATH_SEP=" -R" EXT_FOR_SHARED_LIB=so DEFAULT_LINKAGE=static ;; sparc-sun-solaris2.*) AC_MSG_RESULT(yes) SHARED_LIBS="$(MATH_LIB) -lc" # don't link in libgcc.a SHARED_LIBS_SH="$MATH_LIB -lc" # don't link in libgcc.a LINK_SHARED_OBJ="$CC -shared -mimpure-text" LINK_SHARED_OBJ_SH="$CC -shared -mimpure-text" ERROR_UNDEFINED="-Wl,-z,defs" EXE_RPATH_OPT="-R" EXE_RPATH_SEP=" -R" SHLIB_RPATH_OPT="-R" SHLIB_RPATH_SEP=" -R" CFLAGS_FOR_PIC="-fpic -DMR_PIC" # used only for libgc.{a,so} EXT_FOR_PIC_OBJECTS=o EXT_FOR_LINK_WITH_PIC_OBJECTS=o # # Note that despite the above definition of CFLAGS_FOR_PIC, # we don't use `-fpic' for shared libraries on Solaris # (the definition of EXT_FOR_PIC_OBJECTS=o means that # CFLAGS_FOR_PIC will be used only for building libgc.a # and libgc.so.) # # The reason for this is that shared libraries work without # it (well, at least they are shared on disk -- although the # code is not shared at runtime), and using `-fpic' would # reduce efficiency. # # It works because the Solaris dynamic linker will # actually do the fixups at runtime for non-PIC code. # (The code is mapped copy-on-write, and when the linker # does the fixups, it gets copied. Hence the lack of # runtime sharing.) # We need to link with `gcc -shared -mimpure-text' # rather than `gcc -shared', because `gcc -shared' # passes `-z text' to the linker, which causes it to # report an error if any runtime fixups would be needed. # # If you *do* use `-fpic', you must also use `-DMR_PIC'. # # See runtime/mercury_goto.h for the code that handles PIC # on SPARCs. # Note that mixing PIC and non-PIC code is fine on SPARCs # (though it doesn't work on x86s, due to the use of `ebx' # in runtime/machdeps/i386_regs.h). EXT_FOR_SHARED_LIB=so ;; alpha*-dec-osf*) AC_MSG_RESULT(yes) if test "$GCC_PROG" != ""; then # use gcc to link shared objects LINK_SHARED_OBJ="$GCC_PROG -shared \ -Wl,-O3,-update_registry,\$(SO_LOCATIONS_DIR)so_locations" LINK_SHARED_OBJ_SH="gcc -shared \ -Wl,-O3,-update_registry,\${SO_LOCATIONS_DIR}so_locations" ERROR_UNDEFINED="-Wl,-error_unresolved" EXE_RPATH_OPT="-Wl,-rpath," SHLIB_RPATH_OPT="-Wl,-rpath," else # use cc to link shared objects LINK_SHARED_OBJ="cc -shared \ -update_registry \$(SO_LOCATIONS_DIR)so_locations" LINK_SHARED_OBJ_SH="cc -shared \ -update_registry \${SO_LOCATIONS_DIR}so_locations" ERROR_UNDEFINED="-error_unresolved" EXE_RPATH_OPT="-rpath " SHLIB_RPATH_OPT="-rpath " fi EXE_RPATH_SEP=":" SHLIB_RPATH_SEP=":" EXT_FOR_SHARED_LIB=so # -fpic not needed on Alpha/OSF, since it is the default CFLAGS_FOR_PIC= EXT_FOR_PIC_OBJECTS=o EXT_FOR_LINK_WITH_PIC_OBJECTS=o ;; mips-sgi-irix5.*) LINK_SHARED_OBJ="ld -shared \ -update_registry \$(SO_LOCATIONS_DIR)so_locations \ -quickstart_info -rdata_shared" LINK_SHARED_OBJ_SH="ld -shared \ -update_registry \${SO_LOCATIONS_DIR}so_locations \ -quickstart_info -rdata_shared" ERROR_UNDEFINED="-no_unresolved" EXE_RPATH_OPT="-Wl,-rpath," EXE_RPATH_SEP=":" SHLIB_RPATH_OPT="-rpath " SHLIB_RPATH_SEP=":" # -fpic not needed on IRIX, since it is the default CFLAGS_FOR_PIC= EXT_FOR_PIC_OBJECTS=o EXT_FOR_LINK_WITH_PIC_OBJECTS=o # shared libraries are incompatible with gcc non-local gotos, case "$GRADE" in reg.gc | none.gc | hlc.gc) AC_MSG_RESULT(yes) EXT_FOR_SHARED_LIB=so ;; *) EXT_FOR_SHARED_LIB=a AC_MSG_RESULT(no) AC_MSG_RESULT(Read README.IRIX-5) ;; esac ;; *-cygwin*) # disabled for now, since it hasn't been tested # xxx_MSG_RESULT(yes) # EXT_FOR_SHARED_LIB=dll # USE_DLLS=yes AC_MSG_RESULT(disabled for now because it is untested) CFLAGS_FOR_PIC= EXT_FOR_PIC_OBJECTS=o EXT_FOR_LINK_WITH_PIC_OBJECTS=o DEFAULT_LINKAGE=static ;; *mingw*) # disabled for now, since it hasn't been tested # xxx_MSG_RESULT(yes) # EXT_FOR_SHARED_LIB=dll # USE_DLLS=yes AC_MSG_RESULT(disabled for now because it is untested) CFLAGS_FOR_PIC= EXT_FOR_PIC_OBJECTS=o EXT_FOR_LINK_WITH_PIC_OBJECTS=o DEFAULT_LINKAGE=static ;; *powerpc*apple*darwin*) # If the compiler is gcc then use darwin style dynamic linking. # Otherwise use static linking. if test "$GCC_PROG" != ""; then AC_MSG_RESULT(yes) # Check if the user has explicitly requested that flat # namespaces be used. darwin_flat_namespaces=no AC_ARG_ENABLE(darwin-flat-namespace, [ --enable-darwin-flat-namespace enable flat namespaces on Darwin. This is the default for Darwin versions less than 7 (Mac OS 10.3). On versions greater than or equal to 7 two-level namespaces are used by default. This option therefore only affects Darwin versions greater than or equal to 7.], [ darwin_flat_namespaces=yes ]) SHLIB_USE_INSTALL_NAME="--shlib-linker-use-install-name" SHLIB_INSTALL_NAME_FLAG="-install_name " EXT_FOR_SHARED_LIB=dylib EXT_FOR_LINK_WITH_PIC_OBJECTS=o CFLAGS_FOR_PIC="-fPIC -DMR_PIC" ERROR_UNDEFINED="-undefined error" # Test if the Darwin version is >= 7. If it is # then we can use the -undefined dynamic_lookup option # and two-level namespaces. If it isn't then we use # flat namespaces. AC_MSG_CHECKING(whether to use two-level namespaces) if uname -r | sed "s/^\(@<:@0-9@:>@*\)\..*$/\1/" | \ xargs test "$darwin_flat_namespaces" != "yes" \ -a 7 -le; then AC_MSG_RESULT(yes) # The MACOSX_DEPLOYMENT_TARGET environment variable # needs to be set when linking with two level # namespaces so we can use the # `-undefined dynamic_lookup' option. SET_MACOSX_DEPLOYMENT_TARGET="\ MACOSX_DEPLOYMENT_TARGET=10.3; \ export MACOSX_DEPLOYMENT_TARGET" AC_SUBST(SET_MACOSX_DEPLOYMENT_TARGET) LINK_SHARED_OBJ="$GCC_PROG -multiply_defined suppress \ -dynamiclib -single_module" LINK_SHARED_OBJ_SH="$GCC_PROG -multiply_defined \ suppress -dynamiclib -single_module" ALLOW_UNDEFINED="-undefined dynamic_lookup" else AC_MSG_RESULT(no) LINK_SHARED_OBJ="$GCC_PROG -flat_namespace \ -dynamiclib -single_module" LINK_SHARED_OBJ_SH="$GCC_PROG -flat_namespace \ -dynamiclib -single_module" ALLOW_UNDEFINED="-undefined error" fi else CFLAGS_FOR_PIC= EXT_FOR_PIC_OBJECTS=o EXT_FOR_LINK_WITH_PIC_OBJECTS=o DEFAULT_LINKAGE=static AC_MSG_RESULT(no) fi ;; arm*-linux|arm*-linux-gnu) AC_MSG_RESULT(yes) EXT_FOR_SHARED_LIB=so EXT_FOR_LINK_WITH_PIC_OBJECTS=o # One can build gcc with a default PIC register other than sl # so let's force it. If you change this, # update MR_ARM_PIC_REG in runtime/mercury_goto.h as well. CFLAGS_FOR_PIC="-mpic-register=sl $CFLAGS_FOR_PIC" ;; *) # CFLAGS_FOR_PIC is used by boehm_gc/Makefile when creating # libgc.a. If the system doesn't support shared libraries, # then we should set it to empty, not `-fpic'. CFLAGS_FOR_PIC= EXT_FOR_PIC_OBJECTS=o EXT_FOR_LINK_WITH_PIC_OBJECTS=o DEFAULT_LINKAGE=static AC_MSG_RESULT(no) ;; esac #-----------------------------------------------------------------------------# # Note that changes here may require changes in scripts/mgnuc.in. case "$CC" in *gcc*) COMPILER=gcc CFLAGS_FOR_ANSI="-ansi" # For a full list of the other gcc warnings that we don't # enable, and why, see scripts/mgnuc.in. CFLAGS_FOR_WARNINGS="-Wall -Wwrite-strings -Wshadow -Wmissing-prototypes -Wno-unused -Wno-uninitialized -Wstrict-prototypes" CFLAGS_FOR_OPT="-O2 -fomit-frame-pointer" CFLAGS_FOR_DEBUG="-g" MCFLAGS_FOR_CC= ;; *lcc*) COMPILER=lcc CFLAGS_FOR_ANSI= # turn off all warnings due to spurious warnings. CFLAGS_FOR_WARNINGS="-w" CFLAGS_FOR_OPT= CFLAGS_FOR_DEBUG="-g" MCFLAGS_FOR_CC= ;; *cl* | *CL*) COMPILER=cl CFLAGS_FOR_ANSI= CFLAGS_FOR_WARNINGS= CFLAGS_FOR_OPT= CFLAGS_FOR_DEBUG="/Zi" # Using the MSVC compiler implies that we must use # a maximum jump table size of 512 to avoid a fixed limit # in the compiler. MCFLAGS_FOR_CC="--max-jump-table-size 512" ;; cc* | */cc*) COMPILER=cc CFLAGS_FOR_ANSI= CFLAGS_FOR_OPT="-O" CFLAGS_FOR_WARNINGS= CFLAGS_FOR_DEBUG="-g" MCFLAGS_FOR_CC= ;; *) COMPILER=unknown CFLAGS_FOR_ANSI= CFLAGS_FOR_OPT="-O" CFLAGS_FOR_WARNINGS= CFLAGS_FOR_DEBUG="-g" MCFLAGS_FOR_CC= ;; esac CFLAGS_FOR_OPT="$CFLAGS_FOR_OPT $CFLAGS_FOR_NO_STRICT_ALIASING" AC_SUBST(CFLAGS_FOR_ANSI) AC_SUBST(CFLAGS_FOR_WARNINGS) AC_SUBST(CFLAGS_FOR_OPT) AC_SUBST(CFLAGS_FOR_DEBUG) AC_SUBST(MCFLAGS_FOR_CC) #-----------------------------------------------------------------------------# # Work out how to link statically. # Note that changes here may require changes in scripts/ml.in. LD_STATIC_FLAGS= case $COMPILER in gcc|lcc) LD_STATIC_FLAGS=-static ;; esac case $FULLARCH in *-linux*) # On Linux, if we're linking statically, we need to # pass `-defsym _DYNAMIC=0' to the linker, to avoid # undefined references to _DYNAMIC in # boehm_gc/dyn_load.c. # (We might eventually need similar treatment # for other OSs too) case $COMPILER in gcc) LD_STATIC_FLAGS="-static -Wl-defsym -Wl_DYNAMIC=0" ;; lcc) # for lcc 4.1, we need to use "-Wl,". # for lcc 4.2, we need to use "-Wl" without the comma, # like we do for gcc. AC_MSG_CHECKING(whether lcc requires comma after -Wl) LD_STATIC_FLAGS="-static -Wl-defsym -Wl_DYNAMIC=0" rm -f conftest* echo "int main() { return 0; }" > conftest.c if echo $CC $LD_STATIC_FLAGS conftest.c \ >&AC_FD_CC 2>&1 && $CC $LD_STATIC_FLAGS conftest.c \ >&AC_FD_CC 2>&1 then AC_MSG_RESULT(no) else AC_MSG_RESULT(yes) LD_STATIC_FLAGS="-static -Wl,-defsym -Wl,_DYNAMIC=0" fi rm -f conftest* ;; esac ;; alpha*-dec-osf*) case $COMPILER in cc) LD_STATIC_FLAGS=-non_shared ;; esac ;; *-sun-solaris*) case $COMPILER in cc) LD_STATIC_FLAGS="-B static" ;; esac ;; esac # we can't put the call to MSG_CHECKING at the start of the case statement # above, because of the nested check in the lcc case. So we just put it # here immediately before the MSG_RESULT call. AC_MSG_CHECKING(options for static linking) AC_MSG_RESULT($LD_STATIC_FLAGS) case "$LD_STATIC_FLAGS" in "") AC_MSG_WARN( [\`mmc --linkage static' and \`ml --static' not implemented with **** this C compiler (\`$CC').]) esac #-----------------------------------------------------------------------------# case "$host" in *-cygwin*) EXT_FOR_EXE=".exe" ;; *mingw*) EXT_FOR_EXE=".exe" ;; *) EXT_FOR_EXE= ;; esac #-----------------------------------------------------------------------------# AC_SUBST(LINK_EXE) AC_SUBST(LD_STATIC_FLAGS) AC_SUBST(DEFAULT_LINKAGE) AC_SUBST(LINK_SHARED_OBJ) AC_SUBST(LINK_SHARED_OBJ_SH) AC_SUBST(ERROR_UNDEFINED) AC_SUBST(ALLOW_UNDEFINED) AC_SUBST(EXE_RPATH_OPT) AC_SUBST(EXE_RPATH_SEP) AC_SUBST(SHLIB_RPATH_OPT) AC_SUBST(SHLIB_RPATH_SEP) AC_SUBST(SHLIB_USE_INSTALL_NAME) AC_SUBST(SHLIB_INSTALL_NAME_FLAG) AC_SUBST(CFLAGS_FOR_PIC) AC_SUBST(EXT_FOR_PIC_OBJECTS) AC_SUBST(EXT_FOR_LINK_WITH_PIC_OBJECTS) AC_SUBST(EXT_FOR_SHARED_LIB) AC_SUBST(EXT_FOR_EXE) AC_SUBST(USE_DLLS) AC_SUBST(SHARED_LIBS) AC_SUBST(SHARED_LIBS_SH) AC_SUBST(DEFAULT_LINKAGE) if test $USE_DLLS = "yes"; then AC_DEFINE(MR_USE_DLLS) fi #-----------------------------------------------------------------------------# if test "$BOOTSTRAP_MC" = ""; then BOOTSTRAP_MC=mmc fi BOOTSTRAP_MC_COMPILER="$BOOTSTRAP_MC" BOOTSTRAP_MC_ARGS="$HAVE_BOXED_FLOATS --conf-low-tag-bits $LOW_TAG_BITS --bits-per-word $BITS_PER_WORD --bytes-per-word $BYTES_PER_WORD" BOOTSTRAP_MC="$BOOTSTRAP_MC_COMPILER $BOOTSTRAP_MC_ARGS" AC_SUBST(BOOTSTRAP_MC_COMPILER) AC_SUBST(BOOTSTRAP_MC_ARGS) AC_SUBST(BOOTSTRAP_MC) #-----------------------------------------------------------------------------# # The following allows us to share some subroutines between the # `ml' and `mgnuc' scripts. top=`pwd` INIT_GRADE_OPTIONS=$top/scripts/init_grade_options.sh-subr PARSE_GRADE_OPTIONS=$top/scripts/parse_grade_options.sh-subr FINAL_GRADE_OPTIONS=$top/scripts/final_grade_options.sh-subr PARSE_ML_OPTIONS=$top/scripts/parse_ml_options.sh-subr CANONICAL_GRADE=$top/scripts/canonical_grade.sh-subr # The following allows us to duplicate a subroutine in mgnuc. MGNUC_FILE_OPTS=$top/scripts/mgnuc_file_opts.sh-subr # demangling hangs on cygwin, so don't enable it. case "$host" in *-cygwin*) DEMANGLE=false ;; *) DEMANGLE=true ;; esac AC_SUBST_FILE(INIT_GRADE_OPTIONS) AC_SUBST_FILE(PARSE_GRADE_OPTIONS) AC_SUBST_FILE(FINAL_GRADE_OPTIONS) AC_SUBST_FILE(PARSE_ML_OPTIONS) AC_SUBST_FILE(CANONICAL_GRADE) AC_SUBST_FILE(MGNUC_FILE_OPTS) AC_SUBST(DEMANGLE) # mercury_config includes configure.help to include the help for configure # in its `--help' output and man page. ${CONFIG_SHELL-/bin/sh} "$0" --help | sed -e 's/`/\\`/g' > configure.help CONFIGURE_HELP=$top/configure.help AC_SUBST_FILE(CONFIGURE_HELP) #-----------------------------------------------------------------------------# # # Check for the POSIX struct tms and times() function. # This is used for the time__times procedure in library/times.m. # AC_MSG_CHECKING(for struct tms and times function) AC_CACHE_VAL(mercury_cv_have_posix_times, AC_TRY_LINK([ #include #include ],[ struct tms t; long Ut, St, CUt, CSt; long Ret; Ret = (long) times(&t); Ut = (long) t.tms_utime; St = (long) t.tms_stime; CUt = (long) t.tms_cutime; CSt = (long) t.tms_cstime; ],[mercury_cv_have_posix_times=yes],[mercury_cv_have_posix_times=no])) # # figure out whether the test succeeded # if test "$mercury_cv_have_posix_times" = yes; then AC_MSG_RESULT(yes) AC_DEFINE(MR_HAVE_POSIX_TIMES) else AC_MSG_RESULT(no) fi #-----------------------------------------------------------------------------# # # Check for the WIN32 Sleep function # AC_MSG_CHECKING(for Sleep function) AC_CACHE_VAL(mercury_cv_have_capital_s_sleep, AC_TRY_LINK([ #include ],[ Sleep(1); ],[mercury_cv_have_capital_s_sleep=yes],[mercury_cv_have_capital_s_sleep=no])) if test "$mercury_cv_have_capital_s_sleep" = yes; then AC_MSG_RESULT(yes) AC_DEFINE(MR_HAVE_CAPITAL_S_SLEEP) else AC_MSG_RESULT(no) fi #-----------------------------------------------------------------------------# # # Check for the various IEEE predicates # MERCURY_CHECK_FOR_IEEE_FUNC(isnan) MERCURY_CHECK_FOR_IEEE_FUNC(isnanf) MERCURY_CHECK_FOR_IEEE_FUNC(isinf) MERCURY_CHECK_FOR_IEEE_FUNC(isinff) #-----------------------------------------------------------------------------# # # Check whether sockets work (we need them for the external debugger) # # # check whether we need -lsocket # AC_CHECK_LIB(socket, socket, SOCKET_LIBRARY=-lsocket, SOCKET_LIBRARY="") # # check whether we need -lnsl # AC_CHECK_LIB(nsl, inet_addr, NSL_LIBRARY=-lnsl, NSL_LIBRARY="") # # temporarily add -lsocket to LIBS, for use by TRY_LINK # save_LIBS="$LIBS" LIBS="$LIBS $SOCKET_LIBRARY $NSL_LIBRARY" # # use TRY_LINK to see whether we can use sockets # AC_MSG_CHECKING(whether we can use sockets (for Morphine)) AC_CACHE_VAL(mercury_cv_sockets_work, AC_TRY_LINK([ changequote(<<,>>) /* ** The following code was copied from ** runtime/mercury_trace_external.c */ #include #include #include #include #include #include #include #include #include #include #include #include static int MR_debug_socket = 1; void fatal_error(const char *s) { fprintf(stderr, "", s); exit(1); } ],[ /* this is the body of the test function */ { int fd; int len; FILE *file_in; FILE *file_out; int addr_family; char *unix_socket; char *inet_socket; struct sockaddr_un unix_address; struct sockaddr_in inet_address; struct sockaddr* addr; /* ** We presume that the user's program has been invoked from ** within the debugger (e.g. Opium). ** The debugger (or the user) should set the ** MERCURY_DEBUGGER_UNIX_SOCKET or MERCURY_DEBUGGER_INET_SOCKET ** environment variable to tell the user's program which socket ** it needs to connect to. */ unix_socket = getenv("MERCURY_DEBUGGER_UNIX_SOCKET"); inet_socket = getenv("MERCURY_DEBUGGER_INET_SOCKET"); if (unix_socket == NULL && inet_socket == NULL) { fatal_error("you must set either the " "MERCURY_DEBUGGER_UNIX_SOCKET\n" "or MERCURY_DEBUGGER_INET_SOCKET " "environment variable"); } if (unix_socket != NULL && inet_socket != NULL) { fatal_error("you must set only one of the " "MERCURY_DEBUGGER_UNIX_SOCKET " "and MERCURY_DEBUGGER_INET_SOCKET\n" "environment variables"); } if (unix_socket) { addr_family = AF_UNIX; (memset)(&unix_address, 0, sizeof(unix_address)); unix_address.sun_family = AF_UNIX; strcpy(unix_address.sun_path, unix_socket); addr = (struct sockaddr *) &unix_address; len = strlen(unix_address.sun_path) + sizeof(unix_address.sun_family); } else { char hostname[255]; char port_string[255]; unsigned short port; int host_addr; /* ** Parse the MERCURY_DEBUGGER_INET_SOCKET environment variable. ** It should be in the format " ", ** where is numeric (e.g. "123.456.78.90"). */ if (sscanf(inet_socket, "%254s %254s", hostname, port_string) != 2) { fatal_error("MERCURY_DEBUGGER_INET_SOCKET invalid"); } host_addr = inet_addr(hostname); if (host_addr == -1) { fatal_error("MERCURY_DEBUGGER_INET_SOCKET: " "invalid address"); } if (sscanf(port_string, "%hu", &port) != 1) { fatal_error("MERCURY_DEBUGGER_INET_SOCKET: " "invalid port"); } fprintf(stderr, "Mercury runtime: host = %s, port = %d\n", hostname, port); inet_address.sin_family = AF_INET; inet_address.sin_addr.s_addr = host_addr; inet_address.sin_port = htons(port); addr_family = AF_INET; addr = (struct sockaddr *) &inet_address; len = sizeof(inet_address); } /* ** Open the socket. */ fd = socket(addr_family, SOCK_STREAM, 0); if (fd < 0) { fprintf(stderr, "Mercury runtime: socket() failed: %s\n", strerror(errno)); fatal_error("cannot open socket for debugger"); } else if (MR_debug_socket) { fprintf(stderr,"Mercury runtime: creation of socket ok\n"); } /* ** Connect to the socket */ if (connect(fd, addr, len) < 0) { fprintf(stderr, "Mercury runtime: connect() failed: %s\n", strerror(errno)); fatal_error("can't connect to debugger socket"); } else if (MR_debug_socket) { fprintf(stderr, "Mercury runtime: connection to socket: ok\n"); } /* ** Convert the socket fd to a Mercury stream */ file_in = fdopen(fd, "r"); file_out = fdopen(fd, "w"); if ((file_in == NULL)||(file_out == NULL)) { fprintf(stderr, "Mercury runtime: fdopen() failed: %s\n", strerror(errno)); fatal_error("cannot open debugger socket"); } else if (MR_debug_socket) { fprintf(stderr, "Mercury runtime: fdopen(): ok\n"); } } changequote([,]) ],[mercury_cv_sockets_work=yes],[mercury_cv_sockets_work=no])) # # figure out whether the test succeeded # if test "$mercury_cv_sockets_work" = yes; then AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi # # restore the previous value of LIBS # LIBS="$save_LIBS" #-----------------------------------------------------------------------------# # # Add an option that enables the external debugger support. # By default, external debugger support is enabled if and only if # sockets work. But it is also possible to explicitly disable this # by passing the `--disable-extern-debug' option. This is needed on # some platforms because the test for sockets working sometimes gets # some false positives (e.g. if they work with dynamic linking but # not static linking, then the test will pass, but it will cause # problems later on when we try to link things statically). # AC_ARG_ENABLE(extern-debug, [ --disable-extern-debug disable the external (separate process) debugger], mercury_cv_enable_extern_debug="$enableval", mercury_cv_enable_extern_debug="$mercury_cv_sockets_work") AC_MSG_CHECKING(whether to enable the external debugger) if test "$mercury_cv_enable_extern_debug" = "yes"; then if test "$mercury_cv_sockets_work" = yes; then AC_MSG_RESULT(yes) AC_DEFINE(MR_USE_EXTERNAL_DEBUGGER) else AC_MSG_RESULT(no) AC_MSG_ERROR(Cannot enable external debugger because sockets do not work) fi else AC_MSG_RESULT(no) # don't link with the socket library if we're not going to use it SOCKET_LIBRARY= NSL_LIBRARY= fi AC_SUBST(SOCKET_LIBRARY) AC_SUBST(NSL_LIBRARY) #-----------------------------------------------------------------------------# # # Check for dynamic linking, unless the --disable-dynamic-link option # was specified. # AC_ARG_ENABLE(dynamic-link, [ --disable-dynamic-link disable the use of dynamic linking], mercury_cv_enable_dynamic_link="$enableval",mercury_cv_enable_dynamic_link=yes) if test "$mercury_cv_enable_dynamic_link" = "yes"; then MERCURY_CHECK_FOR_HEADERS(dlfcn.h) AC_CHECK_LIB(dl, dlopen, DL_LIBRARY="-ldl", DL_LIBRARY="") AC_SUBST(DL_LIBRARY) # temporarily add $DL_LIBRARY to LIBS while we check for dlopen etc. save_LIBS="$LIBS" LIBS="$LIBS $DL_LIBRARY" mercury_check_for_functions dlopen dlclose dlsym dlerror # restore old value of LIBS LIBS="$save_LIBS" fi TRACE_LIBS_SYSTEM="$SOCKET_LIBRARY $NSL_LIBRARY $DL_LIBRARY" AC_SUBST(TRACE_LIBS_SYSTEM) #-----------------------------------------------------------------------------# AC_MSG_CHECKING(whether to enable the new MercuryFile struct) AC_ARG_ENABLE(new-mercuryfile-struct, [ --enable-new-mercuryfile-struct enable new MercuryFile struct.], ac_new_mercuryfile_struct=yes,ac_new_mercuryfile_struct=no) if test "$ac_new_mercuryfile_struct" = "yes"; then AC_MSG_RESULT(yes) AC_DEFINE(MR_NEW_MERCURYFILE_STRUCT) else AC_MSG_RESULT(no) fi #-----------------------------------------------------------------------------# AC_ARG_WITH(msvcrt, [ --with-msvcrt use the MS Visual C runtime if using MS C compiler.], mercury_cv_msvcrt=yes,mercury_cv_msvcrt=no) AC_MSG_CHECKING(whether to use the MS Visual C Runtime) if test "$mercury_cv_msvcrt" = "yes"; then if test "$ac_microsoft" = "yes"; then AC_MSG_RESULT(yes) USE_MSVCRT=yes else AC_MSG_RESULT(no as not using the MS C compiler) USE_MSVCRT=no fi else AC_MSG_RESULT(no) USE_MSVCRT=no fi AC_SUBST(USE_MSVCRT) #-----------------------------------------------------------------------------# MERCURY_CHECK_READLINE #-----------------------------------------------------------------------------# #-----------------------------------------------------------------------------# # Check for a XUL browser and xslrproc and if we find both then set the # default xml_browser_command and xml_tmp_filename mdb options. # AC_PATH_PROGS(XUL_BROWSER, firefox mozilla, "") AC_PATH_PROGS(XSLTPROC, xsltproc, "") if test "$XUL_BROWSER" != "" && test "$XSLTPROC" != ""; then DEFAULT_XML_BROWSER_CMD="$XSLTPROC $DEFAULT_MERCURY_DEBUGGER_INIT_DIR/xul_tree.xsl /tmp/mdbtmp.xml > /tmp/mdbtmp.xul && $XUL_BROWSER file:///tmp/mdbtmp.xul" DEFAULT_XML_TMP_FILENAME="/tmp/mdbtmp.xml" else DEFAULT_XML_BROWSER_CMD="" DEFAULT_XML_TMP_FILENAME="" fi AC_SUBST(DEFAULT_XML_BROWSER_CMD) AC_SUBST(DEFAULT_XML_TMP_FILENAME) #-----------------------------------------------------------------------------# mercury_check_c_files () { c_dir=$1 c_date_dir=$2 for c_file in $c_dir/*.c do case $c_file in */'*.c') ;; */*_init.c) some_kept=true ;; *) sed -e '/END_OF_C_GRADE_INFO/q' < $c_file > confscratch if grep "TAG_BITS=$mercury_cv_low_tag_bits" \ confscratch > /dev/null 2>&1 \ && grep "UNBOXED_FLOAT=$mercury_cv_unboxed_floats" \ confscratch > /dev/null 2>&1 then some_kept=true else c_date_file="$c_date_dir/`basename $c_file .c`.c_date" to_delete="$to_delete $c_file $c_date_file" fi ;; esac done } some_kept=false to_delete="" if test "$BOOTSTRAP_MC" != "" ; then MERCURY_MSG("checking whether any C files need to be rebuilt...") for directory in library compiler profiler deep_profiler mdbcomp browser analysis slice do mercury_check_c_files $directory $directory mercury_check_c_files $directory/Mercury/cs $directory/Mercury/c_dates done if test "$to_delete" = "" ; then case $some_kept in true) MERCURY_MSG("no - they are compatible with autoconfigured settings") ;; false) MERCURY_MSG("there are no existing Mercury-generated C files") ;; esac else case $some_kept in true) MERCURY_MSG( "the following C files must be rebuilt in a grade that is consistent with autoconfigured settings $to_delete") ;; false) MERCURY_MSG( "all Mercury generated C files must be rebuilt in a grade that is consistent with the autoconfigured settings") ;; esac MERCURY_MSG("installation may take longer than usual") fi rm -f confscratch $to_delete fi #-----------------------------------------------------------------------------# AC_MSG_CHECKING(for C shell executable) cshpath="" for prog in tcsh csh do for dir in `echo $PATH | tr '[:]' '[ ]'` do if test -x "$dir/$prog" then if test "$cshpath" = "" then cshpath="$dir/$prog" fi fi done done if test "$cshpath" = "" then AC_MSG_RESULT(no) CSHPATH="no csh path" else AC_MSG_RESULT($cshpath) CSHPATH="$cshpath" fi AC_SUBST(CSHPATH) #-----------------------------------------------------------------------------# # We should only set up TESTS_FLAGS if the tests directory is accessible. # It can be in one of two places: # (a) in the mercury directory # (b) a sibling of the mercury directory if test -e tests/TESTS_FLAGS.in then test_flags="tests/TESTS_FLAGS" else if test -e ../tests/TESTS_FLAGS.in then test_flags="../tests/TESTS_FLAGS" else test_flags="" fi fi # The references to $conf_h_copy and $had_old_conf_h below are in code that # autoconf puts into a subshell, so we must export them. conf_h_copy=/tmp/mercury_conf.h.$$ # trap "rm -f $conf_h_copy" 0 1 2 3 13 15 export conf_h_copy if test -f runtime/mercury_conf.h then /bin/rm -f $conf_h_copy cp runtime/mercury_conf.h $conf_h_copy had_old_conf_h=true else had_old_conf_h=false fi export had_old_conf_h # IMPORTANT NOTE # -------------- # Any new entries here may need to be handled by scripts/mercury_config.in. # Failing to do this correctly may break the binary distributions # This is especially true of files in the runtime or java directories; # if you add new .in files to either of those you *must* update # scripts/mercury_config.in. # AC_OUTPUT(Mmake.common scripts/Mmake.vars scripts/mmc scripts/mercury.bat scripts/mprof scripts/mercury_update_interface scripts/mgnuc scripts/parse_ml_options.sh-subr scripts/ml scripts/c2init scripts/mmake scripts/mdb scripts/mdbrc scripts/mdprof scripts/canonical_grade scripts/mkfifo_using_mknod scripts/mercury_config scripts/Mercury.config scripts/Mercury.config.bootstrap scripts/prepare_tmp_dir_fixed_part bindist/bindist.INSTALL bindist/bindist.Makefile tools/lmc tools/dotime runtime/mercury_dotnet.cs java/runtime/Constants.java java/runtime/Native.java compiler/COMP_FLAGS library/LIB_FLAGS mdbcomp/MDBCOMP_FLAGS browser/MDB_FLAGS analysis/ANALYSIS_FLAGS slice/SLICE_FLAGS profiler/PROF_FLAGS deep_profiler/DEEP_FLAGS "$test_flags" , [ # Only do this when compiling the source, not when reconfiguring # an installation. case $reconfiguring in no) for header in $CONFIG_HEADERS ; do if test "$header" = "runtime/mercury_conf.h"; then if $had_old_conf_h && \ cmp runtime/mercury_conf.h "$conf_h_copy" \ > /dev/null && \ test -f runtime/mercury_conf.h.date then # The date file need not be updated, so don't # update it, since that would lead to the # recompilation of a bunch of files. true else touch runtime/mercury_conf.h.date fi fi done # conftest.junk is used to avoid a warning if there # are no files in the list passed to chmod touch conftest.junk chmod +x `echo $CONFIG_FILES | \ sed -e 's/[[^ ]]*Mmake.common//' ` conftest.junk rm -f conftest.junk # The --prefix is hard-coded in the scripts, which are regenerated # every time you run configure, and also (unfortunately) in the .so # files. The following rm commands are here to ensure that things # will work correctly if you rerun configure with a new --prefix and # then don't do a `make clean' before running `make'. rm -f runtime/libmer_rt.so library/libmer_std.so bytecode/libmbi.so rm -f trace/libmer_trace.so browser/libmer_browser.so rm -f mdbcomp/libmer_mdbcomp.so rm -f runtime/libmer_rt.dylib library/libmer_std.dylib rm -f boehm_gc/libgc.dylib bytecode/libmbi.dylib rm -f trace/libmer_trace.dylib browser/libmer_browser.dylib rm -f mdbcomp/libmer_mdbcomp.dylib ;; esac], [reconfiguring=$reconfiguring] ) case "$remake_dependencies.$reconfiguring" in "true.no") MERCURY_MSG( "regenerating dependencies to enable GCC backend.") MMAKE_DIR=`pwd`/scripts scripts/mmake depend || exit 1 ;; esac #-----------------------------------------------------------------------------#