-# 1.6 or newer, and thus that $@ recursion is linear; nothing further
-# needs to be done. But if it is missing, we assume we are being run
-# by M4 1.4.x, that $@ recursion is quadratic, and that we need
-# foreach-based replacement macros. Use the raw builtin to avoid
-# tripping up include tracing.
-m4_ifndef([__m4_version__], [m4_builtin([include], [m4sugar/foreach.m4])])
+# 1.6 or newer, and thus that $@ recursion is linear and debugmode(d)
+# is available for faster checks of dereferencing undefined macros.
+# But if it is missing, we assume we are being run by M4 1.4.x, that
+# $@ recursion is quadratic, and that we need foreach-based
+# replacement macros. Use the raw builtin to avoid tripping up
+# include tracing.
+m4_ifdef([__m4_version__],
+[m4_debugmode([+d])
+m4_copy([_m4_defn], [m4_defn])
+m4_copy([_m4_popdef], [m4_popdef])
+m4_copy([_m4_undefine], [m4_undefine])],
+[m4_builtin([include], [m4sugar/foreach.m4])])