[m-rev.] for review: Put .mh files into Mercury/mhs subdirectory.

Peter Wang novalazy at gmail.com
Tue Jul 23 14:32:47 AEST 2024


Put .mh files into Mercury/mhs subdirectory.

Put .mh files into a Mercury/mhs subdirectory when --use-subdirs
or --use-grade-subdirs is used.

compiler/file_names.m:
    Replace ext_cur_mh with a new option in a new category,
    ext_cur_ngs_max_cur_mh. The new category is similar to that for .mih
    files, except that .mh files are never placed in grade-specific
    subdirectories.

compiler/handle_options.m:
    Add Mercury/mhs subdirs to list of C include directories
    when --use-subdirs or --use-grade-subdirs is in effect.

compiler/write_deps_file.m:
    Add $(mhs_subdir) prefix before %.mh patterns.

    Create a Mercury/mhs -> .. symlink when installing.

    Conform to changes.

compiler/export.m:
compiler/make.file_names.m:
compiler/make.program_target.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mlds_to_c_file.m:
    Conform to changes.

scripts/Mmake.vars.in:
    Define the variable mhs_subdir.

scripts/Mmake.rules:
    Add -I option to find .mh files when --use-subdirs is used.

browser/.mgnuc_copts:
browser/MDB_FLAGS.in:
compiler/.mgnuc_copts:
compiler/COMP_FLAGS.in:
deep_profiler/.mgnuc_copts:
deep_profiler/DEEP_FLAGS.in:
extras/EXTRAS_FLAGS.in:
grade_lib/.mgnuc_copts:
grade_lib/GRADE_LIB_FLAGS.in:
library/.mgnuc_copts:
mdbcomp/.mgnuc_copts:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/.mgnuc_copts:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/.mgnuc_copts:
profiler/PROF_FLAGS.in:
slice/.mgnuc_copts:
slice/SLICE_FLAGS.in:
ssdb/.mgnuc_copts:
ssdb/SSDB_FLAGS.in:
tests/.mgnuc_copts.ws:
tests/WS_FLAGS.ws:
trace/.mgnuc_copts:
tools/lmc.in:
    Add -I options to find .mh files when the workspace is built
    with mmake --use-subdirs.

NEWS.md:
    Announce change.

    Delete trailing whitespace.

diff --git a/NEWS.md b/NEWS.md
index 8f461025d..d78b4097f 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -58,6 +58,12 @@ Changes that may break compatibility
 
 * We have dropped support for the x86 (32-bit) version of Cygwin.
 
+* The `--use-subdirs` and `--use-grade-subdirs` options now cause `.mh` files
+  to be placed in a `Mercury/mhs` subdirectory instead of the current
+  directory. This reduces clutter in the current directory, but may require
+  additional options to be passed to the C compiler in order for it to find
+  those header files.
+
 * We have changed the meaning of `mmc --make name.cs`.
 
   The `mmc --make` target `name.cs` now means "build the .cs file
@@ -66,16 +72,16 @@ Changes that may break compatibility
 
 * Some (undocumented) mmake variables in compiler-generated `.dv` files
   have been renamed:
-  
-    program.cs          -> program.all_cs    
-    program.os          -> program.all_os    
-    program.pic_os      -> program.all_pic_os    
-    program.javas       -> program.all_javas    
-    program.css         -> program.all_css    
 
-    program.all_mhs     -> program.mhs_to_clean    
-    program.all_mihs    -> program.mihs_to_clean    
-    program.all_int0s   -> program.int3s_to_clean    
+    program.cs          -> program.all_cs
+    program.os          -> program.all_os
+    program.pic_os      -> program.all_pic_os
+    program.javas       -> program.all_javas
+    program.css         -> program.all_css
+
+    program.all_mhs     -> program.mhs_to_clean
+    program.all_mihs    -> program.mihs_to_clean
+    program.all_int0s   -> program.int3s_to_clean
 
 Changes to the Mercury standard library
 ---------------------------------------
diff --git a/browser/.mgnuc_copts b/browser/.mgnuc_copts
index ff8717172..79b37cd4b 100644
--- a/browser/.mgnuc_copts
+++ b/browser/.mgnuc_copts
@@ -2,8 +2,11 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
diff --git a/browser/MDB_FLAGS.in b/browser/MDB_FLAGS.in
index 9e1abac79..60283240f 100644
--- a/browser/MDB_FLAGS.in
+++ b/browser/MDB_FLAGS.in
@@ -29,8 +29,10 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --c-include-directory ../mdbcomp
+--c-include-directory ../mdbcomp/Mercury/mhs
 --c-include-directory ../mdbcomp/Mercury/mihs
 --csharp-flag -keyfile:../mercury.snk
 @CSHARP_DELAYSIGN_FLAG@
diff --git a/compiler/.mgnuc_copts b/compiler/.mgnuc_copts
index 0a44865a4..d865787d4 100644
--- a/compiler/.mgnuc_copts
+++ b/compiler/.mgnuc_copts
@@ -2,11 +2,15 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
 -I../ssdb
+-I../ssdb/Mercury/mhs
 -I../ssdb/Mercury/mihs
 -I../trace
diff --git a/compiler/COMP_FLAGS.in b/compiler/COMP_FLAGS.in
index 6fba8ebe7..18f6f60c6 100644
--- a/compiler/COMP_FLAGS.in
+++ b/compiler/COMP_FLAGS.in
@@ -25,12 +25,16 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --c-include-directory ../mdbcomp
+--c-include-directory ../mdbcomp/Mercury/mhs
 --c-include-directory ../mdbcomp/Mercury/mihs
 --c-include-directory ../browser
+--c-include-directory ../browser/Mercury/mhs
 --c-include-directory ../browser/Mercury/mihs
 --c-include-directory ../ssdb
+--c-include-directory ../ssdb/Mercury/mhs
 --c-include-directory ../ssdb/Mercury/mihs
 --c-include-directory ../trace
 --csharp-flag -keyfile:../mercury.snk
diff --git a/compiler/export.m b/compiler/export.m
index 2dc74ed44..746a29862 100644
--- a/compiler/export.m
+++ b/compiler/export.m
@@ -2,7 +2,7 @@
 % vim: ft=mercury ts=4 sw=4 et
 %-----------------------------------------------------------------------------%
 % Copyright (C) 1996-2012 The University of Melbourne.
-% Copyright (C) 2013-2018 The Mercury team.
+% Copyright (C) 2013-2024 The Mercury team.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -645,10 +645,11 @@ produce_header_file(ProgressStream, ModuleInfo, ForeignExportDecls,
         ModuleName, !IO) :-
     % We always produce a .mh file because with intermodule optimization
     % enabled, the .o file depends on all the .mh files of the imported
-    % modules. so we need to produce a .mh file even if it contains nothing.
+    % modules. So we need to produce a .mh file even if it contains nothing.
     module_info_get_globals(ModuleInfo, Globals),
-    module_name_to_file_name_create_dirs(Globals, $pred, ext_cur(ext_cur_mh),
-        ModuleName, FileName, !IO),
+    module_name_to_file_name_create_dirs(Globals, $pred,
+        ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh), ModuleName, FileName,
+        !IO),
     MaybeThisFileName = yes(FileName),
     TmpFileName = FileName ++ ".tmp",
     io.open_output(TmpFileName, Result, !IO),
diff --git a/compiler/file_names.m b/compiler/file_names.m
index 231bb6211..1f972c5cd 100644
--- a/compiler/file_names.m
+++ b/compiler/file_names.m
@@ -205,6 +205,12 @@
             % differ, and they also use a different algorithm for converting
             % module names to file names.
 
+    ;       ext_cur_ngs_max_cur(ext_cur_ngs_max_cur)
+            % All extensions whose files can get put either into the current
+            % directory, or into a non-grade-specific subdirectory, with
+            % search being specified restricting the options to just the first
+            % alternative.
+
     ;       ext_cur_ngs_gs_max_cur(ext_cur_ngs_gs_max_cur)
             % All extensions whose files can get put either into the current
             % directory, or into a non-grade-specific subdirectory, or into
@@ -226,17 +232,13 @@
 % - a prefix, and the name of an option giving the rest of the extension.
 
 :- type ext_cur
-            % Compiler-generated C header file for a module that is intended
-            % for inclusion by user-written C source files.
-    --->    ext_cur_mh                          % ".mh"
-
             % These extensions are used not to create filenames, but to
             % create mmake target names. Some do refer to real files,
             % but they can (and some do) refer to these using extension
             % strings that can contain references to make variables.
             % Some of the other generated make targets are phony targets,
             % meaning that they never correspond to real files at all.
-    ;       ext_cur_pmt_all_int3s               % ".all_int3s"
+    --->    ext_cur_pmt_all_int3s               % ".all_int3s"
     ;       ext_cur_pmt_all_ints                % ".all_int3"
     ;       ext_cur_pmt_all_opts                % ".all_opts"
     ;       ext_cur_pmt_all_trans_opts          % ".all_trans_opts"
@@ -418,6 +420,11 @@
     --->    ext_cur_ngs_gs_java_java            % ".java"
     ;       ext_cur_ngs_gs_java_class.          % ".class"
 
+:- type ext_cur_ngs_max_cur
+            % Compiler-generated C header file for a module that is intended
+            % for inclusion by user-written C source files.
+    --->    ext_cur_ngs_max_cur_mh.             % ".mh"
+
 :- type ext_cur_ngs_gs_max_cur
             % Compiler-generated header file for a module that is intended
             % for inclusion by Mercury-generated C source files.
@@ -709,6 +716,10 @@ extension_to_string(Globals, Ext) = ExtStr :-
         Ext = ext_cur_ngs_gs_java(ExtCurNgsGsJava),
         ext_cur_ngs_gs_java_extension_dir(ExtCurNgsGsJava,
             ExtStr, _SubDirName)
+    ;
+        Ext = ext_cur_ngs_max_cur(ExtCurNgsGsMaxCur),
+        ext_cur_ngs_max_cur_extension_dir(ExtCurNgsGsMaxCur,
+            ExtStr, _SubDirName)
     ;
         Ext = ext_cur_ngs_gs_max_cur(ExtCurNgsGsMaxCur),
         ext_cur_ngs_gs_max_cur_extension_dir(ExtCurNgsGsMaxCur,
@@ -724,8 +735,7 @@ extension_to_string(Globals, Ext) = ExtStr :-
 :- pred ext_cur_extension(ext_cur::in, string::out) is det.
 
 ext_cur_extension(Ext, Str) :-
-    ( Ext = ext_cur_mh,                       Str = ".mh"
-    ; Ext = ext_cur_pmt_all_int3s,            Str = ".all_int3s"
+    ( Ext = ext_cur_pmt_all_int3s,            Str = ".all_int3s"
     ; Ext = ext_cur_pmt_all_ints,             Str = ".all_ints"
     ; Ext = ext_cur_pmt_all_opts,             Str = ".all_opts"
     ; Ext = ext_cur_pmt_all_trans_opts,       Str = ".all_trans_opts"
@@ -880,6 +890,12 @@ ext_cur_ngs_gs_java_extension_dir(Ext, Str, Dir) :-
     ; Ext = ext_cur_ngs_gs_java_class,  Str = ".class", Dir = "classes"
     ).
 
+:- pred ext_cur_ngs_max_cur_extension_dir(ext_cur_ngs_max_cur::in,
+    string::out, string::out) is det.
+
+ext_cur_ngs_max_cur_extension_dir(Ext, Str, Dir) :-
+    Ext = ext_cur_ngs_max_cur_mh, Str = ".mh", Dir = "mhs".
+
 :- pred ext_cur_ngs_gs_max_cur_extension_dir(ext_cur_ngs_gs_max_cur::in,
     string::out, string::out) is det.
 
@@ -912,6 +928,7 @@ module_name_to_base_file_name_no_ext(Ext, ModuleName) = BaseNameNoExt :-
         ; Ext = ext_cur_ngs(_)
         ; Ext = ext_cur_gs(_)
         ; Ext = ext_cur_ngs_gs(_)
+        ; Ext = ext_cur_ngs_max_cur(_)
         ; Ext = ext_cur_ngs_gs_max_cur(_)
         ; Ext = ext_cur_ngs_gs_max_ngs(_)
         ),
@@ -1163,6 +1180,30 @@ ext_to_dir_path(Globals, Search, Ext, DirNames) :-
         % paths that do not include it should call get_java_dir_path.
         get_java_dir_path(Globals, ExtCurNgsGsJava, DirNames0),
         DirNames = DirNames0 ++ ["jmercury"]
+    ;
+        Ext = ext_cur_ngs_max_cur(ExtCurNgsMaxCur),
+        (
+            Search = for_search,
+            % If we are searching for (rather than writing) a `.mh' file,
+            % use the plain file name. This is so that searches for files
+            % in installed libraries will work. `--c-include-directory' is set
+            % so that searches for files in the current directory will work.
+            DirNames = []
+        ;
+            Search = not_for_search,
+            globals.get_subdir_setting(Globals, SubdirSetting),
+            (
+                SubdirSetting = use_cur_dir,
+                DirNames = []
+            ;
+                ( SubdirSetting = use_cur_ngs_subdir
+                ; SubdirSetting = use_cur_ngs_gs_subdir
+                ),
+                ext_cur_ngs_max_cur_extension_dir(ExtCurNgsMaxCur,
+                    _ExtStr, SubDirName),
+                DirNames = make_ngs_dir_names(SubDirName)
+            )
+        )
     ;
         Ext = ext_cur_ngs_gs_max_cur(ExtCurNgsGsMaxCur),
         (
diff --git a/compiler/handle_options.m b/compiler/handle_options.m
index 05e6baec5..06f930963 100644
--- a/compiler/handle_options.m
+++ b/compiler/handle_options.m
@@ -2936,12 +2936,15 @@ handle_directory_options(OpMode, !Globals) :-
             )
         )
     then
+        ToMhsSubdir = (func(Dir) = Dir/"Mercury"/"mhs"),
         globals.lookup_accumulating_option(!.Globals, c_include_directory,
             CIncludeDirs1),
+        MhsSubdir = ToMhsSubdir(dir.this_directory),
         MihsSubdir = ToMihsSubdir(dir.this_directory),
+        SearchLibMhsSubdirs = list.map(ToMhsSubdir, SearchLibFilesDirs),
         SearchLibMihsSubdirs = list.map(ToMihsSubdir, SearchLibFilesDirs),
-        SubdirCIncludeDirs = [dir.this_directory, MihsSubdir |
-            SearchLibMihsSubdirs ++ CIncludeDirs1],
+        SubdirCIncludeDirs = [dir.this_directory, MhsSubdir, MihsSubdir |
+            SearchLibMhsSubdirs ++ SearchLibMihsSubdirs ++ CIncludeDirs1],
         globals.set_option(c_include_directory,
             accumulating(SubdirCIncludeDirs), !Globals)
     else
diff --git a/compiler/make.file_names.m b/compiler/make.file_names.m
index fd5b5c566..0fab770bb 100644
--- a/compiler/make.file_names.m
+++ b/compiler/make.file_names.m
@@ -1,7 +1,7 @@
 %---------------------------------------------------------------------------%
 % vim: ft=mercury ts=4 sw=4 et
 %---------------------------------------------------------------------------%
-% Copyright (C) 2023 The Mercury team.
+% Copyright (C) 2023-2024 The Mercury team.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %---------------------------------------------------------------------------%
@@ -227,7 +227,7 @@ target_type_to_target_extension(Target, TargetExt) :-
             ext_cur_ngs_gs_max_cur(ext_cur_ngs_gs_max_cur_mih))
     ;
         Target = module_target_c_header(header_mh),
-        TargetExt = extension(ext_cur(ext_cur_mh))
+        TargetExt = extension(ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh))
     ;
         Target = module_target_c_code,
         TargetExt = extension(ext_cur_ngs_gs(ext_cur_ngs_gs_target_c))
diff --git a/compiler/make.program_target.m b/compiler/make.program_target.m
index 708b37f65..1cac95aa8 100644
--- a/compiler/make.program_target.m
+++ b/compiler/make.program_target.m
@@ -1756,14 +1756,16 @@ install_ints_and_headers(ProgressStream, Globals, SubdirLinkSucceeded,
             % XXX Should we test
             % ModuleDepInfo ^ contains_foreign_export
             %   = contains_foreign_export?
-            module_name_to_file_name(Globals, $pred, ext_cur(ext_cur_mh),
+            module_name_to_file_name(Globals, $pred,
+                ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh),
                 ModuleName, FileName),
             install_file(ProgressStream, Globals, FileName, LibDir/"inc",
                 HeaderSucceeded1, !IO),
 
             % This is needed so that the file will be found in Mmake's VPATH.
             install_subdir_file(ProgressStream, Globals, SubdirLinkSucceeded,
-                LibDir/"ints", ModuleName, {ext_cur(ext_cur_mh), "mhs"},
+                LibDir/"ints", ModuleName,
+                {ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh), "mhs"},
                 HeaderSucceeded2, !IO),
 
             HeaderSucceeded = HeaderSucceeded1 `and` HeaderSucceeded2
diff --git a/compiler/mercury_compile_llds_back_end.m b/compiler/mercury_compile_llds_back_end.m
index f7f22f0db..fb39cf7af 100644
--- a/compiler/mercury_compile_llds_back_end.m
+++ b/compiler/mercury_compile_llds_back_end.m
@@ -2,7 +2,7 @@
 % vim: ft=mercury ts=4 sw=4 et
 %---------------------------------------------------------------------------%
 % Copyright (C) 2009-2012 The University of Melbourne.
-% Copyright (C) 2017-2018 The Mercury Team.
+% Copyright (C) 2014-2024 The Mercury Team.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %---------------------------------------------------------------------------%
@@ -888,7 +888,8 @@ make_foreign_import_header_code(Globals, FIMSpec, Include, !IO) :-
     FIMSpec = fim_spec(Lang, ModuleName),
     (
         Lang = lang_c,
-        module_name_to_search_file_name(Globals, $pred, ext_cur(ext_cur_mh),
+        module_name_to_search_file_name(Globals, $pred,
+            ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh),
             ModuleName, HeaderFileName),
         IncludeString = "#include """ ++ HeaderFileName ++ """\n",
         Include = foreign_decl_code(lang_c, foreign_decl_is_exported,
diff --git a/compiler/mlds_to_c_file.m b/compiler/mlds_to_c_file.m
index 131f9dd82..5ddca3da8 100644
--- a/compiler/mlds_to_c_file.m
+++ b/compiler/mlds_to_c_file.m
@@ -315,7 +315,7 @@ mlds_output_src_import(Opts, Stream, _Indent, Import, !IO) :-
     Import = mlds_import(ImportType, ModuleName0),
     (
         ImportType = user_visible_interface,
-        HeaderExt = ext_cur(ext_cur_mh)
+        HeaderExt = ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh)
     ;
         ImportType = compiler_visible_interface,
         HeaderExt = ext_cur_ngs_gs_max_cur(ext_cur_ngs_gs_max_cur_mih)
diff --git a/compiler/write_deps_file.m b/compiler/write_deps_file.m
index ca7cb56c2..050fe41f0 100644
--- a/compiler/write_deps_file.m
+++ b/compiler/write_deps_file.m
@@ -713,7 +713,8 @@ construct_intermod_rules(Globals, ModuleName, LongDeps, AllDeps,
     % directly or indirectly.
     (
         Intermod = yes,
-        make_module_file_names_with_ext(Globals, ext_cur(ext_cur_mh),
+        make_module_file_names_with_ext(Globals,
+            ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh),
             set.to_sorted_list(AllDeps), AllDepsFileNames, !Cache, !IO),
         MmakeRuleMhDeps = mmake_simple_rule("machine_dependent_header_deps",
             mmake_rule_is_not_phony,
@@ -840,7 +841,8 @@ construct_c_header_rules(Globals, ModuleName, AllDeps,
     % `:- pragma foreign_import_module' declarations. In some grades the header
     % file won't actually be built (e.g. LLDS grades for modules not containing
     % `:- pragma export' declarations), but this rule won't do any harm.
-    make_module_file_name(Globals, $pred, ext_cur(ext_cur_mh),
+    make_module_file_name(Globals, $pred,
+        ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh),
         ModuleName, MhHeaderFileName, !Cache, !IO),
     make_module_file_name(Globals, $pred,
         ext_cur_ngs_gs_max_cur(ext_cur_ngs_gs_max_cur_mih),
@@ -1025,7 +1027,7 @@ construct_foreign_import_rules(Globals, AugCompUnit, IntermodDeps,
             % .pic_o file. We need to include dependencies for the latter
             % otherwise invoking mmake with a <module>.pic_o target will break.
             ForeignImportTargets = one_or_more(ObjFileName, [PicObjFileName]),
-            ForeignImportExt = ext_cur(ext_cur_mh),
+            ForeignImportExt = ext_cur_ngs_max_cur(ext_cur_ngs_max_cur_mh),
             gather_foreign_import_deps(Globals, ForeignImportExt,
                 ForeignImportTargets, ForeignImportedModuleNames,
                 MmakeRuleForeignImports, !Cache, !IO),
@@ -1704,7 +1706,8 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap,
         ),
         % We use `.mh' files for both low and high level C backends.
         MhSources =
-            [string.format("$(%s.mods:%%=%%.mh)", [s(ModuleMakeVarName)])]
+            [string.format("$(%s.mods:%%=$(mhs_subdir)%%.mh)",
+                [s(ModuleMakeVarName)])]
     ;
         % We don't generate C header files for non-C backends.
         ( Target = target_csharp
@@ -1735,11 +1738,11 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap,
     % it contains header files for all the modules, as for `<module>.all_mihs'
     % above.
     MmakeVarMhsToClean = mmake_var_defn(ModuleMakeVarName ++ ".mhs_to_clean",
-        string.format("$(%s.mods:%%=%%.mh)",
+        string.format("$(%s.mods:%%=$(mhs_subdir)%%.mh)",
             [s(ModuleMakeVarName)])),
     % The deprecated old version of .mhs_to_clean.
     MmakeVarAllMhs = mmake_var_defn(ModuleMakeVarName ++ ".all_mhs",
-        string.format("$(%s.mods:%%=%%.mh)",
+        string.format("$(%s.mods:%%=$(mhs_subdir)%%.mh)",
             [s(ModuleMakeVarName)])),
 
     MmakeVarInts = mmake_var_defn_list(ModuleMakeVarName ++ ".ints",
@@ -2303,7 +2306,7 @@ generate_dep_file_install_targets(Globals, ModuleName, DepsMap,
         "# The following is needed to support the `--use-subdirs' option.",
         "# We try using `$(LN_S)', but if that fails, then we just use",
         "# `$(INSTALL)'.",
-        "for ext in int int2 int3" ++
+        "for ext in mh int int2 int3" ++
             SpaceInt0Str ++ MaybeSpaceOptStr ++ MaybeSpaceTransOptStr ++
             MaybeSpaceDepStr ++ "; do \\",
         "\tdir=""$(INSTALL_INT_DIR)/Mercury/$${ext}s""; \\",
diff --git a/deep_profiler/.mgnuc_copts b/deep_profiler/.mgnuc_copts
index 0a44865a4..d865787d4 100644
--- a/deep_profiler/.mgnuc_copts
+++ b/deep_profiler/.mgnuc_copts
@@ -2,11 +2,15 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
 -I../ssdb
+-I../ssdb/Mercury/mhs
 -I../ssdb/Mercury/mihs
 -I../trace
diff --git a/deep_profiler/DEEP_FLAGS.in b/deep_profiler/DEEP_FLAGS.in
index 49588272e..5125627f5 100644
--- a/deep_profiler/DEEP_FLAGS.in
+++ b/deep_profiler/DEEP_FLAGS.in
@@ -24,10 +24,13 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --c-include-directory ../browser
+--c-include-directory ../browser/Mercury/mhs
 --c-include-directory ../browser/Mercury/mihs
 --c-include-directory ../ssdb
+--c-include-directory ../ssdb/Mercury/mhs
 --c-include-directory ../ssdb/Mercury/mihs
 --c-include-directory ../trace
 --csharp-flag -keyfile:../mercury.snk
diff --git a/extras/EXTRAS_FLAGS.in b/extras/EXTRAS_FLAGS.in
index 371b9df53..e13f06b98 100644
--- a/extras/EXTRAS_FLAGS.in
+++ b/extras/EXTRAS_FLAGS.in
@@ -24,12 +24,16 @@
 --c-include-directory ../../boehm_gc/include
 --c-include-directory ../../runtime
 --c-include-directory ../../library
+--c-include-directory ../../library/Mercury/mhs
 --c-include-directory ../../library/Mercury/mihs
 --c-include-directory ../../mdbcomp
+--c-include-directory ../../mdbcomp/Mercury/mhs
 --c-include-directory ../../mdbcomp/Mercury/mihs
 --c-include-directory ../../browser
+--c-include-directory ../../browser/Mercury/mhs
 --c-include-directory ../../browser/Mercury/mihs
 --c-include-directory ../../ssdb
+--c-include-directory ../../ssdb/Mercury/mhs
 --c-include-directory ../../ssdb/Mercury/mihs
 --c-include-directory ../../trace
 --csharp-flag -keyfile:../../mercury.snk
diff --git a/grade_lib/.mgnuc_copts b/grade_lib/.mgnuc_copts
index 0a44865a4..d865787d4 100644
--- a/grade_lib/.mgnuc_copts
+++ b/grade_lib/.mgnuc_copts
@@ -2,11 +2,15 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
 -I../ssdb
+-I../ssdb/Mercury/mhs
 -I../ssdb/Mercury/mihs
 -I../trace
diff --git a/grade_lib/GRADE_LIB_FLAGS.in b/grade_lib/GRADE_LIB_FLAGS.in
index e1534777f..7ab574084 100644
--- a/grade_lib/GRADE_LIB_FLAGS.in
+++ b/grade_lib/GRADE_LIB_FLAGS.in
@@ -21,6 +21,7 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --csharp-flag -keyfile:../mercury.snk
 --no-java-classpath
diff --git a/library/.mgnuc_copts b/library/.mgnuc_copts
index 91e1de33d..8b6a48fdc 100644
--- a/library/.mgnuc_copts
+++ b/library/.mgnuc_copts
@@ -2,6 +2,7 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../trace
 -I../robdd
diff --git a/mdbcomp/.mgnuc_copts b/mdbcomp/.mgnuc_copts
index 02cce2367..7102e02e7 100644
--- a/mdbcomp/.mgnuc_copts
+++ b/mdbcomp/.mgnuc_copts
@@ -2,7 +2,9 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../trace
diff --git a/mdbcomp/MDBCOMP_FLAGS.in b/mdbcomp/MDBCOMP_FLAGS.in
index 07141085c..ac166fec5 100644
--- a/mdbcomp/MDBCOMP_FLAGS.in
+++ b/mdbcomp/MDBCOMP_FLAGS.in
@@ -26,6 +26,7 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --csharp-flag -keyfile:../mercury.snk
 @CSHARP_DELAYSIGN_FLAG@
diff --git a/mfilterjavac/.mgnuc_copts b/mfilterjavac/.mgnuc_copts
index 0a44865a4..d865787d4 100644
--- a/mfilterjavac/.mgnuc_copts
+++ b/mfilterjavac/.mgnuc_copts
@@ -2,11 +2,15 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
 -I../ssdb
+-I../ssdb/Mercury/mhs
 -I../ssdb/Mercury/mihs
 -I../trace
diff --git a/mfilterjavac/MFILTERJAVAC_FLAGS.in b/mfilterjavac/MFILTERJAVAC_FLAGS.in
index 56c82fff8..2ad418566 100644
--- a/mfilterjavac/MFILTERJAVAC_FLAGS.in
+++ b/mfilterjavac/MFILTERJAVAC_FLAGS.in
@@ -22,10 +22,13 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --c-include-directory ../browser
+--c-include-directory ../browser/Mercury/mhs
 --c-include-directory ../browser/Mercury/mihs
 --c-include-directory ../ssdb
+--c-include-directory ../ssdb/Mercury/mhs
 --c-include-directory ../ssdb/Mercury/mihs
 --c-include-directory ../trace
 --csharp-flag -keyfile:../mercury.snk
diff --git a/profiler/.mgnuc_copts b/profiler/.mgnuc_copts
index 0a44865a4..d865787d4 100644
--- a/profiler/.mgnuc_copts
+++ b/profiler/.mgnuc_copts
@@ -2,11 +2,15 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
 -I../ssdb
+-I../ssdb/Mercury/mhs
 -I../ssdb/Mercury/mihs
 -I../trace
diff --git a/profiler/PROF_FLAGS.in b/profiler/PROF_FLAGS.in
index 5b92afa6a..993a1b8b8 100644
--- a/profiler/PROF_FLAGS.in
+++ b/profiler/PROF_FLAGS.in
@@ -25,12 +25,16 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --c-include-directory ../mdbcomp
+--c-include-directory ../mdbcomp/Mercury/mhs
 --c-include-directory ../mdbcomp/Mercury/mihs
 --c-include-directory ../browser
+--c-include-directory ../browser/Mercury/mhs
 --c-include-directory ../browser/Mercury/mihs
 --c-include-directory ../ssdb
+--c-include-directory ../ssdb/Mercury/mhs
 --c-include-directory ../ssdb/Mercury/mihs
 --c-include-directory ../trace
 --csharp-flag -keyfile:../mercury.snk
diff --git a/scripts/Mmake.rules b/scripts/Mmake.rules
index 4d7054380..0917fae23 100644
--- a/scripts/Mmake.rules
+++ b/scripts/Mmake.rules
@@ -1,7 +1,8 @@
 #-----------------------------------------------------------------------------#
 # vim: ts=8 sw=8 noexpandtab ft=make
 #-----------------------------------------------------------------------------#
-# Copyright (C) 1995-2007, 2010 The University of Melbourne.
+# Copyright (C) 1995-2010 The University of Melbourne.
+# Copyright (C) 2013, 2015-2016, 2022-2024 The Mercury team.
 # This file may only be copied under the terms of the GNU General
 # Public License - see the file COPYING in the Mercury distribution.
 #-----------------------------------------------------------------------------#
@@ -39,7 +40,7 @@ main_target: $(MAIN_TARGET)
 ifeq ($(MMAKE_USE_SUBDIRS),yes)
 
 MCFLAGS += --use-subdirs
-ALL_MGNUCFLAGS += -I. -I$(mihs_subdir).
+ALL_MGNUCFLAGS += -I. -I$(mhs_subdir). -I$(mihs_subdir).
 
 endif
 
diff --git a/scripts/Mmake.vars.in b/scripts/Mmake.vars.in
index 01eab66d6..0df21109e 100644
--- a/scripts/Mmake.vars.in
+++ b/scripts/Mmake.vars.in
@@ -2,7 +2,7 @@
 # vim: ts=8 sw=8 noexpandtab ft=make
 #-----------------------------------------------------------------------------#
 # Copyright (C) 1996-2008, 2010-2011 The University of Melbourne.
-# Copyright (C) 2013, 2015, 2017, 2020, 2023 The Mercury team.
+# Copyright (C) 2013, 2015, 2017, 2020, 2023-2024 The Mercury team.
 # This file may only be copied under the terms of the GNU General
 # Public License - see the file COPYING in the Mercury distribution.
 #-----------------------------------------------------------------------------#
@@ -582,6 +582,7 @@ date3s_subdir=$(SUBDIR)date3s/
 optdates_subdir=$(SUBDIR)optdates/
 trans_opt_dates_subdir=$(SUBDIR)trans_opt_dates/
 useds_subdir=$(SUBDIR)useds/
+mhs_subdir=$(SUBDIR)mhs/
 mihs_subdir=$(SUBDIR)mihs/
 cs_subdir=$(SUBDIR)cs/
 dlls_subdir=$(SUBDIR)dlls/
@@ -619,6 +620,7 @@ date3s_subdir=
 optdates_subdir=
 trans_opt_dates_subdir=
 useds_subdir=
+mhs_subdir=
 mihs_subdir=
 cs_subdir=
 dlls_subdir=
diff --git a/slice/.mgnuc_copts b/slice/.mgnuc_copts
index 0a44865a4..d865787d4 100644
--- a/slice/.mgnuc_copts
+++ b/slice/.mgnuc_copts
@@ -2,11 +2,15 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
 -I../ssdb
+-I../ssdb/Mercury/mhs
 -I../ssdb/Mercury/mihs
 -I../trace
diff --git a/slice/SLICE_FLAGS.in b/slice/SLICE_FLAGS.in
index aae6b05c1..4e7dd23cb 100644
--- a/slice/SLICE_FLAGS.in
+++ b/slice/SLICE_FLAGS.in
@@ -23,10 +23,13 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --c-include-directory ../browser
+--c-include-directory ../browser/Mercury/mhs
 --c-include-directory ../browser/Mercury/mihs
 --c-include-directory ../ssdb
+--c-include-directory ../ssdb/Mercury/mhs
 --c-include-directory ../ssdb/Mercury/mihs
 --c-include-directory ../trace
 --csharp-flag -keyfile:../mercury.snk
diff --git a/ssdb/.mgnuc_copts b/ssdb/.mgnuc_copts
index 1c602c7a1..68bf10d61 100644
--- a/ssdb/.mgnuc_copts
+++ b/ssdb/.mgnuc_copts
@@ -2,10 +2,14 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
 -I../ssdb
+-I../ssdb/Mercury/mhs
 -I../ssdb/Mercury/mihs
diff --git a/ssdb/SSDB_FLAGS.in b/ssdb/SSDB_FLAGS.in
index 5ddd51615..aab398cba 100644
--- a/ssdb/SSDB_FLAGS.in
+++ b/ssdb/SSDB_FLAGS.in
@@ -28,10 +28,13 @@
 --c-include-directory ../boehm_gc/include
 --c-include-directory ../runtime
 --c-include-directory ../library
+--c-include-directory ../library/Mercury/mhs
 --c-include-directory ../library/Mercury/mihs
 --c-include-directory ../mdbcomp
+--c-include-directory ../mdbcomp/Mercury/mhs
 --c-include-directory ../mdbcomp/Mercury/mihs
 --c-include-directory ../browser
+--c-include-directory ../browser/Mercury/mhs
 --c-include-directory ../browser/Mercury/mihs
 --csharp-flag -keyfile:../mercury.snk
 @CSHARP_DELAYSIGN_FLAG@
diff --git a/tests/.mgnuc_copts.ws b/tests/.mgnuc_copts.ws
index 416d03655..1ce2c045c 100644
--- a/tests/.mgnuc_copts.ws
+++ b/tests/.mgnuc_copts.ws
@@ -2,11 +2,15 @@
 -I at WORKSPACE@/boehm_gc/include
 -I at WORKSPACE@/runtime
 -I at WORKSPACE@/library
+-I at WORKSPACE@/library/Mercury/mhs
 -I at WORKSPACE@/library/Mercury/mihs
 -I at WORKSPACE@/mdbcomp
+-I at WORKSPACE@/mdbcomp/Mercury/mhs
 -I at WORKSPACE@/mdbcomp/Mercury/mihs
 -I at WORKSPACE@/browser
+-I at WORKSPACE@/browser/Mercury/mhs
 -I at WORKSPACE@/browser/Mercury/mihs
 -I at WORKSPACE@/trace
 -I at WORKSPACE@/ssdb
+-I at WORKSPACE@/ssdb/Mercury/mhs
 -I at WORKSPACE@/ssdb/Mercury/mihs
diff --git a/tests/WS_FLAGS.ws b/tests/WS_FLAGS.ws
index ed8b3aa78..b006e64d6 100644
--- a/tests/WS_FLAGS.ws
+++ b/tests/WS_FLAGS.ws
@@ -7,13 +7,17 @@
 --c-include-directory @WORKSPACE@/boehm_gc/include
 --c-include-directory @WORKSPACE@/runtime
 --c-include-directory @WORKSPACE@/library
+--c-include-directory @WORKSPACE@/library/Mercury/mhs
 --c-include-directory @WORKSPACE@/library/Mercury/mihs
 --c-include-directory @WORKSPACE@/mdbcomp
+--c-include-directory @WORKSPACE@/mdbcomp/Mercury/mhs
 --c-include-directory @WORKSPACE@/mdbcomp/Mercury/mihs
 --c-include-directory @WORKSPACE@/browser
+--c-include-directory @WORKSPACE@/browser/Mercury/mhs
 --c-include-directory @WORKSPACE@/browser/Mercury/mihs
 --c-include-directory @WORKSPACE@/trace
 --c-include-directory @WORKSPACE@/ssdb
+--c-include-directory @WORKSPACE@/ssdb/Mercury/mhs
 --c-include-directory @WORKSPACE@/ssdb/Mercury/mihs
 --linkage shared
 --csharp-flags -lib:@WORKSPACE@/library
diff --git a/tools/lmc.in b/tools/lmc.in
index 0c61212f3..c7c18e613 100755
--- a/tools/lmc.in
+++ b/tools/lmc.in
@@ -151,8 +151,10 @@ fi
 
 C_FLAGS="--c-include-directory $WORKSPACE/trace \
     --c-include-directory $WORKSPACE/library \
+    --c-include-directory $WORKSPACE/library/Mercury/mhs \
     --c-include-directory $WORKSPACE/library/Mercury/mihs \
     --c-include-directory $WORKSPACE/ssdb \
+    --c-include-directory $WORKSPACE/ssdb/Mercury/mhs \
     --c-include-directory $WORKSPACE/ssdb/Mercury/mihs \
     --c-include-directory $WORKSPACE/runtime \
     --c-include-directory $WORKSPACE/boehm_gc \
diff --git a/trace/.mgnuc_copts b/trace/.mgnuc_copts
index f03f7418f..e222fd372 100644
--- a/trace/.mgnuc_copts
+++ b/trace/.mgnuc_copts
@@ -2,10 +2,13 @@
 -I../boehm_gc/include
 -I../runtime
 -I../library
+-I../library/Mercury/mhs
 -I../library/Mercury/mihs
 -I../mdbcomp
+-I../mdbcomp/Mercury/mhs
 -I../mdbcomp/Mercury/mihs
 -I../browser
+-I../browser/Mercury/mhs
 -I../browser/Mercury/mihs
 -DMR_NO_BACKWARDS_COMPAT
 -DMERCURY_CONF_BOOTSTRAP_H
-- 
2.44.0



More information about the reviews mailing list