[ILUG] Wildcards in makefile
Brian Foster
blf at blf.utvinternet.ie
Tue Nov 28 03:53:30 GMT 2006
| Date: Mon, 27 Nov 2006 16:34:13 +0000
| From: Conor Daly <conor.daly_ilug at cod.homelinux.org>
|
|[... since ] $(MANDIR)/man3/ will contain
| manpages from other programs / libs, I cannot use:
|
| rm -f $(MANDIR)/man3/*; \
|
| for the uninstall. Is there a form of
|
| for FILE in ../man3/*; do rm -f $(MANDIR)/man3/$FILE; done
|
| that I can use in a makefile to accomplish this?
yes. that, modified to be (1) correct,
and (2) take into account make(1) syntax.
the correctness issue is yer FILE variable
is of the form ../man3/foo.3 so the rm(1)
is removing <mandir>/man3/../man3/foo.3
which will usually, but not always, work.
it may fail if <mandir>/man3 is a symlink.
the `make' syntax issue is to use a $ in
a rule, it must be written $$.
hence, something like either of the following
should work (neither tested!):
for FILE in ../man3/*; do \
rm -f $(MANDIR)/man3/$$(basename "$$FILE"); \
done
or:
for FILE in ../man3/*; do \
rm -f $(MANDIR)/man3/$${FILE##*/}; \
done
if you are using GNU `make', there are various
built-in macros which can help. one possiblity
might be (not tested!):
$(foreach file,$(wildcard ../man3/*), \
rm -f $(MANDIR)/man3/$(notdir $(file)))
but, since that is harder to read, and I'm not too
certain I got the syntax right, and it works only
with GNU make (and maybe `clearmake'?), and has no
(in this case) significant advantages, I'd use one
of the first two, shell-embedded-in-Makefile, forms.
cheers!
-blf-
--
Experienced (20+ yrs) kernel/software Eng: | Brian Foster Montpellier,
• Unix, embedded, &tc; • Linux; • doc; | blf at utvinternet.ie FRANCE
• IDL, automated testing, process, &tc. | Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie | http://www.stopesso.com
More information about the ILUG
mailing list