0xDEADBEEF
0xDEADBEEF

Reputation: 858

Passing parameters from Python to a makefile

As we have a slightly complicated makefile setup I'm using Python as an intermediate step in a series of makefiles to give a setup like this - top level makefile identifies what libraries need to be built and calls a Python script for each one. The Python does some processing on the options and calls the library makefile.

In the top level we do this:

$(LIBS_ALL):
    $(PYTHON) config/buildtools.py $(MAKEFILE) BACON=YES EGGS=YES MUESLI=NO

Then ultimately the Python script buildtools.py does this to call gmake with the MAKEFILE:

call([path_to_gmake, MAKEFILE, argv[1], argv[2], argv[3], argv[4]])

This is paraphrased a little but you get the idea. I call gmake and pass through the arguments passed in from the top level. As above, with each argv listed explicitly it works wonderfully, however a slice argv[1:] does not work. The called gmake behaves like it received no arguments. Any ideas?

Upvotes: 1

Views: 473

Answers (1)

Emilien
Emilien

Reputation: 2445

That's because if you slice argv you create a nested list. You should do:

call([path_to_gmake, MAKEFILE]+argv[1:5])

Upvotes: 2

Related Questions