[m-rev.] for review: fix header file problems

Simon Taylor stayl at cs.mu.OZ.AU
Wed May 29 18:44:58 AEST 2002


Estimated hours taken: 25
Branches: main

Fix problems with the compiler-generated header files:
1. the header files are grade dependent, but the header files
   can only be installed for one grade.
2. the generated header files can clash with system headers.

To solve these problems, the compiler now generates a
grade dependent `.mih' file containing the declarations
needed when a module is imported in a high-level C code
grade, and a grade independent `.mh' file, which contains
the prototypes for `:- pragma export' declarations.

compiler/export.m:
	Generate a `.mh' rather than a `.h' file for the `:- pragma export'
	declarations.

	Allow the header file generated by export.m to be used with
	`--high-level-code'.

compiler/modules.m:
library/Mmakefile:
	Add a module.install_grade_hdrs target to install the `.mih'
	files in a grade-dependent directory.

compiler/arg_info.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
	Make it easier to tell if the arg_info field of the proc_info
	has been set.

compiler/mlds_to_c.m:
	Include both the `.mh' and `.mih' files for imported modules.	

	The type used as the return value for a semidet procedure
	exported to C is `MR_bool', not `MR_Word'.

compiler/mlds_to_c.m:
compiler/modules.m:
	Don't add a `mercury.' prefix to the standard library
	header file names. They can't clash with the system
	headers any more.

compiler/mercury_compile.m:
compiler/mlds_to_c.m:
	Use export.m to generate the header file for `:- pragma export'
	declarations even in hlc grades.

compiler/mlds.m:
compiler/ml*.m:
	Distinguish between the `.mh' and `.mih' files
	in `mlds__import's.

compiler/handle_options.m:
scripts/Mmake.vars.in:
scripts/mgnuc.in:
	Add C include directory options for the installed grade
	dependent `.mih' files.

Mmakefile:
scripts/Mmake.rules:
	s/h/mih/ in the commands to save the grade dependent
	files when installing the library grades.

compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.util.m:
	Handle dependencies on `.mh' and `.mih' files.

NEWS:
doc/user_guide.texi:
	Document the change.


Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.77
diff -u -u -r1.77 Mmakefile
--- Mmakefile	15 May 2002 10:11:47 -0000	1.77
+++ Mmakefile	29 May 2002 07:04:15 -0000
@@ -404,15 +404,15 @@
 	cd runtime && rm -rf tmp_dir && mkdir tmp_dir && \
 		{ mv -f *.$O *.pic_o *.$A *.so tmp_dir || true; }
 	cd library && rm -rf tmp_dir && mkdir tmp_dir && \
-		{ mv -f *.dep *.h *.c *.c_date *.$O *.pic_o *.$A *.so *.used \
-			Mercury/useds/*.used Mercury/deps/*.dep \
+		{ mv -f *.dep *.mih *.c *.c_date *.$O *.pic_o *.$A *.so \
+			*.used Mercury/useds/*.used Mercury/deps/*.dep \
 			Mercury/cs/*.c Mercury/c_dates/*.c_date \
-			Mercury/os/*.$O tmp_dir || true; }
+			Mercury/mihs/*.mih Mercury/os/*.$O tmp_dir || true; }
 	cd browser && rm -rf tmp_dir && mkdir tmp_dir && \
-		{ mv -f *.dep *.h *.c *.c_date *.$O *.pic_o *.$A *.so *.used \
-			Mercury/useds/*.used Mercury/deps/*.dep \
+		{ mv -f *.dep *.mih *.c *.c_date *.$O *.pic_o *.$A *.so \
+			*.used Mercury/useds/*.used Mercury/deps/*.dep \
 			Mercury/cs/*.c Mercury/c_dates/*.c_date \
-			Mercury/os/*.$O tmp_dir || true; }
+			Mercury/mihs/*.mih Mercury/os/*.$O tmp_dir || true; }
 	cd trace && rm -rf tmp_dir && mkdir tmp_dir && \
 		{ mv -f *.$O *.pic_o *.$A *.so tmp_dir || true; }
 	#
@@ -432,7 +432,7 @@
 		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_lib ) && \
 		( cd library && \
 		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade depend && \
-		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_hdrs && \
+		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_grade_hdrs && \
 		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_library ) && \
 		( cd browser && \
 		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade depend && \
@@ -441,12 +441,14 @@
 		  $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_lib ) && \
 		( cd boehm_gc && rm -f *.$O *.pic_o *.$A *.so ) && \
 		( cd runtime && rm -f *.$O *.pic_o *.$A *.so ) && \
-		( cd library && rm -f *.dep *.h *.c *.c_date *.$O *.pic_o \
-				*.$A *.so Mercury/cs/*.c \
-				Mercury/c_dates/*.c_date Mercury/os/*.$O ) && \
-		( cd browser && rm -f *.dep *.h *.c *.c_date *.$O *.pic_o \
-				*.$A *.so Mercury/cs/*.c \
-				Mercury/c_dates/*.c_date Mercury/os/*.$O ) && \
+		( cd library && rm -f *.dep *.mih *.c *.c_date \
+			*.$O *.pic_o *.$A *.so Mercury/cs/*.c \
+			Mercury/c_dates/*.c_date Mercury/mihs/*.mih \
+			Mercury/os/*.$O ) && \
+		( cd browser && rm -f *.dep *.mih *.c *.c_date \
+			*.$O *.pic_o *.$A *.so Mercury/cs/*.c \
+			Mercury/c_dates/*.c_date Mercury/mihs/*.mih \
+			Mercury/os/*.$O ) && \
 		( cd trace && rm -f *.$O *.pic_o *.$A *.so ) && \
 		true \
 		|| { scripts/mercury_cleanup_install; exit 1; }; \
@@ -455,6 +457,7 @@
 	cd boehm_gc && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
 	cd runtime  && { mv tmp_dir/* . ; rmdir tmp_dir; true; }
 	cd library  && { [ -d Mercury/cs ] && mv tmp_dir/*.c Mercury/cs; \
+			 [ -d Mercury/mihs ] && mv tmp_dir/*.mih Mercury/mihs; \
 			 [ -d Mercury/os ] && mv tmp_dir/*.$O Mercury/os; \
 			 [ -d Mercury/deps ] && mv tmp_dir/*.dep Mercury/deps;\
 			 [ -d Mercury/c_dates ] && \
@@ -463,6 +466,7 @@
 			 	mv tmp_dir/*.used Mercury/useds;\
 			 mv tmp_dir/* . ; rmdir tmp_dir; true; }
 	cd browser  && { [ -d Mercury/cs ] && mv tmp_dir/*.c Mercury/cs; \
+			 [ -d Mercury/mihs ] && mv tmp_dir/*.mih Mercury/mihs; \
 			 [ -d Mercury/os ] && mv tmp_dir/*.$O Mercury/os; \
 			 [ -d Mercury/deps ] && mv tmp_dir/*.dep Mercury/deps;\
 			 [ -d Mercury/c_dates ] && \
@@ -484,16 +488,20 @@
 	+cd library && \
 	rm -rf tmp_dir && \
 	mkdir tmp_dir && \
-	{ mv -f *.dir *.dep *.h *.c *.$O *.pic_o *.$A *.so \
-		Mercury/cs/*.c Mercury/os/*.$O tmp_dir || true; } && \
+	{ mv -f *.dir *.dep *.mih *.c *.c_date *.$O *.pic_o *.$A *.so \
+		Mercury/cs/*.c Mercury/c_dates/*.c Mercury/mihs/*.mih \
+		Mercury/c_dates Mercury/os/*.$O tmp_dir || true; } && \
 	for grade in $(GRADE) $(LIBGRADES); do \
 	        $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade depend && \
 	        $(SUBDIR_MMAKE) MC=mmc GRADE=$$grade install_split_library || \
 			{ scripts/mercury_cleanup_install; exit 1; }; \
-	        rm -rf *.dir *.dep *.h *.c *.$O *.pic_o *.$A *.so \
-			Mercury/cs/*.c Mercury/os/*.$O; \
+	        rm -rf *.dir *.dep *.mih *.c *.$O *.pic_o *.$A *.so \
+			Mercury/cs/*.c Mercury/c_dates/*.c Mercury/mihs/*.mih \
+			Mercury/c_dates Mercury/os/*.$O; \
 	done && \
 	{ [ -d Mercury/cs ] && mv tmp_dir/*.c Mercury/cs; \
+	  [ -d Mercury/c_dates ] && mv tmp_dir/*.c_date Mercury/c_dates; \
+	  [ -d Mercury/mihs] && mv tmp_dir/*.mih Mercury/mihs; \
 	  [ -d Mercury/os ] && mv tmp_dir/*.$O Mercury/os; \
 	  [ -d Mercury/deps ] && mv tmp_dir/*.dep Mercury/deps; \
 	  mv tmp_dir/* . ; rmdir tmp_dir; true; }
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.257
diff -u -u -r1.257 NEWS
--- NEWS	13 May 2002 03:19:43 -0000	1.257
+++ NEWS	18 May 2002 15:50:15 -0000
@@ -269,6 +269,10 @@
   causes the compiler to issue a warning about any directly recursive
   call that is not a tail call.
 
+* The automatically generated header files for modules containing
+  `pragma export' declarations are now named `<module>.mh', not
+  `<module>.h'. This avoids conflicts with system header files.
+
 * We've fixed a long-standing bug in the handling of module imports.
   Previously, if `module1' imported `module2' which imported `module3' in
   its interface section, then any types, insts, modes and typeclasses defined
Index: compiler/arg_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/arg_info.m,v
retrieving revision 1.37
diff -u -u -r1.37 arg_info.m
--- compiler/arg_info.m	28 Mar 2002 03:42:41 -0000	1.37
+++ compiler/arg_info.m	18 May 2002 15:50:15 -0000
@@ -25,6 +25,11 @@
 	% about its argument passing interface.
 :- pred generate_arg_info(module_info::in, module_info::out) is det.
 
+	% Annotate a single procedure with information
+	% about its argument passing interface.
+:- pred generate_proc_arg_info(proc_info::in, list(type)::in, module_info::in,
+	proc_info::out) is det.
+
 	% Given the list of types and modes of the arguments of a procedure
 	% and its code model, return its argument passing interface.
 :- pred make_arg_infos(list(type)::in, list(mode)::in, code_model::in,
@@ -137,9 +142,6 @@
 		module_info_set_preds(ModuleInfo0, PredTable, ModuleInfo1)
 	),
 	generate_proc_list_arg_info(PredId, ProcIds, ModuleInfo1, ModuleInfo).
-
-:- pred generate_proc_arg_info(proc_info::in, list(type)::in, module_info::in,
-	proc_info::out) is det.
 
 generate_proc_arg_info(ProcInfo0, ArgTypes, ModuleInfo, ProcInfo) :-
 	proc_info_argmodes(ProcInfo0, ArgModes),
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.54
diff -u -u -r1.54 export.m
--- compiler/export.m	7 May 2002 14:43:39 -0000	1.54
+++ compiler/export.m	19 May 2002 09:17:13 -0000
@@ -71,7 +71,7 @@
 :- import_module hlds__hlds_pred, check_hlds__type_util.
 :- import_module backend_libs__code_model.
 :- import_module ll_backend__code_gen, ll_backend__code_util.
-:- import_module ll_backend__llds_out.
+:- import_module ll_backend__llds_out, ll_backend__arg_info.
 :- import_module libs__globals, libs__options.
 
 :- import_module term, varset.
@@ -319,8 +319,15 @@
 	pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
 	pred_info_procedures(PredInfo, ProcTable),
 	map__lookup(ProcTable, ProcId, ProcInfo),
-	proc_info_arg_info(ProcInfo, ArgInfos),
+	proc_info_maybe_arg_info(ProcInfo, MaybeArgInfos),
 	pred_info_arg_types(PredInfo, ArgTypes),
+	( MaybeArgInfos = yes(ArgInfos0) ->
+		ArgInfos = ArgInfos0
+	;
+		generate_proc_arg_info(ProcInfo, ArgTypes,
+			Module, NewProcInfo),
+		proc_info_arg_info(NewProcInfo, ArgInfos)
+	),
 	proc_info_interface_code_model(ProcInfo, CodeModel),
 	assoc_list__from_corresponding_lists(ArgInfos, ArgTypes,
 		ArgInfoTypes0),
@@ -560,7 +567,29 @@
 export__produce_header_file([], _) --> [].
 export__produce_header_file(C_ExportDecls, ModuleName) -->
 	{ C_ExportDecls = [_|_] },
-	module_name_to_file_name(ModuleName, ".h", yes, FileName),
+	export__produce_header_file(C_ExportDecls, ModuleName, ".mh"),
+
+	% XXX  We still need to produce the `.h' file for bootstrapping.
+	% The C files in the trace directory refer to std_util.h and io.h.
+	globals__io_lookup_bool_option(highlevel_code, HighLevelCode),
+	{
+		HighLevelCode = yes,
+		ModuleName = unqualified(StdLibModule),
+		mercury_std_library_module(StdLibModule)
+	->
+		HeaderModuleName = qualified(unqualified("mercury"),
+			       StdLibModule)
+	;
+		HeaderModuleName = ModuleName
+	},
+	export__produce_header_file(C_ExportDecls, HeaderModuleName, ".h").
+
+:- pred export__produce_header_file(foreign_export_decls, module_name, string,
+					io__state, io__state).
+:- mode export__produce_header_file(in, in, in, di, uo) is det.
+
+export__produce_header_file(C_ExportDecls, ModuleName, HeaderExt) -->
+	module_name_to_file_name(ModuleName, HeaderExt, yes, FileName),
 	io__open_output(FileName, Result),
 	(
 		{ Result = ok(FileStream) }
@@ -583,8 +612,12 @@
 			"extern ""C"" {\n",
 			"#endif\n",
 			"\n",
+			"#ifdef MR_HIGHLEVEL_CODE\n",
+			"#include ""mercury.h""\n",
+			"#else\n",
 			"#ifndef MERCURY_HDR_EXCLUDE_IMP_H\n",
 			"#include ""mercury_imp.h""\n",
+			"#endif\n",
 			"#endif\n",
 			"#ifdef MR_DEEP_PROFILING\n",
 			"#include ""mercury_deep_profiling.h""\n",
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.139
diff -u -u -r1.139 handle_options.m
--- compiler/handle_options.m	3 May 2002 06:52:20 -0000	1.139
+++ compiler/handle_options.m	18 May 2002 18:03:36 -0000
@@ -879,8 +879,8 @@
 	),
 
 	%
-	% Handle library search directories. These couldn't be handled
-	% by options.m because they are grade dependent.
+	% Handle C header and library search directories. These couldn't
+	% be handled by options.m because they are grade dependent.
 	%
 	globals__io_lookup_accumulating_option(mercury_library_directories,
 		MercuryLibDirs),
@@ -899,7 +899,20 @@
 		globals__io_lookup_accumulating_option(
 			link_library_directories, LinkLibDirs),
 		globals__io_set_option(link_library_directories,
-			accumulating(LinkLibDirs ++ ExtraLinkLibDirs))
+			accumulating(LinkLibDirs ++ ExtraLinkLibDirs)),
+
+		{ ExtraCIncludeDirs = list__map(
+				(func(MercuryLibDir) =
+					dir__make_path_name(MercuryLibDir,
+					dir__make_path_name("lib",
+					dir__make_path_name(GradeString,
+					dir__make_path_name(FullArch,
+					"inc"))))
+				), MercuryLibDirs) },
+		globals__io_lookup_accumulating_option(c_include_directory,
+			CIncludeDirs),
+		globals__io_set_option(c_include_directory,
+			accumulating(CIncludeDirs ++ ExtraCIncludeDirs))
 	;
 		{ MercuryLibDirs = [] }
 	),
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.283
diff -u -u -r1.283 hlds_out.m
--- compiler/hlds_out.m	7 May 2002 11:02:45 -0000	1.283
+++ compiler/hlds_out.m	19 May 2002 17:34:48 -0000
@@ -3248,7 +3248,7 @@
 	{ proc_info_headvars(Proc, HeadVars) },
 	{ proc_info_argmodes(Proc, HeadModes) },
 	{ proc_info_maybe_arglives(Proc, MaybeArgLives) },
-	{ proc_info_arg_info(Proc, ArgInfos) },
+	{ proc_info_maybe_arg_info(Proc, MaybeArgInfos) },
 	{ proc_info_goal(Proc, Goal) },
 	{ proc_info_context(Proc, ModeContext) },
 	{ proc_info_get_maybe_arg_size_info(Proc, MaybeArgSize) },
@@ -3371,7 +3371,7 @@
 
 	(
 		{ string__contains_char(Verbose, 'A') },
-		{ ArgInfos \= [] }
+		{ MaybeArgInfos = yes(ArgInfos) }
 	->
 		hlds_out__write_indent(Indent),
 		io__write_string("% arg_infos: "),
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.108
diff -u -u -r1.108 hlds_pred.m
--- compiler/hlds_pred.m	7 Apr 2002 10:22:31 -0000	1.108
+++ compiler/hlds_pred.m	18 May 2002 15:50:15 -0000
@@ -1543,7 +1543,7 @@
 :- pred proc_info_set(maybe(determinism), prog_varset, vartypes,
 	list(prog_var), list(mode), inst_varset, maybe(list(is_live)), 
 	hlds_goal, prog_context, stack_slots, determinism, bool,
-	list(arg_info), liveness_info, type_info_varmap,
+	maybe(list(arg_info)), liveness_info, type_info_varmap,
 	typeclass_info_varmap, maybe(arg_size_info),
 	maybe(termination_info), is_address_taken, proc_info).
 :- mode proc_info_set(in, in, in, in, in, in, in, in, in, in, in, in,
@@ -1648,6 +1648,9 @@
 :- pred proc_info_arg_info(proc_info, list(arg_info)).
 :- mode proc_info_arg_info(in, out) is det.
 
+:- pred proc_info_maybe_arg_info(proc_info, maybe(list(arg_info))).
+:- mode proc_info_maybe_arg_info(in, out) is det.
+
 :- pred proc_info_set_arg_info(proc_info, list(arg_info), proc_info).
 :- mode proc_info_set_arg_info(in, in, out) is det.
 
@@ -1883,7 +1886,7 @@
 					% mode checking etc. for complicated
 					% modes of unification procs until
 					% the end of the unique_modes pass.)
-			arg_pass_info	:: list(arg_info),
+			arg_pass_info	:: maybe(list(arg_info)),
 					% calling convention of each arg:
 					% information computed by arg_info.m
 					% (based on the modes etc.)
@@ -2004,7 +2007,7 @@
 	InferredDet = erroneous,
 	map__init(StackSlots),
 	set__init(InitialLiveness),
-	ArgInfo = [],
+	ArgInfo = no,
 	goal_info_init(GoalInfo),
 	ClauseBody = conj([]) - GoalInfo,
 	CanProcess = yes,
@@ -2050,7 +2053,7 @@
 	ModeErrors = [],
 	ProcInfo = procedure(VarSet, VarTypes, HeadVars, HeadModes, ModeErrors,
 		InstVarSet, MaybeHeadLives, Goal, Context, StackSlots,
-		MaybeDeclaredDetism, Detism, yes, [], Liveness, TVarMap,
+		MaybeDeclaredDetism, Detism, yes, no, Liveness, TVarMap,
 		TCVarsMap, eval_normal, no, no, no, IsAddressTaken,
 		RLExprn, no, no, no, no).
 
@@ -2128,7 +2131,14 @@
 proc_info_stack_slots(ProcInfo, ProcInfo^stack_slots).
 proc_info_inferred_determinism(ProcInfo, ProcInfo^inferred_detism).
 proc_info_can_process(ProcInfo, ProcInfo^can_process).
-proc_info_arg_info(ProcInfo, ProcInfo^arg_pass_info).
+proc_info_maybe_arg_info(ProcInfo, ProcInfo^arg_pass_info).
+proc_info_arg_info(ProcInfo, ArgInfo) :-
+	( yes(ArgInfo0) = ProcInfo^arg_pass_info ->
+		ArgInfo = ArgInfo0
+
+	;
+		error("proc_info_arg_info: arg_pass_info not set")
+	).
 proc_info_liveness_info(ProcInfo, ProcInfo^initial_liveness).
 proc_info_typeinfo_varmap(ProcInfo, ProcInfo^proc_type_info_varmap).
 proc_info_typeclass_info_varmap(ProcInfo, ProcInfo^proc_typeclass_info_varmap).
@@ -2156,7 +2166,7 @@
 proc_info_set_inferred_determinism(ProcInfo, ID,
 	ProcInfo^inferred_detism := ID).
 proc_info_set_can_process(ProcInfo, CP, ProcInfo^can_process := CP).
-proc_info_set_arg_info(ProcInfo, AP, ProcInfo^arg_pass_info := AP).
+proc_info_set_arg_info(ProcInfo, AP, ProcInfo^arg_pass_info := yes(AP)).
 proc_info_set_liveness_info(ProcInfo, IL, ProcInfo^initial_liveness := IL).
 proc_info_set_typeinfo_varmap(ProcInfo, TI,
 	ProcInfo^proc_type_info_varmap := TI).
Index: compiler/make.dependencies.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.dependencies.m,v
retrieving revision 1.4
diff -u -u -r1.4 make.dependencies.m
--- compiler/make.dependencies.m	9 May 2002 16:30:55 -0000	1.4
+++ compiler/make.dependencies.m	18 May 2002 17:56:09 -0000
@@ -143,7 +143,8 @@
 target_dependencies(_, short_interface) = interface_file_dependencies.
 target_dependencies(_, unqualified_short_interface) = source `of` self.
 target_dependencies(Globals, aditi_code) = compiled_code_dependencies(Globals).
-target_dependencies(Globals, c_header) = target_dependencies(Globals, c_code).
+target_dependencies(Globals, c_header(_)) =
+		target_dependencies(Globals, c_code).
 target_dependencies(Globals, c_code) = compiled_code_dependencies(Globals).
 target_dependencies(Globals, il_code) = compiled_code_dependencies(Globals).
 target_dependencies(_, il_asm) = il_code `of` self.
@@ -162,18 +163,17 @@
 	HeaderDeps =
 	    ( CompilationTarget = c, HighLevelCode = yes ->
 		combine_deps_list([
-		    c_header `of` direct_imports,
-		    c_header `of` indirect_imports,
-		    c_header `of` parents,
-		    c_header `of` intermod_imports,
-		    c_header `of` foreign_imports
+		    c_header(mih) `of` direct_imports,
+		    c_header(mih) `of` indirect_imports,
+		    c_header(mih) `of` parents,
+		    c_header(mih) `of` intermod_imports
 		])
 	    ;
 		no_deps
 	    ),
 	Deps = combine_deps_list([
 		TargetCode `of` self,
-		c_header `of` foreign_imports,
+		c_header(mh) `of` foreign_imports,
 		HeaderDeps
 	]).
 target_dependencies(_, intermodule_interface) =
Index: compiler/make.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.m,v
retrieving revision 1.6
diff -u -u -r1.6 make.m
--- compiler/make.m	13 May 2002 18:22:24 -0000	1.6
+++ compiler/make.m	18 May 2002 17:35:22 -0000
@@ -140,13 +140,18 @@
 	;	unqualified_short_interface
 	;	intermodule_interface
 	;	aditi_code
-	;	c_header
+	;	c_header(c_header_type)
 	;	c_code
 	;	il_code
 	;	il_asm
 	;	java_code
 	;	asm_code(pic)
 	;	object_code(pic)
+	.
+
+:- type c_header_type
+	--->	mh	% For `:- pragma export' declarations.
+	;	mih	% Declarations for hlc grades, for compiler use only.
 	.
 
 % :- type linked_target_type in mercury_compile.m.
Index: compiler/make.module_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.6
diff -u -u -r1.6 make.module_target.m
--- compiler/make.module_target.m	13 May 2002 18:22:24 -0000	1.6
+++ compiler/make.module_target.m	18 May 2002 17:53:20 -0000
@@ -409,7 +409,7 @@
 			["--make-optimization-interface"].
 compilation_task(_, aditi_code) =
 		process_module(compile_to_target_code) - ["--aditi-only"].
-compilation_task(Globals, c_header) = compilation_task(Globals, c_code).
+compilation_task(Globals, c_header(_)) = compilation_task(Globals, c_code).
 compilation_task(_, c_code) = process_module(compile_to_target_code) -
 					["--compile-to-c"].
 compilation_task(_, il_code) = process_module(compile_to_target_code) -
@@ -497,23 +497,12 @@
 		    % When compiling to high-level C, we always generate
 		    % a header file.
 		    %
-		    { HeaderModuleNames = SourceFileModuleNames }
+		    { HeaderModuleNames = SourceFileModuleNames },
+		    { HeaderTargets0 = make_target_list(HeaderModuleNames,
+		    			c_header(mih)) }
 		;
-		    %
-		    % When compiling to low-level C, we only generate a
-		    % header file if the module contains `:- pragma export'
-		    % declarations.
-		    %
-		    { HeaderModuleNames =
-			list__filter_map(
-			    (func(MImports) =
-			    		MImports ^ module_name is semidet :-
-				contains_foreign_export =
-				    MImports ^ contains_foreign_export
-			    ), ModuleImportsList) }
-		),
-		{ HeaderTargets = make_target_list(HeaderModuleNames,
-					c_header) }
+		    { HeaderTargets0 = [] }	
+		)
 	    ;
 	        { CompilationTarget = asm },
 		%
@@ -525,15 +514,29 @@
 			(func(MImports) = MImports ^ module_name is semidet :-
 			    contains_foreign_code(_) = MImports ^ foreign_code
 			), ModuleImportsList) },
-		{ HeaderTargets = make_target_list(HeaderModuleNames,
-					c_header) }
+		{ HeaderTargets0 = make_target_list(HeaderModuleNames,
+					c_header(mih)) }
 	    ;
 	    	{ CompilationTarget = il },
-		{ HeaderTargets = [] }
+		{ HeaderTargets0 = [] }
 	    ;
 	    	{ CompilationTarget = java },
-		{ HeaderTargets = [] }
+		{ HeaderTargets0 = [] }
 	    ),
+	    { ( CompilationTarget = c ; CompilationTarget = asm ) ->
+	    	PragmaExportModuleNames =
+			list__filter_map(
+			    (func(MImports) =
+			    		MImports ^ module_name is semidet :-
+				contains_foreign_export =
+				    MImports ^ contains_foreign_export
+			    ), ModuleImportsList),
+	    	HeaderTargets =
+			make_target_list(PragmaExportModuleNames, c_header(mh))
+			++ HeaderTargets0
+	    ;
+		HeaderTargets = HeaderTargets0
+	    },
 
 	    { TouchedTargetFiles0 =
 			make_target_list(TargetModuleNames, FileType) },
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.4
diff -u -u -r1.4 make.program_target.m
--- compiler/make.program_target.m	13 May 2002 18:22:24 -0000	1.4
+++ compiler/make.program_target.m	18 May 2002 17:53:50 -0000
@@ -421,7 +421,7 @@
 
 make_clean(ModuleName, Info0, Info) -->
 	list__foldl2(remove_target_file(ModuleName),
-		[errors, c_code, c_header,
+		[errors, c_code, c_header(mih),
 		object_code(pic), object_code(non_pic),
 		asm_code(pic), asm_code(non_pic),
 		il_code, java_code
@@ -459,7 +459,7 @@
 	list__foldl2(remove_target_file(ModuleName),
 		[private_interface, long_interface, short_interface,
 		unqualified_short_interface, intermodule_interface,
-		aditi_code, c_header
+		aditi_code, c_header(mh)
 		],
 		Info1, Info2),
 	remove_file(ModuleName, module_dep_file_extension, Info2, Info3),
Index: compiler/make.util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.6
diff -u -u -r1.6 make.util.m
--- compiler/make.util.m	13 May 2002 18:22:24 -0000	1.6
+++ compiler/make.util.m	18 May 2002 17:56:36 -0000
@@ -565,7 +565,8 @@
 target_extension(_, unqualified_short_interface) = ".int3".
 target_extension(_, intermodule_interface) = ".opt".
 target_extension(_, aditi_code) = ".rlo".
-target_extension(_, c_header) = ".h".
+target_extension(_, c_header(mih)) = ".mih".
+target_extension(_, c_header(mh)) = ".mh".
 target_extension(_, c_code) = ".c".
 target_extension(_, il_code) = ".il".
 target_extension(_, il_asm) = ".dll". % XXX ".exe" if the module contains main.
@@ -613,7 +614,7 @@
 search_for_file_type(unqualified_short_interface) = yes(search_directories).
 search_for_file_type(intermodule_interface) = yes(intermod_directories).
 search_for_file_type(aditi_code) = no.
-search_for_file_type(c_header) = yes(c_include_directory).
+search_for_file_type(c_header(_)) = yes(c_include_directory).
 search_for_file_type(c_code) = no.
 search_for_file_type(il_code) = no.
 search_for_file_type(il_asm) = no.
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.251
diff -u -u -r1.251 mercury_compile.m
--- compiler/mercury_compile.m	9 May 2002 16:30:59 -0000	1.251
+++ compiler/mercury_compile.m	18 May 2002 16:26:12 -0000
@@ -1119,6 +1119,18 @@
 		( { NumErrors = 0 } ->
 		    mercury_compile__maybe_generate_rl_bytecode(HLDS50,
 				Verbose, MaybeRLFile),
+		    ( { Target = c ; Target = asm } ->
+			%
+			% Produce the grade independent header file
+			% <module>.mh containing function prototypes
+			% for the `:- pragma export'ed procedures.
+			%
+		    	{ export__get_foreign_export_decls(HLDS50,
+				ExportDecls) },
+			export__produce_header_file(ExportDecls, ModuleName)
+		    ;
+		    	[]
+		    ),
 		    ( { AditiOnly = yes } ->
 		    	{ HLDS = HLDS50 }
 		    ; { Target = il } ->
@@ -3233,7 +3245,8 @@
 	mercury_compile__output_llds(ModuleName, CFile, LayoutLabels,
 		MaybeRLFile, Verbose, Stats),
 
-	{ C_InterfaceInfo = foreign_interface_info(_, _, _, _, C_ExportDecls, _) },
+	{ C_InterfaceInfo = foreign_interface_info(_, _, _, _,
+					C_ExportDecls, _) },
 	export__produce_header_file(C_ExportDecls, ModuleName),
 
 	%
@@ -3298,7 +3311,8 @@
 		Include) -->
 	(
 		{ Lang = c },
-		module_name_to_file_name(ModuleName, ".h", no, HeaderFileName),
+		module_name_to_file_name(ModuleName, ".mh",
+			no, HeaderFileName),
 		{ string__append_list(
 			["#include """, HeaderFileName, """\n"],
 			IncludeString) },
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.114
diff -u -u -r1.114 ml_code_gen.m
--- compiler/ml_code_gen.m	7 May 2002 11:03:02 -0000	1.114
+++ compiler/ml_code_gen.m	18 May 2002 18:47:12 -0000
@@ -857,7 +857,9 @@
 	module_info_globals(ModuleInfo, Globals),
 	globals__get_target(Globals, Target),
 	module_info_get_all_deps(ModuleInfo, AllImports),
-	P = (func(Name) = mercury_import(mercury_module_name_to_mlds(Name))),
+	P = (func(Name) = mercury_import(
+				import_implementation,
+				mercury_module_name_to_mlds(Name))),
 
 		% For every foreign type determine the import needed to
 		% find the declaration for that type.
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.90
diff -u -u -r1.90 mlds.m
--- compiler/mlds.m	7 May 2002 11:03:04 -0000	1.90
+++ compiler/mlds.m	18 May 2002 18:34:49 -0000
@@ -324,13 +324,29 @@
 
 :- type mlds__imports == list(mlds__import).
 
+:- type mercury_mlds_import_type
+	--->	import_interface	% Import the user-visible interface
+					% to the target code (the prototypes
+					% for the `:- pragma export'
+					% declarations).
+
+	;	import_implementation.	% Import the implementation part
+					% of the target code.
+
 % Currently an import just gives the name of the package to be imported.
 % This might perhaps need to be expanded to cater to different kinds of
 % imports, e.g. imports with wild-cards ("import java.lang.*").
 :- type mlds__import
-	--->	mercury_import(
+	--->
+		% Import the user-visible interface of the target code
+		% for the module (e.g. for C, the function prototypes for
+		% predicates and functions with `:- pragma export'
+		% declarations, which are contained in the `.mh' file).
+		mercury_import(
+			mercury_mlds_import_type :: mercury_mlds_import_type,
 			import_name		:: mlds_module_name
 		)
+
 	;	foreign_import(
 			foreign_import_name	:: foreign_import_name
 		).
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.128
diff -u -u -r1.128 mlds_to_c.m
--- compiler/mlds_to_c.m	7 May 2002 11:03:05 -0000	1.128
+++ compiler/mlds_to_c.m	28 May 2002 08:17:30 -0000
@@ -79,18 +79,6 @@
 
 mlds_to_c__output_mlds(MLDS, Suffix) -->
 	%
-	% We need to use the MLDS package name to compute the header file
-	% names, giving e.g. `mercury.io.h', `mercury.time.h' etc.,
-	% rather than using just the Mercury module name, which would give
-	% just `io.h', `time.h', etc.  The reason for this is that if we
-	% don't, then we get name clashes with the standard C header files.
-	% For example, `time.h' clashes with the standard <time.h> header.
-	%
-	% But to keep the Mmake auto-dependencies working, we still
-	% want to name the `.c' file based on just the Mercury module
-	% name, giving e.g. `time.c', not `mercury.time.c'.
-	% Hence the different treatment of SourceFile and HeaderFile below.
-	%
 	% We write the header file out to <module>.h.tmp and then
 	% call `update_interface' to move the <module>.h.tmp file to
 	% <module>.h; this avoids updating the timestamp on the `.h'
@@ -105,11 +93,9 @@
 	{ ModuleName = mlds__get_module_name(MLDS) },
 	module_name_to_file_name(ModuleName, ".c" ++ Suffix, yes,
 		SourceFile),
-	{ MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName) },
-	{ ModuleSymName = mlds_module_name_to_sym_name(MLDS_ModuleName) },
-	module_name_to_file_name(ModuleSymName, ".h" ++ Suffix ++ ".tmp", yes,
-		TmpHeaderFile),
-	module_name_to_file_name(ModuleSymName, ".h" ++ Suffix, yes,
+	module_name_to_file_name(ModuleName, ".mih" ++ Suffix ++ ".tmp",
+		yes, TmpHeaderFile),
+	module_name_to_file_name(ModuleName, ".mih" ++ Suffix, yes,
 		HeaderFile),
 	{ Indent = 0 },
 	output_to_file(SourceFile, mlds_output_src_file(Indent, MLDS)),
@@ -182,12 +168,30 @@
 :- mode mlds_output_src_import(in, in, di, uo) is det.
 
 mlds_output_src_import(_Indent, Import) -->
-	{ Import = mercury_import(ImportName)
-	; Import = foreign_import(_),
+	{
+		Import = mercury_import(ImportType, ImportName),
+		ModuleName0 = mlds_module_name_to_sym_name(ImportName),
+		( ImportType = import_interface, HeaderExt = ".mh"
+		; ImportType = import_implementation, HeaderExt = ".mih"
+		),
+
+		% Strip off the "mercury" qualifier for standard
+		% library modules.
+		(
+			ModuleName0 = qualified(unqualified("mercury"),
+					ModuleName1),
+			mercury_std_library_module(ModuleName1)
+		->
+			ModuleName = unqualified(ModuleName1)
+		;
+			ModuleName = ModuleName0
+		)
+	;
+		Import = foreign_import(_),
 		unexpected(this_file, "foreign import in C backend")
 	},
-	{ SymName = mlds_module_name_to_sym_name(ImportName) },
-	module_name_to_file_name(SymName, ".h", no, HeaderFile),
+
+	module_name_to_file_name(ModuleName, HeaderExt, no, HeaderFile),
 	io__write_strings(["#include """, HeaderFile, """\n"]).
 
 
@@ -204,11 +208,12 @@
 
 mlds_output_src_file(Indent, MLDS) -->
 	{ MLDS = mlds(ModuleName, AllForeignCode, Imports, Defns) },
-	mlds_output_src_start(Indent, ModuleName), io__nl,
-	mlds_output_src_imports(Indent, Imports), io__nl,
-
 		% Get the foreign code for C
 	{ ForeignCode = mlds_get_c_foreign_code(AllForeignCode) },
+
+	mlds_output_src_start(Indent, ModuleName, ForeignCode), io__nl,
+	mlds_output_src_imports(Indent, Imports), io__nl,
+
 	mlds_output_c_decls(Indent, ForeignCode), io__nl,
 	%
 	% The public types have already been defined in the
@@ -290,11 +295,11 @@
 	mlds_indent(Indent),
 	io__write_string("#include ""mercury.h""\n").
 
-:- pred mlds_output_src_start(indent, mercury_module_name,
+:- pred mlds_output_src_start(indent, mercury_module_name, mlds__foreign_code,
 		io__state, io__state).
-:- mode mlds_output_src_start(in, in, di, uo) is det.
+:- mode mlds_output_src_start(in, in, in, di, uo) is det.
 
-mlds_output_src_start(Indent, ModuleName) -->
+mlds_output_src_start(Indent, ModuleName, ForeignCode) -->
 	mlds_output_auto_gen_comment(ModuleName),
 	mlds_indent(Indent),
 	io__write_string("/* :- module "),
@@ -303,8 +308,23 @@
 	mlds_indent(Indent),
 	io__write_string("/* :- implementation. */\n"),
 	mlds_output_src_bootstrap_defines, io__nl,
+
+	%
+	% If there are `:- pragma export' declarations,
+	% #include the `.mh' file.
+	%
+	( { ForeignCode = mlds__foreign_code(_, _, _, []) } ->
+		[]
+	;
+		mlds_output_src_import(Indent,
+			mercury_import(
+			import_interface,
+			mercury_module_name_to_mlds(ModuleName)))
+	),
 	mlds_output_src_import(Indent,
-		mercury_import(mercury_module_name_to_mlds(ModuleName))),
+		mercury_import(
+			import_implementation,
+			mercury_module_name_to_mlds(ModuleName))),
 	io__nl.
 
 	%
@@ -527,14 +547,11 @@
 		io__state, io__state).
 :- mode mlds_output_c_hdr_decls(in, in, in, di, uo) is det.
 
-mlds_output_c_hdr_decls(ModuleName, Indent, ForeignCode) -->
+mlds_output_c_hdr_decls(_ModuleName, Indent, ForeignCode) -->
 	{ ForeignCode = mlds__foreign_code(RevHeaderCode, _RevImports,
-		_RevBodyCode, ExportDefns) },
+		_RevBodyCode, _ExportDefns) },
 	{ HeaderCode = list__reverse(RevHeaderCode) },
-	io__write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent)),
-	io__write_string("\n"),
-	io__write_list(ExportDefns, "\n",
-			mlds_output_pragma_export_decl(ModuleName, Indent)).
+	io__write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent)).
 
 :- pred mlds_output_c_hdr_decl(indent,
 	foreign_decl_code, io__state, io__state).
@@ -569,7 +586,7 @@
 	    	{ ForeignImport = foreign_import_module(Lang, Import, _) },
 		( { Lang = c } ->
 			mlds_output_src_import(Indent,
-				mercury_import(
+				mercury_import(import_interface,
 					mercury_module_name_to_mlds(Import)))
 	    	;
 			{ sorry(this_file, "foreign code other than C") }
@@ -595,14 +612,6 @@
 mlds_output_c_defn(_Indent, user_foreign_code(il, _, _)) -->
 	{ sorry(this_file, "foreign code other than C") }.
 
-:- pred mlds_output_pragma_export_decl(mlds_module_name, indent,
-		mlds__pragma_export, io__state, io__state).
-:- mode mlds_output_pragma_export_decl(in, in, in, di, uo) is det.
-
-mlds_output_pragma_export_decl(ModuleName, Indent, PragmaExport) -->
-	mlds_output_pragma_export_func_name(ModuleName, Indent, PragmaExport),
-	io__write_string(";").
-
 :- pred mlds_output_pragma_export_defn(mlds_module_name, indent,
 		mlds__pragma_export, io__state, io__state).
 :- mode mlds_output_pragma_export_defn(in, in, in, di, uo) is det.
@@ -656,7 +665,7 @@
 mlds_output_pragma_export_type(prefix, mlds__commit_type) -->
 	io__write_string("MR_Word").
 mlds_output_pragma_export_type(prefix, mlds__native_bool_type) -->
-	io__write_string("MR_Word").
+	io__write_string("MR_bool").
 mlds_output_pragma_export_type(prefix, mlds__native_int_type) -->
 	io__write_string("MR_Integer").
 mlds_output_pragma_export_type(prefix, mlds__native_float_type) -->
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.114
diff -u -u -r1.114 mlds_to_il.m
--- compiler/mlds_to_il.m	7 May 2002 11:03:07 -0000	1.114
+++ compiler/mlds_to_il.m	18 May 2002 18:38:41 -0000
@@ -305,7 +305,7 @@
 			% reference
 		list__map((pred(F::in, I::out) is det :-
 				mangle_foreign_code_module(ModuleName, F, N),
-				I = mercury_import(N)
+				I = mercury_import(import_implementation, N)
 			),
 			set__to_sorted_list(ForeignLangs),
 			ForeignCodeAssemblerRefs),
@@ -2835,7 +2835,7 @@
 	set_rtti_initialization_field(DoneFieldRef, SetInstrs),
 	{ CCtorCalls = list__filter_map(
 		(func(I::in) = (C::out) is semidet :-
-			I = mercury_import(ImportName),
+			I = mercury_import(import_implementation, ImportName),
 			C = call_class_constructor(
 				class_name(ImportName, wrapper_class_name))
 		), Imports) },
@@ -4002,7 +4002,7 @@
 mlds_to_il__generate_extern_assembly(CurrentAssembly, Version, SignAssembly,
 		SeparateAssemblies, Imports, AllDecls) :-
 	Gen = (pred(Import::in, Decl::out) is semidet :-
-		( Import = mercury_import(ImportName),
+		( Import = mercury_import(import_implementation, ImportName),
 			( SignAssembly = yes,
 				AsmDecls = mercury_strong_name_assembly_decls
 			; SignAssembly = no,
Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.29
diff -u -u -r1.29 mlds_to_java.m
--- compiler/mlds_to_java.m	7 May 2002 11:03:08 -0000	1.29
+++ compiler/mlds_to_java.m	28 May 2002 07:27:48 -0000
@@ -316,9 +316,17 @@
 :- mode output_import(in, di, uo) is det.
 
 output_import(Import) -->
-	{ Import = mercury_import(ImportName)
+	% XXX Handle `:- pragma export' to Java.
+	{ Import = mercury_import(ImportType, ImportName),
+		(
+			ImportType = import_interface,
+			unexpected(this_file,
+			    "import_type `import_interface' in Java backend")
+		;
+			ImportType = import_implementation
+		)
 	; Import = foreign_import(_),
-		unexpected(this_file, "foreign import in java backend")
+		unexpected(this_file, "foreign import in Java backend")
 	},
 	{ SymName = mlds_module_name_to_sym_name(ImportName) },
 	{ JavaSafeSymName = valid_module_name(SymName) },
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.231
diff -u -u -r1.231 modules.m
--- compiler/modules.m	16 May 2002 07:47:24 -0000	1.231
+++ compiler/modules.m	29 May 2002 08:16:21 -0000
@@ -786,10 +786,10 @@
 			io__state, io__state).
 :- mode choose_file_name(in, in, in, in, out, di, uo) is det.
 
-choose_file_name(ModuleName, BaseName, Ext, MkDir, FileName) -->
+choose_file_name(_ModuleName, BaseName, Ext, MkDir, FileName) -->
 	globals__io_lookup_bool_option(use_subdirs, UseSubdirs),
 	( { UseSubdirs = no } ->
-		{ FileName0 = BaseName }
+		{ FileName = BaseName }
 	;
 		%
 		% the source files, the final executables,
@@ -812,10 +812,22 @@
 			; Ext = ".split.$(EXT_FOR_SHARED_LIB)"
 			; Ext = ".init"
 			% output files intended for use by the user
-			% (the .h_dump* and .c_dump* MLDS dumps also
-			% fit into this category, but for efficiency,
-			% to keep this as a switch, we deal with them below)
-			; Ext = ".h"
+			% (the .h_dump* and .c_dump* MLDS dumps
+			% also fit into this category, but for
+			% efficiency, to keep this as a switch,
+			% we deal with them below)
+			; Ext = ".mh"
+			; Ext = ".mh.tmp"
+			; Ext = ".h"	% `.h' files are being replaced with
+					% `.mh' files (for the
+					% `:- pragma export'  declarations),
+					% and `.mih' files (for the high-level
+					% C backend's function declarations).
+					% We still generate the `.h' files
+					% for bootstrapping (the trace
+					% directory refers to std_util.h
+					% and io.h).
+			; Ext = ".h.tmp"
 			; Ext = ".err"
 			; Ext = ".ugly"
 			; Ext = ".hlds_dump"
@@ -830,6 +842,7 @@
 			; Ext = ".depend"
 			; Ext = ".install_ints"
 			; Ext = ".install_hdrs"
+			; Ext = ".install_grade_hdrs"
 			; Ext = ".check"
 			; Ext = ".ints"
 			; Ext = ".int3s"
@@ -841,10 +854,6 @@
 			; Ext = ".classes"
 			; Ext = ".opts"
 			; Ext = ".trans_opts"
-			% The current interface to `mercury_update_interface'
-			% requires .h.tmp files to be in the same directory as
-			% the .h files
-			; Ext = ".h.tmp"
 			% The following files are only used by the Aditi
 			% query shell which doesn't know about --use-subdirs.
 			; Ext = ".base_schema"
@@ -858,7 +867,7 @@
 			)
 		}
 	->
-		{ FileName0 = BaseName }
+		{ FileName = BaseName }
 	;
 		%
 		% we need to handle a few cases specially
@@ -924,24 +933,8 @@
 		;
 			[]
 		),
-		{ string__append_list([DirName, Slash, BaseName], FileName0) }
-	),
-	%
-	% For --high-level-code, the header files for the standard
-	% library are named specially (they get a `mercury.' prefix).
-	%
-	globals__io_lookup_bool_option(highlevel_code, HighLevelCode),
-	{
-		HighLevelCode = yes,
-		( Ext = ".h" ; Ext = ".h.tmp" ),
-		ModuleName = unqualified(UnqualModuleName),
-		mercury_std_library_module(UnqualModuleName),
-		\+ string__prefix(FileName0, "mercury.")
-	->
-		string__append("mercury.", FileName0, FileName)
-	;
-		FileName = FileName0
-	}.
+		{ string__append_list([DirName, Slash, BaseName], FileName) }
+	).
 
 module_name_to_split_c_file_name(ModuleName, Num, Ext, FileName) -->
 	module_name_to_file_name(ModuleName, ".dir", no, DirName),
@@ -2138,7 +2131,7 @@
 				ObjFileName, " ",
 				SplitObjPattern, " :"
 			]),
-			write_dependencies_list(AllDeps, ".h", DepStream)
+			write_dependencies_list(AllDeps, ".mih", DepStream)
 		;
 			[]
 		),
@@ -2158,13 +2151,17 @@
 		%
 		module_name_to_file_name(ModuleName, ".c", no, CFileName),
 		module_name_to_file_name(ModuleName, ".s", no, AsmFileName),
-		module_name_to_file_name(ModuleName, ".h", no, HeaderFileName),
+		module_name_to_file_name(ModuleName, ".mh", no, HeaderFileName),
+		module_name_to_file_name(ModuleName, ".mih", no,
+				HeaderFileName2),
 		io__write_strings(DepStream, [
 				"\n\n",
 				"ifeq ($(TARGET_ASM),yes)\n",
-				HeaderFileName, " : ", AsmFileName, "\n",
+				HeaderFileName, " ", HeaderFileName2,
+					" : ", AsmFileName, "\n",
 				"else\n",
-				HeaderFileName, " : ", CFileName, "\n",
+				HeaderFileName, " ",  HeaderFileName2,
+					" : ", CFileName, "\n",
 				"endif"
 		]),
 
@@ -2287,7 +2284,7 @@
 			io__write_string(DepStream, "\n\n"),
 			io__write_string(DepStream, ObjFileName),
 			io__write_string(DepStream, " : "),
-			write_dependencies_list(ForeignImportedModules, ".h",
+			write_dependencies_list(ForeignImportedModules, ".mh",
 				DepStream),
 			io__write_string(DepStream, "\n\n")
 		),
@@ -3660,51 +3657,71 @@
 	io__write_string(DepStream, "\n"),
 
 	io__write_string(DepStream, MakeVarName),
-	io__write_string(DepStream, ".hs = "),
+	io__write_string(DepStream, ".mihs = "),
 	globals__io_lookup_bool_option(highlevel_code, HighLevelCode),
 	( { HighLevelCode = yes } ->
 		( { Target = asm } ->
 			% For the `--target asm' back-end, we only
-			% generate `.h' files for modules that
+			% generate `.mih' files for modules that
 			% contain C code
 			write_dependencies_list(
 				modules_that_need_headers(Modules, DepsMap),
-				".h", DepStream)
+				".mih", DepStream)
 		; { Target = c } ->
 			% For the `--target c' MLDS back-end, we
-			% generate `.h' files for every module
-			write_compact_dependencies_list(Modules, "", ".h",
+			% generate `.mih' files for every module
+			write_compact_dependencies_list(Modules,
+					"$(mihs_subdir)", ".mih",
 					Basis, DepStream)
 		;
 			% For the IL and Java targets, currently we don't
-			% generate `.h' files at all; although perhaps
+			% generate `.mih' files at all; although perhaps
 			% we should...
 			[]
 		)
 	;
-		% For the LLDS back-end, we only generate `.h' files
-		% for modules containing `:- pragma export' declarations.
-		{ LLDSHeaderModules =
+		% For the LLDS back-end, we don't use `.mih' files at all
+		[]
+	),
+	io__write_string(DepStream, "\n"),
+
+	io__write_string(DepStream, MakeVarName),
+	io__write_string(DepStream, ".mhs = "),
+	( { Target = c ; Target = asm } ->
+		% We only generate `.mh' files for modules containing
+		% `:- pragma export' declarations.
+		{ HeaderModules =
 		    list__filter(
 			(pred(Module::in) is semidet :-
 			    map__lookup(DepsMap, Module,
-					deps(_, ModuleImports)),
+			    		deps(_, ModuleImports)),
 			    contains_foreign_export =
-			    	ModuleImports ^ contains_foreign_export 
-		     ), Modules) },
-		write_dependencies_list(LLDSHeaderModules, ".h", DepStream)
+					ModuleImports ^ contains_foreign_export 
+			), Modules) },
+		write_dependencies_list(HeaderModules, ".mh", DepStream)
+	;
+		[]
 	),
 	io__write_string(DepStream, "\n"),
 
-	% The `<module>.all_hs' variable is like `<module>.hs' except
+	% The `<module>.all_mihs' variable is like `<module>.mihs' except
 	% that it contains header files for all the modules, regardless
 	% of the grade or --target option.  It is used by the rule for
 	% `mmake realclean', which should remove anything that could have
 	% been automatically generated, even if the grade or --target option
 	% has changed.
 	io__write_string(DepStream, MakeVarName),
-	io__write_string(DepStream, ".all_hs = "),
-	write_compact_dependencies_list(Modules, "", ".h", Basis, DepStream),
+	io__write_string(DepStream, ".all_mihs = "),
+	write_compact_dependencies_list(Modules, "$(mihs_subdir)", ".mih",
+					Basis, DepStream),
+	io__write_string(DepStream, "\n"),
+
+	% The `<module>.all_mhs' variable is like `<module>.mhs' except
+	% that it contains header files for all the modules, as for
+	% `<module>.all_mihs' above.
+	io__write_string(DepStream, MakeVarName),
+	io__write_string(DepStream, ".all_mhs = "),
+	write_compact_dependencies_list(Modules, "", ".mh", Basis, DepStream),
 	io__write_string(DepStream, "\n"),
 
 	io__write_string(DepStream, MakeVarName),
@@ -4026,38 +4043,69 @@
 		InstallIntsRuleBody
 	]),
 
-	module_name_to_lib_file_name("lib", ModuleName, ".install_hdrs", no,
-				LibInstallHdrsTargetName),
-	globals__io_lookup_bool_option(highlevel_code, HighLevelCode),
-	( { HighLevelCode = yes, ( Target = c ; Target = asm ) } ->
-		%
-		% XXX  Note that we install the header files in two places:
-		% in the `inc' directory, so that the C compiler will find
-		% them, and also in the `ints' directory, so that Mmake
-		% will find them.  That's not ideal, but it works.
-		% (A better fix would be to change the VPATH setting
-		% in scripts/Mmake.vars.in so that Mmake also searches
-		% the `inc' directory, but doing that properly is non-trivial.)
-		%
-		io__write_strings(DepStream, [
-			".PHONY : ", LibInstallHdrsTargetName, "\n",
-			LibInstallHdrsTargetName, " : ",
-				"$(", MakeVarName, ".hs) ",
-				"install_lib_dirs\n",
-			"\tfor hdr in $(", MakeVarName, ".hs); do \\\n",
-			"\t	$(INSTALL) $$hdr $(INSTALL_INC_DIR); \\\n",
-			"\t	$(INSTALL) $$hdr $(INSTALL_INT_DIR); \\\n",
-			"\tdone\n\n"
-		])
-	;
-		% for non-MLDS grades, we don't need to install the header
-		% files, so this rule does nothing
-		io__write_strings(DepStream, [
-			".PHONY : ", LibInstallHdrsTargetName, "\n",
-			LibInstallHdrsTargetName, " :\n",
-			"\t\n\n"
-		])
-	),
+	%
+	% XXX  Note that we install the header files in two places:
+	% in the `lib/inc' or `lib/$(GRADE)/$(FULLARCH)/inc' directory,
+	% so that the C compiler will find them, and also in the `ints'
+	% directory, so that Mmake will find them.  That's not ideal,
+	% but it works.
+	%
+	% (A better fix would be to change the VPATH setting
+	% in scripts/Mmake.vars.in so that Mmake also searches
+	% the `lib/$(GRADE)/$(FULLARCH)/inc' directory, but doing
+	% that properly is non-trivial.)
+	%
+	module_name_to_lib_file_name("lib", ModuleName,
+		".install_hdrs", no, LibInstallHdrsTargetName),
+	io__write_strings(DepStream, [
+		".PHONY : ", LibInstallHdrsTargetName, "\n",
+		LibInstallHdrsTargetName, " : ",
+			"$(", MakeVarName, ".mhs) ",
+			"install_lib_dirs\n", 
+"ifeq ($(", MakeVarName, ".mhs),)
+		@:
+else
+		for hdr in $(", MakeVarName, ".mhs); do \\
+			$(INSTALL) $$hdr $(INSTALL_INT_DIR); \\
+			$(INSTALL) $$hdr $(INSTALL_INC_DIR); \\
+		done
+endif\n\n"]),
+
+	module_name_to_lib_file_name("lib", ModuleName,
+		".install_grade_hdrs", no, LibInstallGradeHdrsTargetName),
+	io__write_strings(DepStream, [
+		".PHONY : ", LibInstallGradeHdrsTargetName, "\n",
+		LibInstallGradeHdrsTargetName, " : ",
+			"$(", MakeVarName, ".mihs) ",
+			"install_grade_dirs\n", 
+"ifeq ($(", MakeVarName, ".mihs),)
+		@:
+else
+		for hdr in $(", MakeVarName, ".mihs); do \\
+			$(INSTALL) $$hdr $(INSTALL_INT_DIR); \\
+			$(INSTALL) $$hdr $(INSTALL_GRADE_INC_DIR); \\
+		done
+		# The following is needed to support the `--use-subdirs' option
+		# We try using `ln -s', but if that fails, then we just use
+		# `$(INSTALL)'.
+		rm -f $(INSTALL_GRADE_INC_SUBDIR)
+		ln -s .. $(INSTALL_GRADE_INC_SUBDIR) || { \\
+			{ [ -d $(INSTALL_GRADE_INC_SUBDIR) ] || \\
+				$(INSTALL_MKDIR) $(INSTALL_GRADE_INC_SUBDIR); \\
+			} && \\
+			$(INSTALL) $(INSTALL_GRADE_INC_DIR)/*.mih \\
+				$(INSTALL_GRADE_INC_SUBDIR); \\
+		} || exit 1
+		rm -f $(INSTALL_INT_DIR)/Mercury/mihs
+		ln -s .. $(INSTALL_INT_DIR)/Mercury/mihs || { \\
+			{ [ -d $(INSTALL_INT_DIR)/Mercury/mihs ] || \\
+				$(INSTALL_MKDIR) \\
+					$(INSTALL_INT_DIR)/Mercury/mihs; \\
+			} && \\
+			$(INSTALL) $(INSTALL_GRADE_INC_DIR)/*.mih \\
+				$(INSTALL_INT_DIR); \\
+		} || exit 1
+endif\n\n"]),
 
 	module_name_to_file_name(ModuleName, ".check", no, CheckTargetName),
 	module_name_to_file_name(ModuleName, ".ints", no, IntsTargetName),
@@ -4134,6 +4182,7 @@
 		"\t-echo $(", MakeVarName, ".num_splits) | xargs rm -rf \n",
 		"\t-echo $(", MakeVarName, ".cs) ", InitCFileName,
 				" | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".mihs) | xargs rm -f\n",
 		"\t-echo $(", MakeVarName, ".all_ss) ", InitAsmFileName,
 				" | xargs rm -f\n",
 		"\t-echo $(", MakeVarName, ".all_pic_ss) ",
@@ -4178,7 +4227,7 @@
 		"\t-echo $(", MakeVarName, ".trans_opts) | xargs rm -f\n",
 		"\t-echo $(", MakeVarName, ".ds) | xargs rm -f\n",
 		"\t-echo $(", MakeVarName, ".module_deps) | xargs rm -f\n",
-		"\t-echo $(", MakeVarName, ".all_hs) | xargs rm -f\n",
+		"\t-echo $(", MakeVarName, ".all_mhs) | xargs rm -f\n",
 		"\t-echo $(", MakeVarName, ".dlls) | xargs rm -f\n",
 		"\t-echo $(", MakeVarName, ".foreign_dlls) | xargs rm -f\n",
 		"\t-echo $(", MakeVarName, ".classes) | xargs rm -f\n",
@@ -4587,16 +4636,7 @@
 
 write_compact_dependencies_list(Modules, Prefix, Suffix, Basis, DepStream) -->
 	(
-		{ Basis = yes(VarName - OldSuffix) },
-		% Don't use the compact dependency lists for names of header
-		% files for modules in the standard library, because it
-		% doesn't take into account the "mercury." prefix
-		% that gets added to those header file names in MLDS grades.
-		\+ {
-			(Suffix = ".h" ; Suffix = ".h.tmp"),
-			list__member(unqualified(StdLibModule), Modules),
-			mercury_std_library_module(StdLibModule)
-		}
+		{ Basis = yes(VarName - OldSuffix) }
 	->
 		io__write_string(DepStream, "$("),
 		io__write_string(DepStream, VarName),
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.311
diff -u -u -r1.311 user_guide.texi
--- doc/user_guide.texi	13 May 2002 18:22:33 -0000	1.311
+++ doc/user_guide.texi	29 May 2002 08:41:27 -0000
@@ -224,10 +224,12 @@
 which contain variable definitions for an entire program.
 
 As usual, @file{.c} files are C source code,
- at file{.h} files are C header files,
 and @file{.o} files are object code.
 In addition, @file{.pic_o} files are object code files
 that contain position-independent code (PIC).
+ at file{.mh} and @file{.mih} files are C header files generated
+by the Mercury compiler. The non-standard extensions are necessary
+to avoid conflicts with system header files.
 @file{.s} files and @file{.pic_s} files are assembly language.
 @file{.java} and @file{.class} files are Java source code
 and Java bytecode respectively.
@@ -572,8 +574,9 @@
 and the error messages produced by the compiler.
 Specifically, this will remove all the @samp{.c}, @samp{.s}, @samp{.o},
 @samp{.pic_o}, @samp{.prof}, @samp{.no}, @samp{.ql}, @samp{.used},
+ at samp{.mih},
 @ifset aditi
- at samp{.schema},
+ at samp{.derived_schema}, @samp{.base_schema}
 @end ifset
 and @samp{.err} files
 belonging to the named @var{main-module} or its imported modules.
@@ -593,7 +596,7 @@
 @ifset aditi
 @samp{.rlo},
 @end ifset
- at samp{.h} and @samp{.d} files
+ at samp{.mh} and @samp{.d} files
 belonging to one of the modules of the program,
 and also the various possible executables, libraries and dependency files
 for the program as a whole ---
Index: library/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/library/Mmakefile,v
retrieving revision 1.90
diff -u -u -r1.90 Mmakefile
--- library/Mmakefile	13 May 2002 08:09:40 -0000	1.90
+++ library/Mmakefile	28 May 2002 16:28:11 -0000
@@ -336,6 +336,9 @@
 .PHONY: install_hdrs
 install_hdrs: lib$(STD_LIB_NAME).install_hdrs
 
+.PHONY: install_grade_hdrs
+install_grade_hdrs: lib$(STD_LIB_NAME).install_grade_hdrs
+
 .PHONY: install_init
 install_init: $(STD_LIB_NAME).init install_lib_dirs
 	cp `vpath_find $(STD_LIB_NAME).init` $(INSTALL_MODULE_DIR)
@@ -402,6 +405,11 @@
 
 .PHONY: install_hdrs
 install_hdrs:
+	echo "Can't do make install without LIBRARY_INTERMODULE=yes"
+	exit 1
+
+.PHONY: install_grade_hdrs
+install_grade_hdrs:
 	echo "Can't do make install without LIBRARY_INTERMODULE=yes"
 	exit 1
 
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.122
diff -u -u -r1.122 Mmake.rules
--- scripts/Mmake.rules	16 May 2002 06:48:42 -0000	1.122
+++ scripts/Mmake.rules	29 May 2002 06:57:23 -0000
@@ -459,7 +459,7 @@
 
 # Note: the `lib%.install_ints' rule is generated in each module's `.dep'
 # file so it can be more easily customised based on the desired level of
-# intermodule optimisation.  Likewise the `lib%.install_hdrs' is also
+# intermodule optimisation.  Likewise the `lib%.install_grade_hdrs' is also
 # generated in the `.dep' file, since it depends on the setting of
 # the `--high-level-code' option.
 
@@ -489,17 +489,17 @@
 lib%.install_grades:
 	rm -rf tmp_dir && \
 	mkdir tmp_dir && \
-	{ mv -f $(deps_subdir)$*.dep $($*.hs) $($*.cs) $($*.c_dates) $($*.os) \
-		$($*.pic_os) *.a *.so tmp_dir || true; } && \
+	{ mv -f $(deps_subdir)$*.dep $($*.mihs) $($*.cs) $($*.c_dates) \
+		$($*.os) $($*.pic_os) *.a *.so tmp_dir || true; } && \
 	for grade in x $(ALL_LIBGRADES); do \
 		if [ "$$grade" != "x" ]; then \
 			$(MMAKE) GRADE=$$grade $*.depend || \
 				exit 1; \
-			$(MMAKE) GRADE=$$grade lib$*.install_hdrs || \
+			$(MMAKE) GRADE=$$grade lib$*.install_grade_hdrs || \
 				exit 1; \
 			$(MMAKE) GRADE=$$grade lib$*.install_library || \
 				exit 1; \
-			rm -f $(deps_subdir)$*.dep $($*.hs) $($*.cs) \
+			rm -f $(deps_subdir)$*.dep $($*.mihs) $($*.cs) \
 				$($*.c_dates) $($*.os) $($*.pic_os) *.a *.so; \
 		fi; \
 	done && \
@@ -513,7 +513,7 @@
 lib%.install_split_grades:
 	rm -rf tmp_dir && \
 	mkdir tmp_dir && \
-	{ mv -f $(deps_subdir)$*.dep $($*.hs) $($*.dirs) *.a *.so \
+	{ mv -f $(deps_subdir)$*.dep $($*.mihs) $($*.dirs) *.a *.so \
 		tmp_dir || true; } && \
 	for grade in x $(ALL_LIBGRADES); do \
 		if [ "$$grade" != "x" ]; then \
@@ -521,7 +521,7 @@
 				exit 1; \
 			$(MMAKE) GRADE=$$grade lib$*.install_split_library || \
 				exit 1; \
-			rm -rf $(deps_subdir)$*.dep $($*.hs) $($*.dirs) \
+			rm -rf $(deps_subdir)$*.dep $($*.mihs) $($*.dirs) \
 				*.a *.so; \
 		fi; \
 	done && \
@@ -543,5 +543,10 @@
 install_grade_dirs: #install_lib_dirs
 	-[ -d $(INSTALL_MERC_LIB_DIR) ] || \
 		$(INSTALL_MKDIR) $(INSTALL_MERC_LIB_DIR)
+	-[ -d $(INSTALL_GRADE_INC_DIR) ] || \
+		$(INSTALL_MKDIR) $(INSTALL_GRADE_INC_DIR)
+	# The following is needed to support the `--use-subdirs' option
+	-[ -d $(INSTALL_GRADE_INC_DIR)/Mercury ] || \
+		$(INSTALL_MKDIR) $(INSTALL_GRADE_INC_DIR)/Mercury
 
 #-----------------------------------------------------------------------------#
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.71
diff -u -u -r1.71 Mmake.vars.in
--- scripts/Mmake.vars.in	16 May 2002 06:48:43 -0000	1.71
+++ scripts/Mmake.vars.in	28 May 2002 07:12:56 -0000
@@ -22,7 +22,8 @@
 EXTRA_C_LIB_DIRS	= \
 	$(patsubst %,%/lib/$(GRADESTRING)/@FULLARCH@,$(EXTRA_LIB_DIRS)) \
 	$(patsubst %,%/lib/@FULLARCH@,$(EXTRA_LIB_DIRS))
-EXTRA_C_INCL_DIRS	= $(patsubst %,%/inc,$(EXTRA_LIB_DIRS))
+EXTRA_C_INCL_DIRS	= $(patsubst %,%/inc,$(EXTRA_LIB_DIRS)) \
+	$(patsubst %,%/lib/$(GRADESTRING)/@FULLARCH@/inc,$(EXTRA_LIB_DIRS))
 EXTRA_INIT_DIRS		= $(patsubst %,%/modules,$(EXTRA_LIB_DIRS))
 MERCURY_EXTRA_INIT_DIRS = $(EXTRA_INIT_DIRS)
 else
@@ -543,6 +544,7 @@
 optdates_subdir=$(SUBDIR)optdates/
 trans_opt_dates_subdir=$(SUBDIR)trans_opt_dates/
 useds_subdir=$(SUBDIR)useds/
+mihs_subdir=$(SUBDIR)mihs/
 cs_subdir=$(SUBDIR)cs/
 dlls_subdir=$(SUBDIR)dlls/
 ss_subdir=$(SUBDIR)ss/
@@ -582,6 +584,7 @@
 optdates_subdir=
 trans_opt_dates_subdir=
 useds_subdir=
+mihs_subdir=
 cs_subdir=
 dlls_subdir=
 ss_subdir=
@@ -677,6 +680,8 @@
 INSTALL_MERC_GRADELESS_LIB_DIR = $(INSTALL_LIBDIR)/lib/$(FULLARCH)
 FINAL_INSTALL_MERC_GRADELESS_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib/$(FULLARCH)
 INSTALL_MERC_LIB_DIR	= $(INSTALL_LIBDIR)/lib/$(GRADESTRING)/$(FULLARCH)
+INSTALL_GRADE_INC_DIR	= $(INSTALL_LIBDIR)/lib/$(GRADESTRING)/$(FULLARCH)/inc
+INSTALL_GRADE_INC_SUBDIR = $(INSTALL_GRADE_INC_DIR)/Mercury/mihs
 FINAL_INSTALL_MERC_LIB_DIR = \
 		$(FINAL_INSTALL_LIBDIR)/lib/$(GRADESTRING)/$(FULLARCH)
 
Index: scripts/mercury_cleanup_install
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mercury_cleanup_install,v
retrieving revision 1.3
diff -u -u -r1.3 mercury_cleanup_install
--- scripts/mercury_cleanup_install	6 Jul 2001 11:25:36 -0000	1.3
+++ scripts/mercury_cleanup_install	28 May 2002 06:36:59 -0000
@@ -68,6 +68,7 @@
 	    [ -d Mercury/os ] && mv -f tmp_dir/*.o tmp_dir/*.pic_o Mercury/os
 	    [ -d Mercury/deps ] && mv -f tmp_dir/*.dep Mercury/deps
 	    [ -d Mercury/c_dates ] && mv -f tmp_dir/*.c_date Mercury/c_dates
+	    [ -d Mercury/mihs ] && mv -f tmp_dir/*.mih Mercury/mihs
 	    [ -d Mercury/useds ] && mv -f tmp_dir/*.used Mercury/useds
 	    mv -f tmp_dir/* .
 	    rmdir tmp_dir
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/mgnuc.in,v
retrieving revision 1.86
diff -u -u -r1.86 mgnuc.in
--- scripts/mgnuc.in	19 Apr 2002 14:59:35 -0000	1.86
+++ scripts/mgnuc.in	29 May 2002 08:29:31 -0000
@@ -219,9 +219,17 @@
 # include the file `final_grade_options.sh-subr'
 @FINAL_GRADE_OPTIONS@
 
+# compute the canonical grade name from the options settings
+#
+
+# include the file `canonical_grade.sh-subr'
+ at CANONICAL_GRADE@
+
 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"} ;;
+    "")	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"}
+	;;
 esac
 
 LOCAL_C_INCL_DIR=${MERCURY_LOCAL_C_INCL_DIR=/usr/local/include}
--------------------------------------------------------------------------
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