Yes, someone on IRC explained to me how macros expand inside rules shortly 
after posting that message and linking them to the mailing list archive. I 
actually came up with your second solution in response to that. However, the 
first one seems interesting as well. One thing I haven't mentioned is that 
although I'm using GNU Make to process the makefiles, I'm limiting myself to 
POSIX features and features that I expect will be eventually standardized by 
POSIX. I was unable to find anything on secondary expansion on the Austin 
Group's bug tracker. Since you're involved there (I've seen you discussing 
numerous make-related issues), perhaps you know anything going on on this front?

Somewhat related, is there any news on pattern rules (bug 0000513)? The related 
proposal on pattern substitution for macros (bug 0000519) seems to have been 
worked out.

Thanks,
Bogdan






On Sunday, October 7, 2018, 4:07:52 PM GMT+3, Paul Smith <[email protected]> 
wrote: 





On Sun, 2018-10-07 at 09:01 -0400, Paul Smith wrote:
>  $(MAKE_DIR)/$$(MODULE): ; mkdir -p $@
> 
> (note the extra "$" when referencing the MODULE variable)

Actually I'm mistaken here: there's no secondary expansion for targets.

You might be able to write this as:

  $(MAKE_DIR)/%.mk: $(SRC_DIR)/%.m4 | $(MAKE_DIR)/$$(MODULE)/.; m4 $< $@
  $(MAKE_DIR)/%/. : ; mkdir -p $@

but I'm not sure (untested).

Another option, obviously, is to simply put the mkdir inside the recipe
(that's how I'd personally do it):

  $(MAKE_DIR)/%.mk: $(SRC_DIR)/%.m4
          mkdir -p $(MAKE_DIR)/$(MODULE)

          m4 $< $@


It may run extra instances of mkdir but I doubt it will be noticeable.


_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make


_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to