In some situations, it would be very useful to be able to override
already-defined rules for a target without having GNU make complaining
about the override.

For example, when writing a "library" of makefiles recipes, organized as
a set of makefile fragments to be included by a "master" (user-written)
makefile, it is useful to be able to seamlessly override some of the
recipes defined in those fragments from the master makefile.  My
Automake fork "Automake-NG" (whose generated Makefiles only target
GNU make) could certainly take great advantage of such an ability in
the future (near future in fact).

I'm not sure what be the best way to implement my proposed feature.
Some random ideas:

  - an all-encompassing option "--no-warn-rule-override", that
    would suppress *all* warnings about overridden rules;

  - a new special target ".OVERRIDABLE-RECIPES:", that would suppress
    the override warnings only for the rules specified as its
    prerequisites;

  - a new built-in to explicitly instruct make to clear the rule(s) so
    far associated to a target:

      $(clear-rules TARGET)

    This approach has the advantage of being very explicit, and to allow
    clearing of not only for normal rules, but also double-colon ones.

  - a new syntax to define special kind of rule for a given target -- a
    rule which can be silently overridden later; e.g.,

      TARGET ?:
         commands that will be overridden
     ...

      TARGET :
         actual commands

     Note that I include this latter approach only for completeness;
     I rather dislike it, because it doesn't give enough power to
     the user -- the writer of the original makefile must decide
     "statically" and beforehand which rules to make overridable.

Thoughts, objections, feedback?

Thanks,
  Stefano

_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to