home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7745 < prev    next >
Encoding:
Internet Message Format  |  1993-01-11  |  1.6 KB

  1. Path: sparky!uunet!mcsun!sunic!dkuug!mentor.dk!not-for-mail
  2. From: tm@mentor.dk (Tonny Madsen)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Makefile parsing (challenge)
  5. Date: 11 Jan 1993 11:30:53 +0100
  6. Organization: Mentor Informatik, Denmark
  7. Lines: 39
  8. Message-ID: <1iri8tINNspv@bach.mentor.dk>
  9. References: <1993Jan9.215626.25646@uvaarpa.Virginia.EDU>
  10. NNTP-Posting-Host: bach.mentor.dk
  11.  
  12. Kevin Burton <noran!iowa!kburton@uunet.uu.net> writes:
  13.  
  14. >I want to extract certain variables defined in a makefile.
  15.  
  16. The easiest way to parse a makefile, is to let make do the parsing!!!
  17.  
  18. Try something like the following (please note that none of these
  19. fragments have been tested!):
  20.  
  21.     TMPFILES=${TMPDIR:-/tmp}/t.$$.
  22.     trap 'rm -rf ${TMPFILES}*' 0
  23.     echo '.printSOURCES:; echo "$(SOURCES)"' > ${TMPFILES}mk
  24.     make -f ${makefile} -f ${TMPFILES}mk .printSOURCES:
  25.  
  26. (This is comp.lang.perl, I know, and it shouldn't be that difficult to
  27. perlify this.)
  28.  
  29. Some make's even let you do:
  30.  
  31.     TMPFILES=${TMPDIR:-/tmp}/t.$$.
  32.     trap 'rm -rf ${TMPFILES}*' 0
  33.     echo '.printSOURCES:; echo "$(SOURCES)"' |
  34.     make -f ${makefile} -f - .printSOURCES:
  35.  
  36. Note that not all make's implements multiple use of the f option. If
  37. none of the above examples work, then try:
  38.  
  39.     TMPFILES=${TMPDIR:-/tmp}/t.$$.
  40.     trap 'rm -rf ${TMPFILES}*' 0
  41.     echo '.printSOURCES:; echo "$(SOURCES)"' > ${TMPFILES}mk
  42.     cat ${makefile} >> ${TMPFILES}mk
  43.     make -f ${TMPFILES}mk .printSOURCES:
  44.  
  45. -- tonny
  46. -- 
  47. -----
  48. Tonny Madsen, Mentor Informatik a/s, Fredens Torv 6, DK-8000 Arhus C, Denmark
  49. telephone: +45 86 20 13 33 telefax  : +45 86 13 01 33
  50. e-mail   : tm@mentor.dk
  51.