Index: trunk/geant4/config/G4VIS_USE.gmk
===================================================================
--- trunk/geant4/config/G4VIS_USE.gmk	(revision 776)
+++ trunk/geant4/config/G4VIS_USE.gmk	(revision 777)
@@ -60,10 +60,8 @@
   G4VIS_USE_OPENGL = 1
   CPPFLAGS += -DG4VIS_USE_OPENGLQT
-  VISLIBS += -lG4OpenGL_moc
+  VISLIBS  += -lG4OpenGL
+  INC_GL    = 1
   INC_QT   = 1
   LOAD_GLQT   = 1
-  INTYLIBS += -DG4VIS_USE_OIQT
-else
-  INTYLIBS += -DNO_G4VIS_USE_OIQT
 endif
 ifdef G4VIS_USE_OPENGLWIN32
@@ -76,5 +74,5 @@
     CPPFLAGS += -I$(G4BASE)/visualization/OpenGL/include
   endif
-  VISLIBS  += -lXX -lG4OpenGL -lXX
+  VISLIBS  += -lG4OpenGL
   INC_GL    = 1
   LOAD_GL   = 1
@@ -91,5 +89,5 @@
   CPPFLAGS += -DG4VIS_USE_OIQT
   INC_QT   = 1
-  LOAD_GLQT   = 1
+  LOAD_QT   = 1
 endif
 ifdef G4VIS_USE_OIWIN32
Index: trunk/geant4/config/common.gmk
===================================================================
--- trunk/geant4/config/common.gmk	(revision 776)
+++ trunk/geant4/config/common.gmk	(revision 777)
@@ -13,12 +13,13 @@
 sources := $(wildcard src/*.cc)
 
+objects := $(patsubst src/%.cc,$(G4TMPDIR)/%.o,$(sources))
+
+dependencies := $(patsubst src/%.cc,$(G4TMPDIR)/%.d,$(sources))
+
 #ifneq ($(G4INTY_BUILD_QT),)
   sources += $(moc_sources)
+  objects += $(moc_objects)
+  dependencies += $(moc_dependencies)
 #endif
-
-objects := $(patsubst src/%.cc,$(G4TMPDIR)/%.o,$(sources))
-moc_tst := $(shell ls -al * >/Users/garnier/tst)
-
-dependencies := $(patsubst src/%.cc,$(G4TMPDIR)/%.d,$(sources))
 
    g4libraries_to_build :=
@@ -48,5 +49,5 @@
 $(G4LIBDIR)/lib$(name).$(SHEXT): $(G4TMPDIR)/obj.last
 	@if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ;fi
-	@echo Creating shared library $@ ...
+	@echo Creating shared library $@ ... $(objects)
 	@$(RM) $@
 #      use architecture specific macro defined in sys/$(G4SYSTEM).gmk
Index: trunk/geant4/config/moc.gmk
===================================================================
--- trunk/geant4/config/moc.gmk	(revision 776)
+++ trunk/geant4/config/moc.gmk	(revision 777)
@@ -13,13 +13,13 @@
 
 ifneq ($(G4INTY_BUILD_QT),)
-  moc_inc := $(shell (grep -l "Q_OBJECT" ../$(dirMoc)/include/*.hh))
-  moc_tst := $(shell ls -al testMoc.gmk)
-  moc_sources := $(patsubst ../$(dirMoc)/include/%.hh, src/%_moc.cc, $(moc_inc))
+#  moc_inc := $(shell (grep -l "Q_OBJECT" ../OpenGL/include/*.hh))
+#  moc_sources := $(patsubst ../OpenGL/include/%.hh, moc/%_moc.cc, $(moc_inc))
+#  moc_tst := $(shell ls -al $(moc_sources) >/Users/garnier/tst)
 
-#  moc_dir_name := $(patsubst G4%_moc, %, $(name))
-#  moc_tst := $(shell ls -al ../$(moc_dir_name) >/Users/garnier/tst)
-#  moc_inc := $(shell (grep -l "Q_OBJECT" ../$(moc_dir_name)/include/*.hh))
-#  moc_tst := $(shell ls -al $(moc_inc) >/Users/garnier/tst)
-#  moc_sources := $(patsubst ../$(moc_dir_name)/include/%.hh, src/%_moc.cc, $(moc_inc))
+  moc_dir_name := OpenGL
+  moc_inc := $(shell (grep -l "Q_OBJECT" ../$(moc_dir_name)/include/*.hh))
+  moc_sources := $(patsubst ../$(moc_dir_name)/include/%.hh, moc/%_moc.cc, $(moc_inc))
+  moc_objects := $(patsubst moc/%.cc,$(G4TMPDIR)/%.o,$(moc_sources))
+  moc_dependencies := $(patsubst moc/%.cc,$(G4TMPDIR)/%.d,$(moc_sources))
 endif
 
@@ -40,14 +40,30 @@
 
 ifneq ($(G4INTY_BUILD_QT),)
-src/%_moc.cc: ../$(dirMoc)/include/%.hh
+$(G4TMPDIR)/%.d: moc/%.cc
+	@echo Making dependency for moc file $< ...
+	@if [ ! -d $(G4TMPDIR) ] ; then mkdir -p $(G4TMPDIR)  ;fi
+	@set -e;\
+	g++ $(GPPFLAGS) $(CPPFLAGS) -w -xc++ $< |\
+	sed 's!$*\.o!$(G4TMPDIR)/& $@!' >$@;\
+	[ -s $@ ] || rm -f $@
+	@echo Making dependency for moc file $< ... END
+
+moc/%_moc.cc: include/%.hh
 	@echo Making moc file for $< ...
+	@if [ ! -d moc ] ; then mkdir -p moc  ;fi
 	@if [ `$(QTMOC) -v 2>&1 | grep "Qt 3" | wc -l ` -gt 0 ]; then \
 	$(QTMOC) -o $@ $<;\
 	else $(QTMOC) $(MOC_MACRO) -o $@ $<; \
 	fi;
+	@echo Making moc file for $< ... END
 
-src/%.cc:
-	@echo Making toto $< ...
-	@if [ ! -d $(G4TMPDIR) ] ; then mkdir -p $(G4TMPDIR)  ;fi
-
+$(G4TMPDIR)/%.o: moc/%_moc.cc
+	@echo Compiling $*.cc ...
+ifdef CPPVERBOSE
+	@echo Compiling moc file $*.cc ...
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F)_moc.o moc/$*_moc.cc
+else
+	@echo Compiling moc file $*.cc ...
+	@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(OUT_OBJ)$(G4TMPDIR)/$(*F)_moc.o moc/$*_moc.cc
 endif
+endif
