In configure, we try detect the non-working combination of gcc 5+,
targeting x86, PIC, and non-local gotos. We assumed that PIC is only
generated when creating shared libraries, but gcc may have been
configured to generate PIC by default. This is very common on more
recent Linux distributions.
configure.ac:
Extend the test mentioned above: if shared libraries are disabled,
check whether gcc generates PIC anyway.
Clean up the code a little.
m4/mercury.m4:
Add helper macros MERCURY_CC_TARGETS_X86 and
MERCURY_CC_GENERATES_PIC.
README.x86:
Update this document.
m4/mercury.m4:
Recent versions of the Java compiler print the output of -version
to the standard output instead of the standard error. Account for
this in order to avoid unwanted noise in the configure script.
Use "gcc -dumpfullversion" to determine the GCC version where available.
Unlike -dumpversion, its output is guaranteed to be in the form
major.minor.patch.
Include the GCC version in the configure progress message.
m4/mercury.m4:
As above.
We currently determine which version of clang we are using by compiling a small
C program and examining the value of the macros __clang_major__ etc. There are
two problems with this.
1. As noted recently on the developers list, having to run the program
interferes with cross-compilation.
2. Apple vendored clangs "lie" about their version. For the Apple versions the
macros __clang__major__ etc, seem to be set to the XCode version, not the
underlying clang version.
Fix both the above issues by parsing the output of -dumpversion as we do with
GCC. (The Apple versions do report the actual clang version when using that
flag.)
m4/mercury.m4:
Make the above change.
There are multiple libraries named "editline" on the net.
The one that Mercury supports is (a port of) the NetBSD editline
library, sometimes also referred to as "libedit". Make it easier
for the user to install the correct library.
.INSTALL.in:
configure.ac:
m4/mercury.m4:
runtime/mercury_conf.h.in:
Mention NetBSD and libedit in a few more places.
Support the use of the editline library as an alternative to GNU readline for
the debugger command-line prompt. The former has a more permissive license
than the latter. If licensing is not an issue then GNU readline is the
preferable choice (e.g. feature wise); as such it is the default option.
NOTE: there are (apparently) two editline libraries, one derived from NetBSD
and one from Minix -- this diff adds support for the former. (Using the latter
should just be a matter of using a different header file and supplying a
different library name to link against, but I haven't tried that yet.)
m4/mercury.m4:
Add a configuration check for editline.
configure.ac:
Check the presence of editline.
runtime/mercury_conf.h.in:
Replace the macro MR_NO_USE_READLINE with MR_USE_READLINE which
is defined if GNU readline is available and the user has not
forbidden its use.
Add a new macro MR_USE_EDITLINE which does the same for editline.
Add a new macro that is defined if the header editline/readline.h
is present.
trace/mercury_trace_completion.c:
trace/mercury_trace_readline.c:
Use editline in place of readline if appropriate.
The MinGW-w64 port of gcc may report a version like "7.3-win32" or
"7.3-posix". Our gcc version detection code did not expect the
suffixes so would extract "3-win32" or "3-posix" as the minor version.
m4/mercury.m4:
Ignore a "-suffix" in the output of gcc -dumpversion.
m4/mercury.m4:
The recently added MERCURY_TRY_STATIC_ASSERT macro uses a struct
with the tag name 'static_assert'. This is problematic with MSVC
as 'static_assert' is a C++ keyword. Use a different tag name
in order to avoid this.
m4/mercury.m4:
Add a macro MERCURY_TRY_STATIC_ASSERT for testing a single
compile-time expression.
configure.ac:
Replace some run-time tests (using AC_TRY_RUN) with compile-time
tests (using MERCURY_TRY_STATIC_ASSERT), allowing said tests to work
when cross-compiling.
Delete code handling mercury_cv_bits_per_word = 16;
we do not support it.
tools/configure_mingw_cross:
Delete some variables that can now be detected by configure when
cross-compiling.
m4/mercury.m4:
In the test for checking whether the JDK is up-to-date, avoid a failed
comparison due to a single precision float being promoted to a double.
Implement thread.yield/2 for the C# grade.
m4/mercury.m4:
Update the C# compiler check to not try the old aliases for the
Mono C# compiler; do not try the DotGNU (which is no longer a going
concern) C# compiler either.
Update the copyright notice for this file.
library/thread.m:
Uncomment and correct the C# implementation of thread.yield/2.
The default configuration of Mercury on Windows breaks when using the Java
grade due to the argument we pass to the Java compiler's '-J' option, in order
to set the maximum heap size, not being quoted in the @file we pass to the Java
compiler when '--restricted-command-line' is enabled.
What should be placed in the @file is:
-J"-Xmx1024m"
What we currently put in it is:
-J-Xmx1024m
The reason for this is that the setting of JAVAC_FLAGS_FOR_HEAP_SIZE in
scripts/Mercury.config does not escape the double quotes, consequently they do
not get passed through the Mercury compiler to the aforementioned @file. This
problem was already correctly identified and documented in the comments
accompanying the MERCURY_CHECK_JAVAC_HEAP_SIZE macro in m4/mercury.m4, but the
actual behaviour of that macro is incorrect. In particular, it fails to
account for the fact that the value of JAVAC_FLAGS_FOR_HEAP_SIZE should differ
depending on whether mmake or 'mmc --make' is using that value. The current
value will work for mmake but not with 'mmc --make'
(and '--restricted-command-line').
The fix is to separate the handling of the mmake and 'mmc --make' cases and
correctly escape the version that is put in Mercury.config.
configure.ac:
m4/mercury.m4:
Define separate configuration variables for mmake and 'mmc --make' to
set the Java compiler's maximum heap size.
scripts/Mercury.config.in:
scripts/Mercury.config.bootstrap.in:
scripts/Mmake.vars.in:
Conform to the above change.
Drop support for lcc as a C compiler. lcc itself does not seem to have been
updated since around 2010 and Mercury's support for it has not been updated for
quite a while before that.
Derivatives of lcc, for example lcc-win32, would almost certainly need to be
treated separately anyway, so this change doesn't affect them (i.e. they are
already not supported).
configure.ac:
m4/mercury.m4:
Do not recognise lcc as a C compiler.
Unrelated change: remove residual support for a.out executables on Linux.
scripts/mgnuc_file_opts.sh-subr:
Do not define the macros __EXTENSIONS__ and _GNU_SOURCE if the mgnuc script
is invoked with --no-ansi. This was originally done to support lcc on Linux.
Doing so on *all* systems as this code actually does is not a good idea.
(If it becomes necessary to reinstate this behaviour on some system, it
should be controlled from the configure script not here.)
runtime/mercury_wrapper.c:
Delete a workaround for lcc.
scripts/mgnuc.in:
scripts/ml.in:
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/globals.m:
compiler/ml_code_gen.m:
Delete support for lcc.
README.lcc:
Delete this file.
The check for the pthreads-win32 implementation did not work because it
compiled a test program that was designed to be run, but did not run it.
Running a test program is undesirable for cross-compilation anyway.
m4/mercury.m4:
Replace MERCURY_HAVE_PTHREADS_WIN32 test with one based only on
successful compilation.
m4/mercury.m4:
Only keep the basename of ERLC and ERL if their initial values
are qualified with directories whose names contains spaces. This
avoids build problems on Windows. (We do the same thing for the
Java tools.)
configure.ac:
Add a new option, --with-csharp-compiler, that allows the user to
specify what C# compiler to use.
m4/mercury.m4:
If the user specified a C# compiler using the --with-csharp-compiler
then use that.
The 'mcs' compiler on my system cannot handle generics. This change to the
configure script macros tests each candidate mono C# compiler for generics
support. If a candidate does not handle generics, then the next candidate
is tested.
m4/mercury.m4:
As above.
I have also stripped trailing whitespace the end of lines in this file.
m4/mercury.m4:
Check for a CLI interpreter *before* working out what
C# compiler to use.
If we have a CLI interpreter, then use that to run the
test program we build for determining the .NET library version.
(Previously, we just tried to execute the .exe directly and this
didn't work on non-Windows systems.)
Delete an unused variable.
# Copyright (C) 1999,2001-2004, 2006-2012 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.
#-----------------------------------------------------------------------------#
#
# aclocal.m4
#
# This file contains Mercury-specific autoconf tests.
#
# We ought to move most of the code in configure.in into this file...
#
#-----------------------------------------------------------------------------#
AC_DEFUN([MERCURY_CHECK_FOR_HEADERS],
[
for mercury_cv_header in $1; do
mercury_cv_header_define="MR_HAVE_`echo $mercury_cv_header | \
tr abcdefghijklmnopqrstuvwxyz./ ABCDEFGHIJKLMNOPQRSTUVWXYZ__`"
AC_CHECK_HEADER($mercury_cv_header, [
AC_DEFINE_UNQUOTED($mercury_cv_header_define)
eval "$mercury_cv_header_define=1"
])
done
])
#-----------------------------------------------------------------------------#
AC_DEFUN([MERCURY_CHECK_FOR_IEEEFP_H],
[
MERCURY_CHECK_FOR_HEADERS(ieeefp.h)
])
AC_DEFUN([MERCURY_CHECK_FOR_IEEE_FUNC],
[
AC_REQUIRE([MERCURY_CHECK_FOR_IEEEFP_H])
AC_MSG_CHECKING(for $1 function)
mercury_cv_ieee_func_define="MR_HAVE_`echo $1 | \
tr abcdefghijklmnopqrstuvwxyz./ ABCDEFGHIJKLMNOPQRSTUVWXYZ__`"
AC_TRY_LINK([
#include <math.h>
#ifdef MR_HAVE_IEEEFP_H
#include <ieeefp.h>
#endif
],[
float f;
$1(f);
],[mercury_cv_have_ieee_func=yes],[mercury_cv_have_ieee_func=no])
if test "$mercury_cv_have_ieee_func" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE_UNQUOTED($mercury_cv_ieee_func_define)
else
AC_MSG_RESULT(no)
fi
])
#-----------------------------------------------------------------------------#
# Test for C99 fp environment functions in the math library.
# The second argument to this macro should be the flags required by the
# C compiler to link against the math library. This is needed because
# some OSs, e.g. Mac OS X, don't have a separate math library.
AC_DEFUN([MERCURY_CHECK_FOR_FENV_FUNC],
[
AC_MSG_CHECKING(for $1 function)
mercury_cv_math_func_define="MR_HAVE_`echo $1 | \
tr abcdefghijklmnopqrstuvwxyz./ ABCDEFGHIJKLMNOPQRSTUVWXYZ__`"
save_libs="$LIBS"
LIBS="$2 $LIBS"
AC_TRY_LINK([
#ifdef MR_HAVE_FENV_H
#include <fenv.h>
#endif
],[
int i = 0;
$1(i);
],[mercury_cv_have_math_func=yes],[mercury_cv_have_math_func=no])
LIBS="$save_libs"
if test "$mercury_cv_have_math_func" = "yes"
then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED([$mercury_cv_math_func_define])
else
AC_MSG_RESULT([no])
fi
])
#-----------------------------------------------------------------------------#
#
# Turn off MacOS's so-called "smart" C preprocessor, if present,
# since it causes lots of spurious warning messages,
# and furthermore it takes way too long and uses way too much memory
# when preprocessing the C code generated by the Mercury compiler's LLDS
# back-end.
#
AC_DEFUN([MERCURY_CHECK_CC_NEEDS_TRAD_CPP],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether C compiler needs -no-cpp-precomp)
AC_CACHE_VAL(mercury_cv_cpp_precomp, [
>conftest.c
if test "$GCC" = yes &&
$CC -v -c conftest.c 2>&1 | \
grep "cpp-precomp.*-smart" > /dev/null
then
mercury_cv_cpp_precomp=yes
else
mercury_cv_cpp_precomp=no
fi
])
AC_MSG_RESULT($mercury_cv_cpp_precomp)
if test $mercury_cv_cpp_precomp = yes; then
CC="$CC -no-cpp-precomp"
fi
])
#-----------------------------------------------------------------------------#
#
# Check whether we need to add any extra directories to the search path for
# header files, and set ALL_LOCAL_C_INCL_DIRS to the -I option(s) needed
# for this, if any.
#
# GNU C normally searches /usr/local/include by default;
# to keep things consistent, we do the same for other C compilers.
#
AC_DEFUN([MERCURY_CHECK_LOCAL_C_INCL_DIRS],
[
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING(whether to pass -I/usr/local/include to C compiler)
ALL_LOCAL_C_INCL_DIRS=""
ALL_LOCAL_C_INCL_DIR_MMC_OPTS=""
if test "$GCC" = yes -o "$USING_MICROSOFT_CL_COMPILER" = yes; then
# Don't add -I/usr/local/include, since it causes a warning
# with gcc 3.1, and gcc already searches /usr/local/include.
# Microsoft compilers don't understand Unix pathnames.
AC_MSG_RESULT(no)
else
# It's some other compiler. We don't know if it searches
# /usr/local/include by default, so add it.
if test -d /usr/local/include/.; then
AC_MSG_RESULT(yes)
ALL_LOCAL_C_INCL_DIRS="-I/usr/local/include "
ALL_LOCAL_C_INCL_DIR_MMC_OPTS="--c-include-directory /usr/local/include "
else
AC_MSG_RESULT(no)
fi
fi
AC_SUBST(ALL_LOCAL_C_INCL_DIRS)
AC_SUBST(ALL_LOCAL_C_INCL_DIR_MMC_OPTS)
])
#-----------------------------------------------------------------------------#
#
# Set ALL_LOCAL_C_LIB_DIRS to any extra directories we need to add to the
# search path for libraries.
#
AC_DEFUN([MERCURY_CHECK_LOCAL_C_LIB_DIRS],
[
AC_MSG_CHECKING(whether to pass -L/usr/local/lib to the linker)
# Microsoft compilers don't understand Unix pathnames.
if test "$USING_MICROSOFT_CL_COMPILER" = no -a -d /usr/local/lib/.; then
AC_MSG_RESULT(yes)
ALL_LOCAL_C_LIB_DIRS=/usr/local/lib
ALL_LOCAL_C_LIB_DIR_MMC_OPTS="-L/usr/local/lib -R/usr/local/lib"
else
AC_MSG_RESULT(no)
ALL_LOCAL_C_LIB_DIRS=
ALL_LOCAL_C_LIB_DIR_MMC_OPTS=
fi
AC_SUBST(ALL_LOCAL_C_LIB_DIRS)
AC_SUBST(ALL_LOCAL_C_LIB_DIR_MMC_OPTS)
])
#-----------------------------------------------------------------------------#
#
# Check for readline and related header files and libraries
#
AC_DEFUN([MERCURY_CHECK_READLINE],
[
AC_ARG_WITH(readline,
[ --without-readline Don't use the GPL'd GNU readline library],
mercury_cv_with_readline="$withval", mercury_cv_with_readline=yes)
if test "$mercury_cv_with_readline" = yes; then
# check for the readline header files
MERCURY_CHECK_FOR_HEADERS(readline/readline.h readline/history.h)
# check for the libraries that readline depends on
MERCURY_MSG('looking for termcap or curses (needed by readline)...')
AC_CHECK_LIB(termcap, tgetent, mercury_cv_termcap_lib=-ltermcap,
[AC_CHECK_LIB(curses, tgetent, mercury_cv_termcap_lib=-lcurses,
[AC_CHECK_LIB(ncurses, tgetent, mercury_cv_termcap_lib=-lncurses,
mercury_cv_termcap_lib='')])])
# check for the readline library
AC_CHECK_LIB(readline, readline, mercury_cv_have_readline=yes,
mercury_cv_have_readline=no, $mercury_cv_termcap_lib)
else
mercury_cv_have_readline=no
fi
# Now figure out whether we can use readline, and define variables according.
# Note that on most systems, we don't actually need the header files in
# order to use readline. (Ain't C grand? ;-).
if test $mercury_cv_have_readline = no; then
TERMCAP_LIBRARY=""
READLINE_LIBRARIES=""
AC_DEFINE(MR_NO_USE_READLINE)
else
TERMCAP_LIBRARY="$mercury_cv_termcap_lib"
READLINE_LIBRARIES="-lreadline $TERMCAP_LIBRARY"
fi
AC_SUBST(TERMCAP_LIBRARY)
AC_SUBST(READLINE_LIBRARIES)
])
#-----------------------------------------------------------------------------#
#
# Microsoft.NET configuration
#
AC_DEFUN([MERCURY_CHECK_DOTNET],
[
AC_PATH_PROG([ILASM], [ilasm])
AC_PATH_PROG([GACUTIL], [gacutil])
AC_MSG_CHECKING([for Microsoft.NET Framework SDK])
AC_CACHE_VAL([mercury_cv_microsoft_dotnet], [
if test "$ILASM" != ""; then
changequote(<<,>>)
MS_DOTNET_SDK_DIR=`expr "$ILASM" : '\(.*\)[/\\]*[bB]in[/\\]*ilasm'`
changequote([,])
mercury_cv_microsoft_dotnet="yes"
else
MS_DOTNET_SDK_DIR=""
mercury_cv_microsoft_dotnet="no"
fi
])
AC_MSG_RESULT([$mercury_cv_microsoft_dotnet])
ILASM=`basename "$ILASM"`
GACUTIL=`basename "$GACUTIL"`
# Check for the C# (C sharp) compiler.
# mcs is the Mono C# compiler targetting all runtimes
# dmcs is the Mono C# compiler targeting the 4.0 runtime
# gmcs is the Mono C# compiler targeting the 2.0 runtime (with generics).
# cscc is the DotGNU C# compiler.
AC_PATH_PROGS([CANDIDATE_CSC], [csc mcs dmcs gmcs cscc])
CANDIDATE_CSC=`basename "$CANDIDATE_CSC"`
# The Microsoft C# compiler and the Chicken Scheme compiler share the same
# executable name so if we find an executable named csc above check that it is
# actually the Microsoft C# compiler and if it is not then try to use one of
# the other instead.
#
case "$CANDIDATE_CSC" in
csc*)
$CANDIDATE_CSC 2>&1 | grep -q "^Microsoft"
if test $? -ne 0
then
AC_MSG_WARN([$CANDIDATE_CSC is not the Microsoft C sharp compiler])
AC_PATH_PROGS([CSC], [mcs dmcs gmcs cscc])
CSC=`basename "$CSC"`
else
CSC="$CANDIDATE_CSC"
fi
;;
*)
CSC="$CANDIDATE_CSC"
;;
esac
case "$CSC" in
csc*)
CSHARP_COMPILER_TYPE=microsoft
;;
mcs*)
CSHARP_COMPILER_TYPE=mono
;;
dmcs*)
CSHARP_COMPILER_TYPE=mono
;;
gmcs*)
CSHARP_COMPILER_TYPE=mono
;;
*)
CSHARP_COMPILER_TYPE=unknown
;;
esac
# We default to the Beta 2 version of the library
mercury_cv_microsoft_dotnet_library_version=1.0.2411.0
if test $mercury_cv_microsoft_dotnet = "yes" &&
test "$CSC" != "";
then
AC_MSG_CHECKING([version of .NET libraries])
cat > conftest.cs << EOF
using System;
using System.Reflection;
public class version {
public static void Main()
{
Assembly asm = Assembly.Load("mscorlib");
AssemblyName name = asm.GetName();
Version version = name.Version;
Console.Write(version);
Console.Write("\n");
}
}
EOF
if
echo $CSC conftest.cs >&AC_FD_CC 2>&1 && \
$CSC conftest.cs >&AC_FD_CC 2>&1 && \
./conftest > conftest.out 2>&1
then
mercury_cv_microsoft_dotnet_library_version=`cat conftest.out`
AC_MSG_RESULT([$mercury_cv_microsoft_dotnet_library_version])
rm -f conftest*
else
rm -f conftest*
if test "$enable_dotnet_grades" = "yes"; then
AC_MSG_ERROR([unable to determine version])
exit 1
else
AC_MSG_WARN([unable to determine version])
fi
fi
fi
MS_DOTNET_LIBRARY_VERSION=$mercury_cv_microsoft_dotnet_library_version
# Check for the assembly linker.
# ilalink is the DotGNU assembly linker.
AC_PATH_PROGS([MS_AL], [al ilalink])
MS_AL=`basename "$MS_AL"`
# Check for an implementation of the Common Language Infrastructure.
AC_PATH_PROGS([CLI_INTERPRETER], [mono])
MONO=`basename "$CLI_INTERPRETER"`
AC_SUBST([ILASM])
AC_SUBST([GACUTIL])
AC_SUBST([CSC])
AC_SUBST([CSHARP_COMPILER_TYPE])
AC_SUBST([MS_AL])
AC_SUBST([MS_DOTNET_SDK_DIR])
AC_SUBST([MS_DOTNET_LIBRARY_VERSION])
AC_SUBST([MS_VISUALCPP_DIR])
AC_SUBST([CLI_INTERPRETER])
])
#-----------------------------------------------------------------------------#
#
# Java configuration
#
AC_DEFUN([MERCURY_CHECK_JAVA],
[
# jikes requires the usual Java SDK to run, so if we checked for javac first,
# then that's what we'd get. If the user has jikes installed, then that
# probably means that they want to use it, so we check for jikes before javac.
# On Windows, the Java SDK has a high chance of being installed in a path
# containing spaces. The simplest solution is to keep only the basename.
# Everything will still work so long as the executables can be found on the
# PATH later.
AC_PATH_PROGS(JAVAC, jikes javac gcj)
case "$JAVAC" in
*" "*)
JAVAC=`basename "$JAVAC"`
;;
esac
case "$JAVAC" in
*gcj)
JAVAC="$JAVAC -C"
;;
esac
AC_PATH_PROG(JAVA_INTERPRETER, java gij)
case "$JAVA_INTERPRETER" in
*" "*)
JAVA_INTERPRETER=`basename "$JAVA_INTERPRETER"`
;;
esac
AC_PATH_PROG(JAR, jar)
case "$JAR" in
*" "*)
JAR=`basename "$JAR"`
;;
esac
AC_CACHE_VAL(mercury_cv_java, [
if test "$JAVAC" != "" -a "$JAVA_INTERPRETER" != "" -a "$JAR" != ""; then
AC_MSG_CHECKING(if the above Java SDK works and is sufficiently recent)
cat > conftest.java << EOF
// This program simply retrieves the constant
// specifying the version number of the Java SDK and
// checks it is at least 1.5, printing "Hello, world"
// if successful.
public class conftest {
public static void main (String[[]] args) {
float version;
String strVer = System.getProperty(
"java.specification.version");
try {
version = Float.valueOf(strVer).floatValue();
}
catch (NumberFormatException e) {
System.out.println("ERROR: \"java." +
"specification.version\" " +
"constant has incorrect " +
"format.\nGot \"" + strVer +
"\", expected a number.");
version = 0f;
}
if (version >= 1.5f) {
System.out.println("Hello, world\n");
} else {
System.out.println("Nope, sorry.\n");
}
}
}
EOF
if
echo "$JAVAC" conftest.java >&AC_FD_CC 2>&1 &&
"$JAVAC" conftest.java >&AC_FD_CC 2>&1 &&
echo "$JAVA_INTERPRETER" conftest > conftest.out 2>&AC_FD_CC &&
CLASSPATH=. "$JAVA_INTERPRETER" conftest > conftest.out 2>&AC_FD_CC &&
test "`tr -d '\015' < conftest.out`" = "Hello, world"
then
mercury_cv_java="yes"
else
mercury_cv_java="no"
fi
AC_MSG_RESULT($mercury_cv_java)
else
if test "$JAVAC" = ""; then
JAVAC="javac"
fi
if test "$JAVA_INTERPRETER" = ""; then
JAVA_INTERPRETER="java"
fi
if test "$JAR" = ""; then
JAR="jar"
fi
mercury_cv_java="no"
fi
])
AC_SUBST(JAVAC)
AC_SUBST(JAVA_INTERPRETER)
AC_SUBST(JAR)
])
AC_DEFUN([MERCURY_CHECK_JAVAC_HEAP_SIZE],
[
# The default maximum heap size is too small to build the standard library and
# other programs so we need to increase it. The option to do that is
# non-standard so we have to check that it is accepted.
AC_CACHE_VAL([mercury_cv_javac_flags_for_heap_size], [
if test "$mercury_cv_java" = "yes"
then
AC_MSG_CHECKING([if the Java compiler accepts the max heap size option])
# There are two versions of this. The _test version is the one we test
# here. The second one, with the escaped quotes, is the one that gets
# included in the output files. The quotes are necessary in order for
# --restricted-command-line to work with the Java backend.
mercury_cv_javac_flags_for_heap_size_test="-J-Xmx256m"
mercury_cv_javac_flags_for_heap_size="-J\"-Xmx1024m\""
if "$JAVAC" "$mercury_cv_javac_flags_for_heap_size_test" -version \
2> /dev/null
then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
mercury_cv_javac_flags_for_heap_size=
fi
else
mercury_cv_javac_flags_for_heap_size=
fi
])
])
#-----------------------------------------------------------------------------#
#
# Erlang configuration
#
# copy of AC_ERLANG_PATH_ERLC from autoconf-2.60
AC_DEFUN([MERCURY_ERLANG_PATH_ERLC],
[AC_ARG_VAR([ERLC], [Erlang/OTP compiler command [autodetected]])dnl
if test -n "$ERLC"; then
AC_MSG_CHECKING([for erlc])
AC_MSG_RESULT([$ERLC])
else
AC_PATH_TOOL(ERLC, erlc, [$1], [$2])
fi
AC_ARG_VAR([ERLCFLAGS], [Erlang/OTP compiler flags [none]])dnl
])
# copy of AC_ERLANG_PATH_ERL from autoconf-2.60
AC_DEFUN([MERCURY_ERLANG_PATH_ERL],
[AC_ARG_VAR([ERL], [Erlang/OTP interpreter command [autodetected]])dnl
if test -n "$ERL"; then
AC_MSG_CHECKING([for erl])
AC_MSG_RESULT([$ERL])
else
AC_PATH_TOOL(ERL, erl, [$1], [$2])[]dnl
fi
])
AC_DEFUN([MERCURY_CHECK_ERLANG],
[
MERCURY_ERLANG_PATH_ERLC
MERCURY_ERLANG_PATH_ERL
if test "$ERLC" != "" -a "$ERL" != ""; then
mercury_cv_erlang="yes"
else
mercury_cv_erlang="no"
fi
AC_SUBST(ERLC)
AC_SUBST(ERL)
])
#-----------------------------------------------------------------------------#
# NOTE: updates to this macro may need to be reflected in compiler/globals.m.
# Generating an executable and running it does not work when cross-compiling.
AC_DEFUN([MERCURY_GCC_VERSION], [
AC_REQUIRE([AC_PROG_CC])
mercury_cv_gcc_version=`$CC -dumpversion | tr . ' ' | {
read major minor patchlevel ignore
echo ${major:-u}_${minor:-u}_${patchlevel:-u}
}`
])
#-----------------------------------------------------------------------------#
# Work out the C compiler type using a stronger test than AC_PROG_CC to
# distinguish between clang and gcc.
# (We don't handle lcc here - I don't think that it's possible to.)
AC_DEFUN([MERCURY_CC_TYPE], [
AC_REQUIRE([AC_PROG_CC])
AC_MSG_CHECKING([what the C compiler type really is])
# MSVC uses different command line options to most other C compilers.
# Try to determine whether CC is MSVC based on the usage message.
#
$CC 2>&1 | grep -q "^Microsoft"
if test $? -eq 0
then
cc_out_opt="-Fe"
nologo_opt="-nologo"
else
cc_out_opt="-o "
nologo_opt=
fi
cat > conftest.c << EOF
#include <stdio.h>
int main(int argc, char **argv)
{
#if defined(__clang__)
printf("clang");
#elif defined(__GNUC__)
printf("gcc");
#elif defined(_MSC_VER)
printf("msvc");
#else
printf("unknown");
#endif
return 0;
}
EOF
echo "$CC $nologo_opt ${cc_out_opt}conftest conftest.c" >&AC_FD_CC 2>&1
if
# We direct the output to /dev/null because it's appears to be the
# only way to shut some C compilers up.
$CC $nologo_opt ${cc_out_opt}conftest conftest.c 2>&1 > /dev/null
then
AC_CACHE_VAL(mercury_cv_cc_type,
mercury_cv_cc_type=`./conftest`)
else
# This shouldn't happen as we have already checked for this.
AC_MSG_ERROR([unexpected: $CC cannot create executable])
fi
AC_MSG_RESULT([$mercury_cv_cc_type])
])
#-----------------------------------------------------------------------------#
AC_DEFUN([MERCURY_CLANG_VERSION], [
AC_REQUIRE([AC_PROG_CC])
cat > conftest.c << EOF
#include <stdio.h>
int main(int argc, char **argv)
{
printf("%d_%d_%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
return 0;
}
EOF
echo "$CC -o conftest contest.c" >&AC_FD_CC 2>&1
if
$CC -o conftest conftest.c
then
mercury_cv_clang_version=`./conftest`
else
# This shouldn't happen as we have already checked for this.
AC_MSG_ERROR([unexpected: $CC cannot create executable])
fi
])
#-----------------------------------------------------------------------------#
AC_DEFUN([MERCURY_MSVC_VERSION], [
AC_REQUIRE([AC_PROG_CC])
cat > conftest.c << EOF
#include <stdio.h>
int main(int argc, char **argv)
{
printf("%d", _MSC_VER);
return 0;
}
EOF
echo "$CC conftest.c -Fecontest" >&AC_FD_CC 2>&1
if
$CC conftest.c -Feconftest > /dev/null
then
mercury_cv_msvc_version=`./conftest`
else
# This shouldn't happen as we have already checked for this.
AC_MSG_ERROR([unexpected: $CC cannot create executable])
fi
])
#-----------------------------------------------------------------------------#
#
# Check if the POSIX threads library is pthreads-win32.
#
AC_DEFUN([MERCURY_HAVE_PTHREADS_WIN32], [
AC_MSG_CHECKING([if we are using pthreads-win32])
cat > conftest.c << EOF
#include <pthread.h>
#include <stdio.h>
int main(int argc, char **argv)
{
#if defined(PTW32_VERSION)
return 0;
#else
return 1;
#endif
}
EOF
echo "$CC -o conftest contest.c" >&AC_FD_CC 2>&1
if
$CC -o conftest conftest.c
then
mercury_cv_have_pthreads_win32="yes"
else
mercury_cv_have_pthreads_win32="no"
fi
AC_MSG_RESULT($mercury_cv_have_pthreads_win32)
])
#-----------------------------------------------------------------------------#
Branches: main, 11.07
Fix the rest of #255: the executable name of the the MS C# compiler clashes
with that of the Chicken Scheme compiler. This was leading to configure
incorrectly assuming the presence of the former when the latter was present.
The remainder of bug #255 relates to the configure script not building on
Mac OS X 10.4 -- I suspect the version of autoconf shipped with that system
is too ancient; I don't intend to do anything about it. (This only applies
to generating the configure script. The script itself, as provided in the
source distribution, should still run.)
m4/mercury.m4:
Do not assume that the presence of an executable named csc indicates
the presence of the MS C# compiler. If csc is not the MS C# compiler,
then attempt to use one of the others.
Quote autoconf macro arguments in the Mercury's .NET configuration
tests as recommended by the autoconf manual.
Estimated hours taken: 4
Branches: main, 11.07
The Microsoft C# compiler only accepts paths in the Windows format, so
add code to format file names depending on which host environment we are
compiling and which C# compiler we are using.
compiler/compile_target_code.m:
Convert to file names to use windows paths when required.
compiler/globals.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
doc/user_guide.texi:
m4/mercury.m4:
scripts/Mercury.config.in:
Add code to determine the C# compiler type and pass it to the compiler.
library/Mmakefile:
We no longer need to detect if we are using csc as the compiler
will fix the posix path as part of mmc --make.
Branches: main
Let Mercury be built with a MinGW cross-compiler.
tools/configure_mingw_cross:
Add shell script to prepare for cross-compilation.
README.MinGW-cross:
Document how to use the shell script.
configure.in:
Mmake.common.in:
Set a new variable CROSS_COMPILING.
Set FULLARCH and BUILD_C_PROGS_FOR_BUILD_SYSTEM variables
to be passed to the Boehm GC build system.
Use $host-ar for AR when cross-compiling.
m4/mercury.m4:
Determine gcc version with gcc -dumpversion instead of building
a program and running it.
Don't run test for mercury_cv_cc_type if set explicitly.
Mmake.workspace:
Use the default c2init and mkinit when cross-compiling.
The copies in the util directory would not be usable then.
boehm_gc/Mmakefile:
Pass configured values of AR, RANLIB down to sub-make.
boehm_gc/Makefile.direct:
boehm_gc/build_atomic_ops.sh:
Use configured value from Mmake.common for HOSTCC.
Pass --host when configuring libatomic_ops.
util/Mmakefile:
Make tools with .exe suffixes on Windows.
Mmakefile:
Use the bootstrap compiler to build libgrades when cross-compiling.
Conform to changed target names in the util directory.
compiler/Mmakefile:
deep_profiler/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
Conform to changed target names in the util directory.
Makefile:
Clean .exe files on Windows.
Branches: main, 11.07
Fix compilation of the java grade on Mac OS X (and probably other things).
m4/mercury.m4:
When testing whether the Java compiler (actually runtime) supports
modifying the heap size, don't use the version with the quoted
runtime argument in the test in the configure script.
Branches: main, 11.07
Fix bug #235: support the --restricted-command-line option with the Java
backend. Its use is necessary on Windows when building the compiler in the
Java grade since otherwise we exceed the command line length limit.
(Building other large programs would presumably be similarly affected.)
compiler/compile_target_code.m:
Optionally allow the use of @ files when compiling .java ->
.class files.
m4/mercury.m4:
compiler/Mmakefile:
We need to quote the argument to the -J option, otherwise
it cannot be read from an @ file.
reviews.
The configure script now supports the --without-hwloc option to disable the use
of hwloc, even if it is installed.
configure.in:
Allow the use of libhwloc to be disabled with the --without-hwloc option.
Distribute the autoconf macros for pkg-config with Mercury.
This allows mercury to be compiled from CVS on hosts that don't have these
macros in their autoconf installation.
acinclude.m4:
m4/mercury.m4:
Moved acinclude.m4 to m4/mercury.m4. This file contains mercury-specific
macros.
m4/pkg.m4:
Copied pkg.m4 from the autoconf installation on taura. This file contains
pkg-config macros.
INSTALL_CVS:
Mmakefile:
tools/test_mercury:
When calling aclocal pass the -I m4 option.
tools/bootcheck:
Create a link to the m4 directory when setting up stage directories.
Fix static linking with mmc --make and hwloc.
compiler/compile_target_code.m:
Conform to changes in scripts/ml.in (where static linking and hwloc is
already handled correctly).
compiler/options.m:
Create new options so that Mercury.config can tell mmc what options are
needed for linking to hwloc.
scripts/Mercury.config:
Pass hwloc linking options to the compiler.