Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Makefile with the following configured for installing man pages

MANDIR = /usr/share/man/man1

MANPAGES = exec1.1 exec2.1

make install triggers the following:

install: $(MANPAGES) install $(MANPAGES) $(MANDIR)

I want to have a make uninstall which will undo this process.

Effectively, I need to do an rm -rf $(MANDIR)/$(MANPAGE) for each man page

Lots of ways I could probably do this, including loops, etc. Any quick tricks though for having rm -rf delete a list of files from a specified folder?

share|improve this question
up vote 1 down vote accepted
        rm -f $(addprefix $(MANDIR)/, $(MANPAGES))
.PHONY: uninstall

Note: make sure you use a [TAB] instead of eight spaces.

share|improve this answer
I'd forgotten about addprefix -- I don't work in make land often enough to remember those tricks. Thanks (and thanks for the TAB reminder). – BSchlinker May 2 '14 at 19:54
@BSchlinker: if it works, would you please up-vote / mark accepted. Thanks! – JoeNahmias May 2 '14 at 19:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.