views:

53

answers:

1

I'm trying to understand how a makefile works for compiling some .ui files to .py (PyQt -> Python). This is the makefile that I am using that was autogenerated:

# Makefile for a PyQGIS plugin 
UI_FILES = Ui_UrbanAnalysis.py

RESOURCE_FILES = resources.py

default: compile
    compile: $(UI_FILES) $(RESOURCE_FILES)

%.py : %.qrc
    pyrcc4 -o $@  $<

%.py : %.ui
    pyuic4 -o $@ $<

When I type:

$ make

I get the following message:

make: *** No rule to make target `compile', needed by `default'.  Stop.

What am I doing incorrectly?

Thanks.

+2  A: 

Not that I know the build steps you are trying to achieve, but both of these lines:

default: compile
    compile: $(UI_FILES) $(RESOURCE_FILES)

look like target lines, so they should probably be:

default: compile

compile: $(UI_FILES) $(RESOURCE_FILES)

As it was make is probably trying to interpret the compile:... line as an action which won't do anything and means that there is no compile target.


One more thing, you might want to use

PHONY: default compile

to tell make that these are abstract targets and do not represent files. Just as a matter of good practice.

dmckee
Yes! The OP needs to be very careful about whitespace in makefiles - for some versions of make, even a tab on its own on the line below a target line can cause problems.
Will Dean
Thanks - that solved the problem. What do you mean by 'abstract targets' ? I'm just starting to understand how makefiles work so I'm not familiar with the terminology
celenius
@celenius: Consider `make clean`. There is no file called "clean" and no expectation that there will be one. That is an abstract target. Contrast that with `make resources.py`, in which make will check to see if the *file* "resources.py" exists is newer than all of it's dependencies and if not, attempt to (re)create that *file*.
dmckee