diff --git a/doc/html/Makefile.in b/doc/html/Makefile.in
index 62c5fd59..432973a2 100644
--- a/doc/html/Makefile.in
+++ b/doc/html/Makefile.in
@@ -1,5 +1,8 @@
-MAGICDIR = ../..
-
+# Provided by configure: the module's source dir + the build top.
+# defs.mak sees `srcdir` already set and skips its own srcdir derivation.
+srcdir = @srcdir@
+VPATH = @srcdir@
+MAGICDIR = @top_builddir@
include $(MAGICDIR)/defs.mak
HTML_INSTDIR=$(INSTALL_LIBDIR)/magic/doc/html
diff --git a/doc/latexfiles/Makefile.in b/doc/latexfiles/Makefile.in
index 21b664a4..68e8df5e 100644
--- a/doc/latexfiles/Makefile.in
+++ b/doc/latexfiles/Makefile.in
@@ -1,5 +1,8 @@
-MAGICDIR = ../..
-
+# Provided by configure: the module's source dir + the build top.
+# defs.mak sees `srcdir` already set and skips its own srcdir derivation.
+srcdir = @srcdir@
+VPATH = @srcdir@
+MAGICDIR = @top_builddir@
include $(MAGICDIR)/defs.mak
# PS_SRCDIR: pre-built PostScript shipped in the source tree (read-only, used by
diff --git a/doc/man/Makefile.in b/doc/man/Makefile.in
index 45fc8966..b33f9bfb 100644
--- a/doc/man/Makefile.in
+++ b/doc/man/Makefile.in
@@ -2,8 +2,11 @@
# makefile for Magic documentation
#
-MAGICDIR = ../..
-
+# Provided by configure: the module's source dir + the build top.
+# defs.mak sees `srcdir` already set and skips its own srcdir derivation.
+srcdir = @srcdir@
+VPATH = @srcdir@
+MAGICDIR = @top_builddir@
MANMACS= tmac.anc
TROFF=ditroff -h
TTROFF=ditroff -Ppsc -t
diff --git a/doc/tutcells/Makefile.in b/doc/tutcells/Makefile.in
index 2831201d..eaab4c41 100644
--- a/doc/tutcells/Makefile.in
+++ b/doc/tutcells/Makefile.in
@@ -2,8 +2,11 @@
# makefile for Magic documentation
#
-MAGICDIR = ../..
-
+# Provided by configure: the module's source dir + the build top.
+# defs.mak sees `srcdir` already set and skips its own srcdir derivation.
+srcdir = @srcdir@
+VPATH = @srcdir@
+MAGICDIR = @top_builddir@
include ${MAGICDIR}/defs.mak
TUTDIR = ${INSTALL_LIBDIR}/magic/tutorial
diff --git a/scmos/cif_template/Makefile.in b/scmos/cif_template/Makefile.in
index d2b0b13b..f8c2386b 100644
--- a/scmos/cif_template/Makefile.in
+++ b/scmos/cif_template/Makefile.in
@@ -1,5 +1,8 @@
-MAGICDIR = ../..
-
+# Provided by configure: the module's source dir + the build top.
+# defs.mak sees `srcdir` already set and skips its own srcdir derivation.
+srcdir = @srcdir@
+VPATH = @srcdir@
+MAGICDIR = @top_builddir@
MKDIR = $(MAGICSRC)/scripts/mkdirs
OBJS_DIR = objs
CIFIN = $(OBJS_DIR)/CIFin