[m-dev.] For review: Simplify specification of some per-program flags
Warwick Harvey
wharvey at cs.monash.edu.au
Thu Jul 1 20:26:39 AEST 1999
Fergus wrote:
> On 01-Jul-1999, Warwick Harvey <wharvey at cs.monash.edu.au> wrote:
> > Anyway, with the GRADEFLAGS stuff, if one does the substitution for both the
> > `$@' and `$*' variables, one gets the grade flags repeated in the call to
> > `c2init', since both match. This is probably harmless. However, I'm going
> > to argue that whenever `$(patsubst %_init.c,%,$@)' gives you `foo',
> > `$(patsubst %_init,%,$*)' will also give you `foo' (`_init.c' files are only
> > ever built by implicit rules, right?), so the substitution is only necessary
> > for the latter.
>
> No, `_init.c' files are almost always generated by explicit rules.
Of course. Clearly I'm still not thinking straight. :-( I think I need a
head transplant.
`$*' _is_ defined for these rules anyway (which is why it worked when I
tested it), as described in the GNU Make documentation:
In an explicit rule, there is no stem; so `$*' cannot be determined
in that way. Instead, if the target name ends with a recognized
suffix (*note Old-Fashioned Suffix Rules: Suffix Rules.), `$*' is
set to the target name minus the suffix. For example, if the
target name is `foo.c', then `$*' is set to `foo', since `.c' is a
suffix. GNU `make' does this bizarre thing only for compatibility
with other implementations of `make'. You should generally avoid
using `$*' except in implicit rules or static pattern rules.
Clearly this usage is deprecated, so I think everybody's in agreement that I
should go with the harmless repetition.
Given my track record lately, I think I'll post one more diff before I
commit (to be sure, to be sure):
Estimated hours taken: 3.5
Specifying GRADEFLAGS and C2INITFLAGS on a per-program basis didn't work
properly for `_init.*' files. Rather than just specifying `-foo' versions,
one had to specify `-foo_init.c' or `-foo_init' versions instead or as well.
This change corrects this.
scripts/Mmake.vars.in:
Strip any `_init' suffix from the `$*' automatic variable and any
`_init.c' suffix from the `$@' automatic variable used in the
per-target definitions of GRADEFLAGS and C2INITFLAGS.
Index: Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.24
diff -u -r1.24 Mmake.vars.in
--- Mmake.vars.in 1998/12/06 23:48:56 1.24
+++ Mmake.vars.in 1999/07/01 10:24:08
@@ -184,11 +184,13 @@
# undefined variables is enabled.
TARGET_GRADEFLAGS = \
- $(maybe-base-GRADEFLAGS-$(findstring undefined,$(origin GRADEFLAGS-$*))) \
- $(maybe-target-GRADEFLAGS-$(findstring undefined,$(origin GRADEFLAGS-$@)))
-maybe-base-GRADEFLAGS- = $(GRADEFLAGS-$*)
+ $(maybe-base-GRADEFLAGS-$(findstring undefined,\
+ $(origin GRADEFLAGS-$(patsubst %_init,%,$*)))) \
+ $(maybe-target-GRADEFLAGS-$(findstring undefined,\
+ $(origin GRADEFLAGS-$(patsubst %_init.c,%,$@))))
+maybe-base-GRADEFLAGS- = $(GRADEFLAGS-$(patsubst %_init,%,$*))
maybe-base-GRADEFLAGS-undefined =
-maybe-target-GRADEFLAGS- = $(GRADEFLAGS-$@)
+maybe-target-GRADEFLAGS- = $(GRADEFLAGS-$(patsubst %_init.c,%,$@))
maybe-target-GRADEFLAGS-undefined =
TARGET_MCFLAGS = \
@@ -197,8 +199,9 @@
maybe-base-MCFLAGS-undefined =
TARGET_C2INITFLAGS = \
- $(maybe-target-C2INITFLAGS-$(findstring undefined,$(origin
C2INITFLAGS-$@)))
-maybe-target-C2INITFLAGS- = $(C2INITFLAGS-$@)
+ $(maybe-target-C2INITFLAGS-$(findstring undefined,\
+ $(origin C2INITFLAGS-$(patsubst %_init.c,%,$@))))
+maybe-target-C2INITFLAGS- = $(C2INITFLAGS-$(patsubst %_init.c,%,$@))
maybe-target-C2INITFLAGS-undefined =
TARGET_MGNUCFLAGS = \
--------------------------------------------------------------------------
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