LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Wildcards in makefile

[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
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell