]> git.draconx.ca Git - dxcommon.git/blobdiff - m4/base.m4
DX_AUTOMAKE_COMPAT: Fix compile with newer Automake.
[dxcommon.git] / m4 / base.m4
index 42e836850eec96e46df21bf3363dda155a9ef1d6..c14ba68d21fcdf15ffb74e930ee8e0d51680e087 100644 (file)
@@ -1,6 +1,6 @@
-dnl Copyright © 2012, 2014, 2021 Nick Bowler
+dnl Copyright © 2012, 2014, 2021, 2023 Nick Bowler
 dnl
-dnl Base directory handling for dxcommon.
+dnl Basic macros for dxcommon.
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
@@ -60,7 +60,8 @@ AC_DEFUN_ONCE([DX_INIT], [m4_do(
   [_DX_SET_BASEDIR([$1])],
   [AC_SUBST([DX_BASEDIR])],
   [AC_CONFIG_COMMANDS_PRE(
-    [[DX_BASEDIR]="AS_ESCAPE(m4_dquote(m4_defn([_DX_BASEDIR])))"])])])
+    [[DX_BASEDIR]="\${top_srcdir}/AS_ESCAPE(
+      m4_dquote(m4_defn([_DX_BASEDIR])))"])])])
 
 dnl DX_BASEDIR
 dnl
@@ -75,3 +76,10 @@ 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_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]))])])