0

I am pretty new to GNUmakefiles.

I am going to place two rules with same target patters as follows:

$(TGTSIP)/$(VERILOG_DIR)/src/%: $(TGTDDVAPI)/$(VERILOG_DIR)/%
      $(test_file)

 $(TGTSIP)/$(VERILOG_DIR)/src/%: $(TGTMODEL)/%
      $(test_file)

i Mentioned above in makefiles. because for few files the pre-requisit will change.Build works fine as expected. But i am not very sure whether this is the right way of having such rules ? If this is not the right way . Could anyone share the best way how we can simplify this?

For more understanding i am trying to copy files from 2 different paths to one same location. In this case target is the path where we are copying and prerequisites are the different paths. How can we handle it in single rule?

santosh
  • 421
  • 1
  • 6
  • 14
  • Maybe [this answer](https://stackoverflow.com/a/11441134/5868851) can help you – Zelnes Jul 24 '19 at 08:22
  • Hi Zelnes, Its not about recepie. Its about target. The link which you shared above applicable if we have same recepie. I am looking for same target with multiple rules handling – santosh Jul 24 '19 at 08:25

1 Answers1

0

Make does not object against multiple concurrent pattern rules with non-empty recipes. In fact, it's totally legit.

However, you should keep in mind that in this case the timestamps of the concurrent sources do not matter: if both patterns match directly (i.e. not by an implicit chaining) and with the same stem length then the first one always wins (and no warning issued). And then only the winner's timestamp will be compared against the target's one.

Therefore, it's possible that the target will not be updated by a source from the second directory (being shadowed by an old source from the first one). If it's okay for you (e.g. there's no conflict between the source dirs) then just do this.

Matt
  • 13,674
  • 1
  • 18
  • 27
  • Matt, Thanks for your Answer. Could you please give some example of target::prerequisite rules? So that i can check if it suites my work environment. – santosh Jul 25 '19 at 07:59
  • @santosh You can read [this](https://www.gnu.org/software/make/manual/make.html#Double_002dColon). But these are ordinary rules, not pattern rules. So you probably don't need them. – Matt Jul 25 '19 at 09:08