-AC_DEFUN_ONCE([DX_INIT], [dnl
-
-dnl Care must be taken to avoid spurious expansions of things that look like
-dnl macros in the filename; this is made especially difficult since
-dnl m4_bpatsubst does not expand to a quoted string.
-m4_define([_DX_BASEDIR], m4_if([$1], [],
- [m4_bpatsubst(m4_dquote(m4_defn([_DX_BASE_FILE])),
- [/m4/[^/]*\.m4\(.\)$], [\1])],
- [[$1]]))
-
-dnl Include the stamp file, which will cause a failure at autoconf time
-dnl if it does not exist in the checkout. We circumvent m4_include to
-dnl avoid warnings about multiple inclusions.
-m4_pushdef([m4_include], [m4_builtin([include], $][@)])
-m4_include(m4_defn([_DX_BASEDIR])[/m4/dx-stamp.m4])
-m4_popdef([m4_include])
-_DX_STAMP_DUMMY
-
-dnl Autoconf scripts should use the DX_BASEDIR m4 macro instead of the
-dnl AC_SUBSTed shell variable, but we use the same name for the macro since
-dnl it means the same thing as the substituted variable.
+
+dnl _DX_SET_BASEDIR([directory])
+dnl
+dnl Defines the macro _DX_BASEDIR to the dxcommon base directory. If the
+dnl argument is empty, the base directory will be determined automatically.
+dnl Otherwise, the base directory is set to the argument (which is not
+dnl subject to macro expansion).
+dnl
+dnl Quoting here is tricky as we must avoid macro expansion of _DX_BASE_FILE,
+dnl but m4_bpatsubst does not quote its result. The resulting _DX_BASEDIR
+dnl macro is a literal string, thus it should not be expanded directly; use
+dnl m4_defn([_DX_BASEDIR]) instead.
+m4_define([_DX_SET_BASEDIR], [m4_do(
+ [m4_define([_DX_BASEDIR], m4_ifval([$1], [[$1]],
+ [m4_bpatsubst(m4_dquote(m4_defn([_DX_BASE_FILE])),
+ [/m4/[^/]*\.m4\(.\)$], [\1])]))],
+ [_DX_STAMP])])
+
+dnl Include the stamp file to force failure at autoconf time if it does
+dnl not exist in the checkout. We circumvent m4_include to avoid warnings
+dnl about multiple inclusions.
+m4_define([_DX_STAMP], [m4_do(
+ [m4_pushdef([m4_include], [m4_builtin([include], $][@)])],
+ [m4_include(m4_defn([_DX_BASEDIR])[/m4/dx-stamp.m4])],
+ [m4_popdef([m4_include])])])
+
+dnl DX_INIT(directory)
+dnl
+dnl Sets the dxcommon base directory, which is used by other macros to
+dnl find any source files that they may need. It is not normally necessary
+dnl to use this macro. If it used, it must be expanded prior to any other
+dnl dxcommon macro. Otherwise, the base directory will be determined
+dnl automatically.
+dnl
+dnl The directory argument is a literal string, not subject to macro expansion.