Parsing a makefile using Python

rick_muller at rick_muller at
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 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:
that suggested the distutils could do this, but I haven't found
anything in the documentation for the distutils.
Any suggestions?

Thanks in advance,


More information about the Python-list mailing list