diff --git a/Makefile b/Makefile
index 9b005c28fb5422f289fae6a082eefd64ac132e03..eb160041e365cb77df1e1e116ab9118b437d39a6 100644
--- a/Makefile
+++ b/Makefile
@@ -720,30 +720,6 @@ src/plugins/gui/gtk_compat.ml: src/plugins/gui/gtk_compat.2.ml
 endif
 GENERATED+=src/plugins/gui/gtk_compat.ml
 
-ifeq ($(HAS_DGRAPH),yes)
-  DGRAPHFILES:=debug_manager
-  GENERATED+=src/plugins/gui/debug_manager.ml
-  ifeq ($(HAS_OCAMLGRAPH_2), yes)
-	DGRAPH_MODULE=Graph_gtk
-	DGRAPH_ERROR=Graph_gtk.DGraphMake.DotError
-  else
-	DGRAPH_MODULE=Dgraph
-	DGRAPH_ERROR=Dgraph.DGraphModel.DotError
-  endif
-  src/plugins/gui/debug_manager.ml \
-  src/plugins/gui/dgraph_helper.ml \
-  src/plugins/callgraph/cg_viewer.ml: %.ml: %.yes.ml Makefile
-	$(RM) $@
-	$(SED) -e 's/DGRAPH_MODULE/$(DGRAPH_MODULE)/g' \
-               -e 's/DGRAPH_ERROR/$(DGRAPH_ERROR)/g' $< > $@
-	$(CHMOD_RO) $@
-else
-  DGRAPHFILES:=
-  src/plugins/gui/dgraph_helper.ml: src/plugins/gui/dgraph_helper.no.ml Makefile
-	$(CP) $< $@
-	$(CHMOD_RO) $@
-endif
-
 SINGLE_GUI_CMO:= \
 	wutil_once \
 	gtk_compat \
diff --git a/Makefile.generating b/Makefile.generating
index e55a39ff38ce2e325850aa68aff2c11074ca1a24..1c89d12715aba8629f180701b1d767f9df1620f0 100644
--- a/Makefile.generating
+++ b/Makefile.generating
@@ -134,6 +134,30 @@ src/libraries/stdlib/transitioning.ml: \
 	cat $< > $@
 	$(CHMOD_RO) $@
 
+ifeq ($(HAS_DGRAPH),yes)
+  DGRAPHFILES:=debug_manager
+  GENERATED+=src/plugins/gui/debug_manager.ml
+  ifeq ($(HAS_OCAMLGRAPH_2), yes)
+	DGRAPH_MODULE=Graph_gtk
+	DGRAPH_ERROR=Graph_gtk.DGraphMake.DotError
+  else
+	DGRAPH_MODULE=Dgraph
+	DGRAPH_ERROR=Dgraph.DGraphModel.DotError
+  endif
+  src/plugins/gui/debug_manager.ml \
+  src/plugins/gui/dgraph_helper.ml \
+  src/plugins/callgraph/cg_viewer.ml: %.ml: %.yes.ml Makefile.generating share/Makefile.config
+	$(RM) $@
+	$(SED) -e 's/DGRAPH_MODULE/$(DGRAPH_MODULE)/g' \
+               -e 's/DGRAPH_ERROR/$(DGRAPH_ERROR)/g' $< > $@
+	$(CHMOD_RO) $@
+else
+  DGRAPHFILES:=
+  src/plugins/gui/dgraph_helper.ml: src/plugins/gui/dgraph_helper.no.ml Makefile.generating share/Makefile.config
+	$(CP) $< $@
+	$(CHMOD_RO) $@
+endif
+
 ##################
 # Frama-C-config #
 ##################