-dnl DX_RUN_LOG(command)
-dnl
-dnl Run a command, logging all of the command, its output, and overall
-dnl exit status to config.log. The expansion of this macro is a single
-dnl complex shell command suitable for use in shell conditionals.
-AC_DEFUN([DX_RUN_LOG], [{ (set -x; $1;) >&AS_MESSAGE_LOG_FD 2>&1
- dx_status=$?; AS_ECHO(["\$? = $dx_status"]) >&AS_MESSAGE_LOG_FD 2>&1
- test $dx_status = 0; }])
+# DX_RUN_LOG(command)
+#
+# Run a command, logging all of the command, its output, and overall
+# exit status to config.log. The expansion of this macro is a single
+# complex shell command suitable for use in shell conditionals.
+AC_DEFUN([DX_RUN_LOG],
+[{ _dx_shopt=$-
+( set -x
+$1
+) >&AS_MESSAGE_LOG_FD 2>&1
+_dx_status=$?
+test x"$-" = x"$_dx_shopt" || set +x # work around DJGPP subshell bug
+AS_ECHO(["\$? = $_dx_status"]) >&AS_MESSAGE_LOG_FD
+test $_dx_status = 0; } 2>/dev/null])
+
+# DX_PATCH_MACRO([macro-name], [regexp], [replacement])
+#
+# Patches the definition of macro-name by replacing substrings that match
+# the given regexp (a la m4_bpatsubst).
+AC_DEFUN([DX_PATCH_MACRO], [m4_ifdef([$1],
+ [m4_define([$1], m4_bpatsubst(m4_dquote(m4_defn([$1])), [$2], [$3]))])])