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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sgiblab!bridge2!alantec!paul
  2. From: paul@alantec.com (G. Paul Ziemba)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Makefile parsing (challenge)
  5. Message-ID: <paul.726777126@alantec>
  6. Date: 11 Jan 93 18:32:06 GMT
  7. References: <1993Jan9.215626.25646@uvaarpa.Virginia.EDU>
  8. Sender: news@alantec.COM
  9. Lines: 32
  10.  
  11. noran!iowa!kburton@uunet.uu.net (Kevin Burton) writes:
  12.  
  13.  
  14. >I want to extract certain variables defined in a makefile.
  15.  
  16. >    SOURCES= foo.c boo.c\
  17. >    tmp.c tmp1.c \
  18. >    a.c b.c c.c
  19.  
  20. Rather than use perl to parse the makefile (*gasp*), why not add a target
  21. to the makefile that emits the value of the macro you're interested
  22. in? This technique avoids any problems you might encounter if make's
  23. parsing is different from your script's parsing.
  24.  
  25. For instance:
  26.  
  27.     emit-sources-value:
  28.         @echo $(SOURCES)
  29.  
  30. If you were interested in an arbitrary macro's value, you could
  31. use perl to construct a makefile fragment with the desired rule,
  32. and then run make on it together with the makefile in question
  33. to get the value, with make's -f flag.
  34.  
  35. cheers,
  36.  
  37.  ~!paul
  38. -- 
  39. Paul Ziemba  paul@alantec.com    alantec!paul  408.955.9000 x227
  40.  
  41. "The first TV I ever owned...I threw from a third story window at a burglar"
  42.  - sjackson@parc.xerox.com
  43.