0

I'm using gnu make and stow to manage some configurations (dotfiles).
I have multiple directories in my repo:

dotfiles/
├── Makefile
├── package1/
└── package2/

Currently, my Makefile looks like:

PACKAGES = package1 package2

.PHONY: all $(PACKAGES)

all: $(PACKAGES)

package1:
    stow --no-fold $@

package2:
    stow --no-fold $@

I want to define a default rule for packages, so I did:

PACKAGES = package1 package2

.PHONY: all $(PACKAGES)

all: $(PACKAGES)

%:
    stow --no-fold $@

But that didn't work:

$ make
make: Nothing to be done for `all'.
$ make package1
make: Nothing to be done for `package1'.
$ make package2
make: Nothing to be done for `package2'.

So: Is it possible to define a "default" rule for directories? If yes, how I do it?

1 Answer 1

2

You could replace your rule with:

$(PACKAGES):
    stow --no-fold $@
3
  • No, that's ok. It's equivalent to specifying identical rules for every member of the list. Commented Feb 8, 2017 at 23:42
  • Thanks for the answer, this solved my issue. Just for completeness, can I override a rule for a package (possibly without generating warnings)?
    – S1cK94
    Commented Feb 9, 2017 at 13:02
  • Thanks for the comment, Gilles. I removed the irrelevant sentence from my answer. @S1cK94: I could not find a way to override a rule without getting a warning, unfortunately.
    – dhag
    Commented Feb 9, 2017 at 14:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .