[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

srcdir != buildir woes

From: Angus Leeming
Subject: srcdir != buildir woes
Date: Tue, 26 Jul 2005 09:13:33 +0100
User-agent: KNode/0.8.1

Guys, I have a Makefile containing some source files:

UISRCS = optionDialogGUIWidget_base.ui \

MOCSRCS = documentPageCache.h \

The .ui files are processed to create .h files:
$(objdir)/%.h: $(srcdir)/%.ui
        $(UIC) $< > $@

The .h files are processed to produce .moc files.
$(objdir)/%.moc: $(srcdir)/%.h
        $(MOC) -o $@ $<

The .moc files are #included in my C++ source.

However, here's the rub. When my srcdir != buildir the generated .h files
are not in the srcdir and so the .h -> .moc step is failing. For obvious

I can add another rule, so:

$(objdir)/%.moc: %.h
        $(MOC) -o $@ $<

(and this works) but obviously things are going to get confused when srcdir
and builddir are the same.

I attach my Makefile. Can you put me back on the right path?


ps, one final question. My build completes as:

ar cru libkviewshell.a documentPageCache.o documentWidget.o history.o
kmultipage.o kprintDialogPage_pageoptions.o kviewpart.o kviewpart_iface.o
kvsprefs.o marklist.o pageSize.o pageSizeDialog.o pageSizeWidget.o
pageView.o renderedDocumentPage.o renderedDocumentPagePixmap.o
renderedDocumentPagePrinter.o searchWidget.o selection.o simplePageSize.o
sizePreview.o tableOfContents.o units.o zoom.o
ranlib libkviewshell.a
rm optionDialogGUIWidget_base.moc optionDialogAccessibilityWidget.moc

Why is it removing these (generated in two steps) .moc files:
    .ui -> .h
    .h -> .moc
It means that my entire build process starts from scratch each time.
Moreover, I find that if my make process fails at some point then all
intermediate files are removed:
make: *** [pageSize.o] Interrupt
make: *** Deleting intermediate file `optionDialogGUIWidget_base.moc'
make: *** Deleting intermediate file `optionDialogAccessibilityWidget.moc'
make: *** Deleting intermediate file `sizePreview.moc'
make: *** Deleting intermediate file `pageSizeWidget_base.moc'
make: *** Deleting intermediate file `tableOfContents.moc'

Can I prevent this from happening?

Attachment: Makefile
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]