[m-dev.] diff: allow multiple --c-include-directory options

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Mar 26 19:06:08 AEST 2000


Estimated hours taken: 0.75

Change the `--c-include-directory' option so that multiple
occurrences of this option accumulate, rather than each
one overriding the previous one.

This change is needed because the use of the MERCURY_MC_ALL_C_INCL_DIRS
environment variable in tools/bootcheck and scripts/mmc.in
(which I recently added to fix a bug that broke tests/hard_coded/split_c_files)
assumes that multiple such options will accumulate.  It also makes it more
consistent with the handling of the `-I' option in gcc.

compiler/options.m:
	Change c_include_directory from a string option
	to an accumulating option (i.e. a list of strings).

compiler/mercury_compile.m:
	Modify to reflect the change to options.m.

compiler/options.m:
doc/user_guide.texi:
	Update the documentation for --c-include-directory to reflect its new
	semantics.  Also document the MERCURY_MC_ALL_C_INCL_DIRS environment
	variable.

Workspace: /home/mercury0/fjh/mercury
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.150
diff -u -d -r1.150 mercury_compile.m
--- compiler/mercury_compile.m	2000/03/10 13:37:46	1.150
+++ compiler/mercury_compile.m	2000/03/26 08:56:30
@@ -2293,12 +2293,10 @@
 	;
 		SubDirInclOpt = ""
 	},
-	globals__io_lookup_string_option(c_include_directory, C_INCL),
-	{ C_INCL = "" ->
-		InclOpt = ""
-	;
-		string__append_list(["-I", C_INCL, " "], InclOpt)
-	},
+	globals__io_lookup_accumulating_option(c_include_directory,
+		C_Incl_Dirs),
+	{ InclOpt = string__append_list(list__condense(list__map(
+		(func(C_INCL) = ["-I", C_INCL, " "]), C_Incl_Dirs))) },
 	globals__io_lookup_bool_option(split_c_files, Split_C_Files),
 	{ Split_C_Files = yes ->
 		SplitOpt = "-DSPLIT_C_FILES "
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.277
diff -u -d -r1.277 options.m
--- compiler/options.m	2000/01/10 00:43:45	1.277
+++ compiler/options.m	2000/03/26 08:17:08
@@ -590,7 +590,7 @@
 					% above two defaults with values
 					% determined at configuration time
 	c_debug			-	bool(no),
-	c_include_directory	-	string(""),
+	c_include_directory	-	accumulating([]),
 					% the `mmc' script will override the
 					% above default with a value determined
 					% at configuration time
@@ -1940,7 +1940,12 @@
 		"--cc <compiler-name>",
 		"\tSpecify which C compiler to use.",
 		"--c-include-directory <dir>",
-		"\tSpecify the directory containing the Mercury C header files.",
+		"\tAppend <dir> to the list of directories to be searched for",
+		"\tC header files.  Note that if you want to override",
+		"\tthis list, rather than append to it, then you can set the",
+		"\t`MERCURY_MC_ALL_C_INCL_DIRS' environment variable to a",
+		"\tsequence of `--c-include-directory' options.",
+
 		"--cflags <options>",
 		"\tSpecify options to be passed to the C compiler.",
 		% The --cflags-for-regs and --cflags-for-gotos options
@@ -2312,7 +2317,8 @@
 	io__write_string("\nMiscellaneous Options:\n"),
 	write_tabbed_lines([
 		"-I <dir>, --search-directory <dir>",
-		"\tAdd <dir> to the list of directories to be searched for \n\t\timported modules.",
+		"\tAppend <dir> to the list of directories to be searched for",
+		"\timported modules.",
 		"--intermod-directory <dir>",
 		"\tAdd <dir> to the list of directories to be",
 		"\tsearched for `.opt' files.",
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.203
diff -u -d -r1.203 user_guide.texi
--- doc/user_guide.texi	2000/03/25 08:14:00	1.203
+++ doc/user_guide.texi	2000/03/26 08:26:17
@@ -3532,7 +3532,10 @@
 
 @sp 1
 @item --c-include-directory @var{dir}
-Specify the directory containing the Mercury C header files.
+Append @var{dir} to the list of directories to be searched for
+C header files.  Note that if you want to override this list, rather than
+append to it, then you can set the @samp{MERCURY_MC_ALL_C_INCL_DIRS}
+environment variable to a sequence of @samp{--c-include-directory} options.
 
 @sp 1
 @item --cflags @var{options}
@@ -4158,8 +4161,9 @@
 @item MERCURY_C_INCL_DIR
 Directory for the C header files for the Mercury runtime system (@file{*.h}).
 This environment variable is used
-only to define the default value of MERCURY_ALL_C_INCL_DIRS,
-so if you define that environment variable separately,
+only to define the default values of MERCURY_ALL_C_INCL_DIRS
+and MERCURY_ALL_MC_INCL_DIRS,
+so if you define those environment variables separately,
 the value of MERCURY_C_INCL_DIR is ignored.
 
 @sp 1
@@ -4167,10 +4171,25 @@
 A list of options for the C compiler that specifies
 all the directories the C compiler should search for the C header files
 of the Mercury runtime system and garbage collector.
-The default value of this option is -I$MERCURY_C_INCL_DIR,
+The default value of this option is @samp{-I$MERCURY_C_INCL_DIR},
 since usually all these header files are installed in one directory.
+This environment variable is used by @samp{mgnuc};
+it should generally be kept in sync with
+ at code{MERCURY_ALL_MC_C_INCL_DIRS}, which is used by @samp{mmc}.
 
 @sp 1
+ at item MERCURY_ALL_MC_C_INCL_DIRS
+A list of options for mmc that specifies
+all the directories it should search for the C header files
+of the Mercury runtime system and garbage collector.
+The default value of this option is
+ at samp{--c-include-directory $MERCURY_C_INCL_DIR},
+since usually all these header files are installed in one directory.
+This environment variable is used by @samp{mmc};
+it should generally be kept in sync with
+ at code{MERCURY_ALL_C_INCL_DIRS}, which is used by @samp{mgnuc}.
+
+ at sp 1
 @item MERCURY_INT_DIR
 Directory for the Mercury library interface
 files (@file{*.int}, @file{*.int2}, @file{*.int3} and @file{*.opt}).
@@ -4181,8 +4200,8 @@
 
 @sp 1
 @item MERCURY_C_LIB_DIR
-Base directory containing the Mercury libraries (@file{libmer.a} and
-possibly @file{libmer.so}) for each configuration and grade.
+Base directory containing the Mercury libraries (@file{libmer_*.a} and
+possibly @file{libmer_*.so}) for each configuration and grade.
 The libraries for each configuration and grade should
 be in the subdirectory @var{config}/@var{grade} of @code{$MERCURY_C_LIB_DIR}.
 
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list