[Interest] Likely qmake bug: Recursion in generated Makefile while building static library

Frans Klaver fransklaver at gmail.com
Mon Sep 24 10:16:02 CEST 2012


On Fri, Sep 14, 2012 at 8:06 AM, Mandeep Sandhu
<mandeepsandhu.chd at gmail.com> wrote:

> I've recently stumbled upon a problem where building a static lib,
> with a QMAKE_POST_LINK step of "make install" results in recursion!

This is basically asking for recursion. qmake creates make files that
you call using make. You are now telling qmake to create makefiles
that call make on themselves, so you're telling it to recurse. How's
that a qmake bug?

Don't call 'make install' from inside your makefile on your makefile.
Call it explicitly from the outside. No QMAKE_POST_LINK and

$ qmake && make install

yield the desired result.

Besides the above, it can be considered bad practice to _always_ install.



> The problem lies in the below snippet of the Makefile:
>
> build/$(TARGET):  $(OBJECTS) $(OBJCOMP)
>     @$(CHK_DIR_EXISTS) build/ || $(MKDIR) build/
>     -$(DEL_FILE) $(TARGET)
>     $(AR) $(TARGET) $(OBJECTS)
>     make install <------------------ Wrong. This step should be the
> last cmd for this target (this is causing the recursion)
>     -$(DEL_FILE) build/$(TARGET)
>     -$(MOVE) $(TARGET) build/

Wrong for your intended behavior maybe. It's called QMAKE_POST_LINK,
and it's executed post link, which is right. There is nothing that
states that it should actually be the last command executed for a
target.


> Whereas the same build rule when making a shared lib looks proper (the
> make install step is the LAST step):
>
> build/$(TARGET):  $(OBJECTS) $(SUBLIBS) $(OBJCOMP)
>     @$(CHK_DIR_EXISTS) build/ || $(MKDIR) build/
>     -$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)
>     $(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)
>     -ln -s $(TARGET) $(TARGET0)
>     -ln -s $(TARGET) $(TARGET1)
>     -ln -s $(TARGET) $(TARGET2)
>     -$(DEL_FILE) build/$(TARGET)
>     -$(DEL_FILE) build/$(TARGET0)
>     -$(DEL_FILE) build/$(TARGET1)
>     -$(DEL_FILE) build/$(TARGET2)
>     -$(MOVE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2) build/
>     make install  < --------------------- correctly done as the last step

Maybe it's just pure luck that you don't encounter the problem with
your shared libs. If this really is the issue, as soon as qmake
decides something needs to be done after the POST_LINK hook, you'll be
having the same problem.


> The pro file is pretty simple so this looks like a qmake bug to me.

Probably not. I'd drop the automatic install step and add it to the
actual build command.

Hope this helps,
Frans



More information about the Interest mailing list