Guys, I have a Makefile containing some source files:
UISRCS = optionDialogGUIWidget_base.ui \
optionDialogAccessibilityWidget.ui
MOCSRCS = documentPageCache.h \
documentWidget.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
reasons.
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?
Regards,
Angus
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
pageSizeWidget_base.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?
A.
srcdir = ..
objdir = .
depsdir=.deps
AR = ar cru
RANLIB = ranlib
RM = rm -f
RMDIR = rm -rf
MOC = /usr/lib/qt-3.3/bin/moc
UIC = /usr/lib/qt-3.3/bin/uic
QTDIR = /usr/lib/qt-3.3/include
INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../kde -I$(QTDIR)
CXX = g++
CXXFLAGS = $(INCLUDES) -DHAVE_CONFIG_H -DQT_THREAD_SUPPORT -D_REENTRANT
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST
-DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION -Wnon-virtual-dtor
-Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W
-Wpointer-arith -Wno-non-virtual-dtor -Wformat-security
-Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common -ansi -O2
CXXCOMPILE = $(CXX) $(CXXFLAGS)
UISRCS = optionDialogGUIWidget_base.ui \
optionDialogAccessibilityWidget.ui \
pageSizeWidget_base.ui
MOCSRCS = documentPageCache.h \
documentWidget.h \
history.h \
kmultipage.h \
kviewpart.h \
kviewpart_iface.h \
marklist.h \
pageSize.h \
pageSizeDialog.h \
pageSizeWidget.h \
pageView.h \
renderedDocumentPage.h \
renderedDocumentPagePixmap.h \
searchWidget.h \
sizePreview.h \
tableOfContents.h \
zoom.h
SRCS = documentPageCache.cpp \
documentWidget.cpp \
history.cpp \
kmultipage.cpp \
kprintDialogPage_pageoptions.cpp \
kviewpart.cpp \
kviewpart_iface.cpp \
kvsprefs.cpp \
marklist.cpp \
pageSize.cpp \
pageSizeDialog.cpp \
pageSizeWidget.cpp \
pageView.cpp \
renderedDocumentPage.cpp \
renderedDocumentPagePixmap.cpp \
renderedDocumentPagePrinter.cpp \
searchWidget.cpp \
selection.cpp \
simplePageSize.cpp \
sizePreview.cpp \
tableOfContents.cpp \
units.cpp \
zoom.cpp
UICS = $(UISRCS:.ui=.cpp)
UIHS = $(UISRCS:.ui=.h)
OBJS = $(SRCS:.cpp=.o)
MOCS = $(MOCSRCS:.h=.moc) $(UIHS:.h=.moc)
all: libkviewshell.a
libkviewshell.a: $(OBJS)
$(AR) $@ $(OBJS)
$(RANLIB) $@
.PHONY: clean distclean
clean:
$(RM) $(OBJS) $(MOCS) $(UICS) $(UIHS) libkviewshell.a
distclean: clean
$(RMDIR) $(depsdir)
mkdepsdir:
test -d $(depsdir) || mkdir $(depsdir)
$(objdir)/%.o: $(srcdir)/%.cpp $(UIHS) $(MOCS) mkdepsdir
if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(depsdir)/$*.Tpo" -c -o $@ $<; \
then mv -f "$(depsdir)/$*.Tpo" "$(depsdir)/$*.Plo"; \
else rm -f "$(depsdir)/$*.Tpo"; exit 1; fi
$(objdir)/%.moc: $(srcdir)/%.h
$(MOC) -o $@ $<
$(objdir)/%.moc: %.h
$(MOC) -o $@ $<
$(objdir)/%.h: $(srcdir)/%.ui
$(UIC) -L /usr/lib/kde3/plugins/designer -nounload $< > $@
-include $(SRCS:%.cpp=$(depsdir)/%.Plo)
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make