published: April 7th, 2009, 10:12 pm, PST
revision: April 7th, 2009, 10:12 pm, PST
topics: GNU Make, python
GNU Make + Python
I thought it would be interesting to use the Python interpreter for a makefile instead of BASH. This is a one line change via the SHELL variable.
The combination of Python’s indentation syntax and Make’s command invocation style did not mix well. The problem is identical to that encountered when specifying a Python program on invocation via the -c option. In Make it’s $(SHELL) -c COMMAND.
In conclusion, it’s certainly possible to use Python and Make together in this way, but I don’t think it’s practical.
Appended is one of the makefile’s I experimented with. Swap the spaces for tabs if you’re going to try this.
#!/usr/bin/make
SHELL = /usr/bin/python
some_make_var := \
$(shell \
print ‘ABCD’; \
)foo:
print ‘$(some_make_var)’;
for c in range(0, 5): \
print c;
for d in range(5,6): \
print d;