[m-rev.] for review: move mmc configuration into options file

Simon Taylor stayl at cs.mu.OZ.AU
Sat Mar 1 02:37:38 AEDT 2003


Estimated hours taken: 20
Branches: main

Move the setting of configuration options from mmc.in to
an options file Mercury.config. This has a few advantages:
- reduces the duplication between mmc and mercury.bat
- reduces the chance of running out of environment space
  on crappy operating systems (although we probably exceed
  the command line length limits on those systems anyway).
- makes it easier to bootstrap changes which add new
  configuration options.

Always read the options files, even without `--make',
to avoid inconsistent behaviour.

scripts/Mercury.config.in:
	New file containing the configuration code from mmc.in.

configure.in:
bindist/bindist.configure.in:
	Create scripts/Mercury.config.

compiler/options.m:
doc/user_guide.texi:
	Add an option `--config-file', which gives the
	name of the configuration file to read.

	Add an environment variable MERCURY_CONFIG_FILE,
	which gives the name of the configuration to use
	by default.

Mmake.workspace:
	Use the configuration file in scripts/.
	This is commented out until the `--config-file'
	is accepted by the installed compilers.

browser/Mmakefile:
compiler/Mmakefile:
scripts/Mmake.vars.in:
	Always pass ALL_MCFLAGS to mmc so that mmc will
	use the configuration file specified in the options.

compiler/handle_options.m:
	Handle the default value of `--config-file'.

compiler/mercury_compile.m:
	Read the configuration file.

	Always read the options files, even without `--make',
	to avoid inconsistent behaviour.

compiler/make.m:
	Pass the variable settings from the configuration file
	to make__process_args.

	The options files have already been read in mercury_compile.m,
	so don't read them again here.

compiler/make.util.m:
	Add a version of build_with_module_options which doesn't
	need a make_info, for use by mercury_compile.m.

compiler/options_file.m:
	Export a predicate to read a single options file.

	Make the predicates to read options files add to an initial
	options_variables map, rather than always creating a new one.

	Allow MERCURY_STDLIB_DIR and MERCURY_CONFIG_FILE
	to be set in the options file.


Index: Mmake.workspace
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.workspace,v
retrieving revision 1.12
diff -u -u -r1.12 Mmake.workspace
--- Mmake.workspace	13 Feb 2003 08:28:42 -0000	1.12
+++ Mmake.workspace	17 Feb 2003 08:35:03 -0000
@@ -98,6 +98,8 @@
 
 VPATH =		$(LIBRARY_DIR)
 
+MCFLAGS +=	--config-file $(SCRIPTS_DIR)/Mercury.config
+
 ifeq ($(MMAKE_USE_MMC_MAKE),yes)
 MCFLAGS +=	--options-file $(WORKSPACE)/Mercury.options
 endif
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.97
diff -u -u -r1.97 Mmakefile
--- Mmakefile	6 Feb 2003 17:05:02 -0000	1.97
+++ Mmakefile	28 Feb 2003 13:47:19 -0000
@@ -609,7 +609,9 @@
 .PHONY : bindist
 bindist: WORK_IN_PROGRESS TODO
 	cd bindist; \
-		PATH="$(INSTALL_PREFIX)/bin:$$PATH" mmake binary_distribution
+		PATH="$(INSTALL_PREFIX)/bin:$$PATH" \
+		MMAKE_DIR="$(INSTALL_MMAKE_DIR)" \
+		mmake -v binary_distribution
 
 #-----------------------------------------------------------------------------#
 
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.355
diff -u -u -r1.355 configure.in
--- configure.in	16 Feb 2003 03:10:09 -0000	1.355
+++ configure.in	18 Feb 2003 07:11:08 -0000
@@ -3536,7 +3536,7 @@
 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
+scripts/mercury_config scripts/Mercury.config
 ,
 [
 # Only do this when compiling the source, not when reconfiguring
Index: bindist/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/Mmakefile,v
retrieving revision 1.38
diff -u -u -r1.38 Mmakefile
--- bindist/Mmakefile	24 Jan 2003 07:17:06 -0000	1.38
+++ bindist/Mmakefile	28 Feb 2003 15:19:29 -0000
@@ -8,6 +8,9 @@
 # You need to have already installed the Mercury compiler.
 
 MERCURY_DIR=..
+# Make sure we get a version of Mmake.vars with INSTALL_PREFIX
+# pointing to the configured installation directory.
+include $(MERCURY_DIR)/scripts/Mmake.vars
 include $(MERCURY_DIR)/Mmake.common
 
 MERCURY_VERSION	= mercury-$(VERSION).$(FULLARCH)
@@ -33,7 +36,7 @@
 		../scripts/ml ../scripts/mmake ../scripts/mprof \
 		../scripts/mdb ../scripts/mkfifo_using_mknod \
 		../scripts/mercury_config ../scripts/Mmake.vars \
-		../scripts/mdbrc
+		../scripts/mdbrc ../scripts/Mercury.config
 
 SCRIPT_FILES	= $(INSTALL_SCRIPTS) ../scripts/*.in ../scripts/*.sh-subr \
 		  ../scripts/Mmake.rules \
Index: bindist/bindist.Makefile.in
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/bindist.Makefile.in,v
retrieving revision 1.30
diff -u -u -r1.30 bindist.Makefile.in
--- bindist/bindist.Makefile.in	24 Jan 2003 07:17:06 -0000	1.30
+++ bindist/bindist.Makefile.in	28 Feb 2003 10:41:42 -0000
@@ -20,7 +20,7 @@
 			scripts/mercury_update_interface scripts/mgnuc \
 			scripts/ml scripts/mmake scripts/mprof \
 			scripts/mdb scripts/mkfifo_using_mknod \
-			scripts/mercury_config
+			scripts/mercury_config scripts/Mercury.config
 
 CGI_PROG_NAME		= mdprof_cgi
 
Index: browser/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.28
diff -u -u -r1.28 Mmakefile
--- browser/Mmakefile	19 Feb 2003 06:31:22 -0000	1.28
+++ browser/Mmakefile	21 Feb 2003 02:57:31 -0000
@@ -87,7 +87,7 @@
 # won't work without the Mercury.modules file.
 .PHONY: Mercury.modules
 Mercury.modules:
-	$(MC) -f *.m
+	$(MC) $(ALL_MCFLAGS) -f *.m
 
 .PHONY: check
 check		: $(BROWSER_LIB_NAME).check
Index: compiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Mmakefile,v
retrieving revision 1.70
diff -u -u -r1.70 Mmakefile
--- compiler/Mmakefile	21 Feb 2003 21:11:57 -0000	1.70
+++ compiler/Mmakefile	22 Feb 2003 13:19:37 -0000
@@ -168,7 +168,7 @@
 # won't work without the Mercury.modules file.
 .PHONY: Mercury.modules
 Mercury.modules:
-	$(MC) -f *.m
+	$(MC) $(ALL_MCFLAGS) -f *.m
 
 .PHONY: all
 all:		mercury
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.175
diff -u -u -r1.175 handle_options.m
--- compiler/handle_options.m	21 Feb 2003 05:13:25 -0000	1.175
+++ compiler/handle_options.m	28 Feb 2003 14:30:35 -0000
@@ -1027,6 +1027,22 @@
 	),
 
 	%
+	% Find the configuration file.
+	%
+	globals__io_lookup_maybe_string_option(config_file, ConfigFile),
+	% yes("") means `--config-file' was not passed on the command line.
+	( { ConfigFile = yes("") } ->
+		( { MaybeStdLibDir = yes(StdLibDir1) } ->
+			globals__io_set_option(config_file, maybe_string(yes(
+				StdLibDir1/"conf"/"Mercury.config")))
+		;
+			globals__io_set_option(config_file, maybe_string(no))
+		)
+	;
+		[]
+	),
+
+	%
 	% Handle the `.opt', C header and library search directories.
 	% These couldn't be handled by options.m because they are grade
 	% dependent.
Index: compiler/make.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.m,v
retrieving revision 1.15
diff -u -u -r1.15 make.m
--- compiler/make.m	28 Jan 2003 14:51:58 -0000	1.15
+++ compiler/make.m	11 Feb 2003 12:51:44 -0000
@@ -19,7 +19,7 @@
 
 :- interface.
 
-:- include_module make__options_file.
+:- include_module make__options_file, make__util.
 
 :- import_module parse_tree.
 
@@ -27,19 +27,21 @@
 :- import_module io, list.
 
 	% make__process_args(OptionArgs, NonOptionArgs).
-:- pred make__process_args(list(string)::in, list(file_name)::in,
-		io__state::di, io__state::uo) is det.
+:- pred make__process_args(options_variables::in, list(string)::in,
+		list(file_name)::in, io__state::di, io__state::uo) is det.
 
 :- pred make__write_module_dep_file(module_imports::in,
 		io__state::di, io__state::uo) is det.
 
 :- func make__module_dep_file_extension = string.
 
+:- type make_info.
+
 %-----------------------------------------------------------------------------%
 :- implementation.
 
 :- include_module make__dependencies, make__module_dep_file.
-:- include_module make__module_target, make__program_target, make__util.
+:- include_module make__module_target, make__program_target.
 
 :- import_module hlds, libs, backend_libs.
 :- import_module top_level. % XXX unwanted dependency
@@ -192,35 +194,8 @@
 
 make__module_dep_file_extension = ".module_dep".
 
-make__process_args(OptionArgs, Targets0) -->
-    read_options_files(MaybeVariables),
-    (
-    	{ MaybeVariables = yes(Variables) },
-	% Look up the MCFLAGS and GRADEFLAGS from the options file.
-    	lookup_mmc_options(Variables, MaybeMCFlags),
-        (
-		{ MaybeMCFlags = yes(MCFlags) },
-		handle_options(MCFlags ++ OptionArgs, MaybeError,
-			_, _, _),
-		(
-			{ MaybeError = yes(OptionsError) },
-			usage_error(OptionsError),
-			{ Continue0 = no }
-		;
-			{ MaybeError = no },
-			{ Continue0 = yes }
-		)
-	;
-		{ MaybeMCFlags = no },
-		{ Continue0 = no }
-	)
-    ;
-	{ MaybeVariables = no },
-	{ Variables = options_variables_init },
-        { Continue0 = no }
-    ),
+make__process_args(Variables, OptionArgs, Targets0) -->
     (
-	{ Continue0 = yes },
 	{ Targets0 = [] }
     ->
     	lookup_main_target(Variables, MaybeMAIN_TARGET),
@@ -241,7 +216,7 @@
 		{ Continue = no }
 	)
     ;
-	{ Continue = Continue0 },
+	{ Continue = yes },
 	{ Targets = Targets0 }
     ),
     ( { Continue = no } ->	
Index: compiler/make.util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.13
diff -u -u -r1.13 make.util.m
--- compiler/make.util.m	11 Feb 2003 02:14:26 -0000	1.13
+++ compiler/make.util.m	11 Feb 2003 12:51:44 -0000
@@ -43,16 +43,37 @@
 
 %-----------------------------------------------------------------------------%
 
-:- type build(T) == pred(T, bool, make_info, make_info, io__state, io__state).
+:- type build(T, Info) == pred(T, bool, Info, Info, io__state, io__state).
+:- type build(T) == build(T, make_info).
 :- inst build == (pred(in, out, in, out, di, uo) is det).
 
+	% build_with_module_options(ModuleName, ExtraArgs, Builder,
+	%	Succeeded, Info0, Info).
+	%
 	% Perform the given closure after updating the option_table in
 	% the globals in the io__state to contain the module-specific
-	% options for the specified module.
+	% options for the specified module and the extra options given
+	% in the ExtraArgs.
+	% Adds `--invoked-by-mmc-make' and `--use-subdirs' to the option
+	% list.
 :- pred build_with_module_options(module_name::in,
 	list(string)::in, build(list(string))::in(build), bool::out,
 	make_info::in, make_info::out, io__state::di, io__state::uo) is det.
 
+	% build_with_module_options(ModuleName, OptionsVariables,
+	%	OptionArgs, ExtraArgs, Builder, Succeeded, Info0, Info).
+	%
+	% Perform the given closure after updating the option_table in
+	% the globals in the io__state to contain the module-specific
+	% options for the specified module and the extra options given
+	% in ExtraArgs and OptionArgs 
+	% Does not add `--invoked-by-mmc-make' and `--use-subdirs'
+	% to the option list.
+:- pred build_with_module_options(module_name::in, options_variables::in,
+	list(string)::in, list(string)::in,
+	build(list(string), Info)::in(build),
+	bool::out, Info::in, Info::out, io__state::di, io__state::uo) is det.
+
 	% Perform the given closure with an output stream created
 	% to append to the error file for the given module.
 :- pred build_with_output_redirect(module_name::in,
@@ -282,14 +303,29 @@
 
 build_with_module_options(ModuleName, ExtraOptions,
 		Build, Succeeded, Info0, Info) -->
-	lookup_mmc_module_options(Info0 ^ options_variables,
-		ModuleName, OptionsResult),
+	build_with_module_options(yes, ModuleName, Info0 ^ options_variables,
+		Info0 ^ option_args, ExtraOptions, Build, Succeeded,
+		Info0, Info).
+
+build_with_module_options(ModuleName, OptionVariables,
+		OptionArgs, ExtraOptions, Build, Succeeded, Info0, Info) -->
+	build_with_module_options(no, ModuleName, OptionVariables,
+		OptionArgs, ExtraOptions, Build, Succeeded, Info0, Info).
+
+:- pred build_with_module_options(bool::in, module_name::in,
+	options_variables::in, list(string)::in, list(string)::in,
+	build(list(string), Info)::in(build),
+	bool::out, Info::in, Info::out, io__state::di, io__state::uo) is det.
+
+build_with_module_options(InvokedByMmcMake, ModuleName, OptionVariables,
+		OptionArgs, ExtraOptions, Build, Succeeded, Info0, Info) -->
+	lookup_mmc_module_options(OptionVariables, ModuleName, OptionsResult),
 	(
 		{ OptionsResult = no },
 		{ Info = Info0 },
 		{ Succeeded = no }
 	;
-		{ OptionsResult = yes(OptionArgs) }, 
+		{ OptionsResult = yes(ModuleOptionArgs) }, 
 		globals__io_get_globals(Globals),
 
 		% --invoked-by-mmc-make disables reading DEFAULT_MCFLAGS
@@ -298,9 +334,17 @@
 		% --use-subdirs is needed because the code to install
 		% libraries uses `--use-grade-subdirs' and assumes the
 		% interface files were built with `--use-subdirs'.
-		{ AllOptionArgs = list__condense([
-		    ["--invoked-by-mmc-make" | OptionArgs],
-		    Info0 ^ option_args, ExtraOptions, ["--use-subdirs"]]) },
+		{ InvokedByMmcMake = yes ->
+			UseSubdirs = ["--use-subdirs"],
+			InvokedByMake = ["--invoked-by-mmc-make"]
+		;
+			UseSubdirs = [],
+			InvokedByMake = []
+		},
+
+		{ AllOptionArgs = list__condense([InvokedByMake,
+			ModuleOptionArgs, OptionArgs,
+			ExtraOptions, UseSubdirs]) },
 		handle_options(AllOptionArgs, OptionsError, _, _, _),
 		(
 			{ OptionsError = yes(OptionsMessage) },
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.277
diff -u -u -r1.277 mercury_compile.m
--- compiler/mercury_compile.m	22 Feb 2003 13:54:40 -0000	1.277
+++ compiler/mercury_compile.m	28 Feb 2003 01:54:21 -0000
@@ -111,7 +111,8 @@
 :- import_module recompilation, recompilation__usage.
 :- import_module recompilation__check.
 :- import_module libs__timestamp.
-:- import_module make, make__options_file, backend_libs__compile_target_code.
+:- import_module make, make__options_file, make__util.
+:- import_module backend_libs__compile_target_code.
 
 	% inter-module analysis framework
 :- import_module analysis.
@@ -128,48 +129,102 @@
 real_main -->
 	gc_init,
 
-	 	% All messages go to stderr
-	io__stderr_stream(StdErr),
-	io__set_output_stream(StdErr, _),
-	io__command_line_arguments(Args0),
-
-	% Lookup the the default options in the
-	% environment (set by the mmc script).
-	( { Args0 = ["--invoked-by-mmc-make" | _] } ->
-		{ MaybeMCFlags = yes([]) }
-	;
-		lookup_default_options(options_variables_init, MaybeMCFlags)
-	),
+         % All messages go to stderr
+    io__stderr_stream(StdErr),
+    io__set_output_stream(StdErr, _),
+    io__command_line_arguments(Args0),
+
+    ( { Args0 = ["--invoked-by-mmc-make" | _] } ->
+        % All the configuration options were passed
+        % on the command line.
+        { process_options(Args0, OptionArgs, NonOptionArgs, _) },
+        { MaybeMCFlags = yes([]) },
+        { Variables = options_variables_init },
+	{ Link = no }
+    ;
+	%
+	% Find out which options files to read.
+	%
+	handle_options(Args0, MaybeError0, OptionArgs, NonOptionArgs, Link),
 	(
-		{ MaybeMCFlags = yes(MCFlags) },
-		handle_options(MCFlags ++ Args0, MaybeError,
-	    		OptionArgs0, NonOptionArgs, Link),
-		(
-			{ MaybeError = no },
-			%
-			% When computing the option arguments to pass
-			% to `--make', only include the command-line
-			% arguments, not the contents of DEFAULT_MCFLAGS.
-			%
-			globals__io_lookup_bool_option(make, Make),
-			{ Make = yes ->
-				process_options(Args0, OptionArgs, _, _)
-			;
-				% OptionArgs is only used with `--make'.
-				OptionArgs = OptionArgs0
-			}
+	    { MaybeError0 = yes(Error0) },
+            usage_error(Error0),
+            { Variables = options_variables_init },
+            { MaybeMCFlags = no }
+	;
+            { MaybeError0 = no },
+            read_options_files(options_variables_init, MaybeVariables0),
+            (
+	        { MaybeVariables0 = yes(Variables0) },
+                lookup_mmc_options(Variables0, MaybeMCFlags0),
+                (
+		    { MaybeMCFlags0 = yes(MCFlags0) },
+
+		    %
+		    % Process the options again to find out which
+		    % configuration file to read.
+		    %
+                    handle_options(MCFlags0 ++ Args0, MaybeError1, 
+                        _, _, _),
+                    (
+                        { MaybeError1 = yes(Error1) },
+                        usage_error(Error1),
+                        { Variables = options_variables_init },
+                        { MaybeMCFlags = no }
+                    ;
+                        { MaybeError1 = no },
+
+                        globals__io_lookup_maybe_string_option(config_file,
+                            MaybeConfigFile),
+                        (
+                            { MaybeConfigFile = yes(ConfigFile) },
+                            read_options_file(ConfigFile, Variables0,
+    				MaybeVariables),
+                            (
+                                { MaybeVariables = yes(Variables) },
+                                lookup_mmc_options(Variables, MaybeMCFlags)
+                            ;
+                                { MaybeVariables = no },
+                                { MaybeMCFlags = no },
+                                { Variables = options_variables_init }
+                            )
+                        ;
+                            { MaybeConfigFile = no },
+                            { Variables = options_variables_init },
+                            lookup_mmc_options(Variables, MaybeMCFlags)
+                        )
+		    )
 		;
-			{ MaybeError = yes(_) },
-			{ OptionArgs = OptionArgs0 }
-		),
-		main_2(MaybeError, OptionArgs, NonOptionArgs, Link)
-	;
-		{ MaybeMCFlags = no },
-		io__set_exit_status(1)
-	).
+		    { MaybeMCFlags0 = no },
+                    { Variables = options_variables_init },
+                    { MaybeMCFlags = no }
+                )
+	    ;
+	    	{ MaybeVariables0 = no },
+                { Variables = options_variables_init },
+                { MaybeMCFlags = no }
+	    )
+        )
+    ),
+    (
+        { MaybeMCFlags = yes(MCFlags) },
+
+        handle_options(MCFlags ++ OptionArgs, MaybeError,
+                _, _, _),
+
+        %
+        % When computing the option arguments to pass
+        % to `--make', only include the command-line
+        % arguments, not the contents of DEFAULT_MCFLAGS.
+        %
+        main_2(MaybeError, Variables, OptionArgs, NonOptionArgs, Link)
+    ;
+        { MaybeMCFlags = no },
+        io__set_exit_status(1)
+    ).
 
 main(Args) -->
-	main_2(no, [], Args, no).
+	main_2(no, options_variables_init, [], Args, no).
 
 %-----------------------------------------------------------------------------%
 
@@ -200,13 +255,13 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pred main_2(maybe(string), list(string), list(string),
+:- pred main_2(maybe(string), options_variables, list(string), list(string),
 		bool, io__state, io__state).
-:- mode main_2(in, in, in, in, di, uo) is det.
+:- mode main_2(in, in, in, in, in, di, uo) is det.
 
-main_2(yes(ErrorMessage), _, _, _) -->
+main_2(yes(ErrorMessage), _, _, _, _) -->
 	usage_error(ErrorMessage).
-main_2(no, OptionArgs, Args, Link) -->
+main_2(no, OptionVariables, OptionArgs, Args, Link) -->
 	globals__io_lookup_bool_option(help, Help),
 	globals__io_lookup_bool_option(generate_source_file_mapping,
 		GenerateMapping),
@@ -246,16 +301,21 @@
 	; { GenerateMapping = yes } ->
 		source_file_map__write_source_file_map(Args)
 	; { Make = yes } ->
-		make__process_args(OptionArgs, Args)
+		make__process_args(OptionVariables, OptionArgs, Args)
 	; { Args = [], FileNamesFromStdin = no } ->
 		usage
 	;
-		process_all_args(Args, ModulesToLink),
+		process_all_args(OptionVariables, OptionArgs,
+			Args, ModulesToLink),
 		io__get_exit_status(ExitStatus),
 		( { ExitStatus = 0 } ->
-			( { Link = yes } ->
-				compile_target_code__link_module_list(
-					ModulesToLink, Succeeded),
+			( { Link = yes, ModulesToLink = [FirstModule | _] } ->
+				{ file_name_to_module_name(FirstModule,
+					MainModuleName) },
+				compile_with_module_options(MainModuleName,
+					OptionVariables, OptionArgs,
+					compile_target_code__link_module_list(
+						ModulesToLink), Succeeded),
 				maybe_set_exit_status(Succeeded)
 			;
 				[]
@@ -281,10 +341,11 @@
 		)
 	).
 
-:- pred process_all_args(list(string), list(string), io__state, io__state).
-:- mode process_all_args(in, out, di, uo) is det.
+:- pred process_all_args(options_variables, list(string),
+		list(string), list(string), io__state, io__state).
+:- mode process_all_args(in, in, in, out, di, uo) is det.
 
-process_all_args(Args, ModulesToLink) -->
+process_all_args(OptionVariables, OptionArgs, Args, ModulesToLink) -->
 	% Because of limitations in the GCC back-end,
 	% we can only call the GCC back-end once (per process),
 	% to generate a single assembler file, rather than
@@ -302,7 +363,8 @@
 			% starting the gcc backend to avoid overwriting
 			% the output assembler file even if recompilation 
 			% is found to be unnecessary.
-		    	mercury_compile__process_args(Args, ModulesToLink)
+		    	mercury_compile__process_args(OptionVariables,
+					OptionArgs, Args, ModulesToLink)
 		    ;
 			io__write_string(
 "Sorry, not implemented: `--target asm' with `--smart-recompilation'\n"),
@@ -312,9 +374,11 @@
 			{ ModulesToLink = [] }
 		    )
 		;
-		    compile_using_gcc_backend(
+		    compile_using_gcc_backend(OptionVariables, OptionArgs,
 		    	string_to_file_or_module(FirstArg),
-			mercury_compile__process_args(Args), ModulesToLink)
+			mercury_compile__process_args(OptionVariables,
+				OptionArgs, Args),
+			ModulesToLink)
 	        )
 	    ;
 		io__write_string(
@@ -326,7 +390,8 @@
 		% If we're NOT using the GCC back-end,
 		% then we can just call process_args directly,
 		% rather than via GCC.
-	    mercury_compile__process_args(Args, ModulesToLink)
+	    mercury_compile__process_args(OptionVariables, OptionArgs,
+	    		Args, ModulesToLink)
 	).
 
 :- pred compiling_to_asm(globals::in) is semidet.
@@ -345,13 +410,14 @@
 		OptionList),
 	bool__or_list(BoolList) = no.
 
-:- pred compile_using_gcc_backend(file_or_module,
-		frontend_callback(list(string)),
+:- pred compile_using_gcc_backend(options_variables, list(string),
+		file_or_module, frontend_callback(list(string)),
 		list(string), io__state, io__state).
-:- mode compile_using_gcc_backend(in, in(frontend_callback),
+:- mode compile_using_gcc_backend(in, in, in, in(frontend_callback),
 		out, di, uo) is det.
 
-compile_using_gcc_backend(FirstFileOrModule, CallBack, ModulesToLink) -->
+compile_using_gcc_backend(OptionVariables, OptionArgs, FirstFileOrModule,
+		CallBack, ModulesToLink) -->
 	% The name of the assembler file that we generate
 	% is based on name of the first module named
 	% on the command line.  (Mmake requires this.)
@@ -418,8 +484,11 @@
 			io__output_stream(OutputStream),
 			get_linked_target_type(TargetType),
 			get_object_code_type(TargetType, PIC),
-			compile_target_code__assemble(OutputStream,
-				PIC, ModuleName, AssembleOK),
+			compile_with_module_options(ModuleName,
+				OptionVariables, OptionArgs,
+				compile_target_code__assemble(OutputStream,
+					PIC, ModuleName),
+				AssembleOK),
 			maybe_set_exit_status(AssembleOK)
 		;
 			[]
@@ -493,23 +562,26 @@
 		{ Result = Result0 }
 	).
 
-:- pred process_args(list(string), list(string), io__state, io__state).
-:- mode process_args(in, out, di, uo) is det.
+:- pred process_args(options_variables, list(string), list(string),
+		list(string), io__state, io__state).
+:- mode process_args(in, in, in, out, di, uo) is det.
 
-process_args(Args, ModulesToLink) -->
+process_args(OptionVariables, OptionArgs, Args, ModulesToLink) -->
 	globals__io_lookup_bool_option(filenames_from_stdin,
 		FileNamesFromStdin),
 	( { FileNamesFromStdin = yes } ->
-		process_stdin_arg_list([], ModulesToLink)
+		process_stdin_arg_list(OptionVariables, OptionArgs,
+			[], ModulesToLink)
 	;
-		process_arg_list(Args, ModulesToLink)
+		process_arg_list(OptionVariables, OptionArgs,
+			Args, ModulesToLink)
 	).
 
-:- pred process_stdin_arg_list(list(string), list(string), 
-		io__state, io__state).
-:- mode process_stdin_arg_list(in, out, di, uo) is det.
+:- pred process_stdin_arg_list(options_variables, list(string), list(string),
+		list(string), io__state, io__state).
+:- mode process_stdin_arg_list(in, in, in, out, di, uo) is det.
 
-process_stdin_arg_list(Modules0, Modules) -->
+process_stdin_arg_list(OptionVariables, OptionArgs, Modules0, Modules) -->
 	( { Modules0 \= [] } -> garbage_collect ; [] ),
 	io__read_line_as_string(FileResult),
 	( 
@@ -519,9 +591,10 @@
 		;
 			Arg = Line
 		},
-		process_arg(Arg, Module),
+		process_arg(OptionVariables, OptionArgs, Arg, Module),
 		{ list__append(Module, Modules0, Modules1) },
-		process_stdin_arg_list(Modules1, Modules)
+		process_stdin_arg_list(OptionVariables, OptionArgs,
+			Modules1, Modules)
 	;
 		{ FileResult = eof },
 		{ Modules = Modules0 }
@@ -534,22 +607,24 @@
 		io__set_exit_status(1)
 	).
 
-:- pred process_arg_list(list(string), list(string), io__state, io__state).
-:- mode process_arg_list(in, out, di, uo) is det.
+:- pred process_arg_list(options_variables, list(string), list(string),
+		list(string), io__state, io__state).
+:- mode process_arg_list(in, in, in, out, di, uo) is det.
 
-process_arg_list(Args, Modules) -->
-	process_arg_list_2(Args, ModulesList),
+process_arg_list(OptionVariables, OptionArgs, Args, Modules) -->
+	process_arg_list_2(OptionVariables, OptionArgs, Args, ModulesList),
 	{ list__condense(ModulesList, Modules) }.
 
-:- pred process_arg_list_2(list(string), list(list(string)),
-			io__state, io__state).
-:- mode process_arg_list_2(in, out, di, uo) is det.
-
-process_arg_list_2([], []) --> [].
-process_arg_list_2([Arg | Args], [Modules | ModulesList]) -->
-	process_arg(Arg, Modules),
+:- pred process_arg_list_2(options_variables, list(string), list(string),
+		list(list(string)), io__state, io__state).
+:- mode process_arg_list_2(in, in, in, out, di, uo) is det.
+
+process_arg_list_2(_, _, [], []) --> [].
+process_arg_list_2(OptionVariables, OptionArgs, [Arg | Args],
+		[Modules | ModulesList]) -->
+	process_arg(OptionVariables, OptionArgs, Arg, Modules),
 	( { Args \= [] } -> garbage_collect ; [] ),
-	process_arg_list_2(Args, ModulesList).
+	process_arg_list_2(OptionVariables, OptionArgs, Args, ModulesList).
 
 	% Figure out whether the argument is a module name or a file name.
 	% Open the specified file or module, and process it.
@@ -557,11 +632,33 @@
 	% if they were compiled to seperate object files)
 	% that should be linked into the final executable.
 
-:- pred process_arg(string, list(string), io__state, io__state).
-:- mode process_arg(in, out, di, uo) is det.
+:- pred process_arg(options_variables, list(string), string,
+		list(string), io__state, io__state).
+:- mode process_arg(in, in, in, out, di, uo) is det.
 
-process_arg(Arg, ModulesToLink) -->
+process_arg(OptionVariables, OptionArgs, Arg, ModulesToLink) -->
 	{ FileOrModule = string_to_file_or_module(Arg) },
+	globals__io_lookup_bool_option(invoked_by_mmc_make, InvokedByMake),
+	( { InvokedByMake = no } ->
+    		build_with_module_options(
+			file_or_module_to_module_name(FileOrModule),
+        		OptionVariables, OptionArgs, [],
+			(pred(_::in, yes::out, _::in,
+					Modules::out, di, uo) is det -->	
+	    			process_arg_2(OptionVariables, OptionArgs,
+					FileOrModule, Modules)
+			), _, [], ModulesToLink)
+	;
+		% `mmc --make' has already set up the options.
+		process_arg_2(OptionVariables, OptionArgs,
+			FileOrModule, ModulesToLink)
+	).
+
+:- pred process_arg_2(options_variables, list(string),
+		file_or_module, list(string), io__state, io__state).
+:- mode process_arg_2(in, in, in, out, di, uo) is det.
+
+process_arg_2(OptionVariables, OptionArgs, FileOrModule, ModulesToLink) -->
 	globals__io_lookup_bool_option(generate_dependencies, GenerateDeps),
 	( { GenerateDeps = yes } ->
 		{ ModulesToLink = [] },
@@ -573,7 +670,8 @@
 			generate_module_dependencies(ModuleName)
 		)
 	;
-		process_module(FileOrModule, ModulesToLink)
+		process_module(OptionVariables, OptionArgs,
+			FileOrModule, ModulesToLink)
 	).
 
 :- type file_or_module
@@ -597,6 +695,13 @@
 		FileOrModule = module(ModuleName) 			
 	).
 
+:- func file_or_module_to_module_name(file_or_module) = module_name.
+
+file_or_module_to_module_name(file(FileName)) = ModuleName :-
+	% Assume the module name matches the file name.
+	file_name_to_module_name(FileName, ModuleName).
+file_or_module_to_module_name(module(ModuleName)) = ModuleName.
+
 :- pred read_module(file_or_module, bool, module_name, file_name,
 		maybe(timestamp), item_list, module_error,
 		read_modules, read_modules, io__state, io__state).
@@ -706,10 +811,11 @@
 	maybe_report_stats(Stats),
 	{ string__append(FileName, ".m", SourceFileName) }.
 
-:- pred process_module(file_or_module, list(string), io__state, io__state).
-:- mode process_module(in, out, di, uo) is det.
+:- pred process_module(options_variables, list(string),
+		file_or_module, list(string), io__state, io__state).
+:- mode process_module(in, in, in, out, di, uo) is det.
 
-process_module(FileOrModule, ModulesToLink) -->
+process_module(OptionVariables, OptionArgs, FileOrModule, ModulesToLink) -->
 	globals__io_lookup_bool_option(halt_at_syntax_errors, HaltSyntax),
 	globals__io_lookup_bool_option(make_interface, MakeInterface),
 	globals__io_lookup_bool_option(make_short_interface,
@@ -738,8 +844,7 @@
 		( { halt_at_module_error(HaltSyntax, Error) } ->
 			[]
 		;
-			split_into_submodules(ModuleName,
-				Items, SubModuleList),
+			split_into_submodules(ModuleName, Items, SubModuleList),
 			list__foldl(
 				(pred(SubModule::in, di, uo) is det -->
 					ProcessModule(FileName, ModuleName,
@@ -817,7 +922,8 @@
 		;
 			( { Target = asm, Smart = yes } ->
 			    % See the comment in process_all_args.
-			    compile_using_gcc_backend(FileOrModule,
+			    compile_using_gcc_backend(OptionVariables,
+			    	OptionArgs, FileOrModule,
 				process_module_2(FileOrModule,
 					ModulesToRecompile, ReadModules),
 				ModulesToLink)
@@ -955,6 +1061,28 @@
 
 module_to_link(ModuleName - _Items, ModuleToLink) -->
 	{ module_name_to_file_name(ModuleName, ModuleToLink) }.
+
+:- type compile == pred(bool, io__state, io__state).
+:- inst compile == (pred(out, di, uo) is det).
+
+:- pred compile_with_module_options(module_name::in, options_variables::in,
+		list(string)::in, compile::in(compile),
+		bool::out, io__state::di, io__state::uo) is det.
+
+compile_with_module_options(ModuleName, OptionVariables, OptionArgs,
+		Compile, Succeeded) -->
+	globals__io_lookup_bool_option(invoked_by_mmc_make, InvokedByMake),
+	( { InvokedByMake = yes } ->
+		% `mmc --make' has already set up the options.
+		Compile(Succeeded)
+	;
+		build_with_module_options(ModuleName, OptionVariables,
+			OptionArgs, [],
+			(pred(_::in, Succeeded0::out,
+					X::in, X::out, di, uo) is det -->
+				Compile(Succeeded0)
+			), Succeeded, unit, _)
+	).
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.406
diff -u -u -r1.406 options.m
--- compiler/options.m	21 Feb 2003 01:54:38 -0000	1.406
+++ compiler/options.m	21 Feb 2003 02:57:37 -0000
@@ -1890,6 +1890,8 @@
 long_option("extra-init-command",	extra_init_command).
 long_option("mercury-configuration-directory",
 				mercury_configuration_directory_special).
+long_option("mercury-config-dir",
+				mercury_configuration_directory_special).
 long_option("install-prefix",		install_prefix).
 long_option("install-command",		install_command).
 long_option("library-grade",		libgrades).
Index: compiler/options_file.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options_file.m,v
retrieving revision 1.15
diff -u -u -r1.15 options_file.m
--- compiler/options_file.m	5 Feb 2003 14:41:14 -0000	1.15
+++ compiler/options_file.m	18 Feb 2003 03:06:48 -0000
@@ -20,7 +20,14 @@
 
 :- func options_variables_init = options_variables.
 
-:- pred read_options_files(maybe(options_variables)::out,
+	% Read a single options file.  No searching will be done.
+	% This is used to read the configuration file.
+:- pred read_options_file(file_name::in, options_variables::in,
+	maybe(options_variables)::out, io__state::di, io__state::uo) is det.
+
+	% Read all options files specified by `--options-file' options.
+:- pred read_options_files(options_variables::in,
+		maybe(options_variables)::out,
 		io__state::di, io__state::uo) is det.
 
 	% Look up the DEFAULT_MCFLAGS variable.
@@ -74,14 +81,37 @@
 
 options_variables_init = map__init.
 
-read_options_files(MaybeVariables) -->
+read_options_file(OptionsFile, Variables0, MaybeVariables) -->
+	promise_only_solution_io(
+	    (pred(R::out, di, uo) is cc_multi -->
+		try_io(
+	    	    (pred((Variables1)::out, di, uo) is det -->
+			read_options_file(error, no_search, no, OptionsFile,
+				Variables0, Variables1)
+		    ), R)
+	    ), OptionsFileResult),
+	(
+		{ OptionsFileResult = succeeded(Variables) },
+		{ MaybeVariables = yes(Variables) }
+	;
+		{ OptionsFileResult = exception(Exception) },
+		{ Exception = univ(found_options_file_error) ->
+			MaybeVariables = no
+		;
+			rethrow(OptionsFileResult)
+		}
+	;
+		{ OptionsFileResult = failed },
+		{ error("read_options_files") }
+	).
+
+read_options_files(Variables0, MaybeVariables) -->
 	promise_only_solution_io(
 	    (pred(R::out, di, uo) is cc_multi -->
 		try_io(
 	    	    (pred((Variables1)::out, di, uo) is det -->
 			globals__io_lookup_accumulating_option(options_files,
 				OptionsFiles),
-			{ Variables0 = options_variables_init },
 			{ ReadFile =
 			    (pred(OptionsFile::in, Vars0::in, Vars::out,
 					di, uo) is det -->
@@ -132,6 +162,10 @@
 		Variables0, Variables) -->
     ( { OptionsFile0 = "-" } ->
 	% Read from standard input.
+	debug_msg(
+		(pred(di, uo) is det -->
+			io__write_string("Reading options file from stdin.\n")
+		)),
 	read_options_lines(dir__this_directory, Variables0, Variables)
     ;
 	( { OptionsFile0 = "Mercury.options" } ->
@@ -171,6 +205,13 @@
 	search_for_file_returning_dir(Dirs, FileToFind, MaybeDir),
 	(
 		{ MaybeDir = ok(FoundDir) },
+		debug_msg(
+			(pred(di, uo) is det -->
+				io__write_string("Reading options file "),
+				io__write_string(FoundDir / OptionsFile),
+				io__nl
+			)),
+
 		read_options_lines(FoundDir, Variables0, Variables),
 		io__input_stream(OptionsStream),
 		io__set_input_stream(OldInputStream, _),
@@ -430,8 +471,14 @@
 :- pred report_undefined_variables(list(string)::in,
 		io__state::di, io__state::uo) is det.
 
-report_undefined_variables([]) --> [].
-report_undefined_variables([_|Rest] @ UndefVars) -->
+report_undefined_variables(Vars) -->
+	report_undefined_variables_2(list__sort_and_remove_dups(Vars)).
+
+:- pred report_undefined_variables_2(list(string)::in,
+		io__state::di, io__state::uo) is det.
+
+report_undefined_variables_2([]) --> [].
+report_undefined_variables_2([_|Rest] @ UndefVars) -->
 	globals__io_lookup_bool_option(warn_undefined_options_variables, Warn),
 	( { Warn = yes } ->
 		io__input_stream_name(FileName),
@@ -439,14 +486,15 @@
 		{ Context = term__context_init(FileName, LineNumber) },
 
 		{ error_util__list_to_pieces(
-			list__map((func(Var) = "`" ++ Var ++ "'"), UndefVars),
+			list__map((func(Var) = "`" ++ Var ++ "'"),
+				list__sort_and_remove_dups(UndefVars)),
 			VarList) },
-		{ Rest = [], Word = "variable"
-		; Rest = [_|_], Word = "variables"
+		{ Rest = [], Word = "variable", IsOrAre = "is"
+		; Rest = [_|_], Word = "variables", IsOrAre = "are"
 		},
 		{ Pieces =
 			[words("Warning: "), words(Word) | VarList]
-			++ [words("are undefined.")] },
+			++ [words(IsOrAre), words("undefined.")] },
 		write_error_pieces(Context, 0, Pieces),
 
 		globals__io_lookup_bool_option(halt_at_warn, Halt),
@@ -775,6 +823,8 @@
 	;	lib_dirs
 	;	lib_grades
 	;	install_prefix
+	;	stdlib_dir
+	;	config_dir
 	;	linkage
 	;	mercury_linkage
 	.
@@ -784,12 +834,15 @@
 	% `LIBRARIES' should come before `MLLIBS' (Mercury libraries
 	% depend on C libraries, but C libraries typically do not
 	% depend on Mercury libraries).
+	% `MERCURY_STDLIB_DIR' and `MERCURY_CONFIG_DIR' should come before
+	% `MCFLAGS'. Settings in `MCFLAGS' (e.g. `--no-mercury-stdlib-dir')
+	% should override settings of these MERCURY_STDLIB_DIR
+	% in the environment.
 options_variable_types =
-	[grade_flags, linkage, mercury_linkage, mmc_flags, c_flags, java_flags,
-	ilasm_flags, csharp_flags, mcpp_flags,
-	ml_objs, lib_dirs, ld_flags,
-	libraries, ml_libs, c2init_args,
-	lib_grades, install_prefix].
+	[grade_flags, linkage, mercury_linkage, lib_grades, stdlib_dir,
+	config_dir, mmc_flags, c_flags, java_flags, ilasm_flags,
+	csharp_flags, mcpp_flags, ml_objs, lib_dirs, ld_flags,
+	libraries, ml_libs, c2init_args, install_prefix].
 
 :- func options_variable_name(options_variable_type) = string.
 
@@ -809,6 +862,8 @@
 options_variable_name(lib_dirs) = "LIB_DIRS".
 options_variable_name(lib_grades) = "LIBGRADES".
 options_variable_name(install_prefix) = "INSTALL_PREFIX".
+options_variable_name(stdlib_dir) = "MERCURY_STDLIB_DIR".
+options_variable_name(config_dir) = "MERCURY_CONFIG_DIR".
 options_variable_name(linkage) = "LINKAGE".
 options_variable_name(mercury_linkage) = "MERCURY_LINKAGE".
 
@@ -828,7 +883,9 @@
 options_variable_type_is_target_specific(c2init_args) = yes.
 options_variable_type_is_target_specific(libraries) = yes.
 options_variable_type_is_target_specific(lib_dirs) = no.
-options_variable_type_is_target_specific(install_prefix) = no.
+options_variable_type_is_target_specific(install_prefix) = yes.
+options_variable_type_is_target_specific(stdlib_dir) = no.
+options_variable_type_is_target_specific(config_dir) = no.
 options_variable_type_is_target_specific(lib_grades) = yes.
 options_variable_type_is_target_specific(linkage) = yes.
 options_variable_type_is_target_specific(mercury_linkage) = yes.
@@ -885,6 +942,8 @@
 mmc_option_type(lib_dirs) = option([], "--mercury-library-directory").
 mmc_option_type(lib_grades) = option(["--no-libgrade"], "--libgrade").
 mmc_option_type(install_prefix) = option([], "--install-prefix").
+mmc_option_type(stdlib_dir) = option([], "--mercury-stdlib-dir").
+mmc_option_type(config_dir) = option([], "--mercury-config-dir").
 mmc_option_type(linkage) = option([], "--linkage").
 mmc_option_type(mercury_linkage) = option([], "--mercury-linkage").
 
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.355
diff -u -u -r1.355 user_guide.texi
--- doc/user_guide.texi	21 Feb 2003 01:57:23 -0000	1.355
+++ doc/user_guide.texi	21 Feb 2003 02:57:43 -0000
@@ -6320,6 +6320,12 @@
 standard input.  By default the file @file{Mercury.options}
 in the current directory will be read.
 
+ at item --config-file @var{file}
+ at findex --config-file
+Read the Mercury compiler's configuration information from @var{file}.
+If the @samp{--config-file} option is not set, a default configuration
+will be used, unless @samp{--no-mercury-stdlib-dir} is passed to mmc.
+
 @sp 1
 @item --options-search-directory @var{dir}
 @findex --options-search-directory
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	21 Feb 2003 11:33:50 -0000
@@ -0,0 +1,88 @@
+#! /bin/sh
+# @configure_input@
+#---------------------------------------------------------------------------#
+# Copyright (C) 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.
+#---------------------------------------------------------------------------#
+#
+# Mercury.config
+#
+# Configuration file for the Melbourne Mercury Compiler.
+#
+# Environment variables: MERCURY_STDLIB_DIR, MERCURY_C_COMPILER,
+# MERCURY_DEFAULT_GRADE, MERCURY_DEFAULT_OPT_LEVEL.
+
+# These settings won't override settings in the environment.
+MERCURY_STDLIB_DIR=@LIBDIR@
+MERCURY_DEFAULT_OPT_LEVEL=-O2
+MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@
+MERCURY_ALL_MC_C_INCL_DIRS=
+MERCURY_C_COMPILER="@CC@"
+MERCURY_MATH_LIB="@MATH_LIB@"
+# $(MATH_LIB) needs to be defined because it may
+# be used by the substitution for SHARED_LIBS.
+MATH_LIB=$(MERCURY_MATH_LIB)
+
+# The default optimization level should be after
+# all the options that describe the machine configuration.
+DEFAULT_MCFLAGS=\
+		$(MERCURY_ALL_MC_C_INCL_DIRS) \
+		@ALL_LOCAL_C_INCL_DIR_MMC_OPTS@ \
+		@ALL_LOCAL_C_LIB_DIR_MMC_OPTS@ \
+		--cc "$(MERCURY_C_COMPILER)" \
+		--grade "$(MERCURY_DEFAULT_GRADE)" \
+		--cflags-for-ansi \"@CFLAGS_FOR_ANSI@\" \
+		--cflags-for-optimization \"@CFLAGS_FOR_OPT@\" \
+		--cflags-for-warnings \"@CFLAGS_FOR_WARNINGS@\" \
+		--cflags-for-threads \"@CFLAGS_FOR_THREADS@\" \
+		--cflags-for-debug \"@CFLAGS_FOR_DEBUG@\" \
+		--cflags-for-regs \"@CFLAGS_FOR_REGS@\" \
+		--cflags-for-gotos \"@CFLAGS_FOR_GOTOS@\" \
+		--cflags-for-pic \"@CFLAGS_FOR_PIC@\" \
+		--c-flag-to-name-object-file \"@OBJFILE_OPT@\" \
+		--object-file-extension \". at OBJ_SUFFIX@\" \
+		--pic-object-file-extension \". at EXT_FOR_PIC_OBJECTS@\" \
+		--link-with-pic-object-file-extension \". at EXT_FOR_LINK_WITH_PIC_OBJECTS@\" \
+		--executable-file-extension \"@EXT_FOR_EXE@\" \
+		--shared-library-extension \". at EXT_FOR_SHARED_LIB@\" \
+		--library-extension \". at LIB_SUFFIX@\" \
+		--create-archive-command \"@AR@\" \
+		--create-archive-command-output-flag \"@AR_LIBFILE_OPT@\" \
+		--create-archive-command-flags \"@ARFLAGS@\" \
+		--ranlib-command \"@RANLIB@\" \
+		--link-executable-command \"@LINK_EXE@\" \
+		--link-shared-lib-command \"@LINK_SHARED_OBJ@\" \
+		--trace-libs \"@TRACE_LIBS_SYSTEM@\" \
+		--thread-libs \"@THREAD_LIBS@\" \
+		--shared-libs \"@SHARED_LIBS@\" \
+		--math-lib \"@MATH_LIB@\" \
+		--readline-libs \"@READLINE_LIBRARIES@\" \
+		--linker-thread-flags \"@LDFLAGS_FOR_THREADS@\" \
+		--shlib-linker-thread-flags \"@LD_LIBFLAGS_FOR_THREADS@\" \
+		--linker-trace-flags "@LDFLAGS_FOR_TRACE@" \
+		--shlib-linker-trace-flags "@LD_LIBFLAGS_FOR_TRACE@" \
+		--linker-static-flags \"@LD_STATIC_FLAGS@\" \
+		--linker-strip-flag \"@LD_STRIP_FLAG@\" \
+		--linker-debug-flags \"@LDFLAGS_FOR_DEBUG@\" \
+		--shlib-linker-debug-flags \"@LD_LIBFLAGS_FOR_DEBUG@\" \
+		--linker-rpath-flag \"@EXE_RPATH_OPT@\" \
+		--linker-rpath-separator \"@EXE_RPATH_SEP@\" \
+		--shlib-linker-rpath-flag \"@SHLIB_RPATH_OPT@\" \
+		--shlib-linker-rpath-separator \"@SHLIB_RPATH_SEP@\" \
+		--linker-allow-undefined-flag \"@ALLOW_UNDEFINED@\" \
+		--linker-error-undefined-flag \"@ERROR_UNDEFINED@\" \
+		--fullarch \"@FULLARCH@\" \
+		--install-prefix \"@prefix@\" \
+		--num-real-r-regs \"@NUM_REAL_R_REGS@\" \
+		--num-real-r-temps \"@NUM_REAL_R_TEMPS@\" \
+		--conf-low-tag-bits \"@LOW_TAG_BITS@\" \
+		--bits-per-word \"@BITS_PER_WORD@\" \
+		--bytes-per-word \"@BYTES_PER_WORD@\" \
+		--dotnet-library-version \"@MS_DOTNET_LIBRARY_VERSION@\" \
+		@HAVE_DELAY_SLOT@ \
+		@HAVE_BOXED_FLOATS@ \
+		@MCFLAGS_FOR_CC@ \
+		$(MERCURY_DEFAULT_OPT_LEVEL) \
+		@LIBGRADE_OPTS@ 
+
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.88
diff -u -u -r1.88 Mmake.vars.in
--- scripts/Mmake.vars.in	10 Feb 2003 09:34:15 -0000	1.88
+++ scripts/Mmake.vars.in	11 Feb 2003 12:51:50 -0000
@@ -57,7 +57,7 @@
 
 DEFAULT_GRADE	= $(MERCURY_DEFAULT_GRADE)
 GRADE		= $(DEFAULT_GRADE)
-GRADESTRING	= $(shell $(MCOGS) $(ALL_GRADEFLAGS))
+GRADESTRING	= $(shell $(MCOGS) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS))
 
 # This may be overridden on the command line
 TARGET_ASM	= no
Index: scripts/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmakefile,v
retrieving revision 1.30
diff -u -u -r1.30 Mmakefile
--- scripts/Mmakefile	24 Jan 2003 07:17:12 -0000	1.30
+++ scripts/Mmakefile	13 Feb 2003 06:48:34 -0000
@@ -34,7 +34,7 @@
 
 .PHONY: all
 all: $(SCRIPTS) $(DEBUGGER_SCRIPTS) $(EMACS_SCRIPTS)
-all: Mmake.vars
+all: Mmake.vars Mercury.config
 
 #-----------------------------------------------------------------------------#
 
@@ -48,7 +48,7 @@
 #-----------------------------------------------------------------------------#
 
 .PHONY: install
-install: install_mmake install_scripts \
+install: install_mmake install_scripts install_config \
 	install_debugger_scripts install_emacs_scripts
 
 .PHONY: install_dirs
@@ -56,6 +56,7 @@
 	[ -d $(INSTALL_BINDIR) ] || mkdir -p $(INSTALL_BINDIR)
 	[ -d $(INSTALL_LIBDIR)/mmake ] || mkdir -p $(INSTALL_LIBDIR)/mmake
 	[ -d $(INSTALL_LIBDIR)/mdb ] || mkdir -p $(INSTALL_LIBDIR)/mdb
+	[ -d $(INSTALL_CONF_DIR) ] || mkdir -p $(INSTALL_CONF_DIR)
 	[ -d $(INSTALL_ELISP_DIR) ] || mkdir -p $(INSTALL_ELISP_DIR)
 	[ -d $(INSTALL_RECONF_DIR)/scripts ] || \
 		mkdir -p $(INSTALL_RECONF_DIR)/scripts
@@ -78,6 +79,11 @@
 	done
 	cp *.in *.sh-subr $(SCRIPTS) $(INSTALL_RECONF_DIR)/scripts
 	-rm -f $(INSTALL_BINDIR)/mmake.old
+
+.PHONY: install_config
+install_config: Mercury.config install_dirs
+	rm -f $(INSTALL_CONF_DIR)/Mercury.config
+	cp `vpath_find Mercury.config` $(INSTALL_CONF_DIR)
 
 .PHONY: install_debugger_scripts
 install_debugger_scripts: $(DEBUGGER_SCRIPTS) install_dirs
Index: scripts/mercury_config.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mercury_config.in,v
retrieving revision 1.1
diff -u -u -r1.1 mercury_config.in
--- scripts/mercury_config.in	24 Jan 2003 07:17:12 -0000	1.1
+++ scripts/mercury_config.in	28 Feb 2003 10:27:17 -0000
@@ -153,6 +153,7 @@
 # Copy the new configuration into place.
 #
 cp runtime/mercury_conf.h $output_libdir/conf || exit 1
+cp scripts/Mercury.config $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} \
@@ -164,7 +165,7 @@
 echo *
 for file in *; do
 	case "$file" in
-		*.in|Mmake.*|mdbrc|*.sh-subr) ;;
+		*.in|Mmake.*|Mercury.config|mdbrc|*.sh-subr) ;;
 		*)
 			cp $file $output_prefix/bin || exit 1
 			chmod u+w $output_prefix/bin/$file || exit 1
Index: scripts/mmc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mmc.in,v
retrieving revision 1.32
diff -u -u -r1.32 mmc.in
--- scripts/mmc.in	17 Feb 2003 07:42:56 -0000	1.32
+++ scripts/mmc.in	17 Feb 2003 08:35:13 -0000
@@ -19,10 +19,11 @@
     "")
 	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
+	MERCURY_CONFIG_DIR=${MERCURY_CONFIG_DIR=$CONFIG_DIR}
+	MERCURY_STDLIB_DIR=${MERCURY_STDLIB_DIR=@LIBDIR@}
+	export MERCURY_CONFIG_DIR MERCURY_STDLIB_DIR
+	STDLIB_DIR_OPT="--mercury-standard-library-directory \"${MERCURY_STDLIB_DIR}\""
+	if [ "$MERCURY_STDLIB_DIR" != "$MERCURY_CONFIG_DIR" ]; then
 		CONFIG_DIR_OPT="--mercury-configuration-directory \"${CONFIG_DIR}\""
 	else
 		CONFIG_DIR_OPT=
@@ -31,6 +32,8 @@
     *)
 	INT_DIR_OPT="-I $MERCURY_INT_DIR"
 	STDLIB_DIR_OPT=--no-mercury-standard-library-directory
+	CONFIG_DIR_OPT=--no-mercury-configuration-directory
+	unset MERCURY_STDLIB_DIR MERCURY_CONFIG_DIR
 	CONFIG_DIR_OPT=
 	;;
 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