Hacker News new | past | comments | ask | show | jobs | submit login

You can't have more than 1 pattern variable but if they are all of the same form you can generate all these rules via $(eval); first define a function that generates one rule, then invoke it for all combinations.

Unfortunately this sort of thing is not very readable because make function parameters are numbered, not named.

  define genrule
  $(1)-$(2).$(3): $(1).f $(2).f $(1).txt $(2).txt pos/$(3)
    ./something --pos=$(3) --f1=$(1).f --f2=$(2).f $(1).txt $(2).txt > $$@
  
  endef

  $(foreach lang1,$(LANGS),\
     $(foreach lang2,$(filter-out $(lang1),$(LANGS)),\
         $(foreach pos,$(POS),\
             $(eval $(call genrule,$(lang1),$(lang2),$(pos))))))



Wow. I had no idea you could have that kind of meta-rules in make, nor am I sure I really want to :-) but that's still pretty neat.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: