[m-rev.] for review: reconfiguration

Simon Taylor stayl at cs.mu.OZ.AU
Fri Jan 3 16:20:11 AEDT 2003


Estimated hours taken: 30
Branches: main

Allow reconfiguration of existing installations, for example
to use a different C compiler. The reconfiguration works
by making a new copy of the scripts and mercury_conf.h,
and storing them in a partial installation directory tree
which uses the libraries and executables from the existing
installation.

Use this method to configure binary distributions, rather
than using a cut down version of the configuration script,
to avoid code duplication and to handle the case where the 
C compiler in use on the installation machine is different
than that used to build the binary distribution.

This is more robust than the previous method of using a different
C compiler, which was to set the MERCURY_C_COMPILER and hope
the different C compilers were compatible enough.

Mmakefile:
runtime/Mmakefile:
scripts/Mmakefile:
	Modify the `install' targets to store files needed to create
	a new configuration in $INSTALL_LIBDIR/reconf.

runtime/Mmakefile:
	Install mercury_conf.h in $INSTALL_LIBDIR/conf, rather than
	$INSTALL_LIBDIR/inc, so that it can be overridden by a
	different configuration.

scripts/mercury_config.in:
	Create a new configuration, by creating part of a Mercury
	source tree from the files stored in $INSTALL_LIBDIR/reconf,
	running configure, then copying the files into a partial
	installation tree. 

scripts/Mmake.vars.in:
	Define ENABLE_DEEP_PROFILER, for use by bindist/bindist.Makefile.	

	Define variables INSTALL_CONF_DIR (contains the files describing
	the configuration) and INSTALL_RECONF_DIR (contains files needed
	to reconfigure an installation).

configure.in:
	Add an option `--enable-reconfigure', for use by
	mercury_config.in.

	Don't look for runtime/mercury_wrapper.c when checking
	for the sources -- it isn't present when reconfiguring.
	Look for scripts/mmc.in instead.

	Look for the runtime headers in the installation hierarchy
	rather than the `runtime/' and `trace/' directories when
	reconfiguring.

	Output the help message for the `configure' script to
	`configure.help'.  This is included in the help message
	for `mercury_config'.

	Add new configuration variables CONFIG_PREFIX and CONFIG_LIBDIR,
	which are like PREFIX and LIBDIR except that they point
	to the configuration files, not the library files.
	In the normal case PREFIX and CONFIG_PREFIX will be the same.

bindist/bindist.INSTALL.in:
bindist/bindist.Makefile.in:
	Use mercury_config to configure binary distributions.

bindist/Mmakefile:
bindist/bindist.configure.in:
bindist/bindist.build_vars.in:
	Remove bindist.configure.in and bindist.build_vars.in.

compiler/options.m:
scripts/parse_ml_options.sh-subr.in:
scripts/mgnuc.in:
doc/user_guide.texi:
	Add an option `--mercury-config-dir', and an environment
	variable MERCURY_CONFIG_DIR, which tell the compiler and
	scripts where to find the configuration files for the
	installation.
	MERCURY_CONFIG_DIR is not documented because it should
	only be used by the scripts.

compiler/compile_target_code.m:
	Pass `--mercury-config-dir' to the scripts.

compiler/handle_options.m:
	Add `--c-include-directory $MERCURY_CONFIG_DIR/conf'.

library/getopt.m:
	Handle `maybe_string_special' options.

doc/user_guide.texi:
	Update the "Using a different C compiler" chapter.

NEWS:
	Document the changes.

Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.94
diff -u -u -r1.94 Mmakefile
--- Mmakefile	2 Jan 2003 06:53:51 -0000	1.94
+++ Mmakefile	2 Jan 2003 07:01:12 -0000
@@ -307,9 +307,9 @@
 	+cd deep_profiler && $(SUBDIR_MMAKE) depend
 	+cd deep_profiler && $(SUBDIR_MMAKE) cs tags
 	+cd doc && $(SUBDIR_MMAKE) info html dvi mdb_doc
-	+cd bindist && $(SUBDIR_MMAKE) bindist.configure
-	# the following command might fail on Windows?
-	-cd bindist && $(SUBDIR_MMAKE) bindist.build_vars
+	# the following commands might fail on Windows?
+	-cd bindist && $(SUBDIR_MMAKE) bindist.Makefile
+	-cd bindist && $(SUBDIR_MMAKE) bindist.INSTALL
 	+cd extras/dynamic_linking && $(SUBSUBDIR_MMAKE) sources
 	# clean up
 	cd scripts && mmake realclean
@@ -400,7 +400,7 @@
 		install_scripts install_util install_runtime install_boehm_gc \
   		install_library install_browser install_trace \
 		install_compiler install_profiler install_deep_profiler \
-		install_doc 
+		install_doc install_config
  
 .PHONY: install_scripts
 install_scripts: scripts
@@ -410,6 +410,11 @@
 install_util: util
 	+cd util && $(SUBDIR_MMAKE) install
 
+.PHONY: install_config
+install_config:
+	cp VERSION aclocal.m4 configure configure.in config.guess \
+		config.sub install-sh $(INSTALL_RECONF_DIR)
+
 .PHONY: install_runtime
 install_runtime: runtime
 	+cd runtime && $(SUBDIR_MMAKE) install
@@ -602,7 +607,8 @@
 
 .PHONY : bindist
 bindist: WORK_IN_PROGRESS TODO
-	cd bindist; mmake binary_distribution
+	cd bindist; \
+		PATH="$(INSTALL_PREFIX)/bin:$$PATH" mmake binary_distribution
 
 #-----------------------------------------------------------------------------#
 
@@ -642,7 +648,7 @@
 
 .PHONY: realclean_config
 realclean_config:
-	rm -f config.cache config.status config.log configure.log
+	rm -f config.cache config.status config.log configure.log configure.help
 
 .PHONY: realclean_tests
 realclean_tests:
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.291
diff -u -u -r1.291 NEWS
--- NEWS	5 Dec 2002 03:52:27 -0000	1.291
+++ NEWS	3 Jan 2003 04:48:12 -0000
@@ -1,5 +1,5 @@
-NEWS for Mercury release 0.12:
-------------------------------
+NEWS since Mercury release 0.11.0:
+----------------------------------
 
 HIGHLIGHTS
 ==========
@@ -10,6 +10,9 @@
 Changes to the Mercury compiler:
 * Nothing yet.
 
+Changes to the Mercury standard library:
+* Nothing yet.
+
 Portability improvements:
 * Nothing yet.
 
@@ -38,6 +41,8 @@
   `is_nan_or_inf/1' to float.m.  These predicates are for use only on
   systems which support IEEE floating point arithmetic.
 
+* getopt.m now accepts a `maybe_string_special' option type.
+
 * The determinisms of the following predicates in the `std_util'
   module have been changed from cc_nondet to cc_multi: arg_cc/3,
   argument_cc/3 and limited_deconstruct_cc/3 (formerly
@@ -56,7 +61,9 @@
 
 Changes to the Mercury compiler:
 
-* Nothing yet.
+* It is now possible to reconfigure an existing Mercury installation
+  to use a different C compiler.  See the "C compilers" chapter
+  of the Mercury User's Guide for details.
 
 Portability improvements:
 
Index: aclocal.m4
===================================================================
RCS file: /home/mercury1/repository/mercury/aclocal.m4,v
retrieving revision 1.16
diff -u -u -r1.16 aclocal.m4
--- aclocal.m4	25 Nov 2002 11:53:16 -0000	1.16
+++ aclocal.m4	3 Dec 2002 15:43:58 -0000
@@ -8,8 +8,7 @@
 #
 # This file contains Mercury-specific autoconf tests.
 #
-# We ought to move most of the code in configure.in and
-# bindist/bindist.configure.in into this file...
+# We ought to move most of the code in configure.in into this file...
 #
 #-----------------------------------------------------------------------------#
 AC_DEFUN(MERCURY_CHECK_FOR_HEADERS,
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.345
diff -u -u -r1.345 configure.in
--- configure.in	2 Jan 2003 06:53:51 -0000	1.345
+++ configure.in	3 Jan 2003 04:54:04 -0000
@@ -9,14 +9,6 @@
 # This file is automatically processed by `autoconf' to produce the
 # `configure' script.
 #
-# IMPORTANT NOTE: any changes here will usually also require changes in
-# bindist/bindist.configure.in and/or bindist/bindist.build_vars.in.
-#
-# XXX Much of the code here is duplicated in bindist/bindist.configure.in.
-#     We should abstract it out into macros defined in aclocal.m4,
-#     so that the same code can be shared between both this file and
-#     bindist/bindist.configure.in.
-#
 #-----------------------------------------------------------------------------#
 #
 # Define a macro MERCURY_MSG, similar to AC_MSG_RESULT, for displaying output.
@@ -25,7 +17,7 @@
 define(MERCURY_MSG,
 [echo $1 1>&AC_FD_MSG])
 #-----------------------------------------------------------------------------#
-AC_INIT(runtime/mercury_wrapper.c)
+AC_INIT(scripts/mmc.in)
 TMPDIR=${TMPDIR=/tmp}
 #-----------------------------------------------------------------------------#
 #
@@ -43,8 +35,11 @@
 		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`
+	status=`cat configure.exit_status`
+	rm -f configure.exit_status
+	exit $status
 fi
+
 #-----------------------------------------------------------------------------#
 remake_dependencies=false
 AC_CONFIG_HEADER(runtime/mercury_conf.h)
@@ -72,6 +67,7 @@
 LIBDIR="$PREFIX/lib/mercury"
 WINDOWS_LIBDIR="`cygpath -w $LIBDIR 2>/dev/null`"
 NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=$PREFIX/lib/nonshared}
+AC_SUBST(VERSION)
 AC_SUBST(PREFIX)
 AC_SUBST(NONSHARED_LIB_DIR)
 AC_SUBST(LIBDIR)
@@ -88,6 +84,65 @@
 		;;
 esac
 #-----------------------------------------------------------------------------#
+# 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.
+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)
+#-----------------------------------------------------------------------------#
+
+# 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
+AC_SUBST(CONFIG_PREFIX)
+AC_SUBST(CONFIG_LIBDIR)
+#-----------------------------------------------------------------------------#
 
 case "$host" in 
 	i386-pc-solaris2.8)	link_static_opt= ;;
@@ -401,7 +456,16 @@
 
 # we also need to add the appropriate `-I' options so that the test programs
 # can #include various Mercury runtime headers.
-CPPFLAGS="-Iruntime -Iruntime/machdeps $CPPFLAGS"
+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
 
 # Make sure we search /usr/local/include and /usr/local/lib for
 # header files and libraries.  GNU C normally searches /usr/local/include
@@ -2542,7 +2606,7 @@
 #define	MR_USE_GCC_GLOBAL_REGISTERS
 #define MR_USE_GCC_NONLOCAL_GOTOS
 #include "mercury_imp.h"
-#include "trace/mercury_trace_spy.h"
+#include "mercury_trace_spy.h"
 
 MR_Spy_Point	spied_procs[2];
 
@@ -2849,6 +2913,12 @@
 AC_SUBST_FILE(PARSE_ML_OPTIONS)
 AC_SUBST_FILE(CANONICAL_GRADE)
 
+# 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.
@@ -3244,33 +3314,44 @@
     rm -f confscratch $to_delete
 fi
 #-----------------------------------------------------------------------------#
-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/mkfifo_using_mknod bindist/bindist.build_vars
+
+# Any new entries here may need to be handled by scripts/mercury_config.
+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/mkfifo_using_mknod bindist/bindist.INSTALL bindist/bindist.Makefile
+scripts/mercury_config
 ,
-for header in $CONFIG_HEADERS ; do
-	if test "$header" = "runtime/mercury_conf.h"; then
-		touch runtime/mercury_conf.h.date
-	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_browse.so
+[
+# 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
+			touch runtime/mercury_conf.h.date
+		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_browse.so
+	;;
+esac],
+[reconfiguring=$reconfiguring]
 )
 
-case $remake_dependencies in true)
+case "$remake_dependencies.$reconfiguring" in "true.no")
 	MERCURY_MSG(
 "regenerating dependencies to enable GCC backend
 	and/or disable Aditi backend.")
@@ -3278,4 +3359,5 @@
 	MMAKE_DIR=`pwd`/scripts scripts/mmake depend || exit 1
 	;;
 esac
+
 #-----------------------------------------------------------------------------#
Index: bindist/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/Mmakefile,v
retrieving revision 1.37
diff -u -u -r1.37 Mmakefile
--- bindist/Mmakefile	3 Dec 2002 08:51:26 -0000	1.37
+++ bindist/Mmakefile	4 Dec 2002 07:52:49 -0000
@@ -14,7 +14,7 @@
 
 INSTALL_LIB_DIR	= $(INSTALL_PREFIX)/lib
 
-LIB_FILES	= bin doc html inc ints lib mdb/mdb_doc modules
+LIB_FILES	= bin conf doc html inc ints lib mdb/mdb_doc modules reconf
 
 # Miscellaneous scripts and utilities not processed by configure
 UTILS		= $(INSTALL_PREFIX)/bin/mkinit$(EXT_FOR_EXE) \
@@ -28,7 +28,14 @@
 		  ../NEWS ../RELEASE_NOTES ../BUGS ../WORK_IN_PROGRESS \
 		  ../TODO ../VERSION ../README.*
 
-SCRIPT_FILES	= ../scripts/*.in ../scripts/*.sh-subr \
+INSTALL_SCRIPTS	= ../scripts/c2init ../scripts/mmc \
+		../scripts/mercury_update_interface ../scripts/mgnuc \
+		../scripts/ml ../scripts/mmake ../scripts/mprof \
+		../scripts/mdb ../scripts/mkfifo_using_mknod \
+		../scripts/mercury_config ../scripts/Mmake.vars \
+		../scripts/mdbrc
+
+SCRIPT_FILES	= $(INSTALL_SCRIPTS) ../scripts/*.in ../scripts/*.sh-subr \
 		  ../scripts/Mmake.rules \
 		  ../scripts/canonical_grade \
 		  ../scripts/gud.el
@@ -41,8 +48,14 @@
 
 # These files have a local version bindist.$filename which will be
 # preprocessed to create the final version.
-MISC_FILES	= INSTALL README \
-		  build_vars Makefile.in configure configure.in
+MISC_FILES	= INSTALL README Makefile
+
+.SUFFIXES: .in
+
+.in:
+	CONFIG_FILES=$@ CONFIG_HEADERS= $(MERCURY_DIR)/config.status
+	# check to ensure there were no mispelt autoconf variable names
+	if grep -n '[^$$]@.*@' $@; then false; else true; fi
 
 #-----------------------------------------------------------------------------#
 
@@ -52,7 +65,7 @@
 bindist: binary_distribution
 
 .PHONY: binary_distribution
-binary_distribution: bindist.configure bindist.build_vars
+binary_distribution: bindist.Makefile bindist.INSTALL
 	# Make a quick check that there is a mercury installation in
 	# $(INSTALL_PREFIX) by looking for mmc and mercury_compile.
 	test -f $(INSTALL_BINDIR)/mmc
@@ -129,27 +142,17 @@
 			-e 's/<FULLARCH>/$(FULLARCH)/g'			\
 			bindist.$$file > $(MERCURY_VERSION)/$$file || exit 1; \
 	done
-	# Ensure the configure file is executable.
-	chmod +x $(MERCURY_VERSION)/configure
+	# Ensure the install file is executable.
+	chmod +x $(MERCURY_VERSION)/INSTALL
 	# (XXX don't use redirection or pipes, because on gnu-win32
 	# stdout defaults to text mode, which breaks tar and gzip)
 	tar -cf ../$(MERCURY_VERSION).tar $(MERCURY_VERSION)
 	gzip ../$(MERCURY_VERSION).tar
 	rm -rf $(MERCURY_VERSION)
 
-bindist.configure: bindist.configure.in ../aclocal.m4
-	autoconf -l .. bindist.configure.in > bindist.configure
-
-bindist.build_vars: bindist.build_vars.in
-	CONFIG_FILES=bindist.build_vars CONFIG_HEADERS= \
-	$(MERCURY_DIR)/config.status
-
 #-----------------------------------------------------------------------------#
 
 clean_local:
 	rm -rf mercury-rotd* mercury-DEV*
-
-realclean_local:
-	rm -f bindist.configure bindist.build_vars
 
 #-----------------------------------------------------------------------------#
Index: bindist/bindist.INSTALL
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/bindist.INSTALL,v
retrieving revision 1.9
diff -u -u -r1.9 bindist.INSTALL
--- bindist/bindist.INSTALL	9 Jul 2001 08:32:41 -0000	1.9
+++ bindist/bindist.INSTALL	3 Jan 2003 04:54:24 -0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-#
+#-----------------------------------------------------------------------------#
 # INSTALL - installation instructions and installation script
 #	    for the binary distribution of Mercury.
 #
@@ -14,26 +14,27 @@
 #	   Do NOT mess with these nested .tar.gz files;
 #	   they will be extracted automatically in step 2.
 #
-# Step 1.  Run `configure'.  (Just type `sh configure'.)
+# Step 1.  Run this script.  (Just type `sh INSTALL'.)
 #
 #	   By default, the files will be installed in the directory
-#	   /usr/local/mercury-<VERSION>.
+#	   /usr/local/mercury-DEV.
 #	   If you want the files to be installed someplace else,
-#	   use the `--prefix <directory>' option to `configure'.
+#	   use the `--prefix <directory>' option to `INSTALL'.
 #
-# Step 2.  Run `make install'.
-#	   This step will copy the various files that make up the distribution
-#	   to their final places.
+#	   For a list of other configuration options, use
+#	   `sh INSTALL --help'.
+#	   `--prefix <directory>', if specified, must precede any
+# 	   other options.
 #
 # Step 3.  Check the permissions on the installed files.
-#	   Add /usr/local/mercury-<VERSION>/bin to your PATH, and
-#	   add /usr/local/mercury-<VERSION>/man to your MANPATH.
-#	   add /usr/local/mercury-<VERSION>/info to your INFOPATH.
+#	   Add /usr/local/mercury-DEV/bin to your PATH, and
+#	   add /usr/local/mercury-DEV/man to your MANPATH.
+#	   add /usr/local/mercury-DEV/info to your INFOPATH.
 #	   You can also add a WWW link to the Mercury documentation in
-#	   /usr/local/mercury-<VERSION>/lib/mercury/html to your WWW
+#	   /usr/local/mercury-DEV/lib/mercury/html to your WWW
 #	   home page, and you may want to print out a hard-copy of the
 #	   documentation from the DVI files in
-#	   /usr/local/mercury-<VERSION>/lib/mercury/doc.
+#	   /usr/local/mercury-DEV/lib/mercury/doc.
 #
 #	   If the binary distribution includes the deep profiler, then check
 #	   whether "make install" was able to copy scripts/mdprof to the web
@@ -46,19 +47,66 @@
 #	   add the following lines to the `.emacs' file in your home directory:
 #
 #	   	(setq load-path (cons (expand-file-name
-#		  "/usr/local/mercury- at VERSION@/lib/mercury/elisp") load-path))
+#		  "/usr/local/mercury-DEV/lib/mercury/elisp") load-path))
 #		(autoload 'mdb "gud" "Invoke the Mercury debugger" t)
 #
-# As a short-cut, steps 1 & 2 are listed below, so they can be replaced
-# by just executing this script.
-
-sh configure &&
-make install
-
+#-----------------------------------------------------------------------------#
+#
 # De-installation:
 # ----------------
 #
 # You may eventually want to uninstall this version of Mercury
 # (to free up disk space so you can install the next version ;-).
 # If you installed in the default location, you can simply
-# use `rm -rf /usr/local/mercury-<VERSION>' to uninstall.
+# use `rm -rf /usr/local/mercury-DEV' to uninstall.
+#-----------------------------------------------------------------------------#
+
+prefix=/usr/local/mercury-DEV
+
+while : ; do
+	case "$1" in
+		-h|--help|"-?")
+			scripts/mercury_config --help
+			exit 0
+			;;
+
+		--prefix)
+			prefix=$2
+			shift
+			;;
+		--prefix=*)
+			prefix=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
+			;;
+
+		--)
+			shift
+			break
+			;;
+		*)
+			break
+			;;
+	esac
+	shift
+done
+
+# Install the files.
+make INSTALL_PREFIX=$prefix install || { echo Installation failed; exit 1; }
+
+# Reconfigure the installation.
+# This is needed because the installation directory and C compiler
+# may be different than on the machine on which the distribution
+# was built.
+case $# in
+	0) scripts/mercury_config --input-prefix $prefix \
+			--output-prefix $prefix || \
+			{ echo Configuration failed; exit 1; } ;;
+	*) scripts/mercury_config --input-prefix $prefix \
+			--output-prefix $prefix -- "$@" || \
+			{ echo Configuration failed; exit 1; } ;;
+esac
+
+# Perform parts of the installation which use
+# values determined by the configuration.
+make MMAKE_VARS=$prefix/lib/mercury/mmake/Mmake.vars post_install || \
+		{ echo Post-installation failed; exit 1; }
+
Index: bindist/bindist.INSTALL.in
===================================================================
RCS file: bindist/bindist.INSTALL.in
diff -N bindist/bindist.INSTALL.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ bindist/bindist.INSTALL.in	19 Dec 2002 06:15:05 -0000
@@ -0,0 +1,112 @@
+#!/bin/sh
+#-----------------------------------------------------------------------------#
+# INSTALL - installation instructions and installation script
+#	    for the binary distribution of Mercury.
+#
+# You need GNU C (2.6.3 or later) and GNU Make (3.69 or later) in order
+# to use Mercury, though you don't need them to install this distribution.
+# To use the Mercury debugger, you may also need GNU Readline.
+#
+# Step 0.  Extract the files from the gzipped tar archive.
+#
+#	   Note: the mercury-*.tar.gz file itself contains
+#	   some other .tar.gz files (lib.tar.gz, info.tar.gz).
+#	   Do NOT mess with these nested .tar.gz files;
+#	   they will be extracted automatically in step 2.
+#
+# Step 1.  Run this script.  (Just type `sh INSTALL'.)
+#
+#	   By default, the files will be installed in the directory
+#	   /usr/local/mercury- at VERSION@.
+#	   If you want the files to be installed someplace else,
+#	   use the `--prefix <directory>' option to `INSTALL'.
+#
+#	   For a list of other configuration options, use
+#	   `sh INSTALL --help'.
+#	   `--prefix <directory>', if specified, must precede any
+# 	   other options.
+#
+# Step 3.  Check the permissions on the installed files.
+#	   Add /usr/local/mercury- at VERSION@/bin to your PATH, and
+#	   add /usr/local/mercury- at VERSION@/man to your MANPATH.
+#	   add /usr/local/mercury- at VERSION@/info to your INFOPATH.
+#	   You can also add a WWW link to the Mercury documentation in
+#	   /usr/local/mercury- at VERSION@/lib/mercury/html to your WWW
+#	   home page, and you may want to print out a hard-copy of the
+#	   documentation from the DVI files in
+#	   /usr/local/mercury- at VERSION@/lib/mercury/doc.
+#
+#	   If the binary distribution includes the deep profiler, then check
+#	   whether "make install" was able to copy scripts/mdprof to the web
+#	   server's CGI directory (normally /usr/lib/cgi-bin). This directory
+#	   is often writeable only by root or by the web server administrator,
+#	   so you may need more than your usual set of privileges to do the
+#	   copy (i.e. you may need to "su" to the appropriate user).
+#
+#	   To use the emacs debugger interface ("M-x mdb"), you also need to
+#	   add the following lines to the `.emacs' file in your home directory:
+#
+#	   	(setq load-path (cons (expand-file-name
+#		  "/usr/local/mercury- at VERSION@/lib/mercury/elisp") load-path))
+#		(autoload 'mdb "gud" "Invoke the Mercury debugger" t)
+#
+#-----------------------------------------------------------------------------#
+#
+# De-installation:
+# ----------------
+#
+# You may eventually want to uninstall this version of Mercury
+# (to free up disk space so you can install the next version ;-).
+# If you installed in the default location, you can simply
+# use `rm -rf /usr/local/mercury- at VERSION@' to uninstall.
+#-----------------------------------------------------------------------------#
+
+prefix=/usr/local/mercury- at VERSION@
+
+while : ; do
+	case "$1" in
+		-h|--help|"-?")
+			scripts/mercury_config --help
+			exit 0
+			;;
+
+		--prefix)
+			prefix=$2
+			shift
+			;;
+		--prefix=*)
+			prefix=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
+			;;
+
+		--)
+			shift
+			break
+			;;
+		*)
+			break
+			;;
+	esac
+	shift
+done
+
+# Install the files.
+make INSTALL_PREFIX=$prefix install || { echo Installation failed; exit 1; }
+
+# Reconfigure the installation.
+# This is needed because the installation directory and C compiler
+# may be different than on the machine on which the distribution
+# was built.
+case $# in
+	0) scripts/mercury_config --input-prefix $prefix \
+			--output-prefix $prefix || \
+			{ echo Configuration failed; exit 1; } ;;
+	*) scripts/mercury_config --input-prefix $prefix \
+			--output-prefix $prefix -- "$@" || \
+			{ echo Configuration failed; exit 1; } ;;
+esac
+
+# Perform parts of the installation which use
+# values determined by the configuration.
+make MMAKE_VARS=$prefix/lib/mercury/mmake/Mmake.vars post_install || \
+		{ echo Post-installation failed; exit 1; }
+
Index: bindist/bindist.Makefile.in
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/bindist.Makefile.in,v
retrieving revision 1.29
diff -u -u -r1.29 bindist.Makefile.in
--- bindist/bindist.Makefile.in	2 Dec 2002 11:24:27 -0000	1.29
+++ bindist/bindist.Makefile.in	18 Dec 2002 06:22:39 -0000
@@ -9,19 +9,18 @@
 
 SHELL=		/bin/sh
 
-INSTALL_PREFIX	= @PREFIX@
 INSTALL_BINDIR	= $(INSTALL_PREFIX)/bin
 INSTALL_LIBDIR	= $(INSTALL_PREFIX)/lib/mercury
 INSTALL_INFODIR = $(INSTALL_PREFIX)/info
 INSTALL_MAN_DIR = $(INSTALL_PREFIX)/man
 INSTALL_ELISP_DIR = $(INSTALL_PREFIX)/lib/mercury/elisp
-INSTALL_CGI_DIR = @CGIDIR@
 
 # These scripts are generated by configure from the corresponding `.in' file
 INSTALL_SCRIPTS		= scripts/c2init scripts/mmc \
 			scripts/mercury_update_interface scripts/mgnuc \
 			scripts/ml scripts/mmake scripts/mprof \
-			scripts/mdb scripts/mkfifo_using_mknod
+			scripts/mdb scripts/mkfifo_using_mknod \
+			scripts/mercury_config
 
 CGI_PROG_NAME		= mdprof_cgi
 
@@ -33,14 +32,15 @@
 
 INSTALL_MDB_EXTRAS	= scripts/mdbrc
 
-LIB_PARTS		= bin doc html inc ints lib mdb/mdb_doc modules
+LIB_PARTS	= bin conf doc html inc ints lib mdb/mdb_doc modules reconf
 
 EXT_FOR_EXE		= @EXT_FOR_EXE@
 
+# The directory names in the installation refer to the FULLARCH
+# on the machine on which the distribution was created, not the
+# machine on which it is being installed.
 FULLARCH		= @FULLARCH@
 
-GACUTIL			= @GACUTIL@
-
 UTIL_PROGS		= util/mkinit util/mdemangle
 UTIL_PROGFILENAMES	= $(UTIL_PROGS:%=%$(EXT_FOR_EXE))
 
@@ -49,8 +49,6 @@
 			  util/mprof_merge_runs util/vpath_find \
 			  util/mercury_cleanup_install
 
-ENABLE_DEEP_PROFILER    = @ENABLE_DEEP_PROFILER@
-
 #-----------------------------------------------------------------------------#
 
 all:
@@ -64,18 +62,12 @@
 
 .PHONY: install
 install: install_lib install_info install_man \
-		install_scripts install_emacs_scripts install_cgi_progs \
-		install_mmake install_mdb install_util install_gac
+		install_scripts install_emacs_scripts \
+		install_mmake install_mdb install_util
 	@echo
 	@echo "-- Don't forget to add $(INSTALL_BINDIR) to your PATH,"
 	@echo "-- $(INSTALL_MAN_DIR) to your MANPATH,"
 	@echo "-- and $(INSTALL_INFODIR) to your INFOPATH,"
-	@if test $(ENABLE_DEEP_PROFILER) != yes || \
-		cmp -s $(INSTALL_CGI_PROG) \
-			$(INSTALL_CGI_DIR)/$(CGI_PROG_NAME); \
-	then true ; else \
-		echo "-- to copy $(INSTALL_CGI_PROG) to $(INSTALL_CGI_DIR),"; \
-	fi
 	@echo "-- and to add the following lines to the \`.emacs' file"
 	@echo "-- in your home directory:"
 	@echo "	(setq load-path (cons (expand-file-name "
@@ -124,6 +116,39 @@
 	test -d $(INSTALL_ELISP_DIR) || mkdir -p $(INSTALL_ELISP_DIR)
 	cp $(INSTALL_EMACS_SCRIPTS) $(INSTALL_ELISP_DIR)
 
+.PHONY: install_mmake
+install_mmake: 
+	test -d $(INSTALL_LIBDIR)/mmake || mkdir -p $(INSTALL_LIBDIR)/mmake
+	cp $(INSTALL_MMAKE_EXTRAS) $(INSTALL_LIBDIR)/mmake
+
+.PHONY: install_mdb
+install_mdb: 
+	test -d $(INSTALL_LIBDIR)/mdb || mkdir -p $(INSTALL_LIBDIR)/mdb
+	cp $(INSTALL_MDB_EXTRAS) $(INSTALL_LIBDIR)/mdb
+
+.PHONY: install_util
+install_util: 
+	test -d $(INSTALL_BINDIR) || mkdir -p $(INSTALL_BINDIR)
+	cp $(UTILS) $(INSTALL_BINDIR)
+
+#
+# The following need to be run after configuration.
+# INSTALL will set MMAKE_VARS to the location of the Mmake.vars
+# file generated by configure.
+#
+ifneq ($(origin MMAKE_VARS),undefined)
+
+# For INSTALL_PREFIX, INSTALL_CGI_DIR, GACUTIL,
+# FULLARCH, ENABLE_DEEP_PROFILER.
+# Most of this Makefile does not require the above variables.
+# The parts that do are invoked by `make post_install', which
+# is run after the installation has been reconfigured by the
+# mercury_config script run by the INSTALL script.
+include $(MMAKE_VARS)
+
+.PHONY: post_install
+post_install: install_cgi_progs install_gac
+
 # The code of the install_cgi_progs target is duplicated from the code
 # of the install_cgi_progs target in deep_profiler/Mmakefile. However,
 # they refer to the script by different paths.
@@ -144,21 +169,12 @@
 			$(INSTALL_CGI_DIR)/$(CGI_PROG_NAME).was ; \
 		cp $(INSTALL_CGI_PROG) $(INSTALL_CGI_DIR) ; \
 	fi
-
-.PHONY: install_mmake
-install_mmake: 
-	test -d $(INSTALL_LIBDIR)/mmake || mkdir -p $(INSTALL_LIBDIR)/mmake
-	cp $(INSTALL_MMAKE_EXTRAS) $(INSTALL_LIBDIR)/mmake
-
-.PHONY: install_mdb
-install_mdb: 
-	test -d $(INSTALL_LIBDIR)/mdb || mkdir -p $(INSTALL_LIBDIR)/mdb
-	cp $(INSTALL_MDB_EXTRAS) $(INSTALL_LIBDIR)/mdb
-
-.PHONY: install_util
-install_util: 
-	test -d $(INSTALL_BINDIR) || mkdir -p $(INSTALL_BINDIR)
-	cp $(UTILS) $(INSTALL_BINDIR)
+	@if test $(ENABLE_DEEP_PROFILER) != yes || \
+		cmp -s $(INSTALL_CGI_PROG) \
+			$(INSTALL_CGI_DIR)/$(CGI_PROG_NAME); \
+	then true ; else \
+		echo "-- Don't forget to copy $(INSTALL_CGI_PROG) to $(INSTALL_CGI_DIR),"; \
+	fi
 
 ifneq ("$(strip $(GACUTIL))","")
 .PHONY: install_gac
@@ -171,5 +187,7 @@
 .PHONY: install_gac
 install_gac: 
 endif
+
+endif	# $(origin MMAKE_VARS) != undefined
 
 #-----------------------------------------------------------------------------#
Index: bindist/bindist.build_vars.in
===================================================================
RCS file: bindist/bindist.build_vars.in
diff -N bindist/bindist.build_vars.in
--- bindist/bindist.build_vars.in	2 Dec 2002 07:59:53 -0000	1.22
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,58 +0,0 @@
-# @configure_input@
-#---------------------------------------------------------------------------#
-# Copyright (C) 1996-2002 The University of Melbourne.
-# This file may only be copied under the terms of the GNU General
-# Public License - see the file COPYING in the Mercury distribution.
-#---------------------------------------------------------------------------#
-#
-# This file contains definitions generated as part of the configuration
-# for the host on which the binary distribution was created.
-
-FULLARCH="@FULLARCH@"
-DEFAULT_GRADE="@DEFAULT_GRADE@"
-LIBGRADES="@LIBGRADES@"
-LIBGRADE_OPTS="@LIBGRADE_OPTS@"
-NUM_REAL_R_REGS="@NUM_REAL_R_REGS@"
-NUM_REAL_R_TEMPS="@NUM_REAL_R_TEMPS@"
-HAVE_BOXED_FLOATS="@HAVE_BOXED_FLOATS@"
-BITS_PER_WORD="@BITS_PER_WORD@"
-BYTES_PER_WORD="@BYTES_PER_WORD@"
-LOW_TAG_BITS="@LOW_TAG_BITS@"
-CFLAGS_FOR_REGS="@CFLAGS_FOR_REGS@"
-CFLAGS_FOR_GOTOS="@CFLAGS_FOR_GOTOS@"
-CFLAGS_FOR_THREADS="@CFLAGS_FOR_THREADS@"
-LINK_SHARED_OBJ="@LINK_SHARED_OBJ@"
-LINK_SHARED_OBJ_SH="@LINK_SHARED_OBJ_SH@"
-EXE_RPATH_OPT="@EXE_RPATH_OPT@"
-EXE_RPATH_SEP="@EXE_RPATH_SEP@"
-SHLIB_RPATH_OPT="@SHLIB_RPATH_OPT@"
-SHLIB_RPATH_SEP="@SHLIB_RPATH_SEP@"
-EXT_FOR_EXE="@EXT_FOR_EXE@"
-EXT_FOR_PIC_OBJECTS="@EXT_FOR_PIC_OBJECTS@"
-EXT_FOR_SHARED_LIB="@EXT_FOR_SHARED_LIB@"
-CFLAGS_FOR_PIC="@CFLAGS_FOR_PIC@"
-SHARED_LIBS='@SHARED_LIBS@'
-SHARED_LIBS_SH='@SHARED_LIBS_SH@'
-HAVE_DELAY_SLOT="@HAVE_DELAY_SLOT@"
-ERROR_UNDEFINED="@ERROR_UNDEFINED@"
-ALLOW_UNDEFINED="@ALLOW_UNDEFINED@"
-DL_LIBRARY="@DL_LIBRARY@"
-SOCKET_LIBRARY="@SOCKET_LIBRARY@"
-NSL_LIBRARY="@NSL_LIBRARY@"
-OBJFILE_OPT="@OBJFILE_OPT@"
-AR="@AR@"
-ARFLAGS="@ARFLAGS@"
-AR_LIBFILE_OPT="@AR_LIBFILE_OPT@"
-USING_MICROSOFT_CL_COMPILER="@USING_MICROSOFT_CL_COMPILER@"
-EXE_SUFFIX="@EXE_SUFFIX@"
-OBJ_SUFFIX="@OBJ_SUFFIX@"
-LIB_SUFFIX="@LIB_SUFFIX@"
-LIB_PREFIX="@LIB_PREFIX@"
-LIB_LIBPATH="@LIB_LIBPATH@"
-LINK_LIB="@LINK_LIB@"
-LINK_OPT_SEP="@LINK_OPT_SEP@"
-FIX_PATH_FOR_CC="@FIX_PATH_FOR_CC@"
-CYGPATH="@CYGPATH@"
-MATH_LIB="@MATH_LIB@"
-CGIDIR="@CGIDIR@"
-ENABLE_DEEP_PROFILER="@ENABLE_DEEP_PROFILER@"
Index: bindist/bindist.configure.in
===================================================================
RCS file: bindist/bindist.configure.in
diff -N bindist/bindist.configure.in
--- bindist/bindist.configure.in	2 Dec 2002 08:27:54 -0000	1.46
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,273 +0,0 @@
-#-----------------------------------------------------------------------------#
-# Copyright (C) 1996-2002 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.
-#-----------------------------------------------------------------------------#
-# bindist.configure.in:
-#	This file is an autoconf script which is used to create the
-#	configure script that gets included with the binary distribution.
-#
-# XXX Much of the code here is duplicated in ../configure.in.
-#     We should abstract it out into macros defined in ../aclocal.m4,
-#     so that the same code can be shared between both ../configure.in and 
-#     this file.
-#-----------------------------------------------------------------------------#
-#
-# 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(./build_vars)
-AC_PREFIX_DEFAULT(/usr/local/mercury-<VERSION>)
-AC_CANONICAL_HOST
-if test "$prefix" = "NONE"; then
-	PREFIX="$ac_default_prefix"
-else
-	PREFIX="$prefix"
-fi
-LIBDIR="$PREFIX/lib/mercury"
-WINDOWS_LIBDIR="`cygpath -w $LIBDIR 2>/dev/null`"
-NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=$PREFIX/lib/nonshared}
-AC_SUBST(PREFIX)
-AC_SUBST(LIBDIR)
-AC_SUBST(WINDOWS_LIBDIR)
-AC_SUBST(NONSHARED_LIB_DIR)
-DEFAULT_MERCURY_DEBUGGER_INIT_DIR=$LIBDIR/mdb
-AC_SUBST(DEFAULT_MERCURY_DEBUGGER_INIT_DIR)
-
-#-----------------------------------------------------------------------------#
-#
-# Source the build_vars script to get the variables whoes bindings
-# were determined at the time when the binary distribution was built.
-
-. ./build_vars
-
-#-----------------------------------------------------------------------------#
-#
-# Pass on the inherited variables
-
-AC_SUBST(FULLARCH)
-AC_SUBST(LIBGRADES)
-AC_SUBST(LIBGRADE_OPTS)
-AC_SUBST(DEFAULT_GRADE)
-AC_SUBST(NUM_REAL_R_REGS)
-AC_SUBST(NUM_REAL_R_TEMPS)
-AC_SUBST(HAVE_BOXED_FLOATS)
-AC_SUBST(BYTES_PER_WORD)
-AC_SUBST(BITS_PER_WORD)
-AC_SUBST(LOW_TAG_BITS)
-AC_SUBST(CFLAGS_FOR_REGS)
-AC_SUBST(CFLAGS_FOR_GOTOS)
-AC_SUBST(CFLAGS_FOR_THREADS)
-AC_SUBST(LINK_SHARED_OBJ)
-AC_SUBST(LINK_SHARED_OBJ_SH)
-AC_SUBST(CFLAGS_FOR_PIC)
-AC_SUBST(EXE_RPATH_OPT)
-AC_SUBST(EXE_RPATH_SEP)
-AC_SUBST(SHLIB_RPATH_OPT)
-AC_SUBST(SHLIB_RPATH_SEP)
-AC_SUBST(EXT_FOR_EXE)
-AC_SUBST(EXT_FOR_PIC_OBJECTS)
-AC_SUBST(EXT_FOR_SHARED_LIB)
-AC_SUBST(SHARED_LIBS)
-AC_SUBST(HAVE_DELAY_SLOT)
-AC_SUBST(ALLOW_UNDEFINED)
-AC_SUBST(ERROR_UNDEFINED)
-AC_SUBST(DL_LIBRARY)
-AC_SUBST(SOCKET_LIBRARY)
-AC_SUBST(NSL_LIBRARY)
-
-AC_SUBST(OBJFILE_OPT)
-AC_SUBST(AR)
-AC_SUBST(ARFLAGS)
-AC_SUBST(AR_LIBFILE_OPT)
-AC_SUBST(USING_MICROSOFT_CL_COMPILER)
-AC_SUBST(EXE_SUFFIX)
-AC_SUBST(OBJ_SUFFIX)
-AC_SUBST(LIB_SUFFIX)
-AC_SUBST(LIB_PREFIX)
-AC_SUBST(LIB_LIBPATH)
-AC_SUBST(LINK_LIB)
-AC_SUBST(LINK_OPT_SEP)
-AC_SUBST(FIX_PATH_FOR_CC)
-AC_SUBST(CYGPATH)
-AC_SUBST(MATH_LIB)
-AC_SUBST(SHARED_LIBS_SH)
-AC_SUBST(CGIDIR)
-AC_SUBST(ENABLE_DEEP_PROFILER)
-
-#-----------------------------------------------------------------------------#
-AC_EXEEXT
-AC_SUBST(EXEEXT)
-#-----------------------------------------------------------------------------#
-AC_PROG_RANLIB
-#-----------------------------------------------------------------------------#
-GNU_MAKE=
-echo looking for GNU Make...
-AC_PROGRAMS_CHECK(GNU_MAKE,gmake make)
-if test "$GNU_MAKE" != ""; then
-	case "`$GNU_MAKE -v bogus 2>&1`" in
-		"GNU Make"*)
-			;;
-		*)
-			GNU_MAKE=
-	esac
-fi
-if test "$GNU_MAKE" = ""; then
-	AC_MSG_ERROR(cannot find GNU Make)
-else
-	echo "found GNU Make: $GNU_MAKE"
-fi
-AC_SUBST(GNU_MAKE)
-#-----------------------------------------------------------------------------#
-echo "looking for a way to create named pipes..."
-
-save_PATH="$PATH"
-PATH="$PATH:/etc:/usr/etc:/sbin"
-
-MKFIFO=
-AC_PATH_PROG(MKFIFO,mkfifo)
-if test "$MKFIFO" != ""; then
-	# check that it really works
-	tmp=/tmp/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
-MKNOD=
-if test "$MKFIFO" = ""; then
-	AC_PATH_PROG(MKNOD,mknod)
-	if test "$MKNOD" != ""; then
-		# check that it really works
-		tmp=/tmp/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
-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 /tmp/configure.XXXXXX < /dev/null`"
-	case "$TMPFILE" in 
-		/tmp/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(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 </dev/null >&AC_FD_CC 2>&1 
-	then
-		mercury_cv_asm_does_full_preprocessing="yes"
-	else
-		AS="gcc -c -x assembler-with-cpp"
-		mercury_cv_asm_does_full_preprocessing="no"
-		AC_MSG_RESULT(no)	
-	fi
-	rm -f conftest*
-else
-	AS="gcc -c -x assembler-with-cpp"
-fi
-])
-AC_MSG_RESULT($mercury_cv_asm_does_full_preprocessing)	
-AC_SUBST(AS)
-#-----------------------------------------------------------------------------#
-AC_PROG_CC
-MERCURY_CHECK_CC_NEEDS_TRAD_CPP
-AC_SUBST(CC)
-#-----------------------------------------------------------------------------#
-# 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
-#-----------------------------------------------------------------------------#
-# Microsoft.NET configuration (the bindist may be installed on a machine
-# that supports .NET even if it was built on a machine that doesn't).
-# 
-MERCURY_CHECK_DOTNET
-
-# 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
-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)
-
-#-----------------------------------------------------------------------------#
-MERCURY_CHECK_READLINE
-#-----------------------------------------------------------------------------#
-AC_OUTPUT(Makefile scripts/mmc scripts/mercury.bat scripts/mprof scripts/mdprof
-scripts/mercury_update_interface scripts/mgnuc scripts/ml
-scripts/mmake scripts/c2init
-scripts/mkfifo_using_mknod scripts/Mmake.vars
-scripts/mdb scripts/mdbrc
-,
-# conftest.junk is used to avoid a warning if there
-# are no files in the list passed to chmod
-touch conftest.junk
-chmod a-w $CONFIG_FILES conftest.junk
-chmod +x `echo $CONFIG_FILES | sed -e 's/[^ ]*Makefile//' ` conftest.junk
-rm -f conftest.junk
-)
-
-#-----------------------------------------------------------------------------#
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.33
diff -u -u -r1.33 compile_target_code.m
--- compiler/compile_target_code.m	23 Dec 2002 12:32:56 -0000	1.33
+++ compiler/compile_target_code.m	2 Jan 2003 03:47:43 -0000
@@ -1099,10 +1099,18 @@
 standard_library_directory_option(Opt) -->
 	globals__io_lookup_maybe_string_option(
 		mercury_standard_library_directory, MaybeStdLibDir),
+	globals__io_lookup_maybe_string_option(
+		mercury_configuration_directory, MaybeConfDir),
 	{
 		MaybeStdLibDir = yes(StdLibDir),
-		Opt = "--mercury-standard-library-directory "
-				++ StdLibDir ++ " "
+		Opt0 = "--mercury-standard-library-directory "
+				++ StdLibDir ++ " ",
+		( MaybeConfDir = yes(ConfDir), ConfDir \= StdLibDir ->
+			Opt = Opt0 ++ "--mercury-configuration-directory "
+					++ ConfDir ++ " "
+		;
+			Opt = Opt0
+		)
 	;
 		MaybeStdLibDir = no,
 		Opt = "--no-mercury-standard-library-directory "
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.161
diff -u -u -r1.161 handle_options.m
--- compiler/handle_options.m	20 Dec 2002 09:46:18 -0000	1.161
+++ compiler/handle_options.m	2 Jan 2003 03:47:44 -0000
@@ -945,6 +945,20 @@
 	),
 
 	%
+	% Add the path to mercury_conf.h.
+	%
+	globals__io_lookup_maybe_string_option(
+		mercury_configuration_directory, MaybeConfDir),
+	( { MaybeConfDir = yes(ConfDir) } ->
+		globals__io_lookup_accumulating_option(c_include_directory,
+			CIncludeDirs0),
+		globals__io_set_option(c_include_directory,
+			accumulating([ConfDir/"lib"/"conf" | CIncludeDirs0]))
+	;
+		[]
+	),
+
+	%
 	% Handle the `.opt', C header and library search directories.
 	% These couldn't be handled by options.m because they are grade
 	% dependent.
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.398
diff -u -u -r1.398 options.m
--- compiler/options.m	2 Jan 2003 06:53:55 -0000	1.398
+++ compiler/options.m	2 Jan 2003 07:01:14 -0000
@@ -573,6 +573,7 @@
 		;	mercury_libraries
 		;	mercury_library_special
 		;	mercury_standard_library_directory
+		;	mercury_standard_library_directory_special
 		;	init_file_directories
 		;	init_files
 		;	trace_init_files
@@ -624,6 +625,8 @@
 		;	extra_init_command
 		;	pre_link_command
 		;	install_prefix
+		;	mercury_configuration_directory
+		;	mercury_configuration_directory_special
 		;	install_command
 		;	libgrades
 		;	options_files
@@ -1167,6 +1170,7 @@
 					% The mmc script will set the default
 					% standard library directory.
 	mercury_standard_library_directory - maybe_string(no),
+	mercury_standard_library_directory_special - maybe_string_special,
 	init_file_directories -		accumulating([]),
 	init_files -			accumulating([]),
 	trace_init_files -		accumulating([]),
@@ -1222,6 +1226,12 @@
 	pre_link_command	-	maybe_string(no),
 	extra_init_command	-	maybe_string(no),
 	install_prefix		-	string("/usr/local/"),
+
+	% If `--mercury-stdlib-dir' is set, `--mercury-config-dir'
+	% must also be set.  This invariant is maintained by the
+	% `special' variants of the options.
+	mercury_configuration_directory_special - string_special,
+	mercury_configuration_directory - maybe_string(no),
 	install_command		-	string("cp"),
 	libgrades		-	accumulating([]),
 	options_files		-	accumulating(["Mercury.options"]),
@@ -1813,8 +1823,9 @@
 long_option("mercury-library-directory", mercury_library_directory_special).
 long_option("mld",			mercury_library_directory_special).
 long_option("mercury-standard-library-directory",
-					mercury_standard_library_directory).
-long_option("mercury-stdlib-dir",	mercury_standard_library_directory).
+				mercury_standard_library_directory_special).
+long_option("mercury-stdlib-dir",
+				mercury_standard_library_directory_special).
 long_option("init-file-directory",	init_file_directories).
 long_option("init-file",		init_files).
 long_option("trace-init-file",		trace_init_files).
@@ -1866,6 +1877,8 @@
 long_option("invoked-by-mmc-make",	invoked_by_mmc_make).
 long_option("pre-link-command",		pre_link_command).
 long_option("extra-init-command",	extra_init_command).
+long_option("mercury-configuration-directory",
+				mercury_configuration_directory_special).
 long_option("install-prefix",		install_prefix).
 long_option("install-command",		install_command).
 long_option("library-grade",		libgrades).
@@ -2021,6 +2034,18 @@
 		mercury_libraries - Lib,
 		init_files - (Lib ++ ".init")
 		], OptionTable0).
+special_handler(mercury_standard_library_directory_special,
+		maybe_string(MaybeStdLibDir), OptionTable0, ok(OptionTable)) :-
+	OptionTable =
+	    map__set(map__set(OptionTable0,
+		mercury_standard_library_directory,
+			maybe_string(MaybeStdLibDir)),
+		mercury_configuration_directory,
+			maybe_string(MaybeStdLibDir)).
+special_handler(mercury_configuration_directory_special,
+		string(ConfDir), OptionTable0, ok(OptionTable)) :-
+	OptionTable = map__set(OptionTable0, mercury_configuration_directory,
+			maybe_string(yes(ConfDir))).
 special_handler(quoted_cflag, string(Flag),
 			OptionTable0, ok(OptionTable)) :-
 	handle_quoted_flag(cflags, Flag, OptionTable0, OptionTable).
@@ -3753,9 +3778,12 @@
 		"--mercury-standard-library-directory <directory>",
 		"--mercury-stdlib-dir <directory>",
 		"\tSearch <directory> for the Mercury standard library.",
+		"\tImplies `--mercury-library-directory <directory>'",
+		"\tand `--mercury-configuration-directory <directory>'.",
 		"--no-mercury-standard-library-directory",
 		"--no-mercury-stdlib-dir",
 		"\tDon't use the Mercury standard library.",
+		"\tImplies `--no-mercury-configuration-directory'.",
 		"--ml <library>, --mercury-library <library>",
 		"\tLink with the specified Mercury library.",
 
@@ -3868,15 +3896,14 @@
 		"--options-search-directory <dir>",
 		"\tAdd <dir> to the list of directories to be searched for",
 		"\toptions files.",
-
-		/* NYI
+		"--mercury-configuration-directory <directory>",
+		"--mercury-config-dir <directory>",
+		"\tSearch <directory> for Mercury system's configuration files.",
 		"--config-file <file>",
 		"\tRead the Mercury compiler's configuration information",
 		"\tfrom <file>.  If the `--config-file' option is not set,",
 		"\ta default configuration will be used, unless",
 		"\t`--no-mercury-stdlib-dir' is passed to mmc.",
-		*/
-
 		"-I <dir>, --search-directory <dir>",
 		"\tAppend <dir> to the list of directories to be searched for",
 		"\timported modules.",
Index: doc/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/Mmakefile,v
retrieving revision 1.32
diff -u -u -r1.32 Mmakefile
--- doc/Mmakefile	29 Nov 2002 07:05:43 -0000	1.32
+++ doc/Mmakefile	29 Nov 2002 07:21:25 -0000
@@ -139,7 +139,7 @@
 
 .PHONY: manpages
 manpages: c2init.1 mmc.1 mgnuc.1 ml.1 mmake.1 mdb.1 mprof.1 \
-	mprof_merge_runs.1 mtags.1
+	mprof_merge_runs.1 mtags.1 mercury_config.1
 
 #-----------------------------------------------------------------------------#
 
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.346
diff -u -u -r1.346 user_guide.texi
--- doc/user_guide.texi	2 Jan 2003 06:53:57 -0000	1.346
+++ doc/user_guide.texi	2 Jan 2003 07:01:15 -0000
@@ -6168,6 +6168,7 @@
 if they are not already up-to-date.
 (Note that this option also enables @samp{--use-subdirs}.)
 
+ at sp 1
 @item -r
 @itemx --rebuild
 @findex -r
@@ -6175,6 +6176,7 @@
 Same as @samp{--make}, but always rebuild the target files
 even if they are up to date.
 
+ at sp 1
 @item --pre-link-command @var{command}
 @findex --pre-link-command
 Specify a command to run before linking with @samp{mmc --make}.
@@ -6187,12 +6189,14 @@
 Occurrences of @samp{@@@@} and @samp{%%} will be replaced
 with @samp{@@} and @samp{%} respectively.
 
+ at sp 1
 @item --extra-init-command @var{command}
 @findex --extra-init-command
 Specify a command to produce extra entries in the @file{.init} file
 for a library. Occurrences of @samp{@@} and @samp{%} in the command
 are substituted as for the @samp{--pre-link-command} option.
 
+ at sp 1
 @item -k
 @itemx --keep-going
 @findex -k
@@ -6200,10 +6204,12 @@
 With @samp{--make} keep going as far as
 possible even if an error is detected.
 
+ at sp 1
 @item --install-prefix @var{dir}
 @findex --install-prefix
 Specify the directory under which to install Mercury libraries.
 
+ at sp 1
 @item --install-command @var{command}
 @findex --install-command
 Specify the command to use to install the files in Mercury
@@ -6212,11 +6218,13 @@
 to install each file in a Mercury library.
 The default command is @samp{cp}.
 
+ at sp 1
 @item --libgrade @var{grade}
 @findex --libgrade
 Add @var{grade} to the list of compilation grades in
 which a library to be installed should be built.
 
+ at sp 1
 @item --options-file @var{file}
 @findex --options-file
 Add @var{file} to the list of options files to be processed.
@@ -6224,10 +6232,20 @@
 standard input.  By default the file @file{Mercury.options}
 in the current directory will be read.
 
+ at sp 1
 @item --options-search-directory @var{dir}
+ at findex --options-search-directory
 Add @var{dir} to the list of directories to be searched for
 options files.
 
+ at sp 1
+ at item --mercury-configuration-directory @var{dir}
+ at itemx --mercury-config-dir @var{dir}
+ at findex --mercury-configuration-directory
+ at findex --mercury-config-dir
+Search @var{dir} for Mercury system's configuration files.
+
+ at sp 1
 @item -I @var{dir}
 @itemx --search-directory @var{dir}
 @findex -I
@@ -6237,6 +6255,7 @@
 Append @var{dir} to the list of directories to be searched for
 imported modules.
 
+ at sp 1
 @item --intermod-directory @var{dir}
 @findex --intermod-directory
 @cindex Directories
@@ -6244,6 +6263,7 @@
 Append @var{dir} to the list of directories to be searched for
 @samp{.opt} files.
 
+ at sp 1
 @item --use-search-directories-for-intermod
 @findex --use-search-directories-for-intermod
 @cindex Directories
@@ -6251,6 +6271,7 @@
 Append the arguments of all -I options to the list of directories
 to be searched for @samp{.opt} files.
 
+ at sp 1
 @item --use-subdirs
 @findex --use-subdirs
 @cindex File names
@@ -6260,6 +6281,7 @@
 Create intermediate files in a @file{Mercury} subdirectory,
 rather than in the current directory.
 
+ at sp 1
 @item --use-grade-subdirs
 @findex --use-grade-subdirs
 @cindex File names
@@ -6521,12 +6543,15 @@
 @findex --mercury-standard-library-directory
 @findex --mercury-stdlib-dir
 Search @var{directory} for the Mercury standard library.
+Implies @samp{--mercury-library-directory @var{directory}}
+and @samp{--mercury-configuration-directory @var{directory}}.
 
 @item --no-mercury-standard-library-directory
 @itemx --no-mercury-stdlib-dir
 @findex --no-mercury-standard-library-directory
 @findex --no-mercury-stdlib-dir
 Don't use the Mercury standard library.
+Implies @samp{--no-mercury-configuration-directory}.
 
 @item --init-file-directory @var{directory}
 @findex --init-file-directory
@@ -6852,19 +6877,16 @@
 it is possible to do so.  Here's what you need to do.
 
 @itemize @bullet
- at item You must specify the name of the new compiler.
-You can do this either by setting the @samp{MERCURY_C_COMPILER}
-environment variable, by adding
- at samp{MGNUC=MERCURY_C_COMPILER=@dots{} mgnuc} to your @samp{Mmake} file,
-or by using the @samp{--cc} option to @samp{mmc}.
-You may need to specify some option(s) to the C compiler
-to ensure that it uses an ANSI preprocessor (e.g.@: if you
-are using the DEC Alpha/OSF 3.2 C compiler, you would need to
-pass @samp{--cc="cc -std"} to @samp{mmc} so that it will pass the
- at samp{-std} option to @samp{cc}).
+ at item Create a new configuration for the Mercury system using the
+ at samp{mercury_config} script, specifying the different C compiler, e.g.@:
+ at samp{mercury_config --output-prefix=/usr/local/mercury-cc --with-cc=cc}.
+
+ at item Add the @samp{bin} directory of the new configuration to the beginning
+of your PATH.
 
 @item
-You must use the grade @samp{none} or @samp{none.gc}.
+You must use a grade beginning with @samp{none}, @samp{hlc} or @samp{hl}
+(e.g.@: @samp{hlc.gc}).
 You can specify the grade in one of three ways: by setting the
 @samp{MERCURY_DEFAULT_GRADE} environment variable, by adding a line
 @vindex MERCURY_DEFAULT_GRADE
Index: library/getopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/getopt.m,v
retrieving revision 1.26
diff -u -u -r1.26 getopt.m
--- library/getopt.m	15 Jan 2002 07:19:07 -0000	1.26
+++ library/getopt.m	12 Nov 2002 07:15:22 -0000
@@ -46,6 +46,7 @@
 %	- bool_special
 %	- int_special
 %	- string_special
+%	- maybe_string_special
 %
 % For the "simple" option types, if there are multiple occurrences
 % of the same option on the command-line, then the last (right-most)
@@ -165,13 +166,15 @@
 	;	special
 	;	bool_special
 	;	int_special
-	;	string_special.
+	;	string_special
+	;	maybe_string_special.
 
 :- type special_data
 	--->	none
 	;	bool(bool)
 	;	int(int)
-	;	string(string).
+	;	string(string)
+	;	maybe_string(maybe(string)).
 
 :- type option_table(OptionType)
 	==	map(OptionType, option_data).
@@ -592,6 +595,15 @@
 	;
 		error("string_special argument expected in getopt__process_option")
 	).
+getopt__process_option(maybe_string_special, Option, Flag, MaybeArg, OptionOps,
+		OptionTable0, Result) :-
+	( MaybeArg = yes(_) ->
+		getopt__process_special(Option, Flag, maybe_string(MaybeArg),
+			OptionOps, OptionTable0, Result)
+	;
+		error("maybe_string_special argument expected in getopt__process_option")
+	).
+
 
 :- pred process_negated_option(string, OptionType, option_ops(OptionType),
 	option_table(OptionType), maybe_option_table(OptionType)).
@@ -617,6 +629,9 @@
 		; OptionData = bool_special ->
 			getopt__process_special(Option, Flag, bool(no),
 				OptionOps, OptionTable0, Result)
+		; OptionData = maybe_string_special ->
+			getopt__process_special(Option, Flag, maybe_string(no),
+				OptionOps, OptionTable0, Result)
 		;
 			string__append_list(["cannot negate option `", Option,
 				"' -- only boolean options can be negated"],
@@ -667,6 +682,7 @@
 getopt__need_arg(bool_special, no).
 getopt__need_arg(int_special, yes).
 getopt__need_arg(string_special, yes).
+getopt__need_arg(maybe_string_special, yes).
 
 :- pred getopt__numeric_argument(string::in, string::in,
 	maybe_option_table(OptionType)::out) is det.
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.97
diff -u -u -r1.97 Mmakefile
--- runtime/Mmakefile	30 Oct 2002 16:35:36 -0000	1.97
+++ runtime/Mmakefile	12 Nov 2002 03:10:02 -0000
@@ -334,6 +334,9 @@
 		mkdir -p $(INSTALL_INC_DIR)/machdeps
 	-[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
 	-[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
+	-[ -d $(INSTALL_CONF_DIR) ] || mkdir -p $(INSTALL_CONF_DIR)
+	-[ -d $(INSTALL_RECONF_DIR)/runtime ] || \
+		mkdir -p $(INSTALL_RECONF_DIR)/runtime
 
 ifeq ($(findstring il,$(GRADE)),il)        
 
@@ -352,10 +355,15 @@
 
 else
 
+# mercury_conf.h needs to be in a separate directory so it can be 
+# overridden by a different configuration.
 .PHONY: install_headers
 install_headers: $(HDRS) $(BODY_HDRS) $(MACHHDRS) $(LIB_GLOBALS_H) install_dirs
 	cp `vpath_find $(HDRS) $(BODY_HDRS) $(LIB_GLOBALS_H)` $(INSTALL_INC_DIR)
-	-chmod u+w $(INSTALL_INC_DIR)/mercury_conf.h
+	rm -f $(INSTALL_INC_DIR)/mercury_conf.h
+	cp `vpath_find mercury_conf.h` $(INSTALL_CONF_DIR)
+	-chmod u+w $(INSTALL_CONF_DIR)/mercury_conf.h
+	cp `vpath_find mercury_conf.h.in` $(INSTALL_RECONF_DIR)/runtime
 	cp `vpath_find $(MACHHDRS)` $(INSTALL_INC_DIR)/machdeps
 
 .PHONY: install_init
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.84
diff -u -u -r1.84 Mmake.vars.in
--- scripts/Mmake.vars.in	2 Jan 2003 06:54:00 -0000	1.84
+++ scripts/Mmake.vars.in	2 Jan 2003 07:01:18 -0000
@@ -707,6 +707,8 @@
 
 # You should not need to override anything below here
 
+INSTALL_CONF_DIR	= $(INSTALL_LIBDIR)/conf
+INSTALL_RECONF_DIR	= $(INSTALL_LIBDIR)/reconf
 INSTALL_MODULE_DIR	= $(INSTALL_LIBDIR)/modules
 INSTALL_INT_DIR		= $(INSTALL_LIBDIR)/ints
 INSTALL_GRADE_INT_DIR	= $(INSTALL_LIBDIR)/ints/$(GRADESTRING)
@@ -721,6 +723,8 @@
 INSTALL_GRADE_INC_SUBDIR = $(INSTALL_GRADE_INC_DIR)/Mercury/mihs
 FINAL_INSTALL_MERC_LIB_DIR = \
 		$(FINAL_INSTALL_LIBDIR)/lib/$(GRADESTRING)/$(FULLARCH)
+
+ENABLE_DEEP_PROFILER	= @ENABLE_DEEP_PROFILER@
 
 #-----------------------------------------------------------------------------#
 
Index: scripts/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmakefile,v
retrieving revision 1.29
diff -u -u -r1.29 Mmakefile
--- scripts/Mmakefile	29 Nov 2002 04:16:40 -0000	1.29
+++ scripts/Mmakefile	29 Nov 2002 07:21:29 -0000
@@ -17,7 +17,7 @@
 SCRIPTS = mmake mmc mdb c2init mgnuc ml mprof mprof_merge_runs \
 	  mtags vpath_find mercury_update_interface \
 	  mkfifo_using_mknod mercury_cleanup_install canonical_grade \
-	  mercury.bat
+	  mercury_config mercury.bat
 DEBUGGER_SCRIPTS = mdbrc
 EMACS_SCRIPTS = gud.el
 
@@ -43,6 +43,7 @@
 parse_ml_options.sh-subr mgnuc canonical_grade: final_grade_options.sh-subr 
 ml c2init: parse_ml_options.sh-subr
 ml c2init canonical_grade: canonical_grade.sh-subr 
+mercury_config: ../configure.help
 
 #-----------------------------------------------------------------------------#
 
@@ -56,6 +57,8 @@
 	[ -d $(INSTALL_LIBDIR)/mmake ] || mkdir -p $(INSTALL_LIBDIR)/mmake
 	[ -d $(INSTALL_LIBDIR)/mdb ] || mkdir -p $(INSTALL_LIBDIR)/mdb
 	[ -d $(INSTALL_ELISP_DIR) ] || mkdir -p $(INSTALL_ELISP_DIR)
+	[ -d $(INSTALL_RECONF_DIR)/scripts ] || \
+		mkdir -p $(INSTALL_RECONF_DIR)/scripts
 
 .PHONY: install_mmake
 install_mmake: Mmake.vars Mmake.rules install_dirs
@@ -73,6 +76,7 @@
 	-for file in $(SCRIPTS); do \
 		chmod u+w $(INSTALL_BINDIR)/$$file ;\
 	done
+	cp *.in *.sh-subr $(SCRIPTS) $(INSTALL_RECONF_DIR)/scripts
 	-rm -f $(INSTALL_BINDIR)/mmake.old
 
 .PHONY: install_debugger_scripts
Index: scripts/mercury_config.in
===================================================================
RCS file: scripts/mercury_config.in
diff -N scripts/mercury_config.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ scripts/mercury_config.in	3 Jan 2003 05:06:14 -0000
@@ -0,0 +1,174 @@
+#! /bin/sh
+# @configure_input@
+#---------------------------------------------------------------------------#
+# Copyright (C) 2003 The University of Melbourne.
+# This file may only be copied under the terms of the GNU General
+# Public License - see the file COPYING in the Mercury distribution.
+#---------------------------------------------------------------------------#
+#
+# IMPORTANT: the manpage is produced automatically from this help
+# message, so if you change the help message, don't forget to check
+# that the manpage still looks OK.
+                
+Help="\
+Name:   mercury_config - generate new configurations for a Mercury installation
+Usage:  mercury_config [<options>] [-- <configure options>]
+Options:
+	--output-prefix <dir>
+		Generate the new copies of the Mercury scripts and
+		configuration files into the given directory.
+		By default mercury_config overwrites the configuration in
+		the installation hierarchy containing the mercury_config
+		script.
+
+Description:
+	Generates an alternative configuration for a Mercury
+	installation, for example to use a different C compiler.
+
+	The <configure options> must result in a configuration
+	which is compatible with the configuration used to build
+	the installed libraries, or else linking using the new
+	configuration will fail.  For example, both configurations
+	must agree on the use of boxed or unboxed floats.
+
+	To use the new configuration, put \`<dir>/bin' at the
+	beginning of your PATH.
+
+Environment variables:
+        MERCURY_DEFAULT_GRADE.
+
+Configure options:
+ at CONFIGURE_HELP@
+"
+#---------------------------------------------------------------------------#
+
+input_prefix=@prefix@
+output_prefix=@CONFIG_PREFIX@
+exe_ext=@EXT_FOR_EXE@
+unset MERCURY_STDLIB_DIR
+unset MERCURY_CONFIG_DIR
+recursive=no
+
+while : ; do
+	case $1 in 
+		# This option is only for use by
+		# bindist/bindist.INSTALL.in
+		--input-prefix=*)
+			input_prefix=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
+			;;
+		--input-prefix)
+			input_prefix="$2"
+			shift
+			;;
+
+		--output-prefix=*)
+			output_prefix=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'`
+			;;
+		--output-prefix)
+			output_prefix="$2"
+			shift
+			;;
+
+		--recursive)
+			recursive=yes
+			;;
+
+		-h|--help|"-?")
+			echo "$Help"
+			exit 0
+			;;
+
+		--)
+			shift
+			break
+			;;
+
+		*)
+			break
+			;;
+	esac
+	shift
+done
+
+input_libdir="$input_prefix/lib/mercury"
+output_libdir="$output_prefix/lib/mercury"
+
+# mercury_config regenerates itself, so we can't just execute it in place.
+case $recursive in
+    no)
+	if [ -d "$TMPDIR" ]; then
+		:
+	elif [ -d /tmp ]; then
+		TMPDIR="/tmp"
+	else
+		TMPDIR="."
+	fi
+	TMPDIR=$TMPDIR/mercury_config.$$
+	trap 'rm -rf $TMPDIR; exit 1' 1 2 3 13 15 
+	[ -d $TMPDIR ] || mkdir -p $TMPDIR || \
+		{ echo mercury_config: invalid TMPDIR: $TMPDIR; exit 1; }
+	export TMPDIR
+
+	cp $input_prefix/bin/mercury_config $TMPDIR
+	case $# in
+	0)
+		exec $TMPDIR/mercury_config --recursive \
+			--input-prefix "$input_prefix" \
+			--output-prefix "$output_prefix" ;;
+	*)
+		exec $TMPDIR/mercury_config --recursive \
+			--input-prefix "$input_prefix" \
+			--output-prefix "$output_prefix" "$@" ;;
+	esac
+esac
+
+cp -r $input_libdir/reconf/* $TMPDIR || exit 1
+mkdir $TMPDIR/bindist || exit 1
+
+# The configure script tries to process these files, but they won't be used.
+touch $TMPDIR/Mmake.common.in $TMPDIR/bindist/bindist.INSTALL.in || exit 1
+touch $TMPDIR/bindist/bindist.Makefile.in || exit 1
+
+cd $TMPDIR
+case $# in
+	0)
+		./configure @RECONFIGURE_ARGS@ \
+			--cache-file=/dev/null \
+			--prefix="$input_prefix" \
+			--enable-reconfigure="$output_prefix" || exit 1
+		;;
+	*)
+		./configure @RECONFIGURE_ARGS@ "$@" \
+			--cache-file=/dev/null \
+			--prefix="$input_prefix" \
+			--enable-reconfigure="$output_prefix" || exit 1
+		;;
+esac
+
+[ -d $output_libdir/conf ] || mkdir -p $output_libdir/conf || exit 1
+[ -d $output_libdir/mmake ] || mkdir -p $output_libdir/mmake || exit 1
+[ -d $output_prefix/bin ] || mkdir -p $output_prefix/bin || exit 1
+
+#
+# Copy the new configuration into place.
+#
+cp runtime/mercury_conf.h $output_libdir/conf || exit 1
+cp scripts/Mmake.vars $output_libdir/mmake || exit 1
+if [ "$input_prefix" != "$output_prefix" ]; then
+	cp $input_prefix/bin/mdemangle${exe_ext} \
+		$input_prefix/bin/mkinit${exe_ext} \
+		$input_prefix/bin/info_to_mdb${exe_ext} $output_prefix/bin
+	cp $input_libdir/mmake/Mmake.rules $output_libdir/mmake
+fi
+cd scripts
+echo *
+for file in *; do
+	case "$file" in
+		*.in|Mmake.*|mdbrc|*.sh-subr) ;;
+		*)
+			cp $file $output_prefix/bin || exit 1
+			chmod u+w $output_prefix/bin/$file || exit 1
+			;;
+	esac
+done
+rm -rf $TMPDIR
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.95
diff -u -u -r1.95 mgnuc.in
--- scripts/mgnuc.in	30 Oct 2002 16:35:37 -0000	1.95
+++ scripts/mgnuc.in	13 Nov 2002 15:29:39 -0000
@@ -88,6 +88,8 @@
 c_optimize=true
 use_activation_counts=false
 preserve_tail_recursion=true
+mercury_config_dir=${MERCURY_STDLIB_DIR- at LIBDIR@}
+mercury_config_dir=${MERCURY_CONFIG_DIR=$mercury_config_dir}
 mercury_stdlib_dir=${MERCURY_STDLIB_DIR=@LIBDIR@}
 
 # include the file `init_grade_options.sh-subr'
@@ -201,10 +203,20 @@
 
 	--mercury-standard-library-directory|--mercury-stdlib-dir)
 		mercury_stdlib_dir="$2"
+		mercury_config_dir="$2"
 		shift
 		;;
 	--no-mercury-standard-library-directory|--no-mercury-stdlib-dir)
-		unset mercury_stdlib_dir ;;
+		unset mercury_stdlib_dir
+		unset mercury_config_dir
+		;;
+
+	--mercury-config-directory|--mercury-config-dir)
+		mercury_config_dir="$2"
+		shift
+		;;
+	# We don't allow `MERCURY_CONFIG_DIR' to be unset
+	# without `MERCURY_STDLIB_DIR' also being unset.
 
 	# include the file `parse_grade_options.sh-subr'
 	@PARSE_GRADE_OPTIONS@
@@ -232,7 +244,11 @@
 case "$mercury_stdlib_dir" in
     "")	MERC_ALL_C_INCL_DIRS=$MERCURY_ALL_C_INCL_DIRS
     	;;
-    *)  MERC_ALL_C_INCL_DIRS=${MERCURY_ALL_C_INCL_DIRS="-I$mercury_stdlib_dir/inc -I$mercury_stdlib_dir/lib/$GRADE/$FULLARCH/inc"}
+    *) 
+	# The option setting code above guarantees that if
+	# `--mercury-stdlib-dir' is set, `--mercury-config-dir'
+	# is also set.
+    	MERC_ALL_C_INCL_DIRS=${MERCURY_ALL_C_INCL_DIRS="-I$mercury_config_dir/conf -I$mercury_stdlib_dir/inc -I$mercury_stdlib_dir/lib/$GRADE/$FULLARCH/inc"}
 	;;
 esac
 
Index: scripts/mmake.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmake.in,v
retrieving revision 1.41
diff -u -u -r1.41 mmake.in
--- scripts/mmake.in	16 May 2002 06:48:43 -0000	1.41
+++ scripts/mmake.in	12 Nov 2002 07:13:36 -0000
@@ -72,6 +72,7 @@
 "
 
 MERCURY_STDLIB_DIR=${MERCURY_STDLIB_DIR=@LIBDIR@}
+MERCURY_CONFIG_DIR=${MERCURY_CONFIG_DIR=@CONFIG_LIBDIR@}
 MMAKE_MAKE=${MMAKE_MAKE=@GNU_MAKE@}
 MERCURY_DEFAULT_GRADE=${MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@}
 MKTEMP=@MKTEMP@
@@ -165,10 +166,20 @@
 
 		--mercury-standard-library-directory|--mercury-stdlib-dir)
 			MERCURY_STDLIB_DIR="$2"
+			MERCURY_CONFIG_DIR="$2"
 			shift
 			;;
 		--no-mercury-standard-library-directory|--no-mercury-stdlib-dir)
-			unset MERCURY_STDLIB_DIR ;;
+			unset MERCURY_STDLIB_DIR
+			unset MERCURY_CONFIG_DIR
+			;;
+
+		--mercury-config-directory-directory|--mercury-config-dir)
+			MERCURY_CONFIG_DIR="$2"
+			shift
+			;;
+		# We don't allow `MERCURY_CONFIG_DIR' to be unset
+		# without `MERCURY_STDLIB_DIR' also being unset.
 
 		--)	
 			MMAKE="$MMAKE $1"
@@ -187,9 +198,10 @@
 	yes)	use_subdirs=yes ;;		
 esac
 
-if [ "$MERCURY_STDLIB_DIR" != "" ]
+if [ "$MERCURY_CONFIG_DIR" != "" ]
 then
-	MMAKE_DIR=${MMAKE_DIR=$MERCURY_STDLIB_DIR/mmake}
+	MMAKE_DIR=${MMAKE_DIR=$MERCURY_CONFIG_DIR/mmake}
+	export MERCURY_CONFIG_DIR
 	export MERCURY_STDLIB_DIR
 fi
 
Index: scripts/mmc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmc.in,v
retrieving revision 1.27
diff -u -u -r1.27 mmc.in
--- scripts/mmc.in	8 Aug 2002 06:22:00 -0000	1.27
+++ scripts/mmc.in	13 Nov 2002 15:34:59 -0000
@@ -10,20 +10,28 @@
 #
 # Use `mmc -h' for help.
 #
-# Environment variables: MERCURY_STDLIB_DIR, MERCURY_INT_DIR,
-# MERCURY_ALL_MC_C_INCL_DIRS, MERCURY_COMPILER, MERCURY_C_COMPILER,
-# MERCURY_DEFAULT_GRADE, MERCURY_DEFAULT_OPT_LEVEL.
+# Environment variables: MERCURY_STDLIB_DIR, MERCURY_CONFIG_DIR,
+# MERCURY_INT_DIR, MERCURY_ALL_MC_C_INCL_DIRS, MERCURY_COMPILER,
+# MERCURY_C_COMPILER, MERCURY_DEFAULT_GRADE, MERCURY_DEFAULT_OPT_LEVEL.
 
 MC=${MERCURY_COMPILER="@LIBDIR@/bin/@FULLARCH@/mercury_compile"}
 case "$MERCURY_INT_DIR" in
     "")
 	INT_DIR_OPT=
+	CONFIG_DIR=${MERCURY_STDLIB_DIR- at LIBDIR@}
+	CONFIG_DIR=${MERCURY_CONFIG_DIR=$CONFIG_DIR}
 	STDLIB_DIR=${MERCURY_STDLIB_DIR=@LIBDIR@}
 	STDLIB_DIR_OPT="--mercury-standard-library-directory \"${STDLIB_DIR}\""
+	if [ "$STDLIB_DIR" != "$CONFIG_DIR" ]; then
+		CONFIG_DIR_OPT="--mercury-configuration-directory \"${CONFIG_DIR}\""
+	else
+		CONFIG_DIR_OPT=
+	fi
 	;;
     *)
 	INT_DIR_OPT="-I $MERCURY_INT_DIR"
 	STDLIB_DIR_OPT=--no-mercury-standard-library-directory
+	CONFIG_DIR_OPT=
 	;;
 esac
 
@@ -61,6 +69,7 @@
 		@HAVE_BOXED_FLOATS@ \
 		${MERCURY_DEFAULT_OPT_LEVEL=-O2} \
 		$STDLIB_DIR_OPT \
+		$CONFIG_DIR_OPT \
 		"}
 export DEFAULT_MCFLAGS
 
Index: scripts/parse_ml_options.sh-subr.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/parse_ml_options.sh-subr.in,v
retrieving revision 1.5
diff -u -u -r1.5 parse_ml_options.sh-subr.in
--- scripts/parse_ml_options.sh-subr.in	19 Apr 2002 14:59:36 -0000	1.5
+++ scripts/parse_ml_options.sh-subr.in	13 Nov 2002 15:36:14 -0000
@@ -17,6 +17,8 @@
 #---------------------------------------------------------------------------#
 
 # initialize common options
+mercury_config_dir=${MERCURY_STDLIB_DIR- at CONFIG_LIBDIR@}
+mercury_config_dir=${MERCURY_CONFIG_DIR=$mercury_config_dir}
 mercury_stdlib_dir=${MERCURY_STDLIB_DIR=@LIBDIR@}
 
 # initialize ml options
@@ -124,6 +126,10 @@
 		The directory in which to find the Mercury standard library.
 	--no-mercury-standard-library-directory, --no-mercury-stdlib-dir
 		Same as \`--mercury-libs none'.
+	--mercury-config-directory <directory>
+	--mercury-config-dir <directory>
+		The location of an alternative configuration
+		(created with mercury_config) to use.
 	-L <directory>, --lib-dir <directory>
 		Include <directory> in the list of directories that the
 		linker will use to search for libraries.
@@ -311,11 +317,18 @@
 
 	--mercury-standard-library-directory|--mercury-stdlib-dir)
 		mercury_stdlib_dir="$2"
+		mercury_config_dir="$2"
 		shift
 		;;
 	--no-mercury-standard-library-directory|--no-mercury-stdlib-dir)
 		mercury_libs=none
 		unset mercury_stdlib_dir
+		unset mercury_config_dir
+		;;
+
+	--mercury-config-directory|--mercury-config-dir)
+		mercury_config_dir="$2"
+		shift
 		;;
 
 	-L|--lib-dir)
--------------------------------------------------------------------------
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