home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!uvaarpa!mmdf
- From: Kevin Burton <noran!iowa!kburton@uunet.uu.net>
- Subject: Makefile parsing (challenge)
- Message-ID: <1993Jan9.215626.25646@uvaarpa.Virginia.EDU>
- Sender: mmdf@uvaarpa.Virginia.EDU (Mail System)
- Reply-To: noran!iowa!kburton@uunet.uu.net
- Organization: The Internet
- Date: Sat, 9 Jan 1993 21:56:26 GMT
- Lines: 49
-
-
- I want to extract certain variables defined in a makefile. If the makefile
- looks like:
-
- .
- .
- .
-
- SOURCES= foo.c boo.c\
- tmp.c tmp1.c \
- a.c b.c c.c
-
- # This is a comment
- a.c : a.h
- al;kdjfl;kajdfl;jkadf
- b.c
-
- .
- .
- .
-
-
- I want to end up with a single string of "foo.c boo.c tmp.c tmp1.c a.c b.c c.c".
- I want to be able to specifie the string or expression for a string that
- describes the variable that I am trying to extract. I came up with the
- following hard-coded perl script. I am a beginner and I know there is a
- better solution than this. This is not even a complete solution, just
- a start. Any ideas ?
-
- #!/usr/local/bin/perl
- # Extract the SOURCE files in a makefile
-
- $* = 1;
- while(<>) {
- $file .= $_;
- }
-
- $file =~ s/\\\n//g;
- $_ = $file;
- $file =~ s/(LIB)?SOURCES\s*=\s*(\w*\.c\s*)+//;
- print $&
-
-
- -
- Kevin Burton
- Noran Instruments voice: (608) 831-6511 x317
- 2551 West Beltline Highway, Room 532 FAX: (608) 836-7224
- Middleton, WI 53562 email: kburton@noran.com
-
-