diff --git a/Makefile.am b/Makefile.am
index 1bb2b53474924f3646147644263bf211c87754b9..f93be3eab956aae0597940ff286f16638302e3ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1031,8 +1031,8 @@ man/%.html.in: man/%.gen man/footer.html
 man/%: man/%.in  $(REPLACE_VARS_SED)
 	sed -f $(REPLACE_VARS_SED) < $< > $@
 
-epydoc.conf: epydoc.conf.in Makefile
-	sed -e 's#@MODULES@#$(strip $(lint_python_code))#g' < $< > $@
+epydoc.conf: epydoc.conf.in $(REPLACE_VARS_SED)
+	sed -f $(REPLACE_VARS_SED) < $< > $@
 
 vcs-version:
 	if test -d .git; then \
@@ -1189,6 +1189,7 @@ $(REPLACE_VARS_SED): Makefile stamp-directories
 	  echo 's#@GNTMASTERDGROUP@#$(MASTERD_GROUP)#g'; \
 	  echo 's#@GNTDAEMONSGROUP@#$(DAEMONS_GROUP)#g'; \
 	  echo 's#@CUSTOM_ENABLE_CONFD@#$(ENABLE_CONFD)#g'; \
+	  echo 's#@MODULES@#$(strip $(lint_python_code))#g'; \
 	} > $@
 
 # Using deferred evaluation