1 | # $Id: moc.gmk,v 1.3 2008/12/03 13:35:36 gcosmo Exp $ |
---|
2 | # ---------------------------------------------------------------- |
---|
3 | # Common part of GNUmakefile for libraries. John Allison, 5/7/95. |
---|
4 | # ---------------------------------------------------------------- |
---|
5 | # Libraries are created according to G4SYSTEM. G.Cosmo, 11/6/96. |
---|
6 | # Introduced G4LIBDIR and G4TMPDIR. G.Cosmo, 23/6/98. |
---|
7 | # Introduced Qt moc rule, L.Garnier 16/2/08. |
---|
8 | |
---|
9 | ifndef G4LIBDIR |
---|
10 | G4LIBDIR := $(G4LIB)/$(G4SYSTEM) |
---|
11 | endif |
---|
12 | G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name) |
---|
13 | |
---|
14 | ifneq ($(G4INTY_BUILD_QT),) |
---|
15 | moc_inc := $(shell ($(GREP) -l "Q_OBJECT" include/*.hh)) |
---|
16 | moc_sources := $(patsubst include/%.hh, moc/%_moc.cc, $(moc_inc)) |
---|
17 | moc_objects := $(patsubst moc/%_moc.cc,$(G4TMPDIR)/%_moc.o,$(moc_sources)) |
---|
18 | moc_dependencies := $(patsubst moc/%_moc.cc,$(G4TMPDIR)/%_moc.d,$(moc_sources)) |
---|
19 | endif |
---|
20 | |
---|
21 | |
---|
22 | ############################################################################### |
---|
23 | # |
---|
24 | # Actual moc files for Qt files |
---|
25 | # |
---|
26 | # moc sources and headers: used for Qt signal/slot |
---|
27 | # - all headers which use signals/slots have the macro "Q_OBJECT" present |
---|
28 | # in the class definitions; these all need to be processed by the |
---|
29 | # "meta object compiler (moc)" which generates extra source code to |
---|
30 | # implement the signal/slots, i.e., if "foo.h" contains the token "Q_OBJECT" |
---|
31 | # it will be used by moc to generate the file "foo_moc.cpp" (the _moc. is |
---|
32 | # just an arbitrary extension to make it easier to identify sources |
---|
33 | # generated by moc). |
---|
34 | |
---|
35 | |
---|
36 | ifneq ($(G4INTY_BUILD_QT),) |
---|
37 | $(G4TMPDIR)/%_moc.d: moc/%_moc.cc |
---|
38 | @echo Making dependency for moc file $< ... |
---|
39 | @if [ ! -d $(G4TMPDIR) ] ; then mkdir -p $(G4TMPDIR) ;fi |
---|
40 | @set -e;\ |
---|
41 | g++ $(GPPFLAGS) $(CPPFLAGS) -w -xc++ $< |\ |
---|
42 | sed 's!$*\.o!$(G4TMPDIR)/& $@!' >$@;\ |
---|
43 | [ -s $@ ] || rm -f $@ |
---|
44 | |
---|
45 | moc/%_moc.cc: include/%.hh |
---|
46 | @echo Making moc file for $< ... |
---|
47 | @if [ ! -d moc ] ; then mkdir -p moc ;fi |
---|
48 | @if [ `$(QTMOC) -v 2>&1 | $(GREP) "Qt 3" | wc -l ` -gt 0 ]; then \ |
---|
49 | $(QTMOC) -o $@ $<;\ |
---|
50 | else $(QTMOC) $(MOC_MACRO) -o $@ $<; \ |
---|
51 | fi; |
---|
52 | |
---|
53 | # could be better if we not duplicate this rule from common.gmk... |
---|
54 | $(G4TMPDIR)/%_moc.o: moc/%_moc.cc |
---|
55 | @echo Compiling $*.cc ... |
---|
56 | ifdef CPPVERBOSE |
---|
57 | @echo Compiling moc file $*.cc ... |
---|
58 | $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F)_moc.o moc/$*_moc.cc |
---|
59 | else |
---|
60 | @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F)_moc.o moc/$*_moc.cc |
---|
61 | endif |
---|
62 | endif |
---|