[m-rev.] diff: auto-detect --traditional-cpp in configure

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Oct 3 13:23:58 AEST 2002


Estimated hours taken: 1
Branches: main

Some more changes for MacOS.

aclocal.m4:
	Define a macro MERCURY_CHECK_CC_NEEDS_CPP_PRECOMP,
	to check whether we need to append `-traditional-cpp' to $CC.

configure.in:
bindist/bindist.configure.in:
	Use the new macro.

README.MacOS:
	Update the documentation: users don't need to configure using
	`--with-cc="cc --traditional-cpp"' any more.

Index: README.MacOS
===================================================================
RCS file: /home/mercury1/repository/mercury/README.MacOS,v
retrieving revision 1.1
diff -u -d -r1.1 README.MacOS
--- README.MacOS	11 Sep 2002 14:29:00 -0000	1.1
+++ README.MacOS	3 Oct 2002 02:57:00 -0000
@@ -4,16 +4,16 @@
 The version of tar in /usr/bin/tar on MacOS (10.1) doesn't work properly --
 it truncates long path names.  Make sure you use GNU tar, which is available
 in /sw/bin/gtar, when unpacking the Mercury source or binary distributions.
+(Also, make sure to use GNU tar if/when *building* such distributions!)
 
 Apple's version of gcc includes support for precompiled headers.
 Unfortunately this support seems to be somewhat buggy, causing it
 to sometimes crash with mysterious errors when building Mercury.
 Furthermore, for the kinds of C code that the Mercury compiler generates,
 it results in a very big slow-down, rather than any speedup.
-So you should use `--traditional-cpp' to disable the use of the
-new ``smart'' [sic] preprocessor.  Configure with
-
-	sh configure --with-cc="cc --traditional-cpp"
+Fortunately this can be disabled by using the --traditional-cpp option.
+The Mercury configure script should enable this option automatically
+if it is needed.
 
 The configure script will by default choose grade reg.gc.
 You can get better performance by using the hlc.gc grade.
Index: aclocal.m4
===================================================================
RCS file: /home/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.10
diff -u -d -r1.10 aclocal.m4
--- aclocal.m4	7 Mar 2002 17:14:21 -0000	1.10
+++ aclocal.m4	3 Oct 2002 02:57:00 -0000
@@ -13,6 +13,34 @@
 #
 #-----------------------------------------------------------------------------#
 #
+# 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 need --traditional-cpp)
+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 --traditional-cpp"
+fi
+])
+#-----------------------------------------------------------------------------#
+#
 # Check for readline and related header files and libraries
 #
 AC_DEFUN(MERCURY_CHECK_READLINE,
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.319
diff -u -d -r1.319 configure.in
--- configure.in	15 Sep 2002 10:05:53 -0000	1.319
+++ configure.in	3 Oct 2002 02:57:01 -0000
@@ -339,6 +339,7 @@
 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.
Index: bindist/bindist.configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/bindist.configure.in,v
retrieving revision 1.39
diff -u -d -r1.39 bindist.configure.in
--- bindist/bindist.configure.in	8 Sep 2002 17:38:38 -0000	1.39
+++ bindist/bindist.configure.in	3 Oct 2002 02:57:01 -0000
@@ -204,6 +204,7 @@
 AC_SUBST(AS)
 #-----------------------------------------------------------------------------#
 AC_PROG_CC
+MERCURY_CHECK_CC_NEEDS_TRAD_CPP
 AC_SUBST(CC)
 #-----------------------------------------------------------------------------#
 # Microsoft.NET configuration (the bindist may be installed on a machine

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list