Makefile.am et al have made me lazy. I come to create a simple makefile for
gnu make and I find I can't :(
Attached is my implementation. There are a number of things wrong with it.
1. I'd like to build the MOCS files before going on to compile the .cpp
ones. However,
srcdir = .
MOCSRCS = foo.h bar.h baz.h
MOCS = $(MOCSRCS:.h=.moc)
.cpp.o: $(MOCS)
command to build .o file
.h.moc:
moc -o $@ $(srcdir)/$<
isn't working. Yes, I'm ignorant of all things vpath.
2. I have, in the past seen some magic to include all the .deps files in a
simple rule, rather than
include ./$(DEPSDIR)/foo.Plo
include ./$(DEPSDIR)/bar.Plo
include ./$(DEPSDIR)/baz.Plo
but I can't for the life of me either remember what it is or find it
through google. Anyway, the simple thing above doesn't work if foo.Plo etc
don't yet exist. Any ideas?
All help accepted most gratefully,
Angus
srcdir = .
AR = ar cru
RANLIB = ranlib
RM = rm -f
RMDIR = rm -rf
DEPSDIR=.deps
MOC = /usr/lib/qt-3.3/bin/moc
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)
MOCSRCS = documentPageCache.h \
documentWidget.h \
history.h \
kmultipage.h \
marklist.h \
pageSize.h \
pageView.h \
renderedDocumentPage.h \
renderedDocumentPagePixmap.h \
searchWidget.h \
tableOfContents.h
SRCS = documentPageCache.cpp \
documentWidget.cpp \
history.cpp \
kmultipage.cpp \
kprintDialogPage_pageoptions.cpp \
kvsprefs.cpp \
marklist.cpp \
pageSize.cpp \
pageView.cpp \
renderedDocumentPage.cpp \
renderedDocumentPagePixmap.cpp \
renderedDocumentPagePrinter.cpp \
searchWidget.cpp \
selection.cpp \
simplePageSize.cpp \
tableOfContents.cpp \
units.cpp
OBJS = $(SRCS:.cpp=.o)
MOCS = $(MOCSRCS:.h=.moc)
all: libkviewshell.a
libkviewshell.a: $(OBJS) $(DEPS)
$(AR) $@ $(OBJS)
$(RANLIB) $@
mocfiles:
$(MOC) -o $@ $(srcdir)/$<
clean:
$(RM) $(OBJS) $(MOCS) libkviewshell.a
distclean: clean
$(RMDIR) $(DEPSDIR)
#include ./$(DEPSDIR)/documentPageCache.Plo
.cpp.o: mocfiles
if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPSDIR)/$*.Tpo" -c -o $@
$(srcdir)/$<; \
then mv -f "$(DEPSDIR)/$*.Tpo" "$(DEPSDIR)/$*.Plo"; else rm -f
"$(DEPSDIR)/$*.Tpo"; exit 1; fi
.h.moc:
$(MOC) -o $@ $(srcdir)/$<
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make