[m-dev.] for review: fix undefined variable warnings

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Aug 4 23:52:48 AEST 1998


On 29-Jul-1998, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> On 29-Jul-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > 
> > Add Mmake support for target-specific MCFLAGS flags (MCFLAGS-foo, etc.)
> > using some tricky GNU Make hackery that avoids warning about undefined
> > variables.
> > Also define ALL_MCFLAGS = $(MCFLAGS) $(TARGET_MCFLAGS) $(EXTRA_MCFLAGS)
> > and use $(ALL_MCFLAGS) instead of $(MCFLAGS).  This allows user Mmakefiles
> > to override MCFLAGS without suppressing the use of the TARGET_MCFLAGS
> > and EXTRA_MCFLAGS.
...
> > scripts/mmake.in:
> > 	Re-enable the warnings about undefined variables,
> > 	since we won't get too many spurious warnings now.
> 
> The change seems fine.  It might be worthwhile documenting this
> feature in both NEWS and doc/user_guide.texi.

Done (see below).  I'll commit this now.

doc/user_guide.texi:
NEWS:
        Document these changes.

Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.130
diff -u -r1.130 user_guide.texi
--- user_guide.texi	1998/07/25 12:29:52	1.130
+++ user_guide.texi	1998/08/04 13:47:23
@@ -878,22 +878,30 @@
 @item MC
 The executable that invokes the Mercury compiler.
 
+ at item GRADEFLAGS and EXTRA_GRADEFLAGS
+Compilation model options (@pxref{Compilation model options})
+to pass to the Mercury compiler, linker, and other tools.
+
 @item MCFLAGS and EXTRA_MCFLAGS
-Flags to pass to the Mercury compiler.
+Options to pass to the Mercury compiler.
+(Note that compilation model options should be
+specified in @code{GRADEFLAGS}, not in @code{MCFLAGS}.)
 
 @item MGNUC
 The executable that invokes the C compiler.
 
 @item MGNUCFLAGS and EXTRA_MGNUCFLAGS
-Flags to pass to the C compiler.
+Options to pass to the C compiler.
 
 @item ML
 The executable that invokes the linker.
 
 @item MLFLAGS and EXTRA_MLFLAGS
-Flags to pass to the linker.
+Options to pass to the linker.
+(Note that compilation model options should be
+specified in @code{GRADEFLAGS}, not in @code{MLFLAGS}.)
 
- at item MLLIBS
+ at item MLLIBS and EXTRA_MLLIBS
 A list of @samp{-l} options specifying libraries used by the program
 (or library) that you are building.  @xref{Using libraries}.
 
@@ -906,21 +914,37 @@
 @file{@var{prefix}/lib/mercury/mmake/Mmake.vars} for a complete list.
 
 If you wish to temporarily change the flags passed to an executable,
-rather than setting the various @samp{FLAGS} variables directly, one can
-supply a @samp{EXTRA_} variable.  When defining a @samp{FLAGS} option
-directly (in your own @samp{Mmake} file), it is recommended you include
-the @samp{EXTRA_} version at the end.  This is particularly intended for
+rather than setting the various @samp{FLAGS} variables directly, you can
+set an @samp{EXTRA_} variable.  This is particularly intended for
 use where a shell script needs to call mmake and add an extra parameter,
-without interfering with the flag settings in the @samp{Mmake} file.
+without interfering with the flag settings in the @samp{Mmakefile}.
+
+For each of the variables for which there is version with an @samp{EXTRA_}
+prefix, there is also a version with an @samp{ALL_} prefix that
+is defined to include both the ordinary and the @samp{EXTRA_} version.
+If you wish to @emph{use} the values any of these variables
+in your Mmakefile (as opposed to @emph{setting} the values),
+then you should use the @samp{ALL_} version.
+
+It is also possible to override these variables on a per-file basis.
+For example, if you have a module called say @file{bad_style.m}
+which triggers lots of compiler warnings, and you want to disable
+the warnings just for that file, but keep them for all the other modules,
+then you can override @code{MCFLAGS} just for that file.  This is done by
+setting the variable @samp{MCFLAGS-bad_style}, as shown here:
 
 @example
-MCFLAGS = -O6 $(EXTRA_MCFLAGS)
+MCFLAGS-bad_style = --inhibit-warnings
 @end example
 
-Note that since Mmake is built on top of Make or GNU Make,
-you can make use of the features supported by the underlying Make.
-In particular, GNU Make has support for running jobs in parallel,
-which is very useful if you have a machine with more than one CPU.
+Mmake has a few options, including @samp{--use-subdirs},
+ at samp{--save-makefile}, @samp{--verbose}, and @samp{--no-warn-undefined-vars}.
+For details about these options, see the man page or type @samp{mmake --help}.
+
+Finally, since Mmake is built on top of Make or GNU Make, you can also
+make use of the features and options supported by the underlying Make.
+In particular, GNU Make has support for running jobs in parallel, which
+is very useful if you have a machine with more than one CPU.
 
 @node Libraries
 @chapter Libraries
Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.110
diff -u -r1.110 NEWS
--- NEWS	1998/07/22 15:20:14	1.110
+++ NEWS	1998/08/04 13:49:49
@@ -429,6 +429,20 @@
   `GRADEFLAGS = --profiling' in your Mmakefile, rather than having to
   use the more obscure incantation `GRADE = asm_fast.gc.prof'.
 
+* Mmake now supports per-file settings of MCFLAGS and other *FLAGS variables.
+
+  For example, if you want to disable singleton variable warnings just
+  for a single module `horrible_code.m', you can just include the line
+
+	  MCFLAGS-horrible_code = --no-warn-singleton-variables
+
+  in your Mmakefile.
+
+* Mmake now warns about variables which are defined but not used.
+
+  To disable this warning, use the `-w-' or `--no-warn-undef-variables'
+  option.
+
 * We've made a few small improvements to the efficiency of the generated code.
 
 * The system has been ported to Linux/PPC.


-- 
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.



More information about the developers mailing list