[Mono-list] Autoconf macros to correctly detect Mono C# mcs
Peter Ross
pro@missioncriticalit.com
Tue, 2 Dec 2003 15:21:10 +0100
--SLDf9lqlvOQaIe6s
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, 2003-11-26 at 22:32, William S Fulton wrote:
> We need to detect whether C# is installed on Unix systems and are
> using a simple autoconf macro to look for mcs. Unfortunately there
> is another program called mcs and so it incorrectly detects mcs.
> Does anyone know of any better autoconf macros to detect whether mcs
> installed and whether or not it is a working C# compiler?
Find attached the code we have in the Mercury compiler to detect whether
one has a recent enough version of the compiler to bootstrap the
compiler.
--SLDf9lqlvOQaIe6s
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=XXX
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 $BOOTSTRAP_MC 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 int.
main(!IO) :-
return_rtti_version(Version),
(
Version >= 8,
ac(2) ^ elem(3, 5) = 17
->
io.print("Hello, world\n", !IO)
;
io.print("Nope.\n", !IO)
).
:- 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_proc("C", return_rtti_version(Version::out),
[[will_not_call_mercury, promise_pure]], "
Version = MR_RTTI_VERSION;
").
EOF
if
# Test for the `--read-config-file-2003-03-01' option
echo $BOOTSTRAP_MC conftest >&AC_FD_CC 2>&1 &&
$BOOTSTRAP_MC \
--verbose \
--read-config-file-2003-03-01 \
--halt-at-warn $link_static_opt conftest \
</dev/null >&AC_FD_CC 2>&1 &&
test "`./conftest 2>&1 | tr -d '\015'`" = "Hello, world"
then
AC_MSG_RESULT(yes)
else
BOOTSTRAP_MC=
AC_MSG_RESULT(no)
fi
rm -f conftest*
fi
--SLDf9lqlvOQaIe6s--