[m-rev.] for review: bootcheck using `mmc --make'

Simon Taylor stayl at cs.mu.OZ.AU
Thu Jun 20 02:49:51 AEST 2002


Estimated hours taken: 5
Branches: main

Allow tools/bootcheck to be run using `mmake --use-mmc-make'.
The tests don't work yet.

compiler/make.m:
compiler/make.module_target.m:
	Handle targets such as `<module>.cs' and `<module>.ints',
	which are used when building stage 3.

Mmake.common.in:
*/Mmakefile:
*/Mercury.options:
	Add Mercury.options files to pass module-specific flags to
	`mmc --make'.

	Avoid triggering the .DEFAULT rule introduced with `--use-mmc-make'
	for optional files like Mmake.params.

compiler/modules.m:
	Build the interface files when building a library in IL grades,
	for consistency with C grades.

library/Mmakefile:
	Improve performance by removing the dependency on the interface
	files when building the library. The files are now always built
	by the libmer_std target.

	Pass the command to build libmer_std.init to `mmc --make'.

tools/bootcheck:
	Add an option `--use-mmc-make'.

	Copy the Mercury.options files into the stage2 and stage3 directories.

compiler/Mmakefile:
tools/bootcheck:
tools/binary_step:
	`mmc --make' doesn't handle `<module>_init.c' targets, so
	don't make the `cs' target depend on `top_level_init.c'.
	As far as I can tell, that dependency is only present so
	that the stage2 and stage3 compilers have the same set of
	C files. bootcheck and binary_step now only compare `.c'
	files which are present in the stage3 directory.

Index: Mmake.common.in
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.common.in,v
retrieving revision 1.64
diff -u -u -r1.64 Mmake.common.in
--- Mmake.common.in	13 May 2002 08:09:33 -0000	1.64
+++ Mmake.common.in	18 Jun 2002 07:17:46 -0000
@@ -208,8 +208,15 @@
 
 #-----------------------------------------------------------------------------#
 
+# Module-specific options should go in Mercury.options so they
+# can be found by `mmc --make'.
+include $(MERCURY_DIR)/Mercury.options
+
 # The Mmake.params file can be used to override definitions in this file
 -include $(MERCURY_DIR)/Mmake.params
+
+# Avoid trying to make this file with `mmc --make' if it doesn't exist.
+$(MERCURY_DIR)/Mmake.params: ;
 
 #-----------------------------------------------------------------------------#
 
Index: Mmake.workspace
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.workspace,v
retrieving revision 1.6
diff -u -u -r1.6 Mmake.workspace
--- Mmake.workspace	13 May 2002 08:09:34 -0000	1.6
+++ Mmake.workspace	18 Jun 2002 07:20:34 -0000
@@ -84,6 +84,10 @@
 
 VPATH =		$(LIBRARY_DIR)
 
+ifeq ($(MMAKE_USE_MMC_MAKE),yes)
+MCFLAGS +=	--options-file $(WORKSPACE)/Mercury.options
+endif
+
 MCFLAGS += 	--no-mercury-stdlib-dir -I$(LIBRARY_DIR)
 MGNUCFLAGS +=	--no-mercury-stdlib-dir
 C2INITFLAGS += 	--trace-init-file $(BROWSER_DIR)/$(BROWSER_LIB_NAME).init
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.79
diff -u -u -r1.79 Mmakefile
--- Mmakefile	31 May 2002 07:02:34 -0000	1.79
+++ Mmakefile	19 Jun 2002 14:05:59 -0000
@@ -233,6 +233,7 @@
 
 Mmake.common: Mmake.common.in config.status
 	./config.status
+	touch Mercury.options
 
 README: .README.in VERSION
 	sed 's/@VERSION@/$(VERSION)/g' .README.in > README
Index: browser/Mercury.options
===================================================================
RCS file: browser/Mercury.options
diff -N browser/Mercury.options
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ browser/Mercury.options	18 Jun 2002 07:17:46 -0000
@@ -0,0 +1 @@
+MCFLAGS-mer_browser = --no-warn-nothing-exported
Index: browser/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/Mmakefile,v
retrieving revision 1.23
diff -u -u -r1.23 Mmakefile
--- browser/Mmakefile	17 Jun 2002 15:30:03 -0000	1.23
+++ browser/Mmakefile	19 Jun 2002 13:29:05 -0000
@@ -19,7 +19,12 @@
 LINK_STDLIB_ONLY=yes
 include $(MERCURY_DIR)/Mmake.common
 
+# Module-specific options should go in Mercury.options so they
+# can be found by `mmc --make'.
+include Mercury.options
+
 MAIN_TARGET=library
+MERCURY_MAIN_MODULES=$(BROWSER_LIB_NAME) browse_test declarative_test
 
 #-----------------------------------------------------------------------------#
 
@@ -33,8 +38,6 @@
 MLLIBS +=	$(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY)	\
 		$(READLINE_LIBRARIES)
 
-MCFLAGS-mer_browser = --no-warn-nothing-exported
-
 MTAGS	=	$(SCRIPTS_DIR)/mtags
 
 LN	=	ln
@@ -107,9 +110,15 @@
 #-----------------------------------------------------------------------------#
 
 .PHONY: os cs ss
+ifeq ($(MMAKE_USE_MMC_MAKE),no)
 os: $($(BROWSER_LIB_NAME).os)
 cs: $($(BROWSER_LIB_NAME).cs)
 ss: $($(BROWSER_LIB_NAME).ss)
+else
+os: $(BROWSER_LIB_NAME).os
+cs: $(BROWSER_LIB_NAME).cs
+ss: $(BROWSER_LIB_NAME).ss
+endif
 
 #-----------------------------------------------------------------------------#
 
Index: compiler/Mercury.options
===================================================================
RCS file: compiler/Mercury.options
diff -N compiler/Mercury.options
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ compiler/Mercury.options	18 Jun 2002 07:17:46 -0000
@@ -0,0 +1,25 @@
+# Compilation of rl_code.c is really slow (about 26 minutes on traveller with
+# --trace deep) at the default level of -O2, due to the C optimizer's use of
+# quadratic algorithms on a couple of 20,000-line functions (the automatically
+# generated index and compare routines on the bytecode type). The code in this
+# module can't really benefit from those algorithms anyway. With -O1, the 26
+# minutes drops to less than 26 seconds.
+CFLAGS-aditi_backend.rl_code=-O1
+
+# process_util.m uses `kill' and `struct sigaction' from <signal.h>,
+# which are not available with `--ansi'.
+MGNUCFLAGS-libs.process_util = --no-ansi
+
+# The c_code in the module gcc.m needs the header files from the GNU C
+# distribution.
+CFLAGS-gcc =	-DMR_NO_BACKWARDS_COMPAT \
+		-DIN_GCC -DHAVE_CONFIG_H \
+		-I. \
+		-I$(GCC_SRC_DIR)/gcc \
+		-I$(GCC_SRC_DIR)/gcc/mercury \
+		-I$(GCC_SRC_DIR)/gcc/config \
+		-I$(GCC_SRC_DIR)/include \
+		-I$(GCC_SRC_DIR)
+# Likewise for mlds_to_gcc.m
+CFLAGS-mlds_to_gcc = $(CFLAGS-gcc)
+
Index: compiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Mmakefile,v
retrieving revision 1.57
diff -u -u -r1.57 Mmakefile
--- compiler/Mmakefile	10 Jun 2002 10:05:47 -0000	1.57
+++ compiler/Mmakefile	19 Jun 2002 14:24:16 -0000
@@ -10,8 +10,18 @@
 LINK_STATIC=yes
 include $(MERCURY_DIR)/Mmake.common
 
+# Module-specific options should go in Mercury.options so they
+# can be found by `mmc --make'.
+# Mercury.options uses $(GCC_SRC_DIR), so make sure it is
+# in the environment of `mmc --make'.
+GCC_SRC_DIR := $(MERCURY_DIR)/$(GCC_SRC_DIR)
+export GCC_SRC_DIR
+include Mercury.options
+
 MAIN_TARGET=mercury
 
+MERCURY_MAIN_MODULES = top_level mlds_to_gcc
+
 VPATH=$(LIBRARY_DIR) $(BROWSER_DIR)
 
 #-----------------------------------------------------------------------------#
@@ -20,7 +30,6 @@
 # This uses the file `mercury_gcc_backend_libs', which is generated by
 # the gcc Makefile (from gcc/mercury/Make-lang.in), which contains
 # a list of the object files and libraries that we need to link in.
-GCC_SRC_DIR := $(MERCURY_DIR)/$(GCC_SRC_DIR)
 ifeq ($(ENABLE_GCC_BACK_END),yes)
 GCC_LIBS = $(shell cat $(GCC_SRC_DIR)/gcc/mercury_gcc_backend_libs)
 GCC_EXTRA_LIBS = $(filter -l%,$(GCC_LIBS))
@@ -32,8 +41,8 @@
 endif
 
 MCFLAGS +=	-I $(BROWSER_DIR)
-ALL_MLLIBS =	../main.$O $(MLLIBS) $(EXTRA_MLLIBS) \
-			$(GCC_BACKEND_LIBS) $(MATH_LIB)
+MLOBJS :=	../main.$O $(MLOBJS)
+ALL_MLLIBS =	$(MLLIBS) $(EXTRA_MLLIBS) $(GCC_BACKEND_LIBS)
 MLFLAGS +=	--no-main --shared
 
 #
@@ -50,32 +59,6 @@
 MLFLAGS += --static
 endif
 
-# Compilation of rl_code.c is really slow (about 26 minutes on traveller with
-# --trace deep) at the default level of -O2, due to the C optimizer's use of
-# quadratic algorithms on a couple of 20,000-line functions (the automatically
-# generated index and compare routines on the bytecode type). The code in this
-# module can't really benefit from those algorithms anyway. With -O1, the 26
-# minutes drops to less than 26 seconds.
-
-CFLAGS-aditi_backend.rl_code=-O1
-
-# process_util.m uses `kill' and `struct sigaction' from <signal.h>,
-# which are not available with `--ansi'.
-MGNUCFLAGS-libs.process_util = --no-ansi
-
-# The c_code in the module gcc.m needs the header files from the GNU C
-# distribution.
-CFLAGS-gcc =	-DMR_NO_BACKWARDS_COMPAT \
-		-DIN_GCC -DHAVE_CONFIG_H \
-		-I. \
-		-I$(GCC_SRC_DIR)/gcc \
-		-I$(GCC_SRC_DIR)/gcc/mercury \
-		-I$(GCC_SRC_DIR)/gcc/config \
-		-I$(GCC_SRC_DIR)/include \
-		-I$(GCC_SRC_DIR)
-# Likewise for mlds_to_gcc.m
-CFLAGS-mlds_to_gcc = $(CFLAGS-gcc)
-
 #-----------------------------------------------------------------------------#
 
 # Rules for preprocessing `.pp' files.
@@ -216,10 +199,10 @@
 mlds_to_gcc.depend: regenerate_preprocessed_files
 
 .PHONY: mercury
-mercury:	$(cs_subdir)mlds_to_gcc.c $(cs_subdir)gcc.c
+mercury:	mlds_to_gcc.c gcc.c
 
 .PHONY: cs
-cs: 		$(cs_subdir)mlds_to_gcc.c $(cs_subdir)gcc.c
+cs: 		mlds_to_gcc.c gcc.c
 
 #-----------------------------------------------------------------------------#
 
@@ -264,9 +247,15 @@
 #-----------------------------------------------------------------------------#
 
 .PHONY: os cs ss
-os: $($(MC_PROG).os) $(os_subdir)$(MC_PROG)_init.$O
-cs: $($(MC_PROG).cs) $(cs_subdir)$(MC_PROG)_init.c
+ifeq ($(USE_MMC_MAKE),no)
+os: $($(MC_PROG).os)
+cs: $($(MC_PROG).cs)
 ss: $($(MC_PROG).ss)
+else
+os: $(MC_PROG).os
+cs: $(MC_PROG).cs
+ss: $(MC_PROG).ss
+endif
 
 #-----------------------------------------------------------------------------#
 
Index: compiler/make.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.m,v
retrieving revision 1.7
diff -u -u -r1.7 make.m
--- compiler/make.m	30 May 2002 12:55:01 -0000	1.7
+++ compiler/make.m	18 Jun 2002 16:36:39 -0000
@@ -159,7 +159,7 @@
 :- type misc_target_type
 	--->	clean
 	;	realclean
-	;	check
+	;	build_all(module_target_type)
 	;	build_library
 	;	install_library
 	.
@@ -342,10 +342,22 @@
 			ModuleNameStr = ModuleNameStr0,
 			TargetType0 = linked_target(executable)
 		;
+			string__append(Suffix1, "s", Suffix),
+			Suffix1 = target_extension(Globals, ModuleTargetType),
+
+			% Not yet implemented. `build_all' targets
+			% are only used by tools/bootcheck, so it
+			% doesn't really matter.
+			ModuleTargetType \= c_header(_)
+		->
+			ModuleNameStr = ModuleNameStr0,
+			TargetType0 = misc_target(
+					build_all(ModuleTargetType))
+		;
 			Suffix = ".check"
 		->
 			ModuleNameStr = ModuleNameStr0,
-			TargetType0 = misc_target(check)
+			TargetType0 = misc_target(build_all(errors))
 		;
 			Suffix = ".clean"
 		->
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.6
diff -u -u -r1.6 make.program_target.m
--- compiler/make.program_target.m	30 May 2002 12:55:01 -0000	1.6
+++ compiler/make.program_target.m	18 Jun 2002 16:45:42 -0000
@@ -28,35 +28,6 @@
 	{ Succeeded = no },
 	{ Info = Info1 }
     ;
-	globals__io_get_target(CompilationTarget),
-	( { CompilationTarget = asm } ->
-	    % An assembler file is only produced for the top-level
-	    % module in each source file.
-	    list__foldl3(
-		(pred(ModuleName::in, ObjModules0::in, ObjModules1::out,
-				MInfo0::in, MInfo::out, di, uo) is det -->
-			get_module_dependencies(ModuleName, MaybeImports,
-				MInfo0, MInfo),
-			{
-				MaybeImports = yes(Imports),
-				ModuleName = Imports ^ source_file_module_name
-			->
-				ObjModules1 = [ModuleName | ObjModules0]
-			;	
-				ObjModules1 = ObjModules0
-			}
-		),
-		set__to_sorted_list(AllModules), [],
-		ObjModules, Info1, Info4)
-	;
-		{ Info4 = Info1 },
-		{ ObjModules = set__to_sorted_list(AllModules) }
-	),
-
-	linked_target_file_name(MainModuleName, FileType, OutputFileName),
-	get_file_timestamp([dir__this_directory], OutputFileName,
-		MaybeTimestamp, Info4, Info5),
-
 	globals__io_lookup_string_option(pic_object_file_extension, PicObjExt),
 	globals__io_lookup_string_option(object_file_extension, ObjExt),
 	{ FileType = shared_library, PicObjExt \= ObjExt ->
@@ -71,6 +42,7 @@
 	% Build the `.c' files first so that errors are
 	% reported as soon as possible.
 	%
+	globals__io_get_target(CompilationTarget),
 	{
 		CompilationTarget = c,
 		IntermediateTargetType = c_code,
@@ -90,13 +62,19 @@
 		ObjectTargetType = object_code(non_pic)
 	},
 
+	get_target_modules(IntermediateTargetType,
+		set__to_sorted_list(AllModules), ObjModules, Info1, Info4),
 	{ IntermediateTargets = make_dependency_list(ObjModules,
 					IntermediateTargetType) },
 	{ ObjTargets = make_dependency_list(ObjModules, ObjectTargetType) },
 
 	foldl2_maybe_stop_at_error(KeepGoing,
 		foldl2_maybe_stop_at_error(KeepGoing, make_module_target),
-		[IntermediateTargets, ObjTargets], _, Info5, Info6),
+		[IntermediateTargets, ObjTargets], _, Info4, Info5),
+
+	linked_target_file_name(MainModuleName, FileType, OutputFileName),
+	get_file_timestamp([dir__this_directory], OutputFileName,
+		MaybeTimestamp, Info5, Info6),
 	check_dependencies(OutputFileName, MaybeTimestamp,
 		ObjTargets, BuildDepsResult, Info6, Info7),
 
@@ -120,6 +98,44 @@
 	)
     ).
 
+:- pred get_target_modules(module_target_type::in, list(module_name)::in,
+	list(module_name)::out, make_info::in, make_info::out,
+	io__state::di, io__state::uo) is det.
+
+get_target_modules(TargetType, AllModules, TargetModules, Info0, Info) -->
+    globals__io_get_target(CompilationTarget),
+    ( 
+	{
+		TargetType = errors
+	;
+		CompilationTarget = asm,
+		( TargetType = asm_code(_)
+		; TargetType = object_code(_)
+		)
+	}
+    ->
+	% `.err' and `.s' files are only produced for the
+	% top-level module in each source file.
+	list__foldl3(
+	    (pred(ModuleName::in, TargetModules0::in, TargetModules1::out,
+			MInfo0::in, MInfo::out, di, uo) is det -->
+		get_module_dependencies(ModuleName, MaybeImports,
+			MInfo0, MInfo),
+		{
+			MaybeImports = yes(Imports),
+			ModuleName = Imports ^ source_file_module_name
+		->
+			TargetModules1 = [ModuleName | TargetModules0]
+		;	
+			TargetModules1 = TargetModules0
+		}
+	    ),
+	    AllModules, [], TargetModules, Info0, Info)
+    ;
+	{ Info = Info0 },
+	{ TargetModules = AllModules }
+    ).
+
 :- pred build_linked_target(module_name::in, linked_target_type::in,
 	file_name::in, maybe_error(timestamp)::in, set(module_name)::in,
 	list(module_name)::in, compilation_target::in, string::in, bool::in,
@@ -358,16 +374,19 @@
 			[ExeExt, LibExt, SharedLibExt, "_init.c", "_init.o"],
 			Info4, Info)
 	;
-		{ TargetType = check },
+		{ TargetType = build_all(ModuleTargetType) },
+		get_target_modules(ModuleTargetType, AllModules,
+			TargetModules, Info3, Info4),
 		globals__io_lookup_bool_option(keep_going, KeepGoing),
 		( { Succeeded0 = no, KeepGoing = no } ->
-			{ Info = Info3 },
+			{ Info = Info4 },
 			{ Succeeded = no }
 		;
 			foldl2_maybe_stop_at_error(KeepGoing,
 				make_module_target,
-				make_dependency_list(AllModules, errors),
-				Succeeded1, Info3, Info),
+				make_dependency_list(TargetModules,
+					ModuleTargetType),
+				Succeeded1, Info4, Info),
 			{ Succeeded = Succeeded0 `and` Succeeded1 }
 		)
 	;
Index: deep_profiler/Mercury.options
===================================================================
RCS file: deep_profiler/Mercury.options
diff -N deep_profiler/Mercury.options
Index: deep_profiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/Mmakefile,v
retrieving revision 1.4
diff -u -u -r1.4 Mmakefile
--- deep_profiler/Mmakefile	29 Apr 2002 08:22:01 -0000	1.4
+++ deep_profiler/Mmakefile	18 Jun 2002 08:01:19 -0000
@@ -12,15 +12,24 @@
 LINK_STATIC=yes
 include $(MERCURY_DIR)/Mmake.common
 
+# Module-specific options should go in Mercury.options so they
+# can be found by `mmc --make'.
+include Mercury.options
+
 ifeq ("$(ENABLE_DEEP_PROFILER)","yes")
 	MAIN_TARGET=mdprof_cgi mdprof_server
+	MERCURY_MAIN_MODULES=mdprof_cgi mdprof_server
 	DEPEND=mdprof_cgi.depend mdprof_server.depend
 	INSTALL=install_deep
 else
 	MAIN_TARGET=nothing
+	MERCURY_MAIN_MODULES=
 	DEPEND=nothing
 	INSTALL=nothing
 endif
+
+# Avoid trying to make this file with `mmc --make' if it doesn't exist.
+Mmake.deep.params: ;
 
 #-----------------------------------------------------------------------------#
 
Index: library/Mercury.options
===================================================================
RCS file: library/Mercury.options
diff -N library/Mercury.options
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ library/Mercury.options	18 Jun 2002 07:17:46 -0000
@@ -0,0 +1,19 @@
+# Modules which use user-guided type specialization need to be
+# compiled with these flags to make sure all calls
+# to the builtin comparison routines are inlined.
+TYPE_SPEC_FLAGS = --inline-vars-threshold 10000
+MCFLAGS-list += $(TYPE_SPEC_FLAGS)
+MCFLAGS-map += $(TYPE_SPEC_FLAGS)
+MCFLAGS-tree234 += $(TYPE_SPEC_FLAGS)
+MCFLAGS-set += $(TYPE_SPEC_FLAGS)
+MCFLAGS-set_ordlist += $(TYPE_SPEC_FLAGS)
+
+# Bug workarounds.
+MCFLAGS-std_util += --no-halt-at-warn
+ 
+# io.m uses library features that are supported by POSIX but which are not
+# part of ANSI C, such as `struct stat', fileno(), and putenv().
+# We need to pass --no-ansi to mgnuc to ensure that these are declared.
+MGNUCFLAGS-io =	--no-ansi
+
+MCFLAGS-mer_std = --no-warn-nothing-exported
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.92
diff -u -u -r1.92 Mmakefile
--- library/Mmakefile	31 May 2002 07:02:37 -0000	1.92
+++ library/Mmakefile	19 Jun 2002 14:26:52 -0000
@@ -18,6 +18,12 @@
 LINK_RUNTIME_ONLY=yes
 include $(MERCURY_DIR)/Mmake.common
 
+# Module-specific options should go in Mercury.options so they
+# can be found by `mmc --make'.
+include Mercury.options
+
+MERCURY_MAIN_MODULES = mer_std
+
 MAIN_TARGET=mercury
 
 VPATH=.
@@ -68,21 +74,6 @@
 MCFLAGS += --strict-sequential --trace minimum --generate-mmc-deps \
 		$(INTERMODULE_OPTS) $(ENABLE_TERM_OPTS) $(CHECK_TERM_OPTS)
 
-# Modules which use user-guided type specialization need to be
-# compiled with these flags to make sure all calls
-# to the builtin comparison routines are inlined.
-TYPE_SPEC_FLAGS = --inline-vars-threshold 10000
-MCFLAGS-list += $(TYPE_SPEC_FLAGS)
-MCFLAGS-map += $(TYPE_SPEC_FLAGS)
-MCFLAGS-tree234 += $(TYPE_SPEC_FLAGS)
-MCFLAGS-set += $(TYPE_SPEC_FLAGS)
-MCFLAGS-set_ordlist += $(TYPE_SPEC_FLAGS)
-
-# Bug workarounds.
-MCFLAGS-std_util += --no-halt-at-warn
-
-MCFLAGS-mer_std = --no-warn-nothing-exported
-
 #-----------------------------------------------------------------------------#
 
 CFLAGS	+=	$(DLL_CFLAGS) -I$(TRACE_DIR)
@@ -110,11 +101,6 @@
 
 endif
 
-# io.m uses library features that are supported by POSIX but which are not
-# part of ANSI C, such as `struct stat', fileno(), and putenv().
-# We need to pass --no-ansi to mgnuc to ensure that these are declared.
-MGNUCFLAGS-io =	--no-ansi
-
 #-----------------------------------------------------------------------------#
 
 # targets
@@ -123,7 +109,7 @@
 all : mercury
 
 .PHONY: mercury
-mercury : all-ints lib_std
+mercury : lib_std
 
 #-----------------------------------------------------------------------------#
 
@@ -182,11 +168,19 @@
 # So don't remove the pic_ss target here.
 
 .PHONY: os cs ss pic_ss ils 
+ifeq ($(MMAKE_USE_MMC_MAKE),no)
 os: $($(STD_LIB_NAME).os)
 cs: $($(STD_LIB_NAME).cs)
 ss: $($(STD_LIB_NAME).ss)
 pic_ss: $($(STD_LIB_NAME).pic_ss)
 ils: $($(STD_LIB_NAME).ils)
+else
+os: $(STD_LIB_NAME).os
+cs: $(STD_LIB_NAME).cs
+ss: $(STD_LIB_NAME).ss
+pic_ss: $(STD_LIB_NAME).pic_ss
+ils: $(STD_LIB_NAME).ils
+endif
 
 #-----------------------------------------------------------------------------#
 
@@ -220,8 +214,7 @@
 library_strong_name.sn:
 	sn -k library_strong_name.sn
 
-mercury.dll: copy_runtime_dlls $($(STD_LIB_NAME).dlls) \
-			$($(STD_LIB_NAME).foreign_dlls) library_strong_name.sn
+mercury.dll: copy_runtime_dlls lib$(STD_LIB_NAME) library_strong_name.sn
 	$(MS_AL) -v:0.0.0.0 -keyf:library_strong_name.sn -out:mercury.dll \
 		$($(STD_LIB_NAME).dlls) $($(STD_LIB_NAME).foreign_dlls) \
 		$(RUNTIME_DLLS) 
@@ -237,14 +230,18 @@
 mercury_mcpp.dll: ../runtime/mercury_mcpp.dll
 	cp ../runtime/mercury_mcpp.dll .
 
-else
+else	# GRADE != il
 
-# the following dependency is just there to improve compilation speed;
+# The following dependency is just there to improve compilation speed;
 # making tree234.$O first improves effective parallelism with parallel makes.
+# `mmc --make' does not support parallel makes, so this dependency just
+# slows things down.
+ifeq ($(MMAKE_USE_MMC_MAKE),no)
 lib_std: $(os_subdir)tree234.$O
+endif
 lib_std: lib$(STD_LIB_NAME)
 
-endif
+ifeq ($(MMAKE_USE_MMC_MAKE),no)
 
 $(STD_LIB_NAME).init: $(deps_subdir)$(STD_LIB_NAME).dep
 	for file in $($(STD_LIB_NAME).ms); do \
@@ -252,6 +249,19 @@
 		echo "INIT mercury__`basename $$file .m`__init"; \
 	done > $(STD_LIB_NAME).init
 
+else
+
+# The command below is invoked as "command >& module.err". The braces
+# stop the output meant for the `.init' file being redirected to the
+# `.err' file.
+MCFLAGS += --make-init-file-command \
+		"{ for module in %; do \
+			grep '^INIT ' $$$${module}.m; \
+			echo INIT mercury__$$$${module}__init; \
+		done > @.init; }"
+endif
+
+endif	# GRADE != il
 #-----------------------------------------------------------------------------#
 
 # Ensure we recompile library__version if VERSION is changed.
Index: profiler/Mercury.options
===================================================================
RCS file: profiler/Mercury.options
diff -N profiler/Mercury.options
Index: profiler/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/profiler/Mmakefile,v
retrieving revision 1.20
diff -u -u -r1.20 Mmakefile
--- profiler/Mmakefile	29 Apr 2002 08:22:02 -0000	1.20
+++ profiler/Mmakefile	18 Jun 2002 07:17:46 -0000
@@ -10,7 +10,12 @@
 LINK_STATIC=yes
 include $(MERCURY_DIR)/Mmake.common
 
+# Module-specific options should go in Mercury.options so they
+# can be found by `mmc --make'.
+include Mercury.options
+
 MAIN_TARGET=mercury_profile
+MERCURY_MAIN_MODULES=mercury_profile
 
 #-----------------------------------------------------------------------------#
 
Index: runtime/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/Mmakefile,v
retrieving revision 1.89
diff -u -u -r1.89 Mmakefile
--- runtime/Mmakefile	29 Apr 2002 08:22:02 -0000	1.89
+++ runtime/Mmakefile	18 Jun 2002 07:17:46 -0000
@@ -13,6 +13,9 @@
 include $(MERCURY_DIR)/Mmake.common
 -include Mmake.runtime.params
 
+# Avoid trying to make this file with `mmc --make' if it doesn't exist.
+Mmake.runtime.params: ;
+
 #-----------------------------------------------------------------------------#
 
 CFLAGS	+= -g $(DLL_CFLAGS) -DMERCURY_BOOTSTRAP_H -DMERCURY_CONF_BOOTSTRAP_H
Index: tools/binary_step
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/binary_step,v
retrieving revision 1.17
diff -u -u -r1.17 binary_step
--- tools/binary_step	29 Apr 2002 08:22:07 -0000	1.17
+++ tools/binary_step	19 Jun 2002 16:37:00 -0000
@@ -250,6 +250,7 @@
 	# Rebuild the stage3 library and compiler from scratch
 
 	/bin/rm -f stage3/library/*.c
+	/bin/rm -f stage3/library/*.c_date
 	/bin/rm -f stage3/library/*.d
 	/bin/rm -f stage3/library/*.optdate
 	/bin/rm -f stage3/library/*.trans_opt_date
@@ -261,6 +262,7 @@
 	/bin/rm -f stage3/library/*.int2
 	/bin/rm -f stage3/library/*.int
 	/bin/rm -f stage3/compiler/*.c
+	/bin/rm -f stage3/compiler/*.c_date
 	/bin/rm -f stage3/compiler/*.d
 	/bin/rm -f stage3/compiler/*.optdate
 	/bin/rm -f stage3/compiler/*.trans_opt_date
@@ -315,10 +317,10 @@
 		cat /dev/null > $outfile
 		for dir in library compiler
 		do
-			for file in stage2.$basis/$dir/*.c
+			for stage3file in stage3/$dir/*.c
 			do
-				stage3file="stage3/$dir/`basename $file`"
-				diff -u $file $stage3file >> $outfile ||
+				stage2file="stage2.$basis/$dir/`basename $file`"
+				diff -u $stage2file $stage3file >> $outfile ||
 					founddiff=true
 			done
 		done
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.127
diff -u -u -r1.127 bootcheck
--- tools/bootcheck	29 Apr 2002 08:22:07 -0000	1.127
+++ tools/bootcheck	19 Jun 2002 13:37:20 -0000
@@ -77,6 +77,9 @@
 	--use-subdirs
 		Assume intermediate files are built in subdirectories.
 		(Same as the \`--use-subdirs' option to mmake and mmc.)
+	--use-mmc-make
+		Use \`mmc --make' to build the files.
+		(Same as the \`--use-mmc-make' option to mmake.)
 	--compile-times
 		Report information about compilation times in the stage 2
 		library and compiler directories.
@@ -134,6 +137,7 @@
 else
 	use_subdirs=${MMAKE_USE_SUBDIRS=no}
 fi
+use_mmc_make=no
 compile_times=false
 write_out_profile_data=false
 type_stats=""
@@ -236,6 +240,11 @@
 	--no-use-subdirs)
 		use_subdirs=no ;;
 
+	--use-mmc-make)
+		use_mmc_make=yes ;;
+	--no-use-mmc-make)
+		use_mmc_make=no ;;
+
 	--compile-times)
 		compile_times=true ;;
 	--no-compile-times)
@@ -310,6 +319,9 @@
 MMAKE_USE_SUBDIRS=$use_subdirs
 export MMAKE_USE_SUBDIRS
 
+MMAKE_USE_MMC_MAKE=$use_mmc_make
+export MMAKE_USE_MMC_MAKE
+
 #-----------------------------------------------------------------------------#
 
 if $use_cp
@@ -428,20 +440,20 @@
 	$LN_S $root/compiler/[t-z]*.m .
 	$LN_S $root/compiler/*.pp .	
 
-	cp $root/compiler/Mmake* .
+	cp $root/compiler/Mmake* $root/compiler/Mercury.options .
 	cd $root/stage2
 	mkdir library
 	cd library
 	$LN_S $root/library/[a-l]*.m .
 	$LN_S $root/library/[m-z]*.m .
 	$LN_S $root/library/library_strong_name.sn .
-	cp $root/library/Mmake* .
+	cp $root/library/Mmake* $root/library/Mercury.options .
 	$LN_S $root/library/$STD_LIB_NAME.init .
 	cd $root/stage2
 	mkdir browser
 	cd browser
 	$LN_S $root/browser/*.m .
-	cp $root/browser/Mmake* .
+	cp $root/browser/Mmake* $root/browser/Mercury.options .
 	$LN_S $root/browser/$BROWSER_LIB_NAME.init .
 	cd $root/stage2
 	if $copy_runtime
@@ -506,12 +518,13 @@
 		mkdir profiler
 		cd profiler
 		$LN_S $root/profiler/*.m .
-		cp $root/profiler/Mmake* .
+		cp $root/profiler/Mmake* $root/profiler/Mercury.options .
 		cd $root/stage2
 		mkdir deep_profiler
 		cd deep_profiler
 		$LN_S $root/deep_profiler/*.m .
 		cp $root/deep_profiler/Mmake* .
+		cp $root/deep_profiler/Mercury.options .
 		cd $root/stage2
 	else
 		$LN_S $root/profiler .
@@ -522,12 +535,17 @@
 	$LN_S $root/VERSION .
 	$LN_S $root/.*.in .
 	rm -f config*.log
-	cp $root/Mmake* .
+	cp $root/Mmake* $root/Mercury.options .
 	if test -f $root/Mmake.stage.params
 	then
 		/bin/rm -f Mmake.params
 		cp $root/Mmake.stage.params Mmake.params
 	fi
+	if test -f $root/Mercury.stage.options
+	then
+		/bin/rm -f Mercury.options
+		cp $root/Mercury.stage.options Mercury.options
+	fi
 	if test "$grade" != ""
 	then
 		echo "GRADE = $grade" >> Mmake.params
@@ -563,8 +581,6 @@
 		exit 1
 	fi
 
-	# the `RM_C=:' ensures that the `.c' files do not get deleted
-
 	if (cd stage2/library && $MMAKE $mmake_opts $jfactor mercury)
 	then
 		echo "building of stage 2 library successful"
@@ -662,20 +678,20 @@
 	$LN_S $root/compiler/[t-z]*.m .
 	$LN_S $root/compiler/*.pp .	
 
-	cp $root/compiler/Mmake* .
+	cp $root/compiler/Mmake* $root/compiler/Mercury.options .
 	cd $root/stage3
 	mkdir library
 	cd library
 	$LN_S $root/library/[a-l]*.m .
 	$LN_S $root/library/[m-z]*.m .
 	$LN_S $root/library/library_strong_name.sn .
-	cp $root/library/Mmake* .
+	cp $root/library/Mmake* $root/library/Mercury.options .
 	$LN_S $root/library/$STD_LIB_NAME.init .
 	cd $root/stage3
 	mkdir browser
 	cd browser
 	$LN_S $root/browser/*.m .
-	cp $root/browser/Mmake* .
+	cp $root/browser/Mmake* $root/browser/Mercury.options .
 	$LN_S $root/browser/$BROWSER_LIB_NAME.init .
 	cd $root/stage3
 	$LN_S $root/boehm_gc .
@@ -692,7 +708,7 @@
 	$LN_S $root/VERSION .
 	$LN_S $root/.*.in .
 	rm -f config*.log
-	cp $root/stage2/Mmake* .
+	cp $root/stage2/Mmake* $root/stage2/Mercury.options .
 	cd $root
 	set -x
 
@@ -807,8 +823,8 @@
 	fi
 
 	for dir in library browser compiler; do
-		for file in stage2/$dir/${target_subdir}*.${target_ext}; do
-		    diff -u $file stage3/$dir/${cs_subdir}`basename $file` ||
+		for file in stage3/$dir/${target_subdir}*.${target_ext}; do
+		    diff -u stage2/$dir/${cs_subdir}`basename $file` $file ||
 			diff_status=1
 		done
 	done
Index: trace/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/Mmakefile,v
retrieving revision 1.30
diff -u -u -r1.30 Mmakefile
--- trace/Mmakefile	13 May 2002 08:09:43 -0000	1.30
+++ trace/Mmakefile	18 Jun 2002 07:17:46 -0000
@@ -14,6 +14,9 @@
 include $(MERCURY_DIR)/Mmake.common
 -include Mmake.trace.params
 
+# Avoid trying to make this file with `mmc --make' if it doesn't exist.
+Mmake.trace.params: ;
+
 #-----------------------------------------------------------------------------#
 
 CFLAGS		+= -I$(BROWSER_DIR) -g $(DLL_CFLAGS) \
--------------------------------------------------------------------------
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