Reputation: 7837
I need to remove in the following case
.
├── a
│ └── index.html
├── a.rst
├── b
│ └── index.html
├── c
│ └── index.html
└── c.rst
folder a
and c
not b
.
I make it work with this Makefile:
$ cat Makefile
.PHONY: clean
HTML_TARGETS:= $(patsubst %.rst,%.html,$(wildcard *.rst))
clean: $(HTML_TARGETS)
%.html: %.rst
@echo rm $(basename $@ .html)
$
$ make
rm a
rm c
$
Is there a better way to write it ? (the patsubst use an unneeded .html
sub)
Upvotes: 0
Views: 776
Reputation: 100956
What I mean is why don't you just do something like:
.PHONY: clean
HTML_DIRS := $(patsubst %/,%,$(dir $(wildcard */*.html)))
RST_FILES := $(basename $(wildcard *.rst))
clean:
echo rm -r $(filter $(RST_FILES),$(HTML_DIRS))
Upvotes: 2