[m-rev.] for review: configure.in improvements

Simon Taylor stayl at cs.mu.OZ.AU
Sat Nov 16 02:30:49 AEDT 2002


On 15-Nov-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Hi Simon,
> 
> The following is an extract from configure.log from logs/test-0.11-hg-asm.out.
> 
>  | checking whether to enable the GCC back-end interface... configure: error: --enable-gcc-back-end requires an already installed Mercury compiler.
>  | + mmake --target asm depend
>  | /tmp/mmake.9VRhaL:765: scripts/Mmake.vars: No such file or directory
>  | /tmp/mmake.9VRhaL:770: Mmake.common: No such file or directory

> As you can see, configure detects that an already installed Mercury compiler
> is required but not present, and issues an error message.
> (The error message would be clearer if it started on a new line.)
> 
> However, after doing this, it goes on and runs `mmake --target asm depend' --
> a dangerous step since `mmake' might not be in the PATH.

The `mmake --target asm depend' is run by test_mercury.
I'll change configure.in to use scripts/mmake.

> This step doesn't work for a different reason: the files that `mmake depend'
> needs have not yet been created.  I'm not sure if this is a consequence
> of the earlier error or whether the files won't get created yet even if
> AC_MSG_ERROR() wasn't called.
> This then leads to some spurious flow-on errors.

AC_MSG_ERROR causes configure to exit, but not with the correct
exit status due to bugs in the code to redirect the output of
configure to configure.log. 
 
> Several points:
> 	- Could you please add a newline to the error message?

I can change it to something like:

checking whether to enable the GCC back-end interface... configure: error:
-enable-gcc-back-end requires an already installed Mercury compiler.

The "configure: error:" part is generated by AC_MSG_ERROR.

> 	- `mmake depend' should not be invoked in cases like the one above.
> 	  Could you please fix this?

Done.

Simon.


Estimated hours taken: 1
Branches: main, release

configure.in:
	Return the correct exit status. The code to redirect
	output to a log file was causing configure to
	always return success.

	Add newlines in error messages to prevent different
	messages running together.

	Fix instances of `AC_MSG_ERROR(...); AC_MSG_ERROR'.
	The first one will call `exit' so the second message
	will never be printed.
	
	Don't quote the argument of AC_MSG_ERROR -- it
	ends up quoted twice in the configure script.

	Use scripts/mmake rather than whatever is in the
	path when regenerating dependencies.


Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.338
diff -u -u -r1.338 configure.in
--- configure.in	7 Nov 2002 16:12:19 -0000	1.338
+++ configure.in	15 Nov 2002 15:19:15 -0000
@@ -33,11 +33,12 @@
 	SUPPRESS_LOG_FILE_RECURSION=yes
 	export SUPPRESS_LOG_FILE_RECURSION
 	trap 0 1 2 3 13 15
-	case $# in
-		0) exec ${CONFIG_SHELL-/bin/sh} "$0"      ;;
-		*) exec ${CONFIG_SHELL-/bin/sh} "$0" "$@" ;;
-	esac | exec tee configure.log
-	exit
+	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
+	exit `cat configure.exit_status`
 fi
 #-----------------------------------------------------------------------------#
 remake_dependencies=false
@@ -185,8 +186,9 @@
 		if test -f "$gcc_src_dir"/gcc/tree.c; then
 			enable_gcc_back_end=yes
 		else
-			AC_MSG_ERROR(--enable-gcc-back-end=$gcc_src_dir specified,)
-			AC_MSG_ERROR(but GCC source code not found in $gcc_src_dir)
+			AC_MSG_ERROR([
+--enable-gcc-back-end=$gcc_src_dir specified,
+but GCC source code not found in $gcc_src_dir])
 			exit 1
 		fi		
 		;;
@@ -198,8 +200,8 @@
 		if test "$gcc_src_dir" = not_found; then
 			case $enable_gcc_back_end in
 				yes)
-					AC_MSG_ERROR(--enable-gcc-back-end specified,)
-					AC_MSG_ERROR(but gcc source code not found)
+					AC_MSG_ERROR([
+--enable-gcc-back-end specified, but gcc source code not found])
 					exit 1
 					;;
 				default)
@@ -216,8 +218,9 @@
 case $enable_gcc_back_end in
 	yes)
 		if test "$BOOTSTRAP_MC" = ""; then
-			AC_MSG_ERROR(--enable-gcc-back-end requires an already installed Mercury compiler.)
-			enable_gcc_back_end=no
+			AC_MSG_ERROR([
+--enable-gcc-back-end requires an already installed Mercury compiler])
+			exit 1
 		else
 			# This will regenerate compiler/maybe_mlds_to_gcc.m.
 			remake_dependencies=true
@@ -242,7 +245,8 @@
 case $enable_aditi_back_end in
 	no)
 		if test "$BOOTSTRAP_MC" = ""; then
-			AC_MSG_WARN(--disable-aditi-back-end requires an already installed Mercury compiler.)
+			AC_MSG_WARN([
+--disable-aditi-back-end requires an already installed Mercury compiler])
 			enable_aditi_back_end=yes
 		else
 			# This will regenerate compiler/rl_out.m and
@@ -304,7 +308,8 @@
 	fi
 fi
 if test "$MKFIFO" = ""; then
-	AC_MSG_WARN(cannot find a working \`mkfifo' or \`mknod')
+	AC_MSG_WARN([
+cannot find a working \`mkfifo' or \`mknod'])
 	MKFIFO=none
 	AC_DEFINE_UNQUOTED(MR_MKFIFO, "")
 else
@@ -328,7 +333,8 @@
 	esac
 fi
 if test "$MKTEMP" = ""; then
-	AC_MSG_WARN(cannot find a working \`mktemp', using \`mkdir || exit'')
+	AC_MSG_WARN([
+cannot find a working \`mktemp', using \`mkdir || exit''])
 	MKTEMP=""
 fi
 AC_SUBST(MKTEMP)
@@ -990,7 +996,7 @@
 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.")
+	AC_MSG_ERROR(Cannot determine the length modifier for the MR_Integer type.)
 fi
 AC_SUBST(MR_INTEGER_LENGTH_MODIFIER)
 
@@ -1103,7 +1109,7 @@
 	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.")
+	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)
@@ -1153,7 +1159,7 @@
 	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.")
+	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)
@@ -1196,7 +1202,7 @@
 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")
+		AC_MSG_ERROR(cannot bootstrap: low tag bits less than 2)
 		exit 1
 	fi
 fi
@@ -1869,7 +1875,8 @@
 
 		if test $mercury_cv_can_enable_deep_profiler = no; then
 			echo
-			AC_MSG_ERROR(--enable-deep-profiler specified but system does not support it)
+			AC_MSG_ERROR([
+--enable-deep-profiler specified but system does not support it])
 			exit 1
 		fi
 
@@ -1882,7 +1889,8 @@
 		true
 	else
 		echo
-		AC_MSG_ERROR(CGI script directory $mercury_cv_cgi_dir does not exist)
+		AC_MSG_ERROR([
+CGI script directory $mercury_cv_cgi_dir does not exist])
 		exit 1
 	fi		
 fi
@@ -3047,8 +3055,8 @@
 		AC_DEFINE(MR_USE_EXTERNAL_DEBUGGER)
 	else
 		AC_MSG_RESULT(no)
-		AC_MSG_ERROR(Cannot enable external debugger)
-		AC_MSG_ERROR(because sockets do not work)
+		AC_MSG_ERROR([
+Cannot enable external debugger because sockets do not work])
 	fi		
 else
 	AC_MSG_RESULT(no)
@@ -3196,11 +3204,7 @@
 	MERCURY_MSG("regenerating dependencies to enable GCC backend")
 	MERCURY_MSG("and/or disable Aditi backend.")
 
-	mmake depend
-	status=$?
-	if test $status != 0; then
-		exit $status
-	fi
+	MMAKE_DIR=`pwd`/scripts scripts/mmake depend || exit 1
 	;;
 esac
 #-----------------------------------------------------------------------------#
--------------------------------------------------------------------------
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