Parsing a makefile using Python

rick_muller at yahoo.com rick_muller at yahoo.com
Thu Sep 2 20:15:34 CEST 2004


I'm interested in parsing a (simple) Makefile using Python. I need to
write a packager for a program I'm supporting, and would like to read
the list of files in the makefile so that I only have to update that
list once.

That is, I have a statement (actually multiple statements) in the
Makefile that looks like:

FILES = a.f b.f c.c d.py e.c \
f.f g.f h.c

and would like a standard way of parsing this. Being able to include
references to other definitions in the makefile, such as

FILES2 = $(FILES) i.f

would be nice as well.

I found an old reference to a post on this topic:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/1e3ccf5d05e743c3/b0f9fc21e3bf32c2#b0f9fc21e3bf32c2
that suggested the distutils could do this, but I haven't found
anything in the documentation for the distutils.
Any suggestions?

Thanks in advance,

Rick




More information about the Python-list mailing list